Glossaire_XH

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Glossaire_XH

Post by frase » Mon Sep 21, 2020 2:17 pm

Un autre problème se pose, par exemple, si vous avez le anchorific-Script dans le template.
L'utilisation des titres h4 dans le popup est défavorable et perturbe également la structure de la page. Peut-être qu'une classe CSS serait appropriée.

ludovicam
Posts: 27
Joined: Tue May 29, 2018 8:23 pm
Contact:

Re: Glossaire_XH

Post by ludovicam » Mon Sep 21, 2020 3:07 pm

cmb wrote:
Mon Sep 21, 2020 12:47 pm
frase wrote:
Mon Sep 21, 2020 11:27 am
DEPRECATED: Function create_function() is deprecated
... \plugins\glossaire\admin.php:180
I don't have the source code at hand, but create_function() should be replaced by an anonymous function.
sorry but i don't have the solution for now.
I am unable to fix this deprecated function.

I have to change this :

Code: Select all

 function array_key_multi_sort(&$arr, $l , $strnat='strnatcasecmp') {
            //return usort($arr, create_function('$a, $b', "return $strnat(OteAccents(\$a['$l']), OteAccents(\$b['$l']));"));
         } 
         if (is_array($lignes)) {array_key_multi_sort($lignes, $choix_tri , $strnat='strnatcasecmp');}
I might try this for example, but it doesn't work :

Code: Select all

 function array_key_multi_sort(&$arr, $l , $strnat='strnatcasecmp') {
            return usort($arr, 
                          function($a, $b){
                             return strnatcasecmp(OteAccents($a[$l]), OteAccents($b[$l]));
                          }
                        );   
         } 
         if (is_array($lignes)) {array_key_multi_sort($lignes, $choix_tri , $strnat='strnatcasecmp');}
Let me add that I haven't touched a line of code for at least two years. I have other activities and other problems at the moment. A little hard to get back to it ...

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Glossaire_XH

Post by frase » Mon Sep 21, 2020 3:36 pm

ludovicam wrote:
Mon Sep 21, 2020 3:07 pm
Let me add that I haven't touched a line of code for at least two years. I have other activities and other problems at the moment. A little hard to get back to it ...
Don't panic! I fully understand that.
I'm currently working on a modified version, just for my own needs ;-)
The plugin is surely applicable in most cases without problems.
The only worry is that the deprecated function will not work with PHP 8 anymore.
Thanks for your help.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Glossaire_XH

Post by cmb » Mon Sep 21, 2020 4:31 pm

ludovicam wrote:
Mon Sep 21, 2020 3:07 pm
sorry but i don't have the solution for now.
I am unable to fix this deprecated function.
Maybe the following works:

Code: Select all

 function array_key_multi_sort(&$arr, $l , $strnat='strnatcasecmp') {
            //return usort($arr, create_function('$a, $b', "return $strnat(OteAccents(\$a['$l']), OteAccents(\$b['$l']));"));
            return usort($arr, 
                          function($a, $b) use ($l, $strnat) {
                             return $strnat(OteAccents($a[$l]), OteAccents($b[$l]));
                          }
                        );   

         } 
         if (is_array($lignes)) {array_key_multi_sort($lignes, $choix_tri , $strnat='strnatcasecmp');}
The relevant change is use($l, $strnat); without it, these variables are not defined in the anonymous function.
Christoph M. Becker – Plugins for CMSimple_XH

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Glossaire_XH

Post by frase » Mon Sep 21, 2020 4:42 pm

cmb wrote:
Mon Sep 21, 2020 4:31 pm
Maybe the following works:
The function seems to work well.
The error message is gone in any case and the plugin works as desired.
If I notice anything later, I will report here.
Thanks for the help.

ludovicam
Posts: 27
Joined: Tue May 29, 2018 8:23 pm
Contact:

Re: Glossaire_XH

Post by ludovicam » Mon Sep 21, 2020 6:08 pm

cmb wrote:
Mon Sep 21, 2020 4:31 pm
ludovicam wrote:
Mon Sep 21, 2020 3:07 pm
sorry but i don't have the solution for now.
I am unable to fix this deprecated function.
Maybe the following works:

