Removing case sensitive from the glossary extension

Author Message

Børge Warvik

Monday 14 August 2006 7:33:49 am

Hi

I'm using the glossary extension and it workes fine. Only problem is that it is case sensitive and therefor doesn't see the words "word", "wOrd" and "Word" as the same. I've turned on the feature so it only shows words once.

How can I fix this?

Børge

Claudia Kosny

Tuesday 15 August 2006 11:26:44 am

Hello,

I haven't used the glossary extension yet, so here just a wild guess based on a quick look at the code in file sckglossarytemplateoperator.php.
Here is an extract (lines 113 to 134)

        // Loop through each element
        foreach( $glossaryTree as $item )
        {
            $tmp = array(); 
            // All variations of the Name, NAME and name
            $tmp[] = strtoupper( $item["Name"] );
            $tmp[] = strtolower( $item["Name"] );
            $tmp[] = ucfirst( $item["Name"] );

            /*
			* Prevent an upfirst version if it equals the uppercase version
			* This prevents problems when using uppercase glossary words
			* */
            $tmp = array_unique( $tmp ); 
            // Take each variation and make a $replace entry for it
            // the $replace entry contains a link to the full object
            foreach( $tmp as $name )
            {
                $search[] = "/\b" . preg_quote( $name, "/" ) . "(?![$exempt]\w)" . "\b/";
                $replace[] = "<a href=\"" . $sys->indexDir() . "/" . $item["URL"] . "\" title=\"" . strip_tags( $item["Desc"] ) . "\">" . $name . "</a>";
			      }
        } 

In the last foreach you can see the regular expression that is used to find the words in the text. If you want to have this case insensitive you need to change this expression. I think that an 'i' for insensitive behind the delimiter (the last slash) in the value for search[] should be sufficient, but I have not tried it out.
You also need to remove the lines

$tmp[] = strtoupper( $item["Name"] );
$tmp[] = strtolower( $item["Name"] );
$tmp[] = ucfirst( $item["Name"] );

and replace them by a single

$tmp[] =  $item["Name"] ;

as otherwise each found word will be replaced three times.

Please keep in mind that I have not tried it all and the above idea might go totally haywire.

Good luck

Claudia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:24:54
Script start
Timing: Jan 31 2025 06:24:54
Module start 'layout'
Timing: Jan 31 2025 06:24:54
Module start 'content'
Timing: Jan 31 2025 06:24:54
Module end 'content'
Timing: Jan 31 2025 06:24:54
Script end

Main resources:

Total runtime0.0184 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0085 588.2813151.2266
Module start 'layout' 0.00860.0034 739.507836.6797
Module start 'content' 0.01190.0050 776.187590.3125
Module end 'content' 0.01690.0014 866.500033.9922
Script end 0.0183  900.4922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002614.2062140.0002
Check MTime0.00115.9517140.0001
Mysql Total
Database connection0.00136.882410.0013
Mysqli_queries0.004021.603930.0013
Looping result0.00000.098710.0000
Template Total0.00115.910.0011
Template load0.00084.578310.0008
Template processing0.00021.300710.0002
Override
Cache load0.00063.102410.0006
General
dbfile0.00189.738280.0002
String conversion0.00000.042840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs