Example #1
0
 /**
  * Formats wiki links and media links in text; all other wiki formatting
  * is ignored
  *
  * @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
  * @param $comment String: text to format links in
  * @param $title An optional title object used to links to sections
  * @param $local Boolean: whether section links should refer to local page
  * @return String
  */
 public static function formatLinksInComment($comment, $title = null, $local = false)
 {
     self::$commentContextTitle = $title;
     self::$commentLocal = $local;
     $html = preg_replace_callback('/\\[\\[:?(.*?)(\\|(.*?))*\\]\\]([^[]*)/', array('Linker', 'formatLinksInCommentCallback'), $comment);
     self::$commentContextTitle = null;
     self::$commentLocal = null;
     return $html;
 }
Example #2
0
    /**
     * Formats wiki links and media links in text; all other wiki formatting
     * is ignored
     *
     * @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
     * @param $comment String: text to format links in
     * @param $title Title|null An optional title object used to links to sections
     * @param $local Boolean: whether section links should refer to local page
     * @return String
     */
    public static function formatLinksInComment($comment, $title = null, $local = false)
    {
        self::$commentContextTitle = $title;
        self::$commentLocal = $local;
        $html = preg_replace_callback('/
				\\[\\[
				:? # ignore optional leading colon
				([^\\]|]+) # 1. link target; page names cannot include ] or |
				(?:\\|
					# 2. a pipe-separated substring; only the last is captured
					# Stop matching at | and ]] without relying on backtracking.
					((?:]?[^\\]|])*+)
				)*
				\\]\\]
				([^[]*) # 3. link trail (the text up until the next link)
			/x', array('Linker', 'formatLinksInCommentCallback'), $comment);
        self::$commentContextTitle = null;
        self::$commentLocal = null;
        return $html;
    }