Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Servious on July 09, 2009, 04:33:44 PM

Title: Subs.php Case Insensitive
Post by: Servious on July 09, 2009, 04:33:44 PM
I was looking at an old MOD to make smileys case insensitive. so  :smile: and SmIlE would be the same thing.

It said it worked with 2.0 beta 3    but it will not work with RC1 and the maker has since left the community.

It does not work with RC1 because the line it is suppose to change is formatted differently now unless i'm looking at the wrong line.

It appears as though it wants to edit this from the RC1 subs.php
$smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~e' . ($context['utf8'] ? 'u' : '');


The old line in previous versions read as:
$smileyfromcache[] = '/(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . preg_quote($smileysfrom[$i], '/') . '|' . preg_quote(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), '/') . ')(?=[^[:alpha:]0-9]|$)/' . ($context['utf8'] ? 'u' : '');

Now in the old version all you have to do to make it case insensitive is add an   i   after   ?=[^[:alpha:]0-9]|$)/ and it would be all fine and dandy.

In the new code there is an ~e  and any modification to that seems to cause major problems weather a php error, all posts disappearing or just when it's suppose to be case insensitive it just deletes the word.

Any help on this issue would be greatly appreciated.
Title: Re: Subs.php Case Insensitive
Post by: Servious on July 13, 2009, 03:56:55 PM
Bump,

Really no one? Is it an impossible request?
Title: Re: Subs.php Case Insensitive
Post by: [SiNaN] on July 15, 2009, 11:46:22 AM
See if this works:

Code (Find) Select
$smileyPregReplacements[$smileysfrom[$i]]

Code (Replace) Select
$smileyPregReplacements[strtolower($smileysfrom[$i])]

Code (Find) Select
$smileyPregReplacements[htmlspecialchars($smileysfrom[$i], ENT_QUOTES)]

Code (Replace) Select
$smileyPregReplacements[strtolower(htmlspecialchars($smileysfrom[$i], ENT_QUOTES))]

Code (Find) Select
(?=[^[:alpha:]0-9]|$)~e

Code (Replace) Select
(?=[^[:alpha:]0-9]|$)~ei

Code (Find) Select
isset($smileyPregReplacements[\'$1\']) ? $smileyPregReplacements[\'$1\']

Code (Replace) Select
isset($smileyPregReplacements[strtolower(\'$1\')]) ? $smileyPregReplacements[strtolower(\'$1\')]
Title: Re: Subs.php Case Insensitive
Post by: Servious on July 16, 2009, 09:20:22 AM
It works great  i can put any combination of caps and lowercase with my custom smilies and they work. Thank you very much.

I'd suggest making this a mod for RC-1 :D
Title: Re: Subs.php Case Insensitive
Post by: [SiNaN] on July 16, 2009, 01:47:26 PM
My pleasure. Marked as solved. ;)