示例#1
0
 /**
  * Check if these options match that of another options set
  *
  * This ignores report limit settings that only affect HTML comments
  *
  * @param ParserOptions $other
  * @return bool
  * @since 1.25
  */
 public function matches(ParserOptions $other)
 {
     $fields = array_keys(get_class_vars(__CLASS__));
     $fields = array_diff($fields, array('mEnableLimitReport', 'onAccessCallback'));
     foreach ($fields as $field) {
         if (!is_object($this->{$field}) && $this->{$field} !== $other->{$field}) {
             return false;
         }
     }
     // Check the object and lazy-loaded options
     return $this->mUserLang->getCode() === $other->mUserLang->getCode() && $this->getDateFormat() === $other->getDateFormat();
 }
示例#2
0
 /**
  * Helper function for parse() that transforms wiki markup into
  * HTML. Only called for $mOutputType == self::OT_HTML.
  *
  * @private
  *
  * @param $text string
  * @param $isMain bool
  * @param $frame bool
  *
  * @return string
  */
 function internalParse($text, $isMain = true, $frame = false)
 {
     wfProfileIn(__METHOD__);
     $origText = $text;
     # Hook to suspend the parser in this state
     if (!wfRunHooks('ParserBeforeInternalParse', array(&$this, &$text, &$this->mStripState))) {
         wfProfileOut(__METHOD__);
         return $text;
     }
     # if $frame is provided, then use $frame for replacing any variables
     if ($frame) {
         # use frame depth to infer how include/noinclude tags should be handled
         # depth=0 means this is the top-level document; otherwise it's an included document
         if (!$frame->depth) {
             $flag = 0;
         } else {
             $flag = Parser::PTD_FOR_INCLUSION;
         }
         $dom = $this->preprocessToDom($text, $flag);
         $text = $frame->expand($dom);
     } else {
         # if $frame is not provided, then use old-style replaceVariables
         $text = $this->replaceVariables($text);
     }
     wfRunHooks('InternalParseBeforeSanitize', array(&$this, &$text, &$this->mStripState));
     $text = Sanitizer::removeHTMLtags($text, array(&$this, 'attributeStripCallback'), false, array_keys($this->mTransparentTagHooks));
     wfRunHooks('InternalParseBeforeLinks', array(&$this, &$text, &$this->mStripState));
     # Tables need to come after variable replacement for things to work
     # properly; putting them before other transformations should keep
     # exciting things like link expansions from showing up in surprising
     # places.
     $text = $this->doTableStuff($text);
     $text = preg_replace('/(^|\\n)-----*/', '\\1<hr />', $text);
     $text = $this->doDoubleUnderscore($text);
     $text = $this->doHeadings($text);
     if ($this->mOptions->getUseDynamicDates()) {
         $df = DateFormatter::getInstance();
         $text = $df->reformat($this->mOptions->getDateFormat(), $text);
     }
     $text = $this->replaceInternalLinks($text);
     $text = $this->doAllQuotes($text);
     $text = $this->replaceExternalLinks($text);
     # replaceInternalLinks may sometimes leave behind
     # absolute URLs, which have to be masked to hide them from replaceExternalLinks
     $text = str_replace($this->mUniqPrefix . 'NOPARSE', '', $text);
     $text = $this->doMagicLinks($text);
     $text = $this->formatHeadings($text, $origText, $isMain);
     wfProfileOut(__METHOD__);
     return $text;
 }