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


PHP Revision::newFromTitle方法代码示例

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


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

示例1: wfSpecialCheckmylinks

function wfSpecialCheckmylinks($par)
{
    global $wgRequest, $wgSitename, $wgLanguageCode;
    global $wgDeferredUpdateList, $wgOut, $wgUser, $wgServer, $wgParser, $wgTitle;
    $fname = "wfCheckmylinks";
    $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_summary'));
    if ($wgUser->getID() > 0) {
        $t = Title::makeTitle(NS_USER, $wgUser->getName() . "/Mylinks");
        if ($t->getArticleID() > 0) {
            $r = Revision::newFromTitle($t);
            $text = $r->getText();
            if ($text != "") {
                $ret = "<h3>" . wfMsg('mylinks') . "</h3>";
                $options = new ParserOptions();
                $output = $wgParser->parse($text, $wgTitle, $options);
                $ret .= $output->getText();
            }
            $size = strlen($ret);
            if ($size > 3000) {
                $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_bad', number_format($size, 0, "", ",")));
            } else {
                $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_good', number_format($size, 0, "", ",")));
            }
        } else {
            $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_error'));
        }
    } else {
        $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_notloggedin'));
    }
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:30,代码来源:Checkmylinks.php

示例2: getRepublishText

 function getRepublishText($t)
 {
     global $wgRequest, $wgContLang, $wgOut, $wgServer;
     if (!$t) {
         return "";
     }
     $r = Revision::newFromTitle($t);
     $mp = Title::newMainPage();
     $title = "<h1 style='margin-bottom: 0px;'><a href=\"" . $t->getFullURL() . "\">" . wfMsg('howto', $t->getText()) . "</a></h1>\n" . wfMsg('republish_taglinelink', $mp->getFullURL()) . "<br/>";
     if (!$r) {
         return "";
     }
     $text = $r->getText();
     if ($wgRequest->getVal('striptags', 'true') != 'false') {
         $text = preg_replace("/\\[\\[" . $wgContLang->getNSText(NS_IMAGE) . "[^\\]]*\\]\\]/", "", $text);
     }
     $output = $wgOut->parse($text);
     //$output = str_replace("<div class='SecL'></div><div class='SecR'></div>", "", $output);
     //$output = preg_replace("/<div id=\"[a-z]*\"/", "<div ", $output);
     $output = str_replace('href="/', 'href="' . $wgServer . '/', $output);
     if ($wgRequest->getVal('striptags', 'true') != 'false') {
         $output = strip_tags($output, '<b><i><h1><h2><ol><ul><li><a>');
     } else {
         $output = str_replace('<img src="/', '<img src="http://www.wikihow.com/', $output);
     }
     $output = preg_replace("@href=(['\"])/@", "href=\$1{$wgServer}/", $output);
     $output = $title . "\n" . $output . wfMsg('republish_footer', $t->getText(), $t->getFullURL());
     $output = preg_replace("/\n\n[\n]*/", "\n", $output);
     return $output;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:30,代码来源:Republish.body.php

示例3: parse

	function parse($grammarName, &$text) {
		wfDebugLog("ParseEngine", "==========Start Parse Engine==========\n");
		$grammar = isset($this->mGrammars[$grammarName]) ? $this->mGrammars[$grammarName] : NULL;
		if ($grammar == NULL) {
			$revision = Revision::newFromTitle(Title::newFromText($grammarName, NS_GRAMMAR));
			$grammar = new DOMDocument();
			if ($revision == NULL || ! $grammar->loadXML($revision->getText(), LIBXML_NOBLANKS)) {
				return TRUE;
			}
			$this->pushTags($grammar->documentElement, NULL);
			$this->mGrammars[$grammarName] = $grammar;
		}
		$doc = new DOMDocument();
		$rootTag = $doc->createElement($grammar->documentElement->getAttribute("rootTag"));
		$startRule = $grammar->documentElement->getAttribute("startRule");
		$xpath = new DOMXPath($grammar);
		$startRule = $xpath->query("/Grammar/*[@name='$startRule']")->item(0);
		$refText = $text;
		if (! $this->parseRec($startRule, "", "", $iter, $refText, $rootTag)) {
			return TRUE;
		}
		$doc->appendChild($rootTag);
		$text = $doc->saveXML();
		wfDebugLog("ParseEngine", "Parsed text - $text\n");
		return TRUE;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:26,代码来源:ParserEngine.php

示例4: displayQuickNoteButtons

 function displayQuickNoteButtons($id = '')
 {
     global $wgLanguageCode;
     // INTL: Only give these buttons to english site
     if ($wgLanguageCode != 'en') {
         return "";
     }
     list($tb1, $tb2, $tb3) = QuickNoteEdit::getQNTemplates();
     $start1 = strpos($tb1, "{{subst:") + strlen("{{subst:");
     $end1 = strpos($tb1, "|") - strlen("{{subst:");
     $tp1 = substr($tb1, $start1, $end1);
     $template = Title::makeTitle(NS_TEMPLATE, $tp1);
     $r = Revision::newFromTitle($template);
     $tb1_message = $r->getText();
     $tb1_message = preg_replace('/<noinclude>(.*?)<\\/noinclude>/is', '', $tb1_message);
     $tb1_message = str_replace("\n", "\\n", $tb1_message);
     $tb1_message = str_replace("'", "\\'", $tb1_message);
     $start3 = strpos($tb3, "{{subst:") + strlen("{{subst:");
     $end3 = strpos($tb3, "|") - strlen("{{subst:");
     $tp3 = substr($tb3, $start3, $end3);
     $template = Title::makeTitle(NS_TEMPLATE, $tp3);
     $r = Revision::newFromTitle($template);
     $tb3_message = $r->getText();
     $tb3_message = preg_replace('/<noinclude>(.*?)<\\/noinclude>/is', '', $tb3_message);
     $tb3_message = str_replace("\n", "\\n", $tb3_message);
     $tb3_message = str_replace("'", "\\'", $tb3_message);
     $buttons = "<div><br /><input tabindex='1' class='button secondary' type='button' value='" . wfMsg('Quicknote_Button1') . "' onclick=\"checkThumbsUp();qnButtons('postcommentForm_" . $id . "', '" . $tb1_message . "')\" />\n\t\t <input tabindex='3' class='button secondary' type='button' value='" . wfMsg('Quicknote_Button3') . "' onclick=\"qnButtons('postcommentForm_" . $id . "', '" . $tb3_message . "')\" /></div>";
     return $buttons;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:QuickNoteEdit.body.php

示例5: execute

 /**
  * Obtain the parse of a wiki article
  */
 public function execute()
 {
     $titles = $this->getPageSet()->getGoodTitles();
     if (count($titles) == 0) {
         return;
     }
     $params = $this->extractRequestParams();
     foreach ($titles as $title) {
         $pageId = $title->getArticleID();
         if (!$title->hasSourceText()) {
             $results = array('errors' => 'Title does not exist');
         } else {
             if (!$title->userCan('read')) {
                 $results = array('errors' => 'Cannot read this title');
             } else {
                 # Get the article text
                 $rev = Revision::newFromTitle($title);
                 if (!is_object($rev)) {
                     $results = array('errors' => 'Could not get revision');
                 } else {
                     $text = $rev->getText();
                     $results['contents'] = $this->getParseTree($text);
                 }
             }
         }
         foreach ($results as $elementName => $item) {
             $fit = $this->addPageSubItem($pageId, $item, $elementName);
             if (!$fit) {
                 /* ?? this should never happen */
             }
         }
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:36,代码来源:ApiQueryParseTree.php

示例6: 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

示例7: validateTitle

 public function validateTitle($title)
 {
     if (!$title) {
         // No form input yet
         return true;
     }
     try {
         $titleObj = Title::newFromTextThrow($title);
     } catch (MalformedTitleException $e) {
         $msg = $this->msg($e->getErrorMessage());
         $params = $e->getErrorMessageParameters();
         if ($params) {
             $msg->params($params);
         }
         return $msg->parse();
     }
     if (!$titleObj->canExist()) {
         return $this->msg('changecontentmodel-title-cantexist', $titleObj->getPrefixedText())->escaped();
     }
     $this->oldRevision = Revision::newFromTitle($titleObj) ?: false;
     if ($this->oldRevision) {
         $oldContent = $this->oldRevision->getContent();
         if (!$oldContent->getContentHandler()->supportsDirectEditing()) {
             return $this->msg('changecontentmodel-nodirectediting')->params(ContentHandler::getLocalizedName($oldContent->getModel()))->escaped();
         }
     }
     return true;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:28,代码来源:SpecialChangeContentModel.php

示例8: 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

示例9: handleRow

 protected function handleRow(stdClass $row)
 {
     $title = Title::makeTitle($row->page_namespace, $row->page_title);
     $this->output("Processing {$title} ({$row->page_id})...\n");
     $rev = Revision::newFromTitle($title);
     $content = $rev->getContent(Revision::RAW);
     $dbw = $this->getDB(DB_MASTER);
     if ($content instanceof JsonContent) {
         if ($content->isValid()) {
             // Yay, actually JSON. We need to just change the
             // page_content_model because revision will automatically
             // use the default, which is *now* JSON.
             $this->output("Setting page_content_model to json...");
             $dbw->update('page', ['page_content_model' => CONTENT_MODEL_JSON], ['page_id' => $row->page_id], __METHOD__);
             $this->output("done.\n");
             wfWaitForSlaves();
         } else {
             // Not JSON...force it to wikitext. We need to update the
             // revision table so that these revisions are always processed
             // as wikitext in the future. page_content_model is already
             // set to "wikitext".
             $this->output("Setting rev_content_model to wikitext...");
             // Grab all the ids for batching
             $ids = $dbw->selectFieldValues('revision', 'rev_id', ['rev_page' => $row->page_id], __METHOD__);
             foreach (array_chunk($ids, 50) as $chunk) {
                 $dbw->update('revision', ['rev_content_model' => CONTENT_MODEL_WIKITEXT], ['rev_page' => $row->page_id, 'rev_id' => $chunk]);
                 wfWaitForSlaves();
             }
             $this->output("done.\n");
         }
     } else {
         $this->output("not a JSON page? Skipping\n");
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:34,代码来源:fixDefaultJsonContentPages.php

示例10: fixLinksFromArticle

function fixLinksFromArticle( $id ) {
	global $wgTitle, $wgParser;

	$wgTitle = Title::newFromID( $id );
	$dbw = wfGetDB( DB_MASTER );

	$linkCache =& LinkCache::singleton();
	$linkCache->clear();

	if ( is_null( $wgTitle ) ) {
		return;
	}
	$dbw->begin();

	$revision = Revision::newFromTitle( $wgTitle );
	if ( !$revision ) {
		return;
	}

	$options = new ParserOptions;
	$parserOutput = $wgParser->parse( $revision->getText(), $wgTitle, $options, true, true, $revision->getId() );
	$update = new LinksUpdate( $wgTitle, $parserOutput, false );
	$update->doUpdate();
	$dbw->commit();
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:videoCleanup.php

示例11: 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

示例12: run

	/**
	 * Run a refreshLinks job
	 * @return boolean success
	 */
	function run() {
		$linkCache = LinkCache::singleton();
		$linkCache->clear();

		if ( is_null( $this->title ) ) {
			$this->error = "refreshLinks: Invalid title";
			return false;
		}

		# Wait for the DB of the current/next slave DB handle to catch up to the master.
		# This way, we get the correct page_latest for templates or files that just changed
		# milliseconds ago, having triggered this job to begin with.
		if ( isset( $this->params['masterPos'] ) && $this->params['masterPos'] !== false ) {
			wfGetLB()->waitFor( $this->params['masterPos'] );
		}

		$revision = Revision::newFromTitle( $this->title, false, Revision::READ_NORMAL );
		if ( !$revision ) {
			$this->error = 'refreshLinks: Article not found "' .
				$this->title->getPrefixedDBkey() . '"';
			return false; // XXX: what if it was just deleted?
		}

		self::runForTitleInternal( $this->title, $revision, __METHOD__ );

		return true;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:31,代码来源:RefreshLinksJob.php

示例13: getHTML

 protected function getHTML($title, $parserParams)
 {
     $restoring = false;
     if ($title->exists()) {
         $latestRevision = Revision::newFromTitle($title);
         if ($latestRevision === null) {
             return false;
         }
         $revision = null;
         if (!isset($parserParams['oldid']) || $parserParams['oldid'] === 0) {
             $parserParams['oldid'] = $latestRevision->getId();
             $revision = $latestRevision;
         } else {
             $revision = Revision::newFromId($parserParams['oldid']);
             if ($revision === null) {
                 return false;
             }
         }
         $restoring = $revision && !$revision->isCurrent();
         $oldid = $parserParams['oldid'];
         $content = $this->requestParsoid('GET', $title, $parserParams);
         if ($content === false) {
             return false;
         }
         $timestamp = $latestRevision->getTimestamp();
     } else {
         $content = '';
         $timestamp = wfTimestampNow();
         $oldid = 0;
     }
     return array('result' => array('content' => $content, 'basetimestamp' => $timestamp, 'starttimestamp' => wfTimestampNow(), 'oldid' => $oldid), 'restoring' => $restoring);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:ApiVisualEditor.php

示例14: smwf_et_Access

function smwf_et_Access($method, $params)
{
    global $smwgQEnabled, $smwgExtTabEnabled;
    $result = "Semantic ExtTab disabled.";
    if ($method == "internalLoad") {
        if ($smwgExtTabEnabled) {
            $p = explode(',', $params, 2);
            $title = $p[1];
            $html = $title;
            global $wgTitle, $smwgIQRunningNumber;
            // pay attention to $smwgIQRunningNumber
            $smwgIQRunningNumber = intval($p[0]) * 10;
            $wgTitle = Title::newFromText($title);
            $revision = Revision::newFromTitle($wgTitle);
            if ($revision !== NULL) {
                global $wgParser, $wgOut;
                $popts = $wgOut->parserOptions();
                $popts->setTidy(true);
                $popts->enableLimitReport();
                $html = $wgParser->parse($revision->getText(), $wgTitle, $popts)->getText();
            }
            return $html;
        }
    } else {
        return "Operation failed, please retry later.";
    }
    return $result;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:28,代码来源:ET_AjaxAccess.php

示例15: getExtract

 public function getExtract($title, $chars = 50)
 {
     $rev = Revision::newFromTitle($title);
     if ($rev) {
         $text = substr($rev->getText(), 0, 16384);
         // Ok, first note this is a TERRIBLE HACK. :D
         //
         // First, we use the system preprocessor to break down the text
         // into text, templates, extensions, and comments:
         global $wgParser;
         $wgParser->mOptions = new ParserOptions();
         $wgParser->clearState();
         $frame = $wgParser->getPreprocessor()->newFrame();
         $dom = $wgParser->preprocessToDom($text);
         $imageArgs = array('image', 'image_skyline', 'img', 'Img');
         // Now, we strip out everything that's not text.
         // This works with both DOM and Hash parsers, but feels fragile.
         $node = $dom->getFirstChild();
         $out = '';
         while ($node) {
             if ($node->getName() == '#text') {
                 $out .= $frame->expand($node, PPFrame::RECOVER_ORIG);
             }
             $node = $node->getNextSibling();
         }
         // The remaining text may still contain wiki and HTML markup.
         // We'll use our shitty hand parser to strip most of those from
         // the beginning of the text.
         $stripped = $this->_stripMarkup($out);
         // And now, we'll grab just the first sentence as text, and
         // also try to rip out a badge image.
         return $this->_extractStart($stripped);
     }
     return '';
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:IndexAbstracts.php


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