Code: Select all

 function array_key_multi_sort(&$arr, $l , $strnat='strnatcasecmp') {
            //return usort($arr, create_function('$a, $b', "return $strnat(OteAccents(\$a['$l']), OteAccents(\$b['$l']));"));
            return usort($arr, 
                          function($a, $b) use ($l, $strnat) {
                             return $strnat(OteAccents($a[$l]), OteAccents($b[$l]));
                          }
                        );   

         } 
         if (is_array($lignes)) {array_key_multi_sort($lignes, $choix_tri , $strnat='strnatcasecmp');}
The relevant change is use($l, $strnat); without it, these variables are not defined in the anonymous function.
indeed, I had forgotten this detail.

Thanks for this correction.

This function is used to filter the columns of words in the administration and everything works perfectly.
I don't believe there are any other deprecated functions in the code but I will check and update the plugin on my site.

I remain attentive to the various comments.
Thanks again.

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Glossaire_XH

Post by frase » Tue Sep 22, 2020 12:15 am

ludovicam wrote:
Mon Sep 21, 2020 6:08 pm
I remain attentive to the various comments.
That's good. And since you're in the middle of it, I might as well make a few more comments.
But please don't feel pressured - they are just comments from a non-expert.

As mentioned above, no headings should appear in the popups (<h3>, <h4>). This can be done with a paragraph with CSS class.
(E.g. in the file gloss_inc2.inc in line 125-126 and line 169.)

The font in the popups should theoretically be like this:

Code: Select all

font-family: system-ui;
Unfortunately we live in a terrible world where browser manufacturers simply do what they want - just not what we want. So this doesn't work.
But you can read here for example: https://css-tricks.com/snippets/css/system-font-stack/. But, that becomes too much effort.
Arial, Verdana and Co, which are suggested in the plugin, did not please me.
So I simply added a new option to the select fields for the font selection. Namely: font-family: inherit
So at least the template font is used, which fits quite well in my case.
In the file admin.php I added two lines:

Code: Select all

Line 857:
<option value="inherit"'.(($titre[2] == "inherit") ? " selected=\"selected\"" : "").'>inherit</option>
...
Line 912:
<option value="inherit"'.(($defin[2] == "inherit") ? " selected=\"selected\"" : "").'>inherit</option>

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Glossaire_XH

Post by frase » Tue Sep 22, 2020 12:44 am

What I have forgotten ...
The terms found on the page will get a link:

Code: Select all

<a href="#gpop3" class="gpop">The Term</a>
This can also be unfavorable under certain circumstances. On the one hand it creates an entry in the browsing history - on the other hand it can lead to jumps if you click on it.
Maybe it's enough to style the term via CSS and give it an ID ???

ludovicam
Posts: 27
Joined: Tue May 29, 2018 8:23 pm
Contact:

Re: Glossaire_XH

Post by ludovicam » Tue Sep 22, 2020 7:30 am

frase wrote:
Tue Sep 22, 2020 12:15 am
...
So I simply added a new option to the select fields for the font selection. Namely: font-family: inherit
So at least the template font is used, which fits quite well in my case.
In the file admin.php I added two lines:

Code: Select all

Line 857:
<option value="inherit"'.(($titre[2] == "inherit") ? " selected=\"selected\"" : "").'>inherit</option>
...
Line 912:
<option value="inherit"'.(($defin[2] == "inherit") ? " selected=\"selected\"" : "").'>inherit</option>
it seems like a good idea to test.

ludovicam
Posts: 27
Joined: Tue May 29, 2018 8:23 pm
Contact:

Re: Glossaire_XH

Post by ludovicam » Tue Sep 22, 2020 7:53 am

frase wrote:
Tue Sep 22, 2020 12:44 am
What I have forgotten ...
The terms found on the page will get a link:

Code: Select all

<a href="#gpop3" class="gpop">The Term</a>
This can also be unfavorable under certain circumstances. On the one hand it creates an entry in the browsing history - on the other hand it can lead to jumps if you click on it.
Maybe it's enough to style the term via CSS and give it an ID ???
I created this plugin about fifteen years ago for another CMS at the time. I evolved it over time and adapted it to CMSimple later.

Today, we could surely review its design. If I had to do it again, I would surely do otherwise.

But I have neither the time nor the will currently (I am looking for a job and have health problems) to tackle such a project.

It will therefore remain as it is now, structurally speaking. I will make a decision later on whether to redesign this plugin or abandon it.

Thank you for your understanding.

Post Reply