/** * */ public function __construct() { parent::__construct(); if (function_exists('ValidateUsernameRegex')) { $this->ValidateUsernameRegex = ValidateUsernameRegex(); } else { $this->ValidateUsernameRegex = "[\\d\\w_]{3,20}"; } // Whether to handle drawing quotes or leave it up to some other plugin $this->HandleRenderQuotes = c('Plugins.Quotes.RenderQuotes', true); }
/** * replaces /library/core/class.format.php function Mention * code is as close to original function (taken from 2.0.18.9) as possible */ public function FormatMentions($Mixed) { if (!is_string($Mixed)) { return Gdn_Format::To($Mixed, 'Mentions'); } // Handle @mentions. if (C('Garden.Format.Mentions')) { // without spaces $StrippedValidationRegex = '[' . str_replace(' ', '', str_replace('\\s', '', C('Garden.User.ValidationRegex'))) . ']' . C('Garden.User.ValidationLength', '{3,20}'); $Mixed = preg_replace('/(^|[\\s,\\.>])@(' . $StrippedValidationRegex . ')\\b/iu', '\\1' . Anchor('@\\2', '/profile/\\2'), $Mixed); // with spaces $Mixed = preg_replace('/(^|[\\s,\\.>])@' . C('Plugins.MentionsPlus.MentionStart', '"') . '(' . ValidateUsernameRegex() . ')' . C('Plugins.MentionsPlus.MentionStop', '"') . '/iu', '\\1' . Anchor('@' . C('Plugins.MentionsPlus.MentionStart', '"') . '\\2' . C('Plugins.MentionsPlus.MentionStop', '"'), '/profile/\\2'), $Mixed); } // Handle #hashtag searches if (C('Garden.Format.Hashtags')) { $Mixed = preg_replace('/(^|[\\s,\\.>])\\#([\\w\\-]+)(?=[\\s,\\.!?]|$)/iu', '\\1' . Anchor('#\\2', '/search?Search=%23\\2&Mode=like') . '\\3', $Mixed); } // Handle "/me does x" action statements if (C('Garden.Format.MeActions')) { $Mixed = preg_replace('/(^|[\\n])(\\' . C('Plugins.MentionsPlus.MeActionCode', '/me') . ')(\\s[^(\\n)]+)/iu', '\\1' . Wrap(Wrap('\\2', 'span', array('class' => 'MeActionName')) . '\\3', 'span', array('class' => 'AuthorAction')), $Mixed); } return $Mixed; }
function ValidateUsername($Value, $Field = '') { $ValidateUsernameRegex = ValidateUsernameRegex(); return ValidateRegex($Value, "/^({$ValidateUsernameRegex})?\$/siu"); }
/** * Validate the a string is valid for use as a username. * * @param mixed $value The value to validate. * @return bool Returns true if the value validates or false otherwise. */ function validateUsername($value) { $ValidateUsernameRegex = ValidateUsernameRegex(); return ValidateRegex($value, "/^({$ValidateUsernameRegex})?\$/siu"); }