当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::newFromRedirectArray方法代码示例

本文整理汇总了PHP中Title::newFromRedirectArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::newFromRedirectArray方法的具体用法?PHP Title::newFromRedirectArray怎么用?PHP Title::newFromRedirectArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Title的用法示例。


在下文中一共展示了Title::newFromRedirectArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (is_null($params['text']) && is_null($params['appendtext']) && is_null($params['prependtext']) && $params['undo'] == 0) {
         $this->dieUsageMsg(array('missingtext'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj || $titleObj->isExternal()) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     if ($params['redirect']) {
         if ($titleObj->isRedirect()) {
             $oldTitle = $titleObj;
             $titles = Title::newFromRedirectArray(Revision::newFromTitle($oldTitle)->getText(Revision::FOR_THIS_USER));
             $redirValues = array();
             foreach ($titles as $id => $newTitle) {
                 if (!isset($titles[$id - 1])) {
                     $titles[$id - 1] = $oldTitle;
                 }
                 $redirValues[] = array('from' => $titles[$id - 1]->getPrefixedText(), 'to' => $newTitle->getPrefixedText());
                 $titleObj = $newTitle;
             }
             $this->getResult()->setIndexedTagName($redirValues, 'r');
             $this->getResult()->addValue(null, 'redirects', $redirValues);
         }
     }
     // Some functions depend on $wgTitle == $ep->mTitle
     global $wgTitle;
     $wgTitle = $titleObj;
     if ($params['createonly'] && $titleObj->exists()) {
         $this->dieUsageMsg(array('createonly-exists'));
     }
     if ($params['nocreate'] && !$titleObj->exists()) {
         $this->dieUsageMsg(array('nocreate-missing'));
     }
     // Now let's check whether we're even allowed to do this
     $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
     if (!$titleObj->exists()) {
         $errors = array_merge($errors, $titleObj->getUserPermissionsErrors('create', $wgUser));
     }
     if (count($errors)) {
         $this->dieUsageMsg($errors[0]);
     }
     $articleObj = new Article($titleObj);
     $toMD5 = $params['text'];
     if (!is_null($params['appendtext']) || !is_null($params['prependtext'])) {
         // For non-existent pages, Article::getContent()
         // returns an interface message rather than ''
         // We do want getContent()'s behavior for non-existent
         // MediaWiki: pages, though
         if ($articleObj->getID() == 0 && $titleObj->getNamespace() != NS_MEDIAWIKI) {
             $content = '';
         } else {
             $content = $articleObj->getContent();
         }
         if (!is_null($params['section'])) {
             // Process the content for section edits
             global $wgParser;
             $section = intval($params['section']);
             $content = $wgParser->getSection($content, $section, false);
             if ($content === false) {
                 $this->dieUsage("There is no section {$section}.", 'nosuchsection');
             }
         }
         $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
         $toMD5 = $params['prependtext'] . $params['appendtext'];
     }
     if ($params['undo'] > 0) {
         if ($params['undoafter'] > 0) {
             if ($params['undo'] < $params['undoafter']) {
                 list($params['undo'], $params['undoafter']) = array($params['undoafter'], $params['undo']);
             }
             $undoafterRev = Revision::newFromID($params['undoafter']);
         }
         $undoRev = Revision::newFromID($params['undo']);
         if (is_null($undoRev) || $undoRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undo']));
         }
         if ($params['undoafter'] == 0) {
             $undoafterRev = $undoRev->getPrevious();
         }
         if (is_null($undoafterRev) || $undoafterRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undoafter']));
         }
         if ($undoRev->getPage() != $articleObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText()));
         }
         if ($undoafterRev->getPage() != $articleObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText()));
         }
         $newtext = $articleObj->getUndoText($undoRev, $undoafterRev);
         if ($newtext === false) {
             $this->dieUsageMsg(array('undo-failure'));
         }
         $params['text'] = $newtext;
         // If no summary was given and we only undid one rev,
         // use an autosummary
         if (is_null($params['summary']) && $titleObj->getNextRevisionID($undoafterRev->getID()) == $params['undo']) {
             $params['summary'] = wfMsgForContent('undo-summary', $params['undo'], $undoRev->getUserText());
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:ApiEditPage.php

示例2: view


//.........这里部分代码省略.........
                 $text = $this->getContent();
                 if ($text === false || $this->getID() == 0) {
                     wfDebug(__METHOD__ . ": showing missing article\n");
                     $this->showMissingArticle();
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 # Another whitelist check in case oldid is altering the title
                 if (!$this->mTitle->userCanRead()) {
                     wfDebug(__METHOD__ . ": denied on secondary read check\n");
                     $wgOut->loginToUse();
                     $wgOut->output();
                     $wgOut->disable();
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 # Are we looking at an old revision
                 if ($oldid && !is_null($this->mRevision)) {
                     $this->setOldSubtitle($oldid);
                     if (!$this->showDeletedRevisionHeader()) {
                         wfDebug(__METHOD__ . ": cannot view deleted revision\n");
                         wfProfileOut(__METHOD__);
                         return;
                     }
                     # If this "old" version is the current, then try the parser cache...
                     if ($oldid === $this->getLatest() && $this->useParserCache(false)) {
                         $this->mParserOutput = $parserCache->get($this, $parserOptions);
                         if ($this->mParserOutput) {
                             wfDebug(__METHOD__ . ": showing parser cache for current rev permalink\n");
                             $wgOut->addParserOutput($this->mParserOutput);
                             $wgOut->setRevisionId($this->mLatest);
                             $outputDone = true;
                             break;
                         }
                     }
                 }
                 # Ensure that UI elements requiring revision ID have
                 # the correct version information.
                 $wgOut->setRevisionId($this->getRevIdFetched());
                 # Pages containing custom CSS or JavaScript get special treatment
                 if ($this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage()) {
                     wfDebug(__METHOD__ . ": showing CSS/JS source\n");
                     $this->showCssOrJsPage();
                     $outputDone = true;
                 } else {
                     $rt = Title::newFromRedirectArray($text);
                     if ($rt) {
                         wfDebug(__METHOD__ . ": showing redirect=no page\n");
                         # Viewing a redirect page (e.g. with parameter redirect=no)
                         # Don't append the subtitle if this was an old revision
                         $wgOut->addHTML($this->viewRedirect($rt, !$wasRedirected && $this->isCurrent()));
                         # Parse just to get categories, displaytitle, etc.
                         $this->mParserOutput = $wgParser->parse($text, $this->mTitle, $parserOptions);
                         $wgOut->addParserOutputNoText($this->mParserOutput);
                         $outputDone = true;
                     }
                 }
                 break;
             case 4:
                 # Run the parse, protected by a pool counter
                 wfDebug(__METHOD__ . ": doing uncached parse\n");
                 $key = $parserCache->getKey($this, $parserOptions);
                 $poolArticleView = new PoolWorkArticleView($this, $key, $useParserCache, $parserOptions);
                 if (!$poolArticleView->execute()) {
                     # Connection or timeout error
                     wfProfileOut(__METHOD__);
                     return;
                 } else {
                     $outputDone = true;
                 }
                 break;
                 # Should be unreachable, but just in case...
             # Should be unreachable, but just in case...
             default:
                 break 2;
         }
     }
     # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
     if ($this->mParserOutput) {
         $titleText = $this->mParserOutput->getTitleText();
         if (strval($titleText) !== '') {
             $wgOut->setPageTitle($titleText);
         }
     }
     # For the main page, overwrite the <title> element with the con-
     # tents of 'pagetitle-view-mainpage' instead of the default (if
     # that's not empty).
     # This message always exists because it is in the i18n files
     if ($this->mTitle->equals(Title::newMainPage()) && ($m = wfMsgForContent('pagetitle-view-mainpage')) !== '') {
         $wgOut->setHTMLTitle($m);
     }
     # Now that we've filled $this->mParserOutput, we know whether
     # there are any __NOINDEX__ tags on the page
     $policy = $this->getRobotPolicy('view');
     $wgOut->setIndexPolicy($policy['index']);
     $wgOut->setFollowPolicy($policy['follow']);
     $this->showViewFooter();
     $this->viewUpdates();
     wfProfileOut(__METHOD__);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:Article.php

示例3: getRedirectHtml

 protected function getRedirectHtml($text)
 {
     $rTargets = Title::newFromRedirectArray($text);
     if ($rTargets) {
         $article = new Article($this->article->getTitle());
         return $article->viewRedirect($rTargets);
     }
     return '';
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:9,代码来源:FlaggablePageView.php

示例4: getPreviewText

 /**
  * Get the rendered text for previewing.
  * @return string
  */
 function getPreviewText()
 {
     global $wgOut, $wgUser, $wgParser, $wgRawHtml;
     wfProfileIn(__METHOD__);
     if ($wgRawHtml && !$this->mTokenOk) {
         // Could be an offsite preview attempt. This is very unsafe if
         // HTML is enabled, as it could be an attack.
         $parsedNote = '';
         if ($this->textbox1 !== '') {
             // Do not put big scary notice, if previewing the empty
             // string, which happens when you initially edit
             // a category page, due to automatic preview-on-open.
             $parsedNote = $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>", true, true);
         }
         wfProfileOut(__METHOD__);
         return $parsedNote;
     }
     if ($this->mTriedSave && !$this->mTokenOk) {
         if ($this->mTokenOkExceptSuffix) {
             $note = wfMsg('token_suffix_mismatch');
         } else {
             $note = wfMsg('session_fail_preview');
         }
     } elseif ($this->incompleteForm) {
         $note = wfMsg('edit_form_incomplete');
     } else {
         $note = wfMsg('previewnote');
     }
     $parserOptions = ParserOptions::newFromUser($wgUser);
     $parserOptions->setEditSection(false);
     $parserOptions->setTidy(true);
     $parserOptions->setIsPreview(true);
     $parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== '');
     # don't parse non-wikitext pages, show message about preview
     # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
     if ($this->isCssJsSubpage || !$this->mTitle->isWikitextPage()) {
         if ($this->mTitle->isCssJsSubpage()) {
             $level = 'user';
         } elseif ($this->mTitle->isCssOrJsPage()) {
             $level = 'site';
         } else {
             $level = false;
         }
         # Used messages to make sure grep find them:
         # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
         if ($level) {
             if (preg_match("/\\.css\$/", $this->mTitle->getText())) {
                 $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg("{$level}csspreview") . "\n</div>";
                 $class = "mw-code mw-css";
             } elseif (preg_match("/\\.js\$/", $this->mTitle->getText())) {
                 $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg("{$level}jspreview") . "\n</div>";
                 $class = "mw-code mw-js";
             } else {
                 throw new MWException('A CSS/JS (sub)page but which is not css nor js!');
             }
         }
         $parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions);
         $previewHTML = $parserOutput->mText;
         $previewHTML .= "<pre class=\"{$class}\" dir=\"ltr\">\n" . htmlspecialchars($this->textbox1) . "\n</pre>\n";
     } else {
         $rt = Title::newFromRedirectArray($this->textbox1);
         if ($rt) {
             $previewHTML = $this->mArticle->viewRedirect($rt, false);
         } else {
             $toparse = $this->textbox1;
             # If we're adding a comment, we need to show the
             # summary as the headline
             if ($this->section == "new" && $this->summary != "") {
                 $toparse = wfMsgForContent('newsectionheaderdefaultlevel', $this->summary) . "\n\n" . $toparse;
             }
             wfRunHooks('EditPageGetPreviewText', array($this, &$toparse));
             $parserOptions->enableLimitReport();
             $toparse = $wgParser->preSaveTransform($toparse, $this->mTitle, $wgUser, $parserOptions);
             $parserOutput = $wgParser->parse($toparse, $this->mTitle, $parserOptions);
             $previewHTML = $parserOutput->getText();
             $this->mParserOutput = $parserOutput;
             $wgOut->addParserOutputNoText($parserOutput);
             if (count($parserOutput->getWarnings())) {
                 $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
             }
         }
     }
     if ($this->isConflict) {
         $conflict = '<h2 id="mw-previewconflict">' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n";
     } else {
         $conflict = '<hr />';
     }
     $previewhead = "<div class='previewnote'>\n" . '<h2 id="mw-previewheader">' . htmlspecialchars(wfMsg('preview')) . "</h2>" . $wgOut->parse($note, true, true) . $conflict . "</div>\n";
     $pageLang = $this->mTitle->getPageLanguage();
     $attribs = array('lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), 'class' => 'mw-content-' . $pageLang->getDir());
     $previewHTML = Html::rawElement('div', $attribs, $previewHTML);
     wfProfileOut(__METHOD__);
     return $previewhead . $previewHTML . $this->previewTextAfterContent;
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:98,代码来源:EditPage.php

示例5: view


//.........这里部分代码省略.........
                 // return status different than HTTP 200 when revision is missing (BAC-630)
                 if (!$this->mRevision instanceof Revision) {
                     global $wgEnableParserCache;
                     wfDebug(__METHOD__ . ": no revision found - disabling parser cache and returning 404\n");
                     $wgOut->getRequest()->response()->header('X-Missing-Revision: 1', true, 404);
                     $useParserCache = false;
                     $wgEnableParserCache = false;
                 }
                 // Wikia change - end
                 # Are we looking at an old revision
                 if ($oldid && $this->mRevision) {
                     $this->setOldSubtitle($oldid);
                     if (!$this->showDeletedRevisionHeader()) {
                         wfDebug(__METHOD__ . ": cannot view deleted revision\n");
                         wfProfileOut(__METHOD__);
                         return;
                     }
                 }
                 # Ensure that UI elements requiring revision ID have
                 # the correct version information.
                 $wgOut->setRevisionId($this->getRevIdFetched());
                 # Preload timestamp to avoid a DB hit
                 $wgOut->setRevisionTimestamp($this->getTimestamp());
                 # Pages containing custom CSS or JavaScript get special treatment
                 if ($this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage()) {
                     wfDebug(__METHOD__ . ": showing CSS/JS source\n");
                     $this->showCssOrJsPage();
                     $outputDone = true;
                 } elseif (!wfRunHooks('ArticleViewCustom', array($this->mContent, $this->getTitle(), $wgOut))) {
                     # Allow extensions do their own custom view for certain pages
                     $outputDone = true;
                 } else {
                     $text = $this->getContent();
                     $rt = Title::newFromRedirectArray($text);
                     if ($rt) {
                         wfDebug(__METHOD__ . ": showing redirect=no page\n");
                         # Viewing a redirect page (e.g. with parameter redirect=no)
                         $wgOut->addHTML($this->viewRedirect($rt));
                         # Parse just to get categories, displaytitle, etc.
                         $this->mParserOutput = $wgParser->parse($text, $this->getTitle(), $parserOptions);
                         $wgOut->addParserOutputNoText($this->mParserOutput);
                         $outputDone = true;
                     }
                 }
                 break;
             case 4:
                 # Run the parse, protected by a pool counter
                 wfDebug(__METHOD__ . ": doing uncached parse\n");
                 $poolArticleView = new PoolWorkArticleView($this, $parserOptions, $this->getRevIdFetched(), $useParserCache, $this->getContent());
                 if (!$poolArticleView->execute()) {
                     $error = $poolArticleView->getError();
                     if ($error) {
                         $wgOut->clearHTML();
                         // for release() errors
                         $wgOut->enableClientCache(false);
                         $wgOut->setRobotPolicy('noindex,nofollow');
                         $errortext = $error->getWikiText(false, 'view-pool-error');
                         $wgOut->addWikiText('<div class="errorbox">' . $errortext . '</div>');
                     }
                     # Connection or timeout error
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 $this->mParserOutput = $poolArticleView->getParserOutput();
                 $wgOut->addParserOutput($this->mParserOutput);
                 // Wikia change - begin - @author: wladek
开发者ID:Tjorriemorrie,项目名称:app,代码行数:67,代码来源:Article.php

示例6: getPreviewText

 /**
  * Get the rendered text for previewing.
  * @return string
  */
 function getPreviewText()
 {
     global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang, $wgMessageCache;
     wfProfileIn(__METHOD__);
     if ($this->mTriedSave && !$this->mTokenOk) {
         if ($this->mTokenOkExceptSuffix) {
             $note = wfMsg('token_suffix_mismatch');
         } else {
             $note = wfMsg('session_fail_preview');
         }
     } else {
         $note = wfMsg('previewnote');
     }
     $parserOptions = ParserOptions::newFromUser($wgUser);
     $parserOptions->setEditSection(false);
     $parserOptions->setIsPreview(true);
     $parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== '');
     global $wgRawHtml;
     if ($wgRawHtml && !$this->mTokenOk) {
         // Could be an offsite preview attempt. This is very unsafe if
         // HTML is enabled, as it could be an attack.
         return $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>");
     }
     # don't parse user css/js, show message about preview
     # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
     if ($this->isCssJsSubpage) {
         if (preg_match("/\\.css\$/", $this->mTitle->getText())) {
             $previewtext = wfMsg('usercsspreview');
         } else {
             if (preg_match("/\\.js\$/", $this->mTitle->getText())) {
                 $previewtext = wfMsg('userjspreview');
             }
         }
         $parserOptions->setTidy(true);
         $parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions);
         $previewHTML = $parserOutput->mText;
     } elseif ($rt = Title::newFromRedirectArray($this->textbox1)) {
         $previewHTML = $this->mArticle->viewRedirect($rt, false);
     } else {
         $toparse = $this->textbox1;
         # If we're adding a comment, we need to show the
         # summary as the headline
         if ($this->section == "new" && $this->summary != "") {
             $toparse = "== {$this->summary} ==\n\n" . $toparse;
         }
         if ($this->mMetaData != "") {
             $toparse .= "\n" . $this->mMetaData;
         }
         // Parse mediawiki messages with correct target language
         if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
             list(, $lang) = $wgMessageCache->figureMessage($this->mTitle->getText());
             $obj = wfGetLangObj($lang);
             $parserOptions->setTargetLanguage($obj);
         }
         $parserOptions->setTidy(true);
         $parserOptions->enableLimitReport();
         $parserOutput = $wgParser->parse($this->mArticle->preSaveTransform($toparse), $this->mTitle, $parserOptions);
         $previewHTML = $parserOutput->getText();
         $this->mParserOutput = $parserOutput;
         $wgOut->addParserOutputNoText($parserOutput);
         if (count($parserOutput->getWarnings())) {
             $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
         }
     }
     $previewhead = '<h2>' . htmlspecialchars(wfMsg('preview')) . "</h2>\n" . "<div class='previewnote'>" . $wgOut->parse($note) . "</div>\n";
     if ($this->isConflict) {
         $previewhead .= '<h2>' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n";
     }
     wfProfileOut(__METHOD__);
     return $previewhead . $previewHTML;
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:75,代码来源:EditPage.php

示例7: getPreviewText

 /**
  * Get the rendered text for previewing.
  * @return string
  */
 function getPreviewText()
 {
     global $wgOut, $wgUser, $wgParser, $wgMessageCache;
     wfProfileIn(__METHOD__);
     if ($this->mTriedSave && !$this->mTokenOk) {
         if ($this->mTokenOkExceptSuffix) {
             $note = wfMsg('token_suffix_mismatch');
         } else {
             $note = wfMsg('session_fail_preview');
         }
     } else {
         $note = wfMsg('previewnote');
     }
     $parserOptions = ParserOptions::newFromUser($wgUser);
     $parserOptions->setEditSection(false);
     $parserOptions->setIsPreview(true);
     $parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== '');
     global $wgRawHtml;
     if ($wgRawHtml && !$this->mTokenOk) {
         // Could be an offsite preview attempt. This is very unsafe if
         // HTML is enabled, as it could be an attack.
         $parsedNote = $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>");
         wfProfileOut(__METHOD__);
         return $parsedNote;
     }
     # don't parse user css/js, show message about preview
     # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
     if ($this->isCssJsSubpage || $this->mTitle->isCssOrJsPage()) {
         $level = 'user';
         if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
             $level = 'site';
         }
         # Used messages to make sure grep find them:
         # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
         if (preg_match("/\\.css\$/", $this->mTitle->getText())) {
             $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg("{$level}csspreview") . "\n</div>";
             $class = "mw-code mw-css";
         } elseif (preg_match("/\\.js\$/", $this->mTitle->getText())) {
             $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg("{$level}jspreview") . "\n</div>";
             $class = "mw-code mw-js";
         } else {
             throw new MWException('A CSS/JS (sub)page but which is not css nor js!');
         }
         $parserOptions->setTidy(true);
         $parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions);
         $previewHTML = $parserOutput->mText;
         $previewHTML .= "<pre class=\"{$class}\" dir=\"ltr\">\n" . htmlspecialchars($this->textbox1) . "\n</pre>\n";
     } else {
         $rt = Title::newFromRedirectArray($this->textbox1);
         if ($rt) {
             $previewHTML = $this->mArticle->viewRedirect($rt, false);
         } else {
             $toparse = $this->textbox1;
             # If we're adding a comment, we need to show the
             # summary as the headline
             if ($this->section == "new" && $this->summary != "") {
                 $toparse = "== {$this->summary} ==\n\n" . $toparse;
             }
             wfRunHooks('EditPageGetPreviewText', array($this, &$toparse));
             // Parse mediawiki messages with correct target language
             if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
                 list(, $lang) = $wgMessageCache->figureMessage($this->mTitle->getText());
                 $obj = wfGetLangObj($lang);
                 $parserOptions->setTargetLanguage($obj);
             }
             $parserOptions->setTidy(true);
             $parserOptions->enableLimitReport();
             $parserOutput = $wgParser->parse($this->mArticle->preSaveTransform($toparse), $this->mTitle, $parserOptions);
             $previewHTML = $parserOutput->getText();
             $this->mParserOutput = $parserOutput;
             $wgOut->addParserOutputNoText($parserOutput);
             if (count($parserOutput->getWarnings())) {
                 $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
             }
         }
     }
     if ($this->isConflict) {
         $conflict = '<h2 id="mw-previewconflict">' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n";
     } else {
         $conflict = '<hr />';
     }
     $previewhead = "<div class='previewnote'>\n" . '<h2 id="mw-previewheader">' . htmlspecialchars(wfMsg('preview')) . "</h2>" . $wgOut->parse($note) . $conflict . "</div>\n";
     wfProfileOut(__METHOD__);
     return $previewhead . $previewHTML . $this->previewTextAfterContent;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:89,代码来源:EditPage.php

