コード例 #1
0
ファイル: OutputPage.php プロジェクト: OrBin/mediawiki
 /**
  * Get/set the ParserOptions object to use for wikitext parsing
  *
  * @param ParserOptions|null $options Either the ParserOption to use or null to only get the
  *   current ParserOption object
  * @return ParserOptions
  */
 public function parserOptions($options = null)
 {
     if ($options !== null && !empty($options->isBogus)) {
         // Someone is trying to set a bogus pre-$wgUser PO. Check if it has
         // been changed somehow, and keep it if so.
         $anonPO = ParserOptions::newFromAnon();
         $anonPO->setEditSection(false);
         if (!$options->matches($anonPO)) {
             wfLogWarning(__METHOD__ . ': Setting a changed bogus ParserOptions: ' . wfGetAllCallers(5));
             $options->isBogus = false;
         }
     }
     if (!$this->mParserOptions) {
         if (!$this->getContext()->getUser()->isSafeToLoad()) {
             // $wgUser isn't unstubbable yet, so don't try to get a
             // ParserOptions for it. And don't cache this ParserOptions
             // either.
             $po = ParserOptions::newFromAnon();
             $po->setEditSection(false);
             $po->isBogus = true;
             if ($options !== null) {
                 $this->mParserOptions = empty($options->isBogus) ? $options : null;
             }
             return $po;
         }
         $this->mParserOptions = ParserOptions::newFromContext($this->getContext());
         $this->mParserOptions->setEditSection(false);
     }
     if ($options !== null && !empty($options->isBogus)) {
         // They're trying to restore the bogus pre-$wgUser PO. Do the right
         // thing.
         return wfSetVar($this->mParserOptions, null, true);
     } else {
         return wfSetVar($this->mParserOptions, $options);
     }
 }
コード例 #2
0
ファイル: MessageCache.php プロジェクト: paladox/mediawiki
 /**
  * ParserOptions is lazy initialised.
  *
  * @return ParserOptions
  */
 function getParserOptions()
 {
     global $wgUser;
     if (!$this->mParserOptions) {
         if (!$wgUser->isSafeToLoad()) {
             // $wgUser isn't unstubbable yet, so don't try to get a
             // ParserOptions for it. And don't cache this ParserOptions
             // either.
             $po = ParserOptions::newFromAnon();
             $po->setEditSection(false);
             return $po;
         }
         $this->mParserOptions = new ParserOptions();
         $this->mParserOptions->setEditSection(false);
     }
     return $this->mParserOptions;
 }