/** * * Constructor. We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Freelink(&$obj) { parent::Text_Wiki_Parse($obj); if ($this->getConf('utf-8')) { $any = '\p{L}'; } else { $any = ''; } $this->regex = '/' . // START regex "\\(\\(" . // double open-parens "(" . // START freelink page patter "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character ")" . // END freelink page pattern "(" . // START display-name "\|" . // a pipe to start the display name "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character ")?" . // END display-name pattern 0 or 1 "(" . // START pattern for named anchors "\#" . // a hash mark "[A-Za-z]" . // 1 alpha "[-A-Za-z0-9_:.]*" . // 0 or more alpha, digit, underscore ")?" . // END named anchors pattern 0 or 1 "()\\)\\)" . // double close-parens '/'.($this->getConf('utf-8') ? 'u' : ''); // END regex }
/** * * Constructor. We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Freelink(&$obj) { parent::Text_Wiki_Parse($obj); return; $this->regex = '/' . "\\[\\[" . "(" . "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&À-ÿ]+" . ")" . "(" . "\\|" . "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&À-ÿ]+" . ")?" . "(" . "\\#" . "[A-Za-z]" . "[-A-Za-z0-9_:.]*" . ")?" . "()\\]\\]" . '/'; // END regex }
/** * * Constructor. * * We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Wikilink(&$obj) { parent::Text_Wiki_Parse($obj); $either = "_A-Za-z0-9À-þ"; // build the regular expression for finding WikiPage names. $this->described_regex = "(!?" . "[{$either}]+" . ")" . "((\\#" . "[{$either}]" . "(" . "[-_{$either}:.]*" . "[-_{$either}]" . ")?)?)"; // end subpatterns (/4)(/3)(/2) $this->encased_regex = "(!?" . "[{$either}]+" . "?)"; // end subpatterns (/4)(/3)(/2) // build the regular expression for finding WikiPage names. /* $this->standalone_regex = "(!?" . // START WikiPage pattern (1) "[$either]" . // 1 upp$eitherer "[$either]*" . // 0+ alpha or digit "[$lower]+" . // 1+ lower or digit "[$upper]" . // 1 upper "[$either]*" . // 0+ or more alpha or digit ")" . // END WikiPage pattern (/1) "((\#" . // START Anchor pattern (2)(3) "[$either]" . // 1 alpha "(" . // start sub pattern (4) "[-_$either:.]*" . // 0+ dash, alpha, digit, underscore, colon, dot "[-_$either]" . // 1 dash, alpha, digit, or underscore ")?)?)"; // end subpatterns (/4)(/3)(/2)*/ }
/** * * Constructor. * * We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Wikilink(&$obj) { parent::Text_Wiki_Parse($obj); // allows numbers as "lowercase letters" in the regex $this->regex = "(!?" . "[A-Z]" . "[A-Za-z0-9]*" . "[a-z0-9]+" . "[A-Z]" . "[A-Za-z0-9]*" . ")" . "((\\#" . "[A-Za-z]" . "(" . "[-A-Za-z0-9_:.]*" . "[-A-Za-z0-9_]" . ")?)?)"; // end subpatterns (/4)(/3)(/2) }
function Text_Wiki_Parse_Magic(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = '/' . "\\(\\(" . "\\:" . "(" . "[a-z]+" . ")" . "((?:" . " " . "[\\w\\W]+" . ")*)" . "\\)\\)" . '/'; // END regex //echo($this); }
/** * * Constructor. * * We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Wikilink(&$obj) { parent::Text_Wiki_Parse($obj); if ($this->getConf('utf-8')) { $upper = 'A-Z\\p{Lu}'; $lower = 'a-z0-9\\p{Ll}'; $either = 'A-Za-z0-9\\p{L}'; } else { if ($this->getConf('ext_chars')) { // use an extended character set; this should // allow for umlauts and so on. taken from the // Tavi project defaults.php file. $upper = 'A-Z\\p{Lu}\\xc0-\\xde'; $lower = 'a-z0-9\\p{Ll}\\xdf-\\xfe'; $either = 'A-Za-z0-9\\p{L}\\xc0-\\xfe'; } else { // the default character set, should be fine // for most purposes. $upper = "A-Z"; $lower = "a-z0-9"; $either = "A-Za-z0-9"; } } // build the regular expression for finding WikiPage names. $this->regex = "(!?" . "[{$upper}]" . "[{$either}]*" . "[{$lower}]+" . "[{$upper}]" . "[{$either}]*" . ")" . "((?:\\#" . "[{$either}]" . "(?:" . "[-_{$either}:.]*" . "[-_{$either}]" . ")?)?)"; // end subpatterns (/)(/)(/2) }
/** * Constructor. * We override the constructor to get Image and Interwiki config * * @param object &$obj the base conversion handler * @return The parser object * @access public */ function Text_Wiki_Parse_Wikilink(&$obj) { $default = $this->conf; parent::Text_Wiki_Parse($obj); // override config options for image if specified if (in_array('Image', $this->wiki->disable)) { $this->imageConf['prefix'] = array(); } else { if (isset($this->wiki->parseConf['Image']) && is_array($this->wiki->parseConf['Image'])) { $this->imageConf = array_merge($this->imageConf, $this->wiki->parseConf['Image']); } } // override config options for interwiki if specified if (in_array('Interwiki', $this->wiki->disable)) { $this->interwikiConf['sites'] = array(); $this->interwikiConf['interlangage'] = array(); } else { if (isset($this->wiki->parseConf['Interwiki']) && is_array($this->wiki->parseConf['Interwiki'])) { $this->interwikiConf = array_merge($this->interwikiConf, $this->wiki->parseConf['Interwiki']); } if (empty($this->conf['langage'])) { $this->interwikiConf['interlangage'] = array(); } } // convert the list of recognized schemes to a regex OR, /* $schemes = $this->getConf('schemes', $default['schemes']); $this->url = str_replace( '#delim#', $this->wiki->delim, '#(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://' . $this->getConf('host_regexp', $default['host_regexp']) . $this->getConf('path_regexp', $default['path_regexp']) .'#'); */ }
/** * Constructor. * We override the constructor to build up the url regex from config * * @param object &$obj the base conversion handler * @return The parser object * @access public */ function Text_Wiki_Parse_Image(&$obj) { $default = $this->conf; parent::Text_Wiki_Parse($obj); // convert the list of recognized schemes to a regex OR, $schemes = $this->getConf('schemes', $default['schemes']); $this->url = str_replace('#delim#', $this->wiki->delim, '#(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://' . $this->getConf('host_regexp', $default['host_regexp']) . $this->getConf('path_regexp', $default['path_regexp']) . '#'); }
/** * * Constructor. We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Freelink(&$obj) { parent::Text_Wiki_Parse($obj); if ($this->getConf('utf-8')) { $any = '\\p{L}'; } else { $any = ''; } $this->regex = '/' . '\\[\\[' . '(' . "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&" . $any . "À-ÿ]+" . ')' . '(' . '\\|' . "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&" . $any . "À-ÿ]+" . ')?' . '(' . '\\#' . '[A-Za-z]' . '[-A-Za-z0-9_:.]*' . ')?' . '\\]\\]' . '/' . ($this->getConf('utf-8') ? 'u' : ''); // END regex }
function Text_Wiki_Parse_SpecialChar(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = ''; foreach ($this->types as $type) { if ($this->regex) { $this->regex .= '|'; } $this->regex .= preg_quote($type); } $this->regex = '/(' . $this->regex . '|("|") \\-\\- (?:\\2)|\\~\\d+\\~)/'; }
/** * * Constructor. * * We override the constructor so we can comment the regex nicely. * * @access public * */ function Text_Wiki_Parse_Url(&$obj) { parent::Text_Wiki_Parse($obj); // convert the list of recognized schemes to a regex-safe string, // where the pattern delim is a slash $tmp = array(); $list = $this->getConf('schemes', array()); foreach ($list as $val) { $tmp[] = preg_quote($val, '/'); } $schemes = implode('|', $tmp); // build the regex $this->regex = "({$schemes})" . "(" . "[^ \\/\"\\'{$this->wiki->delim}]*\\/" . ")*" . "[^ \\t\\n\\/\"\\'{$this->wiki->delim}]*" . "[A-Za-z0-9\\/?=&~_]"; }
/** * Constructor. * We override the constructor to build up the regex from config * * @param object &$obj the base conversion handler * @return The parser object * @access public */ function Text_Wiki_Parse_Image(&$obj) { $default = $this->conf; parent::Text_Wiki_Parse($obj); // convert the list of recognized schemes to a regex OR, $schemes = $this->getConf('schemes', $default['schemes']); $this->regex = '#\\[img]((?:(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://' . $this->getConf('url_regexp', $default['url_regexp']); if ($local = $this->getConf('local_regexp', $default['local_regexp'])) { $this->regex .= '|' . (is_array($local) ? implode('|', $local) : $local); } $this->regex .= ')'; // add the extensions if any if ($extensions = $this->getConf('extensions', array())) { if (is_array($extensions)) { $extensions = implode('|', $extensions); } $this->regex .= '\\.(?:' . $extensions . ')'; } // replace delim in the regexps $this->regex = str_replace('#delim#', $this->wiki->delim, $this->regex); $this->regex .= ')\\[/img]#i'; }
/** * * Constructor. * * We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Wikilink(&$obj) { parent::Text_Wiki_Parse($obj); if ($this->getConf('utf-8')) { $upper = 'A-Z\p{Lu}'; $lower = 'a-z0-9\p{Ll}'; $either = 'A-Za-z0-9\p{L}'; } else if ($this->getConf('ext_chars')) { // use an extended character set; this should // allow for umlauts and so on. taken from the // Tavi project defaults.php file. $upper = 'A-Z\xc0-\xde'; $lower = 'a-z0-9\xdf-\xfe'; $either = 'A-Za-z0-9\xc0-\xfe'; } else { // the default character set, should be fine // for most purposes. $upper = "A-Z"; $lower = "a-z0-9"; $either = "A-Za-z0-9"; } // build the regular expression for finding WikiPage names. $this->regex = "( ! ?" . // START WikiPage pattern (1) "[$upper]" . // 1 upper "[$either]*" . // 0+ alpha or digit "[$lower]+" . // 1+ lower or digit "[$upper]" . // 1 upper "[$either]*" . // 0+ or more alpha or digit ")" . // END WikiPage pattern (/1) "((\#" . // START Anchor pattern (2)(3) "[$either]" . // 1 alpha "(" . // start sub pattern (4) "[-_$either:.]*" . // 0+ dash, alpha, digit, underscore, colon, dot "[-_$either]" . // 1 dash, alpha, digit, or underscore ")?)?)"; // end subpatterns (/4)(/3)(/2) }
/** * Constructor. * We override the constructor to build up the regex from config * * @param object &$obj the base conversion handler * @return The parser object * @access public */ function Text_Wiki_Parse_Smiley(&$obj) { $default = $this->conf; parent::Text_Wiki_Parse($obj); // read the list of smileys to sort out variantes and :xxx: while building the regexp $this->_smileys = $this->getConf('smileys', $default['smileys']); $autoNose = $this->getConf('auto_nose', $default['auto_nose']); $reg1 = $reg2 = ''; $sep1 = ':(?:'; $sep2 = ''; foreach ($this->_smileys as $smiley => $def) { for ($i = 1; $i < count($def); $i++) { if ($i > 1) { $cur = $def[$i]; $this->_smileys[$cur] =& $this->_smileys[$smiley]; } else { $cur = $smiley; } $len = strlen($cur); if ($cur[0] == ':' && $len > 2 && $cur[$len - 1] == ':') { $reg1 .= $sep1 . preg_quote(substr($cur, 1, -1), '#'); $sep1 = '|'; continue; } if ($autoNose && $len === 2) { $variante = $cur[0] . '-' . $cur[1]; $this->_smileys[$variante] =& $this->_smileys[$smiley]; $cur = preg_quote($cur[0], '#') . '-?' . preg_quote($cur[1], '#'); } else { $cur = preg_quote($cur, '#'); } $reg2 .= $sep2 . $cur; $sep2 = '|'; } } $delim = '[\\n\\r\\s' . $this->wiki->delim . '$^]'; $this->regex = '#(?<=' . $delim . ')(' . ($reg1 ? $reg1 . '):' . ($reg2 ? '|' : '') : '') . $reg2 . ')(?=' . $delim . ')#i'; }
/** * * Constructor. We override the Text_Wiki_Parse constructor so we can * explicitly comment each part of the $regex property. * * @access public * * @param object &$obj The calling "parent" Text_Wiki object. * */ function Text_Wiki_Parse_Freelink(&$obj) { parent::Text_Wiki_Parse($obj); // $this->regex = // '/' . // START regex // "\\[\\[\\[" . // double open-parens // "(" . // START freelink page patter // "[^\\]\\|\\[\#]+" . // 1 or more of just about any character // ")" . // END freelink page pattern // "(" . // START display-name // "\|" . // a pipe to start the display name // "[^\\]\\|\\[\#]*" . // 1 or more of just about any character // ")?" . // END display-name pattern 0 or 1 // "(" . // START pattern for named anchors // "\#" . // a hash mark // "[A-Za-z]" . // 1 alpha // "[-A-Za-z0-9_:.]*" . // 0 or more alpha, digit, underscore // ")?" . // END named anchors pattern 0 or 1 // "()\\]\\]\\]" . // double close-parens // '/'; // END regex $this->regex = '/' . "\\[\\[\\[" . "(" . "[^\\]\\|\\[\\#]+" . ")" . "\\s*" . "(" . "\\#" . "[A-Za-z]" . "[-A-Za-z0-9_:.]*" . ")?" . "\\s*" . "(" . "\\|" . "[^\\]\\|\\[\\#]*" . ")?" . "()\\]\\]\\]" . '/'; // END regex }
/** * Constructor. * We override the constructor to build up the regex from config * * @param object &$obj the base conversion handler * @return The parser object * @access public */ function Text_Wiki_Parse_Url(&$obj) { $default = $this->conf; parent::Text_Wiki_Parse($obj); // store the list of refused schemes $this->refused = $this->getConf('refused', array()); if (is_string($this->refused)) { $this->refused = array($this->refused); } // convert the list of recognized schemes to a regex OR, $schemes = $this->getConf('schemes', $default['schemes']); $url = '(?:(' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://'; // add the "lazy" prefixes if any $prefixes = $this->getConf('prefixes', array()); foreach ($prefixes as $val) { $url .= '|' . preg_quote($val, '#') . '\\.'; } $host = $this->getConf('host_regexp', $default['host_regexp']); $path = $this->getConf('path_regexp', $default['path_regexp']); // the full url regexp $url .= ')' . $host . $path; // the full email regexp $email = $this->getConf('user_regexp', $default['user_regexp']) . '@' . $host; // inline to disable ? if (!$this->getConf('inline_enable', true)) { unset($this->regex[1]); unset($this->regex[3]); } // relative url to enable ? if ($this->getConf('relative_enable', false)) { $this->regex[5] = str_replace('#url#', $path, $this->regex[0]); } // replace in the regexps $this->regex = str_replace('#url#', $url, $this->regex); $this->regex = str_replace('#email#', $email, $this->regex); $this->regex = str_replace('#delim#', $this->wiki->delim, $this->regex); }
/** * * Constructor. Overrides the Text_Wiki_Parse constructor so that we * can set the $regex property dynamically (we need to include the * Text_Wiki $delim character. * * @param object &$obj The calling "parent" Text_Wiki object. * * @param string $name The token name to use for this rule. * */ function Text_Wiki_Parse_delimiter(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = '/' . $this->wiki->delim . '/'; }
/** * * Constructor. Overrides the Text_Wiki_Parse constructor so that we * can set the $regex property dynamically (we need to include the * Text_Wiki $delim character). * * @param object &$obj The calling "parent" Text_Wiki object. * * @param string $name The token name to use for this rule. * */ function Text_Wiki_Parse_Url(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = '/((?:\\[\\[ *((?:http:\\/\\/|https:\\/\\/|ftp:\\/\\/|mailto:|\\/)[^\\|\\]\\n ]*)( *\\| *([^\\]\\n]*))? *\\]\\])|((http:\\/\\/|https:\\/\\/|ftp:\\/\\/|mailto:)[^\'\\"\\n ' . $this->wiki->delim . ']*[A-Za-z0-9\\/\\?\\=\\&\\~\\_]))/'; }
/** * * Constructor. Overrides the Text_Wiki_Parse constructor so that we * can set the $regex property dynamically (we need to include the * Text_Wiki $delim character. * * @param object &$obj The calling "parent" Text_Wiki object. * * @param string $name The token name to use for this rule. * */ function Text_Wiki_Parse_delimiter(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = "/" . utf8_encode("þ") . "/"; }
public function __construct(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = '/((?:\\[\\[' . Wicked::REGEXP_WIKIWORD . ':\\s+.*?\\]\\]\\s*)+)/'; }
/** * * Constructor. Overrides the Text_Wiki_Parse constructor so that we * can set the $regex property dynamically (we need to include the * Text_Wiki $delim character). * * @param object &$obj The calling "parent" Text_Wiki object. * * @param string $name The token name to use for this rule. * */ function Text_Wiki_Parse_Image(&$obj) { parent::Text_Wiki_Parse($obj); $this->regex = '/{{([^' . $this->wiki->delim . ']*)(\\|([^' . $this->wiki->delim . ']*))?}}/U'; }