示例8: view


//.........这里部分代码省略.........
                 // FIXME: This would be a nice place to load the 'no such page' text.
             } else {
                 $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid);
                 # Allow admins to see deleted content if explicitly requested
                 if ($this->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                     if (!$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT)) {
                         $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission');
                         $wgOut->setPageTitle($this->mTitle->getPrefixedText());
                         wfProfileOut(__METHOD__);
                         return;
                     } else {
                         $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                         // and we are allowed to see...
                     }
                 }
                 // Is this the current revision and otherwise cacheable? Try the parser cache...
                 if ($oldid === $this->getLatest() && $this->useParserCache(false) && $wgOut->tryParserCache($this)) {
                     $outputDone = true;
                 }
             }
         }
         // Ensure that UI elements requiring revision ID have
         // the correct version information.
         $wgOut->setRevisionId($this->getRevIdFetched());
         if ($outputDone) {
             // do nothing...
             // Pages containing custom CSS or JavaScript get special treatment
         } else {
             if ($this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage()) {
                 $wgOut->addHTML(wfMsgExt('clearyourcache', 'parse'));
                 // Give hooks a chance to customise the output
                 if (wfRunHooks('ShowRawCssJs', array($this->mContent, $this->mTitle, $wgOut))) {
                     // Wrap the whole lot in a <pre> and don't parse
                     $m = array();
                     preg_match('!\\.(css|js)$!u', $this->mTitle->getText(), $m);
                     $wgOut->addHTML("<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n");
                     $wgOut->addHTML(htmlspecialchars($this->mContent));
                     $wgOut->addHTML("\n</pre>\n");
                 }
             } else {
                 if ($rt = Title::newFromRedirectArray($text)) {
                     # get an array of redirect targets
                     # Don't append the subtitle if this was an old revision
                     $wgOut->addHTML($this->viewRedirect($rt, !$wasRedirected && $this->isCurrent()));
                     $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser));
                     $wgOut->addParserOutputNoText($parseout);
                 } else {
                     if ($pcache) {
                         # Display content and save to parser cache
                         $this->outputWikiText($text);
                     } else {
                         # Display content, don't attempt to save to parser cache
                         # Don't show section-edit links on old revisions... this way lies madness.
                         if (!$this->isCurrent()) {
                             $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false);
                         }
                         # Display content and don't save to parser cache
                         # With timing hack -- TS 2006-07-26
                         $time = -wfTime();
                         $this->outputWikiText($text, false);
                         $time += wfTime();
                         # Timing hack
                         if ($time > 3) {
                             wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->mTitle->getPrefixedDBkey()));
                         }
                         if (!$this->isCurrent()) {
                             $wgOut->parserOptions()->setEditSection($oldEditSectionSetting);
                         }
                     }
                 }
             }
         }
     }
     /* title may have been set from the cache */
     $t = $wgOut->getPageTitle();
     if (empty($t)) {
         $wgOut->setPageTitle($this->mTitle->getPrefixedText());
         # For the main page, overwrite the <title> element with the con-
         # tents of 'pagetitle-view-mainpage' instead of the default (if
         # that's not empty).
         if ($this->mTitle->equals(Title::newMainPage()) && wfMsgForContent('pagetitle-view-mainpage') !== '') {
             $wgOut->setHTMLTitle(wfMsgForContent('pagetitle-view-mainpage'));
         }
     }
     # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
     if ($ns == NS_USER_TALK && IP::isValid($this->mTitle->getText())) {
         $wgOut->addWikiMsg('anontalkpagetext');
     }
     # If we have been passed an &rcid= parameter, we want to give the user a
     # chance to mark this new article as patrolled.
     if (!empty($rcid) && $this->mTitle->exists() && $this->mTitle->quickUserCan('patrol')) {
         $wgOut->addHTML("<div class='patrollink'>" . wfMsgHtml('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}")) . '</div>');
     }
     # Trackbacks
     if ($wgUseTrackbacks) {
         $this->addTrackbacks();
     }
     $this->viewUpdates();
     wfProfileOut(__METHOD__);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:101,代码来源:Article.php


注:本文中的Title::newFromRedirectArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。