本文整理汇总了PHP中WikiPage::loadPageData方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::loadPageData方法的具体用法?PHP WikiPage::loadPageData怎么用?PHP WikiPage::loadPageData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::loadPageData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* UI entry point for page deletion
*/
public function delete()
{
# This code desperately needs to be totally rewritten
$title = $this->getTitle();
$user = $this->getContext()->getUser();
# Check permissions
$permission_errors = $title->getUserPermissionsErrors('delete', $user);
if (count($permission_errors)) {
throw new PermissionsError('delete', $permission_errors);
}
# Read-only check...
if (wfReadOnly()) {
throw new ReadOnlyError();
}
# Better double-check that it hasn't been deleted yet!
$this->mPage->loadPageData('fromdbmaster');
if (!$this->mPage->exists()) {
$deleteLogPage = new LogPage('delete');
$outputPage = $this->getContext()->getOutput();
$outputPage->setPageTitle(wfMessage('cannotdelete-title', $title->getPrefixedText()));
$outputPage->wrapWikiMsg("<div class=\"error mw-error-cannotdelete\">\n\$1\n</div>", array('cannotdelete', wfEscapeWikiText($title->getPrefixedText())));
$outputPage->addHTML(Xml::element('h2', null, $deleteLogPage->getName()->text()));
LogEventsList::showLogExtract($outputPage, 'delete', $title);
return;
}
$request = $this->getContext()->getRequest();
$deleteReasonList = $request->getText('wpDeleteReasonList', 'other');
$deleteReason = $request->getText('wpReason');
if ($deleteReasonList == 'other') {
$reason = $deleteReason;
} elseif ($deleteReason != '') {
// Entry from drop down menu + additional comment
$colonseparator = wfMessage('colon-separator')->inContentLanguage()->text();
$reason = $deleteReasonList . $colonseparator . $deleteReason;
} else {
$reason = $deleteReasonList;
}
if ($request->wasPosted() && $user->matchEditToken($request->getVal('wpEditToken'), array('delete', $this->getTitle()->getPrefixedText()))) {
# Flag to hide all contents of the archived revisions
$suppress = $request->getVal('wpSuppress') && $user->isAllowed('suppressrevision');
$this->doDelete($reason, $suppress);
if ($user->isLoggedIn() && $request->getCheck('wpWatch') != $user->isWatched($title)) {
if ($request->getCheck('wpWatch')) {
WatchAction::doWatch($title, $user);
} else {
WatchAction::doUnwatch($title, $user);
}
}
return;
}
// Generate deletion reason
$hasHistory = false;
if (!$reason) {
try {
$reason = $this->generateReason($hasHistory);
} catch (MWException $e) {
# if a page is horribly broken, we still want to be able to delete it. so be lenient about errors here.
wfDebug("Error while building auto delete summary: {$e}");
$reason = '';
}
}
// If the page has a history, insert a warning
if ($hasHistory) {
$revisions = $this->mTitle->estimateRevisionCount();
// @todo FIXME: i18n issue/patchwork message
$this->getContext()->getOutput()->addHTML('<strong class="mw-delete-warning-revisions">' . wfMessage('historywarning')->numParams($revisions)->parse() . wfMessage('word-separator')->plain() . Linker::linkKnown($title, wfMessage('history')->escaped(), array('rel' => 'archives'), array('action' => 'history')) . '</strong>');
if ($this->mTitle->isBigDeletion()) {
global $wgDeleteRevisionsLimit;
$this->getContext()->getOutput()->wrapWikiMsg("<div class='error'>\n\$1\n</div>\n", array('delete-warning-toobig', $this->getContext()->getLanguage()->formatNum($wgDeleteRevisionsLimit)));
}
}
$this->confirmDelete($reason);
}
示例2: mergePage
/**
* Merge page histories
*
* @param integer $id The page_id
* @param Title $newTitle The new title
* @return bool
*/
private function mergePage($row, Title $newTitle)
{
$id = $row->page_id;
// Construct the WikiPage object we will need later, while the
// page_id still exists. Note that this cannot use makeTitleSafe(),
// we are deliberately constructing an invalid title.
$sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title);
$sourceTitle->resetArticleID($id);
$wikiPage = new WikiPage($sourceTitle);
$wikiPage->loadPageData('fromdbmaster');
$destId = $newTitle->getArticleId();
$this->beginTransaction($this->db, __METHOD__);
$this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
$this->db->delete('page', array('page_id' => $id), __METHOD__);
/* Call LinksDeletionUpdate to delete outgoing links from the old title,
* and update category counts.
*
* Calling external code with a fake broken Title is a fairly dubious
* idea. It's necessary because it's quite a lot of code to duplicate,
* but that also makes it fragile since it would be easy for someone to
* accidentally introduce an assumption of title validity to the code we
* are calling.
*/
$update = new LinksDeletionUpdate($wikiPage);
$update->doUpdate();
$this->commitTransaction($this->db, __METHOD__);
return true;
}
示例3: loadPageData
/**
* Set the page field data loaded from some source
* @param $data Database row object or "fromdb"
* @return void
*/
public function loadPageData($data = 'fromdb')
{
$this->mDataLoaded = true;
// sanity
# Fetch data from DB as needed...
if ($data === 'fromdb' || $data === 'fromdbmaster') {
$db = $data == 'fromdbmaster' ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
$data = $this->pageDataFromTitle($db, $this->mTitle);
}
# Load in primary page data...
parent::loadPageData($data);
# Load in FlaggedRevs page data...
$this->stable = 0;
// 0 => "found nothing"
$this->stableRev = null;
// defer this one...
$this->revsArePending = false;
// false => "found nothing" or "none pending"
$this->pendingRevCount = null;
// defer this one...
$this->pageConfig = FRPageConfig::getDefaultVisibilitySettings();
// default
$this->syncedInTracking = true;
// false => "unreviewed" or "synced"
# Load in flaggedrevs Row data if the page exists...(sanity check NS)
if ($data && FlaggedRevs::inReviewNamespace($this->mTitle)) {
if ($data->fpc_override !== null) {
// page config row found
$this->pageConfig = FRPageConfig::getVisibilitySettingsFromRow($data);
}
if ($data->fp_stable !== null) {
// stable rev found
$this->stable = (int) $data->fp_stable;
$this->revsArePending = $data->fp_pending_since !== null;
// revs await review
$this->syncedInTracking = (bool) $data->fp_reviewed;
}
}
}
示例4: onUnwatchArticleComplete
/**
* Handles removed watched articles to the global watch list.
*
* @access public
* @param object User object of the user who unwatched this page.
* @param object Article object of the unwatched page.
* @return boolean True
*/
public static function onUnwatchArticleComplete(User $user, WikiPage $article)
{
if (!$article->mDataLoaded) {
$article->loadPageData();
}
$curseUser = \CurseAuthUser::getInstance($user);
if (!$curseUser->getId() || $article->mTitle->mArticleID < 1) {
return true;
}
//The newFromUser function will check if the user is valid. False will be return if not.
$gwl = globalWatchlist::newFromUser($user);
if ($gwl !== false && $gwl->removeArticle($article) === true) {
//If removing the specific page the user requested to unwatch was successful then we need to remove the associated namespace page.
$title = Title::newFromText($article->mTitle->getText(), MWNamespace::getAssociated($article->mTitle->mNamespace));
$associated = new WikiPage($title);
if (!$associated->mDataLoaded) {
$associated->loadPageData();
}
$gwl->removeArticle($associated);
//Save since at least the requested page to unwatch was successful lets save it. If the $associated page is not removed successfully we do not want it to stop the process.
$success = $gwl->save();
}
return true;
}
示例5: internalAttemptSave
//.........这里部分代码省略.........
return $status;
} elseif (!$wgUser->isAllowed('editcontentmodel')) {
$status->setResult(false, self::AS_NO_CHANGE_CONTENT_MODEL);
return $status;
}
$changingContentModel = true;
$oldContentModel = $this->mTitle->getContentModel();
}
if ($this->changeTags) {
$changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange($this->changeTags, $wgUser);
if (!$changeTagsStatus->isOK()) {
$changeTagsStatus->value = self::AS_CHANGE_TAG_ERROR;
return $changeTagsStatus;
}
}
if (wfReadOnly()) {
$status->fatal('readonlytext');
$status->value = self::AS_READ_ONLY_PAGE;
return $status;
}
if ($wgUser->pingLimiter() || $wgUser->pingLimiter('linkpurge', 0)) {
$status->fatal('actionthrottledtext');
$status->value = self::AS_RATE_LIMITED;
return $status;
}
# If the article has been deleted while editing, don't save it without
# confirmation
if ($this->wasDeletedSinceLastEdit() && !$this->recreate) {
$status->setResult(false, self::AS_ARTICLE_WAS_DELETED);
return $status;
}
# Load the page data from the master. If anything changes in the meantime,
# we detect it by using page_latest like a token in a 1 try compare-and-swap.
$this->page->loadPageData('fromdbmaster');
$new = !$this->page->exists();
if ($new) {
// Late check for create permission, just in case *PARANOIA*
if (!$this->mTitle->userCan('create', $wgUser)) {
$status->fatal('nocreatetext');
$status->value = self::AS_NO_CREATE_PERMISSION;
wfDebug(__METHOD__ . ": no create permission\n");
return $status;
}
// Don't save a new page if it's blank or if it's a MediaWiki:
// message with content equivalent to default (allow empty pages
// in this case to disable messages, see bug 50124)
$defaultMessageText = $this->mTitle->getDefaultMessageText();
if ($this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false) {
$defaultText = $defaultMessageText;
} else {
$defaultText = '';
}
if (!$this->allowBlankArticle && $this->textbox1 === $defaultText) {
$this->blankArticle = true;
$status->fatal('blankarticle');
$status->setResult(false, self::AS_BLANK_ARTICLE);
return $status;
}
if (!$this->runPostMergeFilters($textbox_content, $status, $wgUser)) {
return $status;
}
$content = $textbox_content;
$result['sectionanchor'] = '';
if ($this->section == 'new') {
if ($this->sectiontitle !== '') {
// Insert the section title above the content.