News:

Wondering if this will always be free?  See why free is better.

Main Menu

Glossary

Started by slinouille, December 24, 2008, 10:33:47 AM

Previous topic - Next topic

Harvester

Quote from: Kindred on February 26, 2017, 02:23:36 PM
This line added in Subs.php generates a php deprecated error...
working on finding the correct replacement


      $message = preg_replace(
        '/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : '') .'e' ,
        "'\$2' == '\$1' ? stripslashes('\$1') : '<span class=\"glossary\" title=\"".addslashes($definition)."\">$1</span>'",
        $message,
        (isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
      );


Any luck on finding a replacement?

Harvester

I just installed this on 2.0.13 (had to use parser) and when I click on the Glossary link in the top menu I get this error:

Table 'jared867_smf2.smf_glossary_groups' doesn't exist
File: /home/jared867/public_html/Sources/Glossary.php
Line: 422

tried to install on a test site (i use for a sandbox) and i got same error...

I checked phpmyadmin and sure enough the smf_glossary__groups does not exist. Actually there is no smf_glossary_* databases at all.

can someone help  here? Id love to use this mod.

Arantor

Try this replacement code. I have no idea if it will work, I haven't tested it, but this doesn't look like a complex change.


$message = preg_replace_callback(
'/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => ''')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => ''')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : ''),
function ($matches) use ($definition) {
return $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span class="glossary" title="' . addslashes($definition) . '">' . $matches[1] . '</span>';
},
$message,
(isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
);


As to the install issues, this is because the installer predates 2.0 RC2 or RC3 where the DB code changed. The tables will likely exist but not have the smf_ prefix in which case you just need to rename the tables.

Harvester

Arantor, you were 100% correct about the database. I found the tables without the prefix.

How do I rename them now? I clicked on the table and then clicked Edit but what came up left me clueless lol


By the way, were does that edited code go? what file?


Arantor

Go into the tables in phpMyAdmin and go to the Operations tab where you can rename them.

Kindred

the edited code (still untested) would replace the line that I mention in Subs.php
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Harvester

Quote from: Arantor on March 04, 2017, 06:47:16 PM
Try this replacement code. I have no idea if it will work, I haven't tested it, but this doesn't look like a complex change.


$message = preg_replace_callback(
'/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => ''')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => ''')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : ''),
function ($matches) use ($definition) {
return $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span class="glossary" title="' . addslashes($definition) . '">' . $matches[1] . '</span>';
},
$message,
(isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
);


As to the install issues, this is because the installer predates 2.0 RC2 or RC3 where the DB code changed. The tables will likely exist but not have the smf_ prefix in which case you just need to rename the tables.

im viewing the subs in the parser and i cannot figure out what this new code replaces.   any help please?

Kindred

Quote from: Kindred on March 04, 2017, 07:37:44 PM
the edited code (still untested) would replace the line that I mention in Subs.php
Quote from: Kindred on February 26, 2017, 02:23:36 PM
This line added in Subs.php generates a php deprecated error...
working on finding the correct replacement


      $message = preg_replace(
        '/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : '') .'e' ,
        "'\$2' == '\$1' ? stripslashes('\$1') : '<span class=\"glossary\" title=\"".addslashes($definition)."\">$1</span>'",
        $message,
        (isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
      );

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Kindred

except, having just tried it....  it generates a fatal php error

[06-Mar-2017 19:48:57 UTC] PHP Parse error:  syntax error, unexpected '')), '' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /....../Sources/Subs.php on line 5025
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Kindred

Looks like this might be better code.



      $message = preg_replace_callback(
'/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '')), '/') . '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b' . preg_quote(strtr($word, array('\'' => '')), '/') . '\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : ''),
function ($matches) use ($definition) {
if ($matches[2] == $matches[1])
return stripslashes($matches[1]);
else
return '<span class="glossary" title="' . addslashes($definition) . '">' . $matches[1] . '</span>';
},
$message,
(isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
);


no php errors with this..,.

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Something else must be wrong because I still see it using the 'e' operator which is the one in 5.5 that causes it to throw a wobbly in the first place.

If the code runs any PHP evaluation, it used to have to use the 'e' option, or use a callback with the preg_replace_callback function. Since this is doing neither, what you have isn't going to work correctly.

It's also not helped by the fact that SMF actually broke the code I posted since there's a section in the quote with three ' in a row, but that wasn't what I posted. What I posted was a & #039; (without the space) as the middle quote, which is necessary to deal with issues around XSS injection. It's the bit just before the )), that it complains about.

Kindred

hmmm.... interesting.

I don't get the e operator with my code...


but your, corrected as you mention

$message = preg_replace_callback(
'/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : ''),
function ($matches) use ($definition) {
return $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span class="glossary" title="' . addslashes($definition) . '">' . $matches[1] . '</span>';
},
$message,
(isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
);

does seem to work now
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Harvester

Thank you guys! I really appreciate your hard work.. but please forgive my for being slow lol  I am looking at the parser and what changes the mod makes to Subs.php (which from what I gather, is here this edit goes) but of the 3 edits made in teh Subs.php, I do not know which this new code replaces. Im sorry. Im lost at the moment.

Arantor

That's not the code you originally posted, which is what confused me. As to why your updated code snippet works, it works right up until there's an apostrophe in the dictionary term.

Kindred

Code (find in Subs.php) Select

      $message = preg_replace(
        '/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : '') .'e' ,
        "'\$2' == '\$1' ? stripslashes('\$1') : '<span class=\"glossary\" title=\"".addslashes($definition)."\">$1</span>'",
        $message,
        (isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
      );



Code (replace with (Thanks to Arantor)) Select

$message = preg_replace_callback(
'/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : ''),
function ($matches) use ($definition) {
return $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span class="glossary" title="' . addslashes($definition) . '">' . $matches[1] . '</span>';
},
$message,
(isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
);

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Harvester

I can't (well Dreamweaver cant) find

      $message = preg_replace(
        '/((<a.+\/a>)|(\b'. preg_quote(strtr($word, array('\'' => '&#039;')), '/'). '(?=[^A-Za-z0-9&agrave;-??-??-?_\-s]))|(\b'.preg_quote(strtr($word, array('\'' => '&#039;')), '/').'\b))/'. (!empty($modSettings['glossary_none_sensitive']) ? 'i' : '') .'e' ,
        "'\$2' == '\$1' ? stripslashes('\$1') : '<span class=\"glossary\" title=\"".addslashes($definition)."\">$1</span>'",
        $message,
        (isset($modSettings['glossary_unique_word']) && $modSettings['glossary_unique_word']==1) ? 1 : -1
      );


I edited my original Subs.php with the edits tht the parser the mod links to and changed what it told me to change. This is the file i have searched for the above code.  For arguments sake I even searched the Subs.php before i made the glossary edits.

Im now a bit confused.

I desperately want this Mod. It is exactly what I was looking for. I was going to make a glossary using a board and topics (one for each term) but with that I'd have no way to really organize other than post date. This Mod would be fantastic if I can get it to work. When I upload all the edited files currently, entering a topic displays a blank white area where the post once was.

Kindred

Well, the base automatic install works just fine, after you change the tables to use the correct prefix.

Then, after the install, you go to subs.php and search for a little bit of that code...like glossary_unique_word
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Harvester

Ok I finally got  the mod installed and Arantors edit in place. Oddly the mods install was not placing that code at the end of the file and that is why I had no clue what code to replace. I used a different parser and saw what should have been added at the end of the subs file and then I made arantors edit and pasted that at the end of the subs

Now my glossary is working but I made a test word in the glossary and when that word appears in a post nothing happens.. no tool tip no highlight.. no nothing... any ideas?

Kindred

strangely enough...   I just checked one of my other sites that has the glossary installed and you're right....   that code doesn't exist in that installation... and the tooltips work just fine. Actually, the function parse_glossary($message) is VERY different in that installation for some reason.

So, in that case "putting it in" is incorrect...   and replacing it with Arantor's code won't do anything.



However, in a third installation, the code IS there... but putting the replacement code in breas things and gives Parse error: syntax error, unexpected T_FUNCTION...
I suspect that is an old php version issue...maybe.
all three indicate version 0.3.1 of the mod...
strange....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Harvester

ok so I wasn't losing my mind. lol So what do I do now to make this work on my site?

Advertisement: