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


PHP Title::newFromRedirectRecurse方法代码示例

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


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

示例1: execute

 public function execute()
 {
     global $wgCityId;
     $db = wfGetDB(DB_MASTER);
     (new WikiaSQL())->SELECT('*')->FROM('page')->WHERE('page_is_redirect')->EQUAL_TO(1)->runLoop($db, function ($a, $row) use($db) {
         $title = Title::newFromID($row->page_id);
         if (!$title->isDeleted()) {
             $rev = Revision::newFromTitle($title);
             $text = $rev->getText();
             $rt = Title::newFromRedirectRecurse($text);
             if (!$rt) {
                 // page is marked as redirect but $text is not valid redirect
                 $this->output('Fixed ID: ' . $title->getArticleID() . ' Title: ' . $title->getText() . "\n");
                 // Fix page table
                 (new WikiaSQL())->UPDATE('page')->SET('page_is_redirect', 0)->WHERE('page_id')->EQUAL_TO($row->page_id)->RUN($db);
                 // remove redirect from redirect table
                 (new WikiaSQL())->DELETE('redirect')->WHERE('rd_from')->EQUAL_TO($row->page_id)->RUN($db);
                 // clear cache
                 LinkCache::singleton()->addGoodLinkObj($row->page_id, $title, strlen($text), 0, $rev->getId());
                 if ($title->getNamespace() == NS_FILE) {
                     RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
                 }
             }
         }
     });
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:fixFalseRedirects.php

示例2: updateRevisionOn

 /**
 * Update the page record to point to a newly saved revision.
 *
 * @param $dbw DatabaseBase: object
 * @param $revision Revision: For ID number, and text used to set
                    length and redirect status fields
 * @param $lastRevision Integer: if given, will not overwrite the page field
 *                      when different from the currently set value.
 *                      Giving 0 indicates the new page flag should be set
 *                      on.
 * @param $lastRevIsRedirect Boolean: if given, will optimize adding and
 *                           removing rows in redirect table.
 * @return bool true on success, false on failure
 * @private
 */
 public function updateRevisionOn(&$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null)
 {
     wfProfileIn(__METHOD__);
     $text = $revision->getText();
     $rt = Title::newFromRedirectRecurse($text);
     $conditions = array('page_id' => $this->getId());
     if (!is_null($lastRevision)) {
         # An extra check against threads stepping on each other
         $conditions['page_latest'] = $lastRevision;
     }
     $dbw->update('page', array('page_latest' => $revision->getId(), 'page_touched' => $dbw->timestamp(), 'page_is_new' => $lastRevision === 0 ? 1 : 0, 'page_is_redirect' => $rt !== null ? 1 : 0, 'page_len' => strlen($text)), $conditions, __METHOD__);
     $result = $dbw->affectedRows() != 0;
     if ($result) {
         $this->updateRedirectOn($dbw, $rt, $lastRevIsRedirect);
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:33,代码来源:Article.php

示例3: isRedirect

 /**
  * Tests if the article text represents a redirect
  *
  * @param $text String: FIXME
  * @return bool
  */
 public function isRedirect($text = false)
 {
     if ($text === false) {
         if ($this->mDataLoaded) {
             return $this->mIsRedirect;
         }
         // Apparently loadPageData was never called
         $this->loadContent();
         $titleObj = Title::newFromRedirectRecurse($this->fetchContent());
     } else {
         $titleObj = Title::newFromRedirect($text);
     }
     return $titleObj !== null;
 }
开发者ID:BackupTheBerlios,项目名称:swahili-dict,代码行数:20,代码来源:Article.php

示例4: printForm

 static function printForm(&$form_name, &$target_name, $alt_forms = array(), $redirectOnError = false)
 {
     global $wgOut, $wgRequest, $wgUser, $sfgFormPrinter;
     // initialize some variables
     $target_title = null;
     $page_name_formula = null;
     $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
     // If the given form is not a valid title, bail out.
     if (!$form_title) {
         return 'sf_formedit_badurl';
     }
     $form_article = new Article($form_title, 0);
     $form_definition = $form_article->getContent();
     // If the form page is a redirect, use the other form
     // instead.
     if ($form_title->isRedirect()) {
         $form_title = Title::newFromRedirectRecurse($form_definition);
         $form_article = new Article($form_title, 0);
         $form_definition = $form_article->getContent();
     }
     $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_definition);
     if (is_null($target_name)) {
         $target_name = '';
     }
     if ($target_name === '') {
         // parse the form to see if it has a 'page name' value set
         $matches;
         if (preg_match('/{{{info.*page name\\s*=\\s*(.*)}}}/m', $form_definition, $matches)) {
             $page_name_elements = SFUtils::getFormTagComponents($matches[1]);
             $page_name_formula = $page_name_elements[0];
         } elseif (count($alt_forms) == 0) {
             return 'sf_formedit_badurl';
         }
     } else {
         $target_title = Title::newFromText($target_name);
         if ($target_title && $target_title->exists()) {
             if ($wgRequest->getVal('query') == 'true') {
                 $page_contents = null;
                 //$page_is_source = false;
             } else {
                 // If page already exists and 'redlink'
                 // is in the query string, redirect to
                 // the actual page, just like
                 // MediaWiki does it.
                 if ($wgRequest->getBool('redlink')) {
                     $wgOut->redirect($target_title->getFullURL());
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 $target_article = new Article($target_title, 0);
                 $page_contents = $target_article->getContent();
                 //$page_is_source = true;
             }
         } else {
             $target_name = str_replace('_', ' ', $target_name);
         }
     }
     if (!$form_title || !$form_title->exists()) {
         if (count($alt_forms) > 0) {
             $text = '<div class="infoMessage">' . wfMsg('sf_formedit_altformsonly') . ' ' . self::printAltFormsList($alt_forms, $form_name) . "</div>\n";
         } else {
             $text = Html::rawElement('p', array('class' => 'error'), wfMsgExt('sf_formstart_badform', 'parseinline', SFUtils::linkText(SF_NS_FORM, $form_name))) . "\n";
         }
     } elseif ($target_name === '' && $page_name_formula === '') {
         $text = Html::element('p', array('class' => 'error'), wfMsg('sf_formedit_badurl')) . "\n";
     } else {
         $save_page = $wgRequest->getCheck('wpSave');
         $preview_page = $wgRequest->getCheck('wpPreview');
         $diff_page = $wgRequest->getCheck('wpDiff');
         $form_submitted = $save_page || $preview_page || $diff_page;
         // get 'preload' query value, if it exists
         if (!$form_submitted) {
             if ($wgRequest->getCheck('preload')) {
                 $page_is_source = true;
                 $page_contents = SFFormUtils::getPreloadedText($wgRequest->getVal('preload'));
             } else {
                 // let other extensions preload the page, if they want
                 wfRunHooks('sfEditFormPreloadText', array(&$page_contents, $target_title, $form_title));
                 $page_is_source = $page_contents != null;
             }
         } else {
             $page_is_source = false;
             $page_contents = null;
         }
         list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $page_is_source, $form_article->getID(), $page_contents, $target_name, $page_name_formula);
         // Before we do anything else, set the form header
         // title - this needs to be done after formHTML() is
         // called, because otherwise it doesn't take hold
         // for some reason if the form is disabled.
         if (empty($target_title)) {
             $s = wfMsg('sf_formedit_createtitlenotarget', $form_title->getText());
         } elseif ($target_title->exists()) {
             $s = wfMsg('sf_formedit_edittitle', $form_title->getText(), $target_title->getPrefixedText());
         } else {
             $s = wfMsg('sf_formedit_createtitle', $form_title->getText(), $target_title->getPrefixedText());
         }
         $wgOut->setPageTitle($s);
         if ($form_submitted) {
             if (!is_null($page_name_formula) && $page_name_formula !== '') {
                 $target_name = $generated_page_name;
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:SF_FormEdit.php

示例5: resolveRedirects

 private function resolveRedirects($title)
 {
     if (!$title->isRedirect()) {
         return $title;
     }
     $article = new Article($title, 0);
     if (method_exists($title, 'newFromRedirectRecurse')) {
         return Title::newFromRedirectRecurse($article->getContent());
     } else {
         return Title::newFromRedirect($article->getContent());
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:12,代码来源:Collection.suggest.php

示例6: getPreloadedText

 /**
  * Get the contents to be preloaded into the box, either set by
  * an earlier setPreloadText() or by loading the given page.
  *
  * @param $preload String: representing the title to preload from.
  * @return String
  */
 protected function getPreloadedText($preload)
 {
     global $wgUser, $wgParser;
     if (!empty($this->mPreloadText)) {
         return $this->mPreloadText;
     } elseif ($preload !== '') {
         $title = Title::newFromText($preload);
         # Check for existence to avoid getting MediaWiki:Noarticletext
         if (isset($title) && $title->exists() && $title->userCanRead()) {
             $article = new Article($title);
             if ($article->isRedirect()) {
                 $title = Title::newFromRedirectRecurse($article->getContent());
                 # Redirects to missing titles are displayed, to hidden pages are followed
                 # Copying observed behaviour from ?action=view
                 if ($title->exists()) {
                     if ($title->userCanRead()) {
                         $article = new Article($title);
                     } else {
                         return "";
                     }
                 }
             }
             $parserOptions = ParserOptions::newFromUser($wgUser);
             return $wgParser->getPreloadText($article->getContent(), $title, $parserOptions);
         }
     }
     return '';
 }
开发者ID:natalieschauser,项目名称:csp_media_wiki,代码行数:35,代码来源:EditPage.php

示例7: getFormTitle

 /**
  * Get the Title object of a form suitable for editing the target page.
  *
  * @return Title
  * @throws MWException
  */
 protected function getFormTitle()
 {
     // if no form was explicitly specified, try for explicitly set alternate forms
     if ($this->mOptions['form'] === '') {
         $this->logMessage('No form specified. Will try to find the default form for the target page.', self::DEBUG);
         $formNames = array();
         // try explicitly set alternative forms
         if (array_key_exists('alt_form', $this->mOptions)) {
             $formNames = (array) $this->mOptions['alt_form'];
             // cast to array to make sure we get an array, even if only a string was sent
         }
         // if no alternate forms were explicitly set, try finding a default form for the target page
         if (count($formNames) === 0) {
             // if no form and and no alt forms and no target page was specified, give up
             if ($this->mOptions['target'] === '') {
                 throw new MWException(wfMessage('sf_autoedit_notargetspecified')->parse());
             }
             $targetTitle = Title::newFromText($this->mOptions['target']);
             // if the specified target title is invalid, give up
             if (!$targetTitle instanceof Title) {
                 throw new MWException(wfMessage('sf_autoedit_invalidtargetspecified', $this->mOptions['target'])->parse());
             }
             $formNames = SFFormLinker::getDefaultFormsForPage($targetTitle);
             // if no default form can be found, try alternate forms
             if (count($formNames) === 0) {
                 $formNames = SFFormLinker::getFormsThatPagePointsTo($targetTitle->getText(), $targetTitle->getNamespace(), SFFormLinker::ALTERNATE_FORM);
                 // if still no form can be found, give up
                 if (count($formNames) === 0) {
                     throw new MWException(wfMessage('sf_autoedit_noformfound')->parse());
                 }
             }
         }
         // if more than one form was found, issue a notice and give up
         // this happens if no default form but several alternate forms are defined
         if (count($formNames) > 1) {
             throw new MWException(wfMessage('sf_autoedit_toomanyformsfound')->parse(), self::DEBUG);
         }
         $this->mOptions['form'] = $formNames[0];
         $this->logMessage('Using ' . $this->mOptions['form'] . ' as default form.', self::DEBUG);
     }
     $formTitle = Title::makeTitleSafe(SF_NS_FORM, $this->mOptions['form']);
     // if the given form is not a valid title, give up
     if (!$formTitle instanceof Title) {
         throw new MWException(wfMessage('sf_autoedit_invalidform', $this->mOptions['form'])->parse());
     }
     // if the form page is a redirect, follow the redirect
     if ($formTitle->isRedirect()) {
         $this->logMessage('Form ' . $this->mOptions['form'] . ' is a redirect. Finding target.', self::DEBUG);
         $formWikiPage = WikiPage::factory($formTitle);
         if (method_exists($formWikiPage, 'getContent')) {
             // MW 1.21+
             $formTitle = $formWikiPage->getContent(Revision::RAW)->getUltimateRedirectTarget();
         } else {
             $formTitle = Title::newFromRedirectRecurse($formWikiPage->getRawText());
         }
         // if we exeeded $wgMaxRedirects or encountered an invalid redirect target, give up
         if ($formTitle->isRedirect()) {
             $newTitle = WikiPage::factory($formTitle)->getRedirectTarget();
             if ($newTitle instanceof Title && $newTitle->isValidRedirectTarget()) {
                 throw new MWException(wfMessage('sf_autoedit_redirectlimitexeeded', $this->mOptions['form'])->parse());
             } else {
                 throw new MWException(wfMessage('sf_autoedit_invalidredirecttarget', $newTitle->getFullText(), $this->mOptions['form'])->parse());
             }
         }
     }
     // if specified or found form does not exist (e.g. is a red link), give up
     // FIXME: Throw specialized error message, so a list of alternative forms can be shown
     if (!$formTitle->exists()) {
         throw new MWException(wfMessage('sf_autoedit_invalidform', $this->mOptions['form'])->parse());
     }
     return $formTitle;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:78,代码来源:SF_AutoeditAPI.php

示例8: updateRevisionOn

 /**
  * Update the page record to point to a newly saved revision.
  *
  * @param $dbw DatabaseBase: object
  * @param $revision Revision: For ID number, and text used to set
  *                  length and redirect status fields
  * @param $lastRevision Integer: if given, will not overwrite the page field
  *                      when different from the currently set value.
  *                      Giving 0 indicates the new page flag should be set
  *                      on.
  * @param $lastRevIsRedirect Boolean: if given, will optimize adding and
  *                           removing rows in redirect table.
  * @return bool true on success, false on failure
  * @private
  */
 public function updateRevisionOn($dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null)
 {
     wfProfileIn(__METHOD__);
     $text = $revision->getText();
     $len = strlen($text);
     $rt = Title::newFromRedirectRecurse($text);
     $conditions = array('page_id' => $this->getId());
     if (!is_null($lastRevision)) {
         # An extra check against threads stepping on each other
         $conditions['page_latest'] = $lastRevision;
     }
     $now = wfTimestampNow();
     $dbw->update('page', array('page_latest' => $revision->getId(), 'page_touched' => $dbw->timestamp($now), 'page_is_new' => $lastRevision === 0 ? 1 : 0, 'page_is_redirect' => $rt !== null ? 1 : 0, 'page_len' => $len), $conditions, __METHOD__);
     $result = $dbw->affectedRows() > 0;
     if ($result) {
         $this->updateRedirectOn($dbw, $rt, $lastRevIsRedirect);
         $this->setLastEdit($revision);
         $this->setCachedLastEditTime($now);
         $this->mLatest = $revision->getId();
         $this->mIsRedirect = (bool) $rt;
         # Update the LinkCache.
         LinkCache::singleton()->addGoodLinkObj($this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest);
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:41,代码来源:WikiPage.php

示例9: overrideRedirect

 public static function overrideRedirect(Title $title, WebRequest $request, &$ignoreRedirect, &$target, Article &$article)
 {
     global $wgMemc, $wgParserCacheExpireTime;
     $fa = FlaggableWikiPage::getTitleInstance($title);
     // on $wgTitle
     if (!$fa->isReviewable()) {
         return true;
         // nothing to do
     }
     # Viewing an old reviewed version...
     if ($request->getVal('stableid')) {
         $ignoreRedirect = true;
         // don't redirect (same as ?oldid=x)
         return true;
     }
     $srev = $fa->getStableRev();
     $view = FlaggablePageView::singleton();
     # Check if we are viewing an unsynced stable version...
     if ($srev && $view->showingStable() && $srev->getRevId() != $article->getLatest()) {
         # Check the stable redirect properties from the cache...
         $key = wfMemcKey('flaggedrevs', 'overrideRedirect', $article->getId());
         $tuple = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
         if (is_array($tuple)) {
             // cache hit
             list($ignoreRedirect, $target) = $tuple;
         } else {
             // cache miss; fetch the stable rev text...
             $text = $srev->getRevText();
             $redirect = $fa->getRedirectURL(Title::newFromRedirectRecurse($text));
             if ($redirect) {
                 $target = $redirect;
                 // use stable redirect
             } else {
                 $ignoreRedirect = true;
                 // make MW skip redirection
             }
             $data = FlaggedRevs::makeMemcObj(array($ignoreRedirect, $target));
             $wgMemc->set($key, $data, $wgParserCacheExpireTime);
             // cache results
         }
         $clearEnvironment = (bool) $target;
         # Check if the we are viewing a draft or synced stable version...
     } else {
         # In both cases, we can just let MW use followRedirect()
         # on the draft as normal, avoiding any page text hits.
         $clearEnvironment = $article->isRedirect();
     }
     # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle
     if ($clearEnvironment) {
         $view->clear();
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:53,代码来源:FlaggedRevsUI.hooks.php

示例10: getCurrentTitle

 /**
  * @brief Return current title object
  *
  * Return current title, which is later used by getUserFromTitle method
  * @return Title
  *
  */
 public function getCurrentTitle()
 {
     $this->app->wf->ProfileIn(__METHOD__);
     $title = $this->getVal('title');
     if (!empty($title) && is_string($title) && strpos($title, ':') !== false) {
         $title = F::build('Title', array($title), 'newFromText');
     }
     if ($title instanceof Title && $title->isRedirect()) {
         $article = new Article($title);
         $redirect = Title::newFromRedirectRecurse($article->getContent());
         if ($redirect instanceof Title) {
             $title = $redirect;
         }
     }
     $this->app->wf->ProfileOut(__METHOD__);
     return $title;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:24,代码来源:UserProfilePageController.class.php

示例11: getFormTitle

 /**
  * Get the Title object of a form suitable for editing the target page.
  *
  * @return Title
  * @throws MWException
  */
 protected function getFormTitle()
 {
     // if no form was specified, try finding the default form for the target page.
     if ($this->mOptions['form'] === '') {
         $this->logMessage('No form specified. Will try to find the default form for the target page.', self::DEBUG);
         // if no form and no target page was specified, give up
         if ($this->mOptions['target'] === '') {
             throw new MWException(wfMessage('sf_autoedit_notargetspecified')->parse());
         }
         $targetTitle = Title::newFromText($this->mOptions['target']);
         // if the specified target title is invalid, give up
         if (!$targetTitle instanceof Title) {
             throw new MWException(wfMessage('sf_autoedit_invalidtargetspecified', $this->mOptions['target'])->parse());
         }
         $formNames = SFFormLinker::getDefaultFormsForPage($targetTitle);
         // if no form can be found, give up
         if (count($formNames) === 0) {
             throw new MWException(wfMessage('sf_autoedit_noformfound')->parse());
         }
         // if more than one form was found, issue a warning and use the first form
         // FIXME: If we have more than one form, should we stop?
         if (count($formNames) > 1) {
             $this->logMessage(wfMessage('sf_autoedit_toomanyformsfound')->parse(), self::WARNING);
         }
         $this->mOptions['form'] = $formNames[0];
         $this->logMessage('Using ' . $this->mOptions['form'] . ' as default form.', self::DEBUG);
     }
     $formTitle = Title::makeTitleSafe(SF_NS_FORM, $this->mOptions['form']);
     // if the given form is not a valid title, give up
     if (!$formTitle instanceof Title) {
         throw new MWException(wfMessage('sf_autoedit_invalidform', $this->mOptions['form'])->parse());
     }
     // if the form page is a redirect, follow the redirect
     if ($formTitle->isRedirect()) {
         $this->logMessage('Form ' . $this->mOptions['form'] . ' is a redirect. Finding target.', self::DEBUG);
         // FIXME: Title::newFromRedirectRecurse is deprecated as of MW 1.21
         $formTitle = Title::newFromRedirectRecurse(WikiPage::factory($formTitle)->getRawText());
         // if we exeeded $wgMaxRedirects or encountered an invalid redirect target, give up
         if ($formTitle->isRedirect()) {
             $newTitle = WikiPage::factory($formTitle)->getRedirectTarget();
             if ($newTitle instanceof Title && $newTitle->isValidRedirectTarget()) {
                 throw new MWException(wfMessage('sf_autoedit_redirectlimitexeeded', $this->mOptions['form'])->parse());
             } else {
                 throw new MWException(wfMessage('sf_autoedit_invalidredirecttarget', $newTitle->getFullText(), $this->mOptions['form'])->parse());
             }
         }
     }
     // if specified or found form does not exist (e.g. is a red link), give up
     // FIXME: Throw specialized error message, so a list of alternative forms can be shown
     if (!$formTitle->exists()) {
         throw new MWException(wfMessage('sf_autoedit_invalidform', $this->mOptions['form'])->parse());
     }
     return $formTitle;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:60,代码来源:SF_AutoeditAPI.php


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