本文整理汇总了PHP中Revision::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::getTitle方法的具体用法?PHP Revision::getTitle怎么用?PHP Revision::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeWhenAvailable
/**
* Render the diff page
* @return boolean false when revision not exist
* @param string $par Revision IDs separated by three points (e.g. 123...124)
*/
function executeWhenAvailable($par)
{
$ctx = MobileContext::singleton();
$this->setHeaders();
$output = $this->getOutput();
// @FIXME add full support for git-style notation (eg ...123, 123...)
$revisions = $this->getRevisionsToCompare(explode('...', $par));
$rev = $revisions[1];
$prev = $revisions[0];
if (is_null($rev)) {
$this->executeBadQuery();
return false;
}
$this->revId = $rev->getId();
$this->rev = $rev;
$this->prevRev = $prev;
$this->targetTitle = $this->rev->getTitle();
$output->setPageTitle($this->msg('mobile-frontend-diffview-title', $this->targetTitle->getPrefixedText()));
$output->addModuleStyles(array('mobile.pagesummary.styles', 'mobile.special.pagefeed.styles'));
// Allow other extensions to load more stuff here
Hooks::run('BeforeSpecialMobileDiffDisplay', array(&$output, $ctx, $revisions));
$output->addHtml('<div id="mw-mf-diffview" class="content-unstyled"><div id="mw-mf-diffarea">');
$this->showHeader();
$this->showDiff();
$output->addHtml('</div>');
$this->showFooter();
$output->addHtml('</div>');
return true;
}
示例2: processRevision
/**
* Callback function for each revision, preprocessToObj()
* @param Revision $rev
*/
public function processRevision($rev)
{
$content = $rev->getContent(Revision::RAW);
if ($content->getModel() !== CONTENT_MODEL_WIKITEXT) {
return;
}
try {
$this->mPreprocessor->preprocessToObj(strval($content->getNativeData()), 0);
} catch (Exception $e) {
$this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText());
}
}
示例3: loadRevisionData
/**
* Load revision metadata for the specified articles. If newid is 0, then compare
* the old article in oldid to the current article; if oldid is 0, then
* compare the current article to the immediately previous one (ignoring the
* value of newid).
*
* If oldid is false, leave the corresponding revision object set
* to false. This is impossible via ordinary user input, and is provided for
* API convenience.
*
* @return bool
*/
public function loadRevisionData()
{
if ($this->mRevisionsLoaded) {
return true;
}
// Whether it succeeds or fails, we don't want to try again
$this->mRevisionsLoaded = true;
$this->loadRevisionIds();
// Load the new revision object
if ($this->mNewid) {
$this->mNewRev = Revision::newFromId($this->mNewid);
} else {
$this->mNewRev = Revision::newFromTitle($this->getTitle(), false, Revision::READ_NORMAL);
}
if (!$this->mNewRev instanceof Revision) {
return false;
}
// Update the new revision ID in case it was 0 (makes life easier doing UI stuff)
$this->mNewid = $this->mNewRev->getId();
$this->mNewPage = $this->mNewRev->getTitle();
// Load the old revision object
$this->mOldRev = false;
if ($this->mOldid) {
$this->mOldRev = Revision::newFromId($this->mOldid);
} elseif ($this->mOldid === 0) {
$rev = $this->mNewRev->getPrevious();
if ($rev) {
$this->mOldid = $rev->getId();
$this->mOldRev = $rev;
} else {
// No previous revision; mark to show as first-version only.
$this->mOldid = false;
$this->mOldRev = false;
}
}
/* elseif ( $this->mOldid === false ) leave mOldRev false; */
if (is_null($this->mOldRev)) {
return false;
}
if ($this->mOldRev) {
$this->mOldPage = $this->mOldRev->getTitle();
}
// Load tags information for both revisions
$dbr = wfGetDB(DB_SLAVE);
if ($this->mOldid !== false) {
$this->mOldTags = $dbr->selectField('tag_summary', 'ts_tags', array('ts_rev_id' => $this->mOldid), __METHOD__);
} else {
$this->mOldTags = false;
}
$this->mNewTags = $dbr->selectField('tag_summary', 'ts_tags', array('ts_rev_id' => $this->mNewid), __METHOD__);
return true;
}
示例4: handleRevision
/**
* Callback function for each revision, turn into HTML and save
* @param Revision $rev
*/
public function handleRevision($rev)
{
$title = $rev->getTitle();
if (!$title) {
$this->error("Got bogus revision with null title!");
return;
}
$display = $title->getPrefixedText();
$this->count++;
$sanitized = rawurlencode($display);
$filename = sprintf("%s/%s-%07d-%s.html", $this->outputDirectory, $this->prefix, $this->count, $sanitized);
$this->output(sprintf("%s\n", $filename, $display));
$user = new User();
$options = ParserOptions::newFromUser($user);
$content = $rev->getContent();
$output = $content->getParserOutput($title, null, $options);
file_put_contents($filename, "<!DOCTYPE html>\n" . "<html lang=\"en\" dir=\"ltr\">\n" . "<head>\n" . "<meta charset=\"UTF-8\" />\n" . "<title>" . htmlspecialchars($display) . "</title>\n" . "</head>\n" . "<body>\n" . $output->getText() . "</body>\n" . "</html>");
}
示例5: cleanupArticle
/**
* Find the latest revision of the article that does not contain spam and revert to it
*/
function cleanupArticle(Revision $rev, $regexes, $match)
{
$title = $rev->getTitle();
$revId = $rev->getId();
while ($rev) {
$matches = false;
foreach ($regexes as $regex) {
$matches = $matches || preg_match($regex, $rev->getText());
}
if (!$matches) {
// Didn't find any spam
break;
}
# Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
#$rev = $rev->getPrevious();
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
if (!$rev) {
// Didn't find a non-spammy revision, delete the page
/*
print "All revisions are spam, deleting...\n";
$article = new Article( $title );
$article->doDeleteArticle( "All revisions matched the spam blacklist" );
*/
// Too scary, blank instead
print "All revisions are spam, blanking...\n";
$text = '';
$comment = "All revisions matched the spam blacklist ({$match}), blanking";
} else {
// Revert to this revision
$text = $rev->getText();
$comment = "Cleaning up links to {$match}";
}
$wikiPage = new WikiPage($title);
$wikiPage->doEdit($text, $comment);
$dbw->commit();
}
示例6: handleRevision
/**
* @param Revision $rev
*/
function handleRevision($rev)
{
$title = $rev->getTitle();
if (!$title) {
$this->progress("Got bogus revision with null title!");
return;
}
if ($this->skippedNamespace($title)) {
return;
}
$this->revCount++;
$this->report();
if (!$this->dryRun) {
call_user_func($this->importCallback, $rev);
}
}
示例7: runParser
/**
* Parse the text from a given Revision
*
* @param Revision $revision
*/
function runParser(Revision $revision)
{
$content = $revision->getContent();
$content->getParserOutput($revision->getTitle(), $revision->getId());
if ($this->clearLinkCache) {
$this->linkCache->clear();
}
}
示例8: revComment
/**
* Wrap and format the given revision's comment block, if the current
* user is allowed to view it.
*
* @param $rev Revision object
* @param $local Boolean: whether section links should refer to local page
* @param $isPublic Boolean: show only if all users can see it
* @return String: HTML fragment
*/
static function revComment(Revision $rev, $local = false, $isPublic = false)
{
if ($rev->getRawComment() == "") {
return "";
}
if ($rev->isDeleted(Revision::DELETED_COMMENT) && $isPublic) {
$block = " <span class=\"comment\">" . wfMsgHtml('rev-deleted-comment') . "</span>";
} elseif ($rev->userCan(Revision::DELETED_COMMENT)) {
$block = self::commentBlock($rev->getComment(Revision::FOR_THIS_USER), $rev->getTitle(), $local);
} else {
$block = " <span class=\"comment\">" . wfMsgHtml('rev-deleted-comment') . "</span>";
}
if ($rev->isDeleted(Revision::DELETED_COMMENT)) {
return " <span class=\"history-deleted\">{$block}</span>";
}
return $block;
}
示例9: showContributionsRow
/**
* Render the contribution of the pagerevision (time, bytes added/deleted, pagename comment)
* @param Revision $rev
*/
protected function showContributionsRow(Revision $rev)
{
$user = $this->getUser();
$userId = $rev->getUser(Revision::FOR_THIS_USER, $user);
if ($userId === 0) {
$username = IP::prettifyIP($rev->getUserText(Revision::RAW));
$isAnon = true;
} else {
$username = $rev->getUserText(Revision::FOR_THIS_USER, $user);
$isAnon = false;
}
// FIXME: Style differently user comment when this is the case
if ($rev->userCan(Revision::DELETED_COMMENT, $user)) {
$comment = $rev->getComment(Revision::FOR_THIS_USER, $user);
$comment = $this->formatComment($comment, $this->title);
} else {
$comment = $this->msg('rev-deleted-comment')->plain();
}
$ts = $rev->getTimestamp();
$this->renderListHeaderWhereNeeded($this->getLanguage()->userDate($ts, $this->getUser()));
$ts = new MWTimestamp($ts);
if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
$diffLink = SpecialPage::getTitleFor('MobileDiff', $rev->getId())->getLocalUrl();
} else {
$diffLink = false;
}
// FIXME: Style differently user comment when this is the case
if (!$rev->userCan(Revision::DELETED_USER, $user)) {
$username = $this->msg('rev-deleted-user')->plain();
}
$bytes = null;
if (isset($this->prevLengths[$rev->getParentId()])) {
$bytes = $rev->getSize() - $this->prevLengths[$rev->getParentId()];
}
$isMinor = $rev->isMinor();
$this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $rev->getTitle(), $isAnon, $bytes, $isMinor);
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:41,代码来源:SpecialMobileContributions.php
示例10: getRevisionHeader
/**
* Get a header for a specified revision.
*
* @param $rev Revision
* @param $complete String: 'complete' to get the header wrapped depending
* the visibility of the revision and a link to edit the page.
* @return String HTML fragment
*/
protected function getRevisionHeader(Revision $rev, $complete = '')
{
$lang = $this->getLanguage();
$user = $this->getUser();
$revtimestamp = $rev->getTimestamp();
$timestamp = $lang->userTimeAndDate($revtimestamp, $user);
$dateofrev = $lang->userDate($revtimestamp, $user);
$timeofrev = $lang->userTime($revtimestamp, $user);
$header = $this->msg($rev->isCurrent() ? 'currentrev-asof' : 'revisionasof', $timestamp, $dateofrev, $timeofrev)->escaped();
if ($complete !== 'complete') {
return $header;
}
$title = $rev->getTitle();
$header = Linker::linkKnown($title, $header, array(), array('oldid' => $rev->getID()));
if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
$editQuery = array('action' => 'edit');
if (!$rev->isCurrent()) {
$editQuery['oldid'] = $rev->getID();
}
$msg = $this->msg($title->quickUserCan('edit', $user) ? 'editold' : 'viewsourceold')->escaped();
$header .= ' ' . $this->msg('parentheses')->rawParams(Linker::linkKnown($title, $msg, array(), $editQuery))->plain();
if ($rev->isDeleted(Revision::DELETED_TEXT)) {
$header = Html::rawElement('span', array('class' => 'history-deleted'), $header);
}
} else {
$header = Html::rawElement('span', array('class' => 'history-deleted'), $header);
}
return $header;
}
示例11: extractRevisionInfo
/**
* Extract information from the Revision
*
* @param Revision $revision
* @param object $row Should have a field 'ts_tags' if $this->fld_tags is set
* @return array
*/
protected function extractRevisionInfo(Revision $revision, $row)
{
$title = $revision->getTitle();
$user = $this->getUser();
$vals = array();
$anyHidden = false;
if ($this->fld_ids) {
$vals['revid'] = intval($revision->getId());
if (!is_null($revision->getParentId())) {
$vals['parentid'] = intval($revision->getParentId());
}
}
if ($this->fld_flags) {
$vals['minor'] = $revision->isMinor();
}
if ($this->fld_user || $this->fld_userid) {
if ($revision->isDeleted(Revision::DELETED_USER)) {
$vals['userhidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_USER, $user)) {
if ($this->fld_user) {
$vals['user'] = $revision->getUserText(Revision::RAW);
}
$userid = $revision->getUser(Revision::RAW);
if (!$userid) {
$vals['anon'] = true;
}
if ($this->fld_userid) {
$vals['userid'] = $userid;
}
}
}
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
}
if ($this->fld_size) {
if (!is_null($revision->getSize())) {
$vals['size'] = intval($revision->getSize());
} else {
$vals['size'] = 0;
}
}
if ($this->fld_sha1) {
if ($revision->isDeleted(Revision::DELETED_TEXT)) {
$vals['sha1hidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_TEXT, $user)) {
if ($revision->getSha1() != '') {
$vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
}
if ($this->fld_contentmodel) {
$vals['contentmodel'] = $revision->getContentModel();
}
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_COMMENT, $user)) {
$comment = $revision->getComment(Revision::RAW);
if ($this->fld_comment) {
$vals['comment'] = $comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($comment, $title);
}
}
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
ApiResult::setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
$content = null;
global $wgParser;
if ($this->fetchContent) {
$content = $revision->getContent(Revision::FOR_THIS_USER, $this->getUser());
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ($content && $this->section !== false) {
$content = $content->getSection($this->section, false);
if (!$content) {
//.........这里部分代码省略.........
示例12: buildRollbackLink
/**
* Build a raw rollback link, useful for collections of "tool" links
*
* @param Revision $rev
* @param IContextSource|null $context Context to use or null for the main context.
* @param int $editCount Number of edits that would be reverted
* @return string HTML fragment
*/
public static function buildRollbackLink($rev, IContextSource $context = null, $editCount = false)
{
global $wgShowRollbackEditCount, $wgMiserMode;
// To config which pages are affected by miser mode
$disableRollbackEditCountSpecialPage = array('Recentchanges', 'Watchlist');
if ($context === null) {
$context = RequestContext::getMain();
}
$title = $rev->getTitle();
$query = array('action' => 'rollback', 'from' => $rev->getUserText(), 'token' => $context->getUser()->getEditToken(array($title->getPrefixedText(), $rev->getUserText())));
if ($context->getRequest()->getBool('bot')) {
$query['bot'] = '1';
$query['hidediff'] = '1';
// bug 15999
}
$disableRollbackEditCount = false;
if ($wgMiserMode) {
foreach ($disableRollbackEditCountSpecialPage as $specialPage) {
if ($context->getTitle()->isSpecial($specialPage)) {
$disableRollbackEditCount = true;
break;
}
}
}
if (!$disableRollbackEditCount && is_int($wgShowRollbackEditCount) && $wgShowRollbackEditCount > 0) {
if (!is_numeric($editCount)) {
$editCount = self::getRollbackEditCount($rev, false);
}
if ($editCount > $wgShowRollbackEditCount) {
$editCount_output = $context->msg('rollbacklinkcount-morethan')->numParams($wgShowRollbackEditCount)->parse();
} else {
$editCount_output = $context->msg('rollbacklinkcount')->numParams($editCount)->parse();
}
return self::link($title, $editCount_output, array('title' => $context->msg('tooltip-rollback')->text()), $query, array('known', 'noclasses'));
} else {
return self::link($title, $context->msg('rollbacklink')->escaped(), array('title' => $context->msg('tooltip-rollback')->text()), $query, array('known', 'noclasses'));
}
}
示例13: compareEventRecordWithRevision
function compareEventRecordWithRevision($dbname, $oRow, $debug)
{
global $wgTitle, $wgLanguageCode;
$langcode = WikiFactory::getVarValueByName('wgLanguageCode', $oRow->wiki_id);
$lang_id = WikiFactory::LangCodeToId($langcode);
$cats = WikiFactory::getCategory($oRow->wiki_id);
$cat_id = !empty($cats) ? $cats->cat_id : 0;
$result = false;
if (is_object($oRow) && !empty($oRow->page_id) && !empty($oRow->rev_id)) {
$data = loadFromDB($dbname, $oRow->page_id, $oRow->rev_id);
if (is_object($data)) {
$oRevision = new Revision($data);
if ($oRow->rev_id > 0) {
$wgTitle = Title::makeTitle($data->page_namespace, $data->page_title);
} else {
$wgTitle = $oRevision->getTitle();
}
$content = $oRevision->getText(Revision::FOR_THIS_USER);
$is_bot = _user_is_bot($data->rev_user_text);
$is_content = _revision_is_content();
$is_redirect = _revision_is_redirect($content);
$size = intval($oRevision->getSize());
$words = str_word_count($content);
$links = _make_links($oRow->page_id, $oRow->rev_id, $content);
$timestamp = $data->ts;
if ($data->rev_page == $oRow->page_id && $data->page_namespace == $oRow->page_ns && $data->rev_id == $oRow->rev_id && $timestamp == $oRow->rev_timestamp && $data->rev_user == $oRow->user_id && $is_bot == $oRow->user_is_bot && $is_content == $oRow->is_content && $is_redirect == $oRow->is_redirect && $size == $oRow->rev_size && $words == $oRow->total_words && $cat_id == $oRow->wiki_cat_id && $lang_id == $oRow->wiki_lang_id && $links['image'] == $oRow->image_links && $links['video'] == $oRow->video_links) {
$result = true;
} else {
if ($debug) {
echo <<<TEXT
\tpage: {$data->rev_page} == {$oRow->page_id}
\tnamespage: {$data->page_namespace}\t== {$oRow->page_ns}
\trevision: {$data->rev_id}\t== {$oRow->rev_id}
\ttimestamp: {$timestamp} == {$oRow->rev_timestamp}
\tuser: {$data->rev_user} == {$oRow->user_id}
\tis_bot: {$is_bot} == {$oRow->user_is_bot}
\tis_content: {$is_content} == {$oRow->is_content}
\tis_redirect: {$is_redirect} == {$oRow->is_redirect}
\tsize: {$size} == {$oRow->rev_size}
\twords: {$words} == {$oRow->total_words}
\tcategory: {$cat_id} == {$oRow->wiki_cat_id}
\tlanguage: {$lang_id} == {$oRow->wiki_lang_id}
\timage links:{$links['image']} == {$oRow->image_links}
\tvideo links: {$links['video']} == {$oRow->video_links}
TEXT;
}
}
} else {
echo "Not local data found for: page: {$oRow->page_id} && revision: {$oRow->rev_id} \n";
}
} else {
echo "Not events data found for: page: {$oRow->page_id} && revision: {$oRow->rev_id} \n";
}
return $result;
}
示例14: processRevision
/**
* Callback function for each revision, parse with both parsers and compare
* @param Revision $rev
*/
public function processRevision($rev)
{
$title = $rev->getTitle();
$parser1Name = $this->getOption('parser1');
$parser2Name = $this->getOption('parser2');
self::checkParserLocally($parser1Name);
self::checkParserLocally($parser2Name);
$parser1 = new $parser1Name();
$parser2 = new $parser2Name();
$content = $rev->getContent();
if ($content->getModel() !== CONTENT_MODEL_WIKITEXT) {
$this->error("Page {$title->getPrefixedText()} does not contain wikitext " . "but {$content->getModel()}\n");
return;
}
$text = strval($content->getNativeData());
$output1 = $parser1->parse($text, $title, $this->options);
$output2 = $parser2->parse($text, $title, $this->options);
if ($output1->getText() != $output2->getText()) {
$this->failed++;
$this->error("Parsing for {$title->getPrefixedText()} differs\n");
if ($this->saveFailed) {
file_put_contents($this->saveFailed . '/' . rawurlencode($title->getPrefixedText()) . ".txt", $text);
}
if ($this->showDiff) {
$this->output(wfDiff($this->stripParameters($output1->getText()), $this->stripParameters($output2->getText()), ''));
}
} else {
$this->output($title->getPrefixedText() . "\tOK\n");
if ($this->showParsedOutput) {
$this->output($this->stripParameters($output1->getText()));
}
}
}
示例15: buildRollbackLink
/**
* Build a raw rollback link, useful for collections of "tool" links
*
* @param Revision $rev
* @return string
*/
public function buildRollbackLink($rev)
{
global $wgRequest, $wgUser;
$title = $rev->getTitle();
$extra = $wgRequest->getBool('bot') ? '&bot=1' : '';
$extra .= '&token=' . urlencode($wgUser->editToken(array($title->getPrefixedText(), $rev->getUserText())));
return $this->makeKnownLinkObj($title, wfMsgHtml('rollbacklink'), 'action=rollback&from=' . urlencode($rev->getUserText()) . $extra);
}