示例#1
0
 /**
  * Constructor.
  * We override the constructor to build up the url regex from config
  *
  * @param Wiki $obj the base conversion handler
  */
 public function __construct($obj)
 {
     $default = $this->conf;
     parent::__construct($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']) . '#');
 }
示例#2
0
 /**
  * Constructor.
  * We override the constructor so we can comment the regex nicely.
  *
  * @param Wiki $obj
  */
 public function __construct($obj)
 {
     parent::__construct($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\\/?=&~_#]";
 }
示例#3
0
 /**
  * Constructor.
  * We override the constructor to build up the regex from config
  *
  * @param Wiki $obj the base conversion handler
  */
 public function __construct($obj)
 {
     $default = $this->conf;
     parent::__construct($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';
 }
示例#4
0
 /**
  * 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 Wiki &$obj The calling "parent" Text_Wiki object.
  */
 public function __construct($obj)
 {
     parent::__construct($obj);
     $this->regex = '/' . $this->wiki->delim . '/';
 }