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


PHP Title::newFromRedirect方法代码示例

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


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

示例1: onInternalParseBeforeLinks

	/**
	 * This method will be called before an article is displayed or previewed.
	 * For display and preview we strip out the semantic properties and append them
	 * at the end of the article.
	 *
	 * @param Parser $parser
	 * @param string $text
	 */
	static public function onInternalParseBeforeLinks( &$parser, &$text ) {
		global $smwgStoreAnnotations, $smwgLinksInValues;

		SMWParseData::stripMagicWords( $text, $parser );

		// Store the results if enabled (we have to parse them in any case,
		// in order to clean the wiki source for further processing).
		$smwgStoreAnnotations = smwfIsSemanticsProcessed( $parser->getTitle()->getNamespace() );
		SMWParserExtensions::$mTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]]

		// Process redirects, if any (it seems that there is indeed no more direct way of getting this info from MW)
		if ( $smwgStoreAnnotations ) {
			$rt = Title::newFromRedirect( $text );
			
			if ( !is_null( $rt ) ) {
				$p = new SMWDIProperty( '_REDI' );
				$di = SMWDIWikiPage::newFromTitle( $rt, '__red' );
				SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $p, $di );
			}
		}

		// only used in subsequent callbacks, forgotten afterwards
		SMWParserExtensions::$mTempParser = $parser;

		// In the regexp matches below, leading ':' escapes the markup, as known for Categories.
		// Parse links to extract semantic properties.
		if ( $smwgLinksInValues ) { // More complex regexp -- lib PCRE may cause segfaults if text is long :-(
			$semanticLinkPattern = '/\[\[                 # Beginning of the link
			                        (?:([^:][^]]*):[=:])+ # Property name (or a list of those)
			                        (                     # After that:
			                          (?:[^|\[\]]         #   either normal text (without |, [ or ])
			                          |\[\[[^]]*\]\]      #   or a [[link]]
			                          |\[[^]]*\]          #   or an [external link]
			                        )*)                   # all this zero or more times
			                        (?:\|([^]]*))?        # Display text (like "text" in [[link|text]]), optional
			                        \]\]                  # End of link
			                        /xu';
			$text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'parsePropertiesCallback' ), $text );
		} else { // Simpler regexps -- no segfaults found for those, but no links in values.
			$semanticLinkPattern = '/\[\[                 # Beginning of the link
			                        (?:([^:][^]]*):[=:])+ # Property name (or a list of those)
			                        ([^\[\]]*)            # content: anything but [, |, ]
			                        \]\]                  # End of link
			                        /xu';
			$text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'simpleParsePropertiesCallback' ), $text );
		}

		// Add link to RDF to HTML header.
		// TODO: do escaping via Html or Xml class.
		SMWOutputs::requireHeadItem(
			'smw_rdf', '<link rel="alternate" type="application/rdf+xml" title="' .
			htmlspecialchars( $parser->getTitle()->getPrefixedText() ) . '" href="' .
			htmlspecialchars(
				SpecialPage::getTitleFor( 'ExportRDF', $parser->getTitle()->getPrefixedText() )->getLocalUrl( 'xmlmime=rdf' )
			) . "\" />"
		);

		SMWOutputs::commitToParser( $parser );
		return true; // always return true, in order not to stop MW's hook processing!
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:68,代码来源:SMW_ParserExtensions.php

示例2: redircite_render

