Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

Mentions+ setting problem. Your help will be appreciated.

This discussion is related to the Mentions+ addon.
boardwalkboardwalk New
edited September 2014 in Localization

First of all, I didn't want to bother you guys with every single questions, so I tried to figure it out by myself entire day.

But I surrendered. :(

I am Korean, I am trying to set up Mentions+ for Korean Language.

Definitely, there is few Koreans who build forum with Vanilla.

I need your help.

.
.

(1) To begin with Regular Expression, Yes I am not sure about Korean regex..... (Why is it so difficult??)

To make 'my own regex',

After this '\d\w_ ', should I put Korean regex? ex) '\d\w_ [가-힣]'

or should I replace whole phrase? ex) '[가-힣a-zA-Z0-9]'

I am trying to test every cases, but I don't know I'm doing right or not.

.
.

(2) Moreover, my site get crashed whenever I change /conf/config.php

I did what @R_J‌ mentioned : http://vanillaforums.org/post/quote/24691/Comment_190750

R_J mentioned config.ini but I couldn't find that file, and I thought is is /conf/config.php

anyway, there is no $Configuration['Garden']['User']['ValidationRegex'] = 'my own regex'

(In my case 'my own regex' should match All Numbers, English, and Korean. Am I right?)

However, whenever I change config.php, my site get crashed with this message: 'Something has gone wrong.' with huge vanillicon :-(

To get it back.

① I have to delete /conf/bootstrap.after.php

At this moment, if I add new /conf/bootstrap.after.php → Site crash again.

So I have to do ①first, ②then enable Mentions+ ③upload new /conf/bootstrap.after.php → Site come back to normal.
(I did it many times)

In this case, I am not sure the change I made above(adding new line) in /conf/config.php is working or not.

.
.

(3) And I am not sure about library/core/fuctions.validation.php line152

C("Garden.User.ValidationRegex","\d\w_"),

Should I change this '\d\w_' with 'my own regex'? (I tried both ways)

I did this : https://github.com/vanilla/vanilla/pull/1653/files
`- '/(^|[\s,.>])@(\w{1,50})\b/i', //{3,20}

  • '/(^|[\s,.>])@('.ValidateUsernameRegex().')\b/i', //{3,20}`

Also I did this : https://github.com/vanilla/vanilla/pull/1654/files#diff-604330a5cab4bf405103e84612897812R1404
`- '/(?:^|[\s,.>])@(\w{3,20})\b/i',

  • '/(?:^|[\s,.>])@('.ValidateUsernameRegex().')\b/i'`

.
.

(4) Also I tried this Unicode setting?
http://vanillaforums.org/post/quote/24691/Comment_190756

But you also have to go to the lines that you've already changed in functions.general.php and class.format.php and change /i'(end of the line) to '/iu'

.
.

(5) 'my own regex' should be equal in where and where?
class.mentionsplus.plugin.php config.php functions.validation.php ?

.
.

....So.... would anyone tell me where should I begin again? (I am harshly confused now.)

«1

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator
    1. Enable the plugin. That will not change anything, but gives you the possibility to change the settings as needed(example.com/settings/mentionsplus)
    2. As the letters allowed in user names, you would need following regex parts: letters, numbers, other characters, the unicode range of Korean characters. It should look like that: '\w\d_- [\x{AC00}-\x{D7A3}]'
    3. Now that the settings are made, add/change the /conf/bootstrap.after.php so that it contains Gdn::FactoryInstall('MentionsFormatter', 'UmlautMentionsFormatter', NULL, Gdn::FactoryInstance); (use the template that's in the zip file).

    The entry in the bootstrap will force Vanilla not to use the built in mentions functions and so you do not have to change any core files.

    Bleistivt
  • Oh.. my quote went to wrong...
    So do you mean I should keep my changes above? and try your 1~3?

  • boardwalkboardwalk New
    edited September 2014

    to be specific, should I keep the changes in config.php fuctions.validation.php, functions.general.php. class.format.php?

    and make all '\w\d_' to '\w\d_- [ㄱ-ㅎ가-힣]'(example)

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    If you mean the changes in functions.general.php and class.format.php, you should reverse them. You also don't need to change your config.php file manually. Simply reverse anything to the start and do the three steps from above (enable, configure, add bootstrap)

  • OK. I will reset everything and follow your simple 3 steps.

    In addition, you mean I don't need /i to /iu right?

  • boardwalkboardwalk New
    edited September 2014

    Also I don't need to change
    from '/(?:^|[\s,\.>])@(\w{3,20})\b/i'

    to '/(?:^|[\s,\.>])@('.ValidateUsernameRegex().')\b/i', in fuctions.general.php and class.format.php

    is it right? None of codes in the files needs to be manually corrected?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @R_J said:
    The entry in the bootstrap will force Vanilla not to use the built in mentions functions and so you do not have to change any core files.

    All your ValidateUsernameRegex changes in the two mentioned files will not be processed anyway, when you use Mentions+

  • I deleted all files and DB. Re-installed Vanilla Forum.
    I tried just 3 simple steps.

    All the post contents disappeared. Is it because of my wrong regex?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @boardwalk said:
    I deleted all files and DB.
    (..)
    All the post contents disappeared

    You've deleted everything and you are surprised that everything is gone? You are joking...

    If not: that has nothing to do with regexes at all. If you delete data it is gone. Comments are stored in the database, so I hope you have a backup.

  • boardwalkboardwalk New
    edited September 2014

    oh.....man. of course I made new discussions ...

    The posts are gone after I put the regex at Mentions+ setting.
    I mean posts' contents are not visible.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    :D glad I just misinterpreted what you said!

    I guess it is a problem with the regex. Could you simply change it in the settings back to \d\w and see if the content is viewable again?

  • boardwalkboardwalk New
    edited September 2014

    Yes. with '\d\w' it came back to normal. I'm trying to put every cases to work, but I haven't found good one yet.

    So.. maybe can I try with /iu ? or no need to change?

  • boardwalkboardwalk New
    edited September 2014

    This is the place to put regex. Right?

    I'm curious why even the regex you wrote is not working. It makes contents not viewable. As same as above.

    8.png 12.1K
  • BleistivtBleistivt MVP
    edited September 2014

    Try \w\d_\- \x{AC00}-\x{D7A3}

    My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations

  • boardwalkboardwalk New
    edited September 2014

    @Bleistivt‌ Not working. invisible same :(

  • peregrineperegrine MVP
    edited September 2014

    what about something like this

    /\.?{Hangul}+/u

    /[d_-\p{Hangul}]/

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine‌ Not working. Contents are not viewable...

  • peregrineperegrine MVP
    edited September 2014

    where are you changing regex I'm lost

    only in the mentions plus plugin?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • boardwalkboardwalk New
    edited September 2014

    Here. Settings>Addons>Plugins>Mentions+ Settings

    9.png 6.6K
  • BleistivtBleistivt MVP
    edited September 2014

    You can't have grouping or delimiters in the regex, as it gets wrapped in [ ]

    try \.?{Hangul}+

    Also make sure you reverted all of the changes you made above that were unnecessary.

    My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations

    peregrine
  • @Bleistivt said:
    You can't have grouping or delimiters in the regex, as it gets wrapped in [ ]

    try \.?{Hangul}+

    Also make sure you reverted all of the changes you made above that were unnecessary.

    Oh,, shouldn't I use / and [ ] ? OK... that's why sometimes contents are viewable or not during many regex trials.

    Without that, contents are viewable, but Mention feature is not working.

  • peregrineperegrine MVP
    edited September 2014

    you should try to debug with breakpoints or a separate test program just to test the matches, against a few hardcoded names and then also put breakpoints in to see what is being checked or returned.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • but \w\d_\- \x{AC00}-\x{D7A3} this case also not viewable.(without / and [])

    I am getting lost.

  • @peregrine said:
    you should try to debug with breakpoints or a separate test program just to test the matches, against a few hardcoded names and then also put breakpoints in to see what is being checked or returned.

    Ehh.... I don't understand what to do ;-(

  • peregrineperegrine MVP
    edited September 2014

    http://php.net/manual/en/function.preg-match.php

    create a new program outside of vanilla try regex to match a korean name. and then with @_koreanname

    once you've got a decent expression. try it

    if you can't match outside vanilla, you won't match inside vanilla

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    boardwalk
  • this is what I meant.

    unfortunately the regex breaks in the validation expression but seems to work here (if I am not deluding myself....

    <!DOCTYPE html>
    <meta charset="utf-8" />
    <?php
    //$pattern ='/[\^\w_\x{AC00}-\x{D7A3}\s]$/u';
    // $pattern ='/(\p{Hangul}+)/u';
    $pattern ='/[\p{Han}+\p{Katakana}+\p{Hiragana}+\p{Hangul}]+/iu';
     // $match_string = "印刷最安 ニ";
    
     $match_string = "@_印刷最계란말이 산책책로123 는여 기 사는 ";
    
    if (preg_match($pattern, $match_string,$matches)) {
        echo "Found - pattern $pattern";
    } else {
        echo "Not found - pattern $pattern";
    }
    echo "<pre>";
    var_dump($matches);
    echo "</pre>";
    

    ?>

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    boardwalkBleistivt
  • boardwalkboardwalk New
    edited September 2014

    Would you guys give me more your own Regex EXAMPLES? so that I can compare with it.

    The default value of Mentions+ is \d\w_ äöüß (is it German?)

    Anyway, I added new user äöüß , and tried to make mention: @äöüß but it didn't work.

    It should work... shouldn't it? ...

    Ah.. that was not the proper word. I made another user Schön

    and @Schön is working

    R_Jperegrine
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    That's a bug! Yes, those characters are German special characters and mentions do not work as expected if the umlaut is the last character of the username. Great finding, thanks for that! I'll work on it and also try to work out the correct setting for Korean characters. Please be patient!

  • @R_J said:
    That's a bug! Yes, those characters are German special characters and mentions do not work as expected if the umlaut is the last character of the username. Great finding, thanks for that! I'll work on it and also try to work out the correct setting for Korean characters. Please be patient!

    Oh... it seems that I found out something important... :wink: (I didn't mean to but...)

    Wow, are you going to check Korean language regex for me?
    and does it mean that I should stop trying to put new combinations of regex for Korean characters by myself?

    I have been trying to put a lot of cases of regex, but nothing worked properly.
    Can I stop this agony for a moment? lol.

    peregrine
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    All fixed now, and support for Korean letters works right from the start!

    I've uploaded a new version. Now if you simply put in \d\w everything should be fine. You can add underscore, dash and space if you like to allow that characters, too (\d\w_- ). Note that usernames with spaces have to be mentioned like that @힣가 힣가. I've tested it with @가-힣가-힣가-힣 and @가힣가 and they have been formatted correctly. Because I had no users like that, I simply assume that also the notification is working. Please tell me if that still doesn't work.

    You now have to do the following:
    a) download the current version: http://vanillaforums.org/get/mentionsplus-plugin-0.12
    b) unzip it into the plugin folder
    c) goto settings and enter \d\w-_ to let mentions work with numbers ("\d"), letters ("\w" including Korean!), dash and underscore ("-_"). Save that.

    I hope it works now. Thanks for helping making that plugin more versatile :)

    Bleistivtboardwalkperegrine
«1
Sign In or Register to comment.