function redircite_render($input, $args, &$parser) {
	// Generate HTML code and add it to the $redirciteMarkerList array
	// Add "xx-redircite-marker-NUMBER-redircite-xx" to the output,
	// which will be translated to the HTML stored in $redirciteMarkerList by
	// redircite_afterTidy()
	global $redirciteMarkerList;
	# Verify that $input is a valid title
	$inputTitle = Title::newFromText($input);
	if(!$inputTitle)
		return $input;
	$link1 = $parser->recursiveTagParse("[[$input]]");
	$title1 = Title::newFromText($input);
	if(!$title1->exists()) // Page doesn't exist
		// Just output a normal (red) link
		return $link1;
	$articleObj = new Article($title1);
	$title2 = Title::newFromRedirect($articleObj->fetchContent());
	if(!$title2) // Page is not a redirect
		// Just output a normal link
		return $link1;
	
	$link2 = $parser->recursiveTagParse("[[{$title2->getPrefixedText()}|$input]]");
	
	$marker = "xx-redircite-marker-" . count($redirciteMarkerList) . "-redircite-xx";
	$onmouseout = 'this.firstChild.innerHTML = "'. Xml::escapeJsString($input) . '";';
	$onmouseover = 'this.firstChild.innerHTML = "' . Xml::escapeJsString($title2->getPrefixedText()) . '";';
	return Xml::tags('span', array(
					'onmouseout' => $onmouseout,
					'onmouseover' => $onmouseover),
					$link2);
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:redircite.php

示例3: getTopLevelCategories

 function getTopLevelCategories()
 {
     global $wgCategoriesArticle;
     wfLoadExtensionMessages('Sitemap');
     $results = array();
     $revision = Revision::newFromTitle(Title::newFromText(wfMsg('categories_article')));
     if (!$revision) {
         return $results;
     }
     // INTL: If there is a redirect to a localized page name, follow it
     if (strpos($revision->getText(), "#REDIRECT") !== false) {
         $revision = Revision::newFromTitle(Title::newFromRedirect($revision->getText()));
     }
     $lines = split("\n", $revision->getText());
     foreach ($lines as $line) {
         if (preg_match('/^\\*[^\\*]/', $line)) {
             $line = trim(substr($line, 1));
             switch ($line) {
                 case "Other":
                 case "wikiHow":
                     break;
                 default:
                     $results[] = $line;
             }
         }
     }
     return $results;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:28,代码来源:Sitemap.body.php

示例4: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     # Make a link to the redirect itself
     $rd_title = Title::makeTitle($result->namespace, $result->title);
     $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
     $rd_link = $skin->makeKnownLinkObj($rd_title, '', 'redirect=no');
     # Find out where the redirect leads
     $revision = Revision::newFromTitle($rd_title);
     if ($revision) {
         # Make a link to the destination page
         $target = Title::newFromRedirect($revision->getText());
         if ($target) {
             $targetLink = $skin->makeLinkObj($target);
         } else {
             /** @todo Put in some decent error display here */
             $targetLink = '*';
         }
     } else {
         /** @todo Put in some decent error display here */
         $targetLink = '*';
     }
     # Format the whole thing and return it
     return "{$rd_link} {$arr} {$targetLink}";
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:25,代码来源:SpecialListredirects.php

示例5: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     # Make a link to the redirect itself
     $rd_title = Title::makeTitle($result->namespace, $result->title);
     $rd_link = $skin->makeKnownLinkObj($rd_title, '', 'redirect=no');
     # Find out where the redirect leads
     $revision = Revision::newFromTitle($rd_title);
     if ($revision) {
         # Make a link to the destination page
         $target = Title::newFromRedirect($revision->getText());
         if ($target) {
             $targetLink = $skin->makeLinkObj($target);
         } else {
             /** @todo Put in some decent error display here */
             $targetLink = '*';
         }
     } else {
         /** @todo Put in some decent error display here */
         $targetLink = '*';
     }
     # Check the language; RTL wikis need a &larr;
     $arr = $wgContLang->isRTL() ? ' &larr; ' : ' &rarr; ';
     # Format the whole thing and return it
     return $rd_link . $arr . $targetLink;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:26,代码来源:SpecialListredirects.php

示例6: onEditConflict

 /**
  * @since 1.1
  *
  * @param EditPage $editor
  * @param OutputPage &$out
  *
  * @return true
  */
 public function onEditConflict(EditPage &$editor, OutputPage &$out)
 {
     $conctext = $editor->textbox1;
     $actualtext = $editor->textbox2;
     $initialtext = $editor->getBaseRevision()->mText;
     // TODO: WTF?!
     $editor->mArticle->doEdit($actualtext, $editor->summary, $editor->minoredit ? EDIT_MINOR : 0);
     $query = Title::newFromRedirect($actualtext) === null ? '' : 'redirect=no';
     $out->redirect($editor->mTitle->getFullURL($query));
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:DSMW.hooks.php

示例7: addArticle

 public function addArticle($month, $day, $year, $page)
 {
     $lines = array();
     $temp = "";
     $head = array();
     $article = new Article(Title::newFromText($page));
     if (!$article->exists()) {
         return "";
     }
     $redirectCount = 0;
     if ($article->isRedirect() && $this->setting('disableredirects')) {
         return '';
     }
     while ($article->isRedirect() && $redirectCount < 10) {
         $redirectedArticleTitle = Title::newFromRedirect($article->getContent());
         $article = new Article($redirectedArticleTitle);
         $redirectCount += 1;
     }
     $body = $article->fetchContent(0, false, false);
     if (strlen(trim($body)) == 0) {
         return "";
     }
     $lines = split("\n", $body);
     $cntLines = count($lines);
     // dont use section events... only line 1 of the page
     if ($this->setting('disablesectionevents')) {
         $key = $lines[0];
         //initalize the key
         $head[$key] = "";
         $cntLines = 0;
     }
     for ($i = 0; $i < $cntLines; $i++) {
         $line = $lines[$i];
         if (substr($line, 0, 2) == '==') {
             $arr = split("==", $line);
             $key = $arr[1];
             $head[$key] = "";
             $temp = "";
         } else {
             if ($i == 0) {
                 // $i=0  means this is a one event page no (==event==) data
                 $key = $line;
                 //initalize the key
                 $head[$key] = "";
             } else {
                 $temp .= "{$line}\n";
                 $head[$key] = Common::cleanWiki($temp);
             }
         }
     }
     while (list($event, $body) = each($head)) {
         $this->buildEvent($month, $day, $year, trim($event), $page, $body);
     }
 }
开发者ID:radii,项目名称:noisecal,代码行数:54,代码来源:CalendarArticles.php

示例8: run

 function run()
 {
     if (!$this->redirTitle) {
         $this->setLastError('Invalid title');
         return false;
     }
     $targetRev = Revision::newFromTitle($this->title);
     if (!$targetRev) {
         wfDebug(__METHOD__ . ": target redirect already deleted, ignoring\n");
         return true;
     }
     $text = $targetRev->getText();
     $currentDest = Title::newFromRedirect($text);
     if (!$currentDest || !$currentDest->equals($this->redirTitle)) {
         wfDebug(__METHOD__ . ": Redirect has changed since the job was queued\n");
         return true;
     }
     # Check for a suppression tag (used e.g. in periodically archived discussions)
     $mw = MagicWord::get('staticredirect');
     if ($mw->match($text)) {
         wfDebug(__METHOD__ . ": skipping: suppressed with __STATICREDIRECT__\n");
         return true;
     }
     # Find the current final destination
     $newTitle = self::getFinalDestination($this->redirTitle);
     if (!$newTitle) {
         wfDebug(__METHOD__ . ": skipping: single redirect, circular redirect or invalid redirect destination\n");
         return true;
     }
     if ($newTitle->equals($this->redirTitle)) {
         # The redirect is already right, no need to change it
         # This can happen if the page was moved back (say after vandalism)
         wfDebug(__METHOD__ . ": skipping, already good\n");
     }
     # Preserve fragment (bug 14904)
     $newTitle = Title::makeTitle($newTitle->getNamespace(), $newTitle->getDBkey(), $currentDest->getFragment());
     # Fix the text
     # Remember that redirect pages can have categories, templates, etc.,
     # so the regex has to be fairly general
     $newText = preg_replace('/ \\[ \\[  [^\\]]*  \\] \\] /x', '[[' . $newTitle->getFullText() . ']]', $text, 1);
     if ($newText === $text) {
         $this->setLastError('Text unchanged???');
         return false;
     }
     # Save it
     global $wgUser;
     $oldUser = $wgUser;
     $wgUser = $this->getUser();
     $article = new Article($this->title);
     $reason = wfMsgForContent('double-redirect-fixed-' . $this->reason, $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText());
     $article->doEdit($newText, $reason, EDIT_UPDATE | EDIT_SUPPRESS_RC);
     $wgUser = $oldUser;
     return true;
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:54,代码来源:DoubleRedirectJob.php

示例9: getRS

 function getRS()
 {
     global $wgMemc;
     $key_rs = wfMemcKey("risingstar-feed3:" . date('YmdG') . ":" . number_format(date('i') / 10, 0, '', ''));
     $rsOut = $wgMemc->get($key_rs);
     if (!empty($rsOut)) {
         return $rsOut;
     }
     $t = Title::newFromText('wikiHow:Rising-star-feed');
     if ($t->getArticleId() > 0) {
         $r = Revision::newFromTitle($t);
         $text = $r->getText();
     } else {
         return false;
     }
     //NOTE: temporary patch to handle archives.  the authoritative source for RS needs to be moved to the DB versus the feed article. add archive to array.
     $archives = array('wikiHow:Rising-star-feed/archive1');
     foreach ($archives as $archive) {
         $tarch = Title::newFromText($archive);
         if ($tarch->getArticleId() > 0) {
             $r = Revision::newFromTitle($tarch);
             $text = $r->getText() . "\n" . $text;
         }
     }
     $rsout = array();
     $rs = $text;
     $rs = preg_replace("/==\n/", ',', $rs);
     $rs = preg_replace("/^==/", "", $rs);
     $lines = preg_split("/\r|\n/", $rs, null, PREG_SPLIT_NO_EMPTY);
     $count = 0;
     foreach ($lines as $line) {
         if (preg_match('/^==(.*?),(.*?)$/', $line, $matches)) {
             $dt = $matches[1];
             $pattern = "/{$wgServer}/";
             $title = preg_replace("/http:\\/\\/www\\.wikihow\\.com\\//", "", $matches[2]);
             $title = preg_replace("/http:\\/\\/.*?\\.com\\//", "", $matches[2]);
             $t = Title::newFromText($title);
             if (!isset($t)) {
                 continue;
             }
             $a = new Article($t);
             if ($a->isRedirect()) {
                 $t = Title::newFromRedirect($a->fetchContent());
                 $a = new Article($t);
             }
             $rsout[$t->getPartialURL()] = $dt;
         }
     }
     // sort by most recent first
     $rsout = array_reverse($rsout);
     $wgMemc->set($key_rs, $rsout);
     return $rsout;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:53,代码来源:RisingStar.php

示例10: hUnknownAction

 public function hUnknownAction($action, &$article)
 {
     // check if request 'action=formsubmit'
     if ($action != 'formsubmit') {
         return true;
     }
     // continue hook-chain.
     $article->loadContent();
     // follow redirects
     if ($article->mIsRedirect == true) {
         $title = Title::newFromRedirect($article->getContent());
         $article = new Article($title);
         $article->loadContent();
     }
     // Extract the code
     // Use our runphpClass helper
     $runphp = new runphpClass();
     $runphp->initFromContent($article->getContent());
     // Execute Code
     $code = $runphp->getCode(true);
     if (!empty($code)) {
         $callback = eval($code);
     }
     // we might implement functionality around a callback method in the future
     // Was there an expected class defined?
     $name = $article->mTitle->getDBkey();
     // the page name might actually be a sub-page; extract the basename without the full path.
     $pn = explode('/', $name);
     if (!empty($pn)) {
         $rn = array_reverse($pn);
         $name = $rn[0];
     }
     $name .= 'Class';
     if (class_exists($name)) {
         $class = new $name();
         if (is_object($class)) {
             if (method_exists($class, 'submit')) {
                 $class->submit();
             }
         }
     }
     // ... then it was a page built from ground up; nothing more to do here.
     return false;
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:44,代码来源:FormProc.body.php

示例11: execute

 public function execute()
 {
     $this->output("Fetching redirects...\n");
     $dbr = wfGetDB(DB_SLAVE);
     $result = $dbr->select(array('page'), array('page_namespace', 'page_title', 'page_latest'), array('page_is_redirect' => 1));
     $count = $result->numRows();
     $this->output("Found {$count} total redirects.\n" . "Looking for bad redirects:\n\n");
     foreach ($result as $row) {
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $rev = Revision::newFromId($row->page_latest);
         if ($rev) {
             $target = Title::newFromRedirect($rev->getText());
             if (!$target) {
                 $this->output($title->getPrefixedText() . "\n");
             }
         }
     }
     $this->output("\ndone.\n");
 }
开发者ID:rocLv,项目名称:conference,代码行数:19,代码来源:checkBadRedirects.php

示例12: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     # Make a link to the redirect itself
     $rd_title = Title::makeTitle($result->namespace, $result->title);
     $rd_link = $skin->makeLinkObj($rd_title, '', 'redirect=no');
     # Find out where the redirect leads
     $revision = Revision::newFromTitle($rd_title);
     if ($revision) {
         # Make a link to the destination page
         $target = Title::newFromRedirect($revision->getText());
         if ($target) {
             $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
             $targetLink = $skin->makeLinkObj($target);
             return "{$rd_link} {$arr} {$targetLink}";
         } else {
             return "<s>{$rd_link}</s>";
         }
     } else {
         return "<s>{$rd_link}</s>";
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:22,代码来源:SpecialListredirects.php

示例13: redirectThread

 function redirectThread()
 {
     $rev = Revision::newFromId($this->root()->getLatest());
     $rtitle = Title::newFromRedirect($rev->getRawText());
     if (!$rtitle) {
         return null;
     }
     $this->dieIfHistorical();
     $rthread = Threads::withRoot(new Article($rtitle));
     return $rthread;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:11,代码来源:Thread.php

示例14: statelessFetchTemplate

 /**
  * Static function to get a template
  * Can be overridden via ParserOptions::setTemplateCallback().
  */
 static function statelessFetchTemplate($title, $parser = false)
 {
     $text = $skip = false;
     $finalTitle = $title;
     $deps = array();
     // Loop to fetch the article, with up to 1 redirect
     for ($i = 0; $i < 2 && is_object($title); $i++) {
         # Give extensions a chance to select the revision instead
         $id = false;
         // Assume current
         wfRunHooks('BeforeParserFetchTemplateAndtitle', array($parser, &$title, &$skip, &$id));
         if ($skip) {
             $text = false;
             $deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => null);
             break;
         }
         $rev = $id ? Revision::newFromId($id) : Revision::newFromTitle($title);
         $rev_id = $rev ? $rev->getId() : 0;
         // If there is no current revision, there is no page
         if ($id === false && !$rev) {
             $linkCache = LinkCache::singleton();
             $linkCache->addBadLinkObj($title);
         }
         $deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => $rev_id);
         if ($rev) {
             $text = $rev->getText();
         } elseif ($title->getNamespace() == NS_MEDIAWIKI) {
             global $wgContLang;
             $message = $wgContLang->lcfirst($title->getText());
             $text = wfMsgForContentNoTrans($message);
             if (wfEmptyMsg($message, $text)) {
                 $text = false;
                 break;
             }
         } else {
             break;
         }
         if ($text === false) {
             break;
         }
         // Redirect?
         $finalTitle = $title;
         $title = Title::newFromRedirect($text);
     }
     return array('text' => $text, 'finalTitle' => $finalTitle, 'deps' => $deps);
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:50,代码来源:Parser.php

示例15: statelessFetchTemplate

 /**
  * Static function to get a template
  * Can be overridden via ParserOptions::setTemplateCallback().
  *
  * @param $title  Title
  * @param $parser Parser
  *
  * @return array
  */
 static function statelessFetchTemplate($title, $parser = false)
 {
     $text = $skip = false;
     $finalTitle = $title;
     $deps = array();
     # Loop to fetch the article, with up to 1 redirect
     for ($i = 0; $i < 2 && is_object($title); $i++) {
         # Give extensions a chance to select the revision instead
         $id = false;
         # Assume current
         wfRunHooks('BeforeParserFetchTemplateAndtitle', array($parser, $title, &$skip, &$id));
         if ($skip) {
             $text = false;
             $deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => null);
             break;
         }
         # Get the revision
         $rev = $id ? Revision::newFromId($id) : Revision::newFromTitle($title, false, Revision::READ_NORMAL);
         $rev_id = $rev ? $rev->getId() : 0;
         # If there is no current revision, there is no page
         if ($id === false && !$rev) {
             $linkCache = LinkCache::singleton();
             $linkCache->addBadLinkObj($title);
         }
         $deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => $rev_id);
         if ($rev && !$title->equals($rev->getTitle())) {
             # We fetched a rev from a different title; register it too...
             $deps[] = array('title' => $rev->getTitle(), 'page_id' => $rev->getPage(), 'rev_id' => $rev_id);
         }
         if ($rev) {
             $text = $rev->getText();
         } elseif ($title->getNamespace() == NS_MEDIAWIKI) {
             global $wgContLang;
             $message = wfMessage($wgContLang->lcfirst($title->getText()))->inContentLanguage();
             if (!$message->exists()) {
                 $text = false;
                 break;
             }
             $text = $message->plain();
         } else {
             break;
         }
         if ($text === false) {
             break;
         }
         # Redirect?
         $finalTitle = $title;
         $title = Title::newFromRedirect($text);
     }
     return array('text' => $text, 'finalTitle' => $finalTitle, 'deps' => $deps);
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:60,代码来源:Parser.php


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