本文整理汇总了PHP中Article::getRevIdFetched方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getRevIdFetched方法的具体用法?PHP Article::getRevIdFetched怎么用?PHP Article::getRevIdFetched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::getRevIdFetched方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setArticleHeader
/**
* Display a message to the user if (a) "blank if unapproved" is set,
* (b) the page is approvable, (c) the user has 'viewlinktolatest'
* permission, and (d) either the page has no approved revision, or
* the user is looking at a revision that's not the latest - the
* displayed message depends on which of those cases it is.
* @TODO - this should probably get split up into two methods.
*
* @since 0.5.6
*
* @param Article &$article
* @param boolean $outputDone
* @param boolean $useParserCache
*
* @return true
*/
public static function setArticleHeader(Article &$article, &$outputDone, &$useParserCache)
{
global $wgOut, $wgRequest, $egApprovedRevsBlankIfUnapproved;
// For now, we only set the header if "blank if unapproved"
// is set.
if (!$egApprovedRevsBlankIfUnapproved) {
return true;
}
$title = $article->getTitle();
if (!ApprovedRevs::pageIsApprovable($title)) {
return true;
}
// If the user isn't supposed to see these kinds of
// messages, exit.
if (!$title->userCan('viewlinktolatest')) {
return false;
}
// If there's an approved revision for this page, and the
// user is looking at it - either by simply going to the page,
// or by looking at the revision that happens to be approved -
// don't display anything.
$approvedRevID = ApprovedRevs::getApprovedRevID($title);
if (!empty($approvedRevID) && (!$wgRequest->getCheck('oldid') || $wgRequest->getInt('oldid') == $approvedRevID)) {
return true;
}
// Disable caching, so that if it's a specific ID being shown
// that happens to be the latest, it doesn't show a blank page.
$useParserCache = false;
$wgOut->addHTML('<span style="margin-left: 10.75px">');
// If the user is looking at a specific revision, show an
// "approve this revision" message - otherwise, it means
// there's no approved revision (we would have exited out if
// there were), so show a message explaining why the page is
// blank, with a link to the latest revision.
if ($wgRequest->getCheck('oldid')) {
if (ApprovedRevs::userCanApprove($title)) {
// @TODO - why is this message being shown
// at all? Aren't the "approve this revision"
// links in the history page always good
// enough?
$wgOut->addHTML(Xml::tags('span', array('id' => 'contentSub2'), Xml::element('a', array('href' => $title->getLocalUrl(array('action' => 'approve', 'oldid' => $wgRequest->getInt('oldid')))), wfMessage('approvedrevs-approvethisrev')->text())));
}
} else {
$wgOut->addSubtitle(htmlspecialchars(wfMessage('approvedrevs-blankpageshown')->text()) . ' ' . Xml::element('a', array('href' => $title->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMessage('approvedrevs-viewlatestrev')->text()));
}
$wgOut->addHTML('</span>');
return true;
}
示例2: onArticleViewHeader
/**
* Hook to insert things into article headers.
*
* @since 0.5.6
*
* @param Article &$article
* @param boolean $outputDone
* @param boolean $useParserCache
*
* @return true
*/
public static function onArticleViewHeader(Article &$article, &$outputDone, &$useParserCache)
{
global $wgOut, $wgRequest, $egApprovedRevsBlankIfUnapproved;
if (ApprovedRevs::pageIsApprovable($article->getTitle()) && $article->getTitle()->userCan('approverevisions')) {
$approvedId = ApprovedRevs::getApprovedRevID($article->getTitle());
if ($egApprovedRevsBlankIfUnapproved && (empty($approvedId) || $wgRequest->getCheck('oldid') && $wgRequest->getInt('oldid') != $approvedId)) {
$wgOut->addHTML('<span style="margin-left:10.75px">');
if ($wgRequest->getCheck('oldid')) {
$wgOut->addHTML(Xml::tags('span', array('id' => 'contentSub2'), Xml::element('a', array('href' => $article->getTitle()->getLocalUrl(array('action' => 'approve', 'oldid' => $wgRequest->getInt('oldid')))), wfMsg('approvedrevs-approvethisrev'))));
} else {
$wgOut->appendSubtitle(htmlspecialchars(wfMsg('approvedrevs-blankpageshown')) . ' ' . Xml::element('a', array('href' => $article->getTitle()->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMsg('approvedrevs-viewlatestrev')));
}
$wgOut->addHTML('</span>');
}
}
return true;
}
示例3: showEditForm
/**
* Send the edit form and related headers to $wgOut
* @param callable|null $formCallback That takes an OutputPage parameter; will be called
* during form output near the top, for captchas and the like.
*
* The $formCallback parameter is deprecated since MediaWiki 1.25. Please
* use the EditPage::showEditForm:fields hook instead.
*/
function showEditForm($formCallback = null)
{
global $wgOut, $wgUser;
# need to parse the preview early so that we know which templates are used,
# otherwise users with "show preview after edit box" will get a blank list
# we parse this near the beginning so that setHeaders can do the title
# setting work instead of leaving it in getPreviewText
$previewOutput = '';
if ($this->formtype == 'preview') {
$previewOutput = $this->getPreviewText();
}
Hooks::run('EditPage::showEditForm:initial', array(&$this, &$wgOut));
$this->setHeaders();
if ($this->showHeader() === false) {
return;
}
$wgOut->addHTML($this->editFormPageTop);
if ($wgUser->getOption('previewontop')) {
$this->displayPreviewArea($previewOutput, true);
}
$wgOut->addHTML($this->editFormTextTop);
$showToolbar = true;
if ($this->wasDeletedSinceLastEdit()) {
if ($this->formtype == 'save') {
// Hide the toolbar and edit area, user can click preview to get it back
// Add an confirmation checkbox and explanation.
$showToolbar = false;
} else {
$wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1\n</div>", 'deletedwhileediting');
}
}
// @todo add EditForm plugin interface and use it here!
// search for textarea1 and textares2, and allow EditForm to override all uses.
$wgOut->addHTML(Html::openElement('form', array('id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID, 'method' => 'post', 'action' => $this->getActionURL($this->getContextTitle()), 'enctype' => 'multipart/form-data')));
if (is_callable($formCallback)) {
wfWarn('The $formCallback parameter to ' . __METHOD__ . 'is deprecated');
call_user_func_array($formCallback, array(&$wgOut));
}
// Add an empty field to trip up spambots
$wgOut->addHTML(Xml::openElement('div', array('id' => 'antispam-container', 'style' => 'display: none;')) . Html::rawElement('label', array('for' => 'wpAntiSpam'), wfMessage('simpleantispam-label')->parse()) . Xml::element('input', array('type' => 'text', 'name' => 'wpAntispam', 'id' => 'wpAntispam', 'value' => '')) . Xml::closeElement('div'));
Hooks::run('EditPage::showEditForm:fields', array(&$this, &$wgOut));
// Put these up at the top to ensure they aren't lost on early form submission
$this->showFormBeforeText();
if ($this->wasDeletedSinceLastEdit() && 'save' == $this->formtype) {
$username = $this->lastDelete->user_name;
$comment = $this->lastDelete->log_comment;
// It is better to not parse the comment at all than to have templates expanded in the middle
// TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
$key = $comment === '' ? 'confirmrecreate-noreason' : 'confirmrecreate';
$wgOut->addHTML('<div class="mw-confirm-recreate">' . wfMessage($key, $username, "<nowiki>{$comment}</nowiki>")->parse() . Xml::checkLabel(wfMessage('recreate')->text(), 'wpRecreate', 'wpRecreate', false, array('title' => Linker::titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>');
}
# When the summary is hidden, also hide them on preview/show changes
if ($this->nosummary) {
$wgOut->addHTML(Html::hidden('nosummary', true));
}
# If a blank edit summary was previously provided, and the appropriate
# user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
# user being bounced back more than once in the event that a summary
# is not required.
# ####
# For a bit more sophisticated detection of blank summaries, hash the
# automatic one and pass that in the hidden field wpAutoSummary.
if ($this->missingSummary || $this->section == 'new' && $this->nosummary) {
$wgOut->addHTML(Html::hidden('wpIgnoreBlankSummary', true));
}
if ($this->undidRev) {
$wgOut->addHTML(Html::hidden('wpUndidRevision', $this->undidRev));
}
if ($this->selfRedirect) {
$wgOut->addHTML(Html::hidden('wpIgnoreSelfRedirect', true));
}
if ($this->hasPresetSummary) {
// If a summary has been preset using &summary= we don't want to prompt for
// a different summary. Only prompt for a summary if the summary is blanked.
// (Bug 17416)
$this->autoSumm = md5('');
}
$autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
$wgOut->addHTML(Html::hidden('wpAutoSummary', $autosumm));
$wgOut->addHTML(Html::hidden('oldid', $this->oldid));
$wgOut->addHTML(Html::hidden('parentRevId', $this->parentRevId ?: $this->mArticle->getRevIdFetched()));
$wgOut->addHTML(Html::hidden('format', $this->contentFormat));
$wgOut->addHTML(Html::hidden('model', $this->contentModel));
if ($this->section == 'new') {
$this->showSummaryInput(true, $this->summary);
$wgOut->addHTML($this->getSummaryPreview(true, $this->summary));
}
$wgOut->addHTML($this->editFormTextBeforeContent);
if (!$this->isCssJsSubpage && $showToolbar && $wgUser->getOption('showtoolbar')) {
$wgOut->addHTML(EditPage::getEditToolbar($this->mTitle));
}
if ($this->blankArticle) {
//.........这里部分代码省略.........
示例4: getParentRevId
/**
* Get the edit's parent revision ID
*
* The "parent" revision is the ancestor that should be recorded in this
* page's revision history. It is either the revision ID of the in-memory
* article content, or in the case of a 3-way merge in order to rebase
* across a recoverable edit conflict, the ID of the newer revision to
* which we have rebased this page.
*
* @since 1.27
* @return int Revision ID
*/
public function getParentRevId()
{
if ($this->parentRevId) {
return $this->parentRevId;
} else {
return $this->mArticle->getRevIdFetched();
}
}
示例5: setArticleHeader
/**
* Display a message
*
* @since 0.5.6
*
* @param Article &$article
* @param boolean $outputDone
* @param boolean $useParserCache
*
* @return true
*/
public static function setArticleHeader(Article &$article, &$outputDone, &$useParserCache)
{
global $wgOut, $wgRequest, $egApprovedRevsBlankIfUnapproved;
// For now, we only set the header if "blank if unapproved"
// is set.
if (!$egApprovedRevsBlankIfUnapproved) {
return true;
}
$title = $article->getTitle();
if (!ApprovedRevs::pageIsApprovable($title)) {
return true;
}
if (!ApprovedRevs::userCanApprove($title)) {
return true;
}
$approvedRevID = ApprovedRevs::getApprovedRevID($title);
if (!empty($approvedRevID) && !($wgRequest->getCheck('oldid') && $wgRequest->getInt('oldid') == $approvedRevID)) {
return true;
}
// Disable caching, so that if it's a specific ID being shown
// that happens to be the latest, it doesn't show a blank page.
$useParserCache = false;
$wgOut->addHTML('<span style="margin-left: 10.75px">');
if ($wgRequest->getCheck('oldid')) {
$wgOut->addHTML(Xml::tags('span', array('id' => 'contentSub2'), Xml::element('a', array('href' => $title->getLocalUrl(array('action' => 'approve', 'oldid' => $wgRequest->getInt('oldid')))), wfMsg('approvedrevs-approvethisrev'))));
} else {
$wgOut->appendSubtitle(htmlspecialchars(wfMsg('approvedrevs-blankpageshown')) . ' ' . Xml::element('a', array('href' => $title->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMsg('approvedrevs-viewlatestrev')));
}
$wgOut->addHTML('</span>');
return true;
}
示例6: createTargetTalkPages
private function createTargetTalkPages()
{
for ($m = 0; $m < count($this->data); $m++) {
// create talk page
$talkRevids = array();
$found = false;
for ($p = 0; $p < count($this->data[$m]); $p++) {
if ($this->data[$m][$p]['talkrevid']) {
$found = true;
break;
}
}
if ($found && !$this->data[$m][0]['talkrevid']) {
$mergeTargetTalkTitle = Title::newFromText($this->data[$m][0]['title'], $this->namespace == 'Family' && $m == 0 ? NS_FAMILY_TALK : NS_PERSON_TALK);
$article = new Article($mergeTargetTalkTitle, 0);
if ($article) {
$article->doEdit('', 'Create page in preparation for merge', EDIT_NEW);
$this->data[$m][0]['talkrevid'] = $article->getRevIdFetched();
}
}
}
}
示例7: writeOutput
//.........这里部分代码省略.........
$comment = $wgRequest->getVal("comment_text");
foreach ($wgRequest->getValues() as $key => $value) {
if (strpos($key, "comment_text") === 0) {
$comment = $value;
break;
}
}
$topic = $wgRequest->getVal("topic_name");
//echo "$dateStr<br/>";
// remove leading space, tends to be a problem with a lot of talk page comments as it breaks the
// HTML on the page
$comment = preg_replace('/\\n[ ]*/', "\n", trim($comment));
// Check to see if the user is also getting a thumbs up. If so, append the thumbs message and give a thumbs up
if ($wgRequest->getVal('thumb')) {
$comment .= "\n\n" . wfMsg('qn_thumbs_up');
$userName = explode(":", $wgRequest->getVal('target'));
ThumbsUp::quickNoteThumb($wgRequest->getVal('revold'), $wgRequest->getVal('revnew'), $wgRequest->getVal('pageid'), $userName[1]);
}
$formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, $comment);
if ($wgRequest->getVal('fromajax') == 'true') {
$wgOut->setArticleBodyOnly(true);
}
$text = "";
$r = Revision::newFromTitle($t);
if ($r) {
$text = $r->getText();
}
$text .= "\n\n{$formattedComment}\n\n";
$wgOut->setStatusCode(500);
//echo "updating with text:<br/> $text";
//exit;
$tmp = "";
if ($wgUser->isBlocked()) {
$wgOut->blockedPage();
return;
}
if (!$wgUser->getID() && $wgWhitelistEdit) {
$this->userNotLoggedInPage();
return;
}
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
if ($target == "Spam-Blacklist") {
$wgOut->readOnlyPage();
return;
}
if ($wgUser->pingLimiter()) {
$wgOut->rateLimited();
return;
}
if ($wgFilterCallback && $wgFilterCallback($t, $text, $tmp)) {
# Error messages or other handling should be performed by the filter function
return;
}
$matches = array();
$preg = "/http:\\/\\/[^] \n'\">]*/";
$mod = str_ireplace('http://www.wikihow.com', '', $comment);
preg_match_all($preg, $mod, $matches);
if (sizeof($matches[0]) > 2) {
$wgOut->errorPage("postcomment", "postcomment_urls_limit");
return;
}
if (trim(strip_tags($comment)) == "") {
$wgOut->errorpage("postcomment", "postcomment_nopostingtoadd");
return;
}
if (!$t->userCanEdit()) {
$wgOut->errorpage("postcomment", "postcomment_discussionprotected");
return;
}
$watch = false;
if ($wgUser->getID() > 0) {
$watch = $wgUser->isWatched($t);
}
$fc = new FancyCaptcha();
$pass_captcha = $fc->passCaptcha();
if (!$pass_captcha && $wgUser->getID() == 0) {
$wgOut->addHTML("Sorry, please enter the correct word. Click <a onclick='window.location.reload(true);'>here</a> to get a new one.<br/><br/>");
return;
}
$article->doEdit($text, "");
if ($wgRequest->getVal('jsonresponse') == 'true') {
$article->loadLastEdit(true);
$this->revId = $article->getRevIdFetched();
}
//XX Vu added to notify users of usertalk updates
if ($t->getNamespace() == NS_USER_TALK) {
AuthorEmailNotification::notifyUserTalk($t->getArticleID(), $wgUser->getID(), $comment);
}
$wgOut->setStatusCode(200);
if ($wgRequest->getVal('fromajax') == 'true') {
$wgOut->redirect('');
$wgTitle = $t;
$formattedComment = $wgParser->preSaveTransform($formattedComment, $t, $wgUser, new ParserOptions());
$wgOut->addHTML($wgOut->parse("\n" . $formattedComment));
return;
}
}
示例8: execute
//.........这里部分代码省略.........
}
$watch = $this->getWatchlistValue($params['watchlist'], $titleObj);
// Deprecated parameters
if ($params['watch']) {
$watch = true;
} elseif ($params['unwatch']) {
$watch = false;
}
if ($watch) {
$reqArr['wpWatchthis'] = '';
}
$req = new FauxRequest($reqArr, true);
$ep->importFormData($req);
// Run hooks
// Handle CAPTCHA parameters
global $wgRequest;
if (!is_null($params['captchaid'])) {
$wgRequest->setVal('wpCaptchaId', $params['captchaid']);
}
if (!is_null($params['captchaword'])) {
$wgRequest->setVal('wpCaptchaWord', $params['captchaword']);
}
$r = array();
if (!wfRunHooks('APIEditBeforeSave', array($ep, $ep->textbox1, &$r))) {
if (count($r)) {
$r['result'] = 'Failure';
$this->getResult()->addValue(null, $this->getModuleName(), $r);
return;
} else {
$this->dieUsageMsg(array('hookaborted'));
}
}
// Do the actual save
$oldRevId = $articleObj->getRevIdFetched();
$result = null;
// Fake $wgRequest for some hooks inside EditPage
// FIXME: This interface SUCKS
$oldRequest = $wgRequest;
$wgRequest = $req;
$retval = $ep->internalAttemptSave($result, $wgUser->isAllowed('bot') && $params['bot']);
$wgRequest = $oldRequest;
global $wgMaxArticleSize;
switch ($retval) {
case EditPage::AS_HOOK_ERROR:
case EditPage::AS_HOOK_ERROR_EXPECTED:
$this->dieUsageMsg(array('hookaborted'));
case EditPage::AS_IMAGE_REDIRECT_ANON:
$this->dieUsageMsg(array('noimageredirect-anon'));
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
$this->dieUsageMsg(array('noimageredirect-logged'));
case EditPage::AS_SPAM_ERROR:
$this->dieUsageMsg(array('spamdetected', $result['spam']));
case EditPage::AS_FILTERING:
$this->dieUsageMsg(array('filtered'));
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
$this->dieUsageMsg(array('blockedtext'));
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
$this->dieUsageMsg(array('contenttoobig', $wgMaxArticleSize));
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg(array('noedit-anon'));
case EditPage::AS_READ_ONLY_PAGE_LOGGED:
$this->dieUsageMsg(array('noedit'));
case EditPage::AS_READ_ONLY_PAGE:
$this->dieReadOnly();
case EditPage::AS_RATE_LIMITED:
示例9: execute
//.........这里部分代码省略.........
// Deprecated parameters
if ($params['watch']) {
$watch = true;
} elseif ($params['unwatch']) {
$watch = false;
}
if ($watch) {
$requestArray['wpWatchthis'] = '';
}
global $wgTitle, $wgRequest;
$req = new DerivativeRequest($this->getRequest(), $requestArray, true);
// Some functions depend on $wgTitle == $ep->mTitle
// TODO: Make them not or check if they still do
$wgTitle = $titleObj;
$articleObject = new Article($titleObj);
$ep = new EditPage($articleObject);
// allow editing of non-textual content.
$ep->allowNonTextContent = true;
$ep->setContextTitle($titleObj);
$ep->importFormData($req);
// Run hooks
// Handle APIEditBeforeSave parameters
$r = array();
if (!wfRunHooks('APIEditBeforeSave', array($ep, $ep->textbox1, &$r))) {
if (count($r)) {
$r['result'] = 'Failure';
$apiResult->addValue(null, $this->getModuleName(), $r);
return;
} else {
$this->dieUsageMsg('hookaborted');
}
}
// Do the actual save
$oldRevId = $articleObject->getRevIdFetched();
$result = null;
// Fake $wgRequest for some hooks inside EditPage
// @todo FIXME: This interface SUCKS
$oldRequest = $wgRequest;
$wgRequest = $req;
$status = $ep->internalAttemptSave($result, $user->isAllowed('bot') && $params['bot']);
$wgRequest = $oldRequest;
global $wgMaxArticleSize;
switch ($status->value) {
case EditPage::AS_HOOK_ERROR:
case EditPage::AS_HOOK_ERROR_EXPECTED:
$this->dieUsageMsg('hookaborted');
case EditPage::AS_PARSE_ERROR:
$this->dieUsage($status->getMessage(), 'parseerror');
case EditPage::AS_IMAGE_REDIRECT_ANON:
$this->dieUsageMsg('noimageredirect-anon');
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
$this->dieUsageMsg('noimageredirect-logged');
case EditPage::AS_SPAM_ERROR:
$this->dieUsageMsg(array('spamdetected', $result['spam']));
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
$this->dieUsageMsg('blockedtext');
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
$this->dieUsageMsg(array('contenttoobig', $wgMaxArticleSize));
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg('noedit-anon');
case EditPage::AS_READ_ONLY_PAGE_LOGGED:
$this->dieUsageMsg('noedit');
case EditPage::AS_READ_ONLY_PAGE:
$this->dieReadOnly();
case EditPage::AS_RATE_LIMITED:
示例10: logootIntegrate
/**
*Integrates the operation(LogootOp) into the article via the logoot algorithm
*
* @param <Object> $operation
* @param <String or Object> $article
*/
function logootIntegrate($operations, $article)
{
global $wgCanonicalNamespaceNames;
$indexNS = 0;
wfDebugLog('p2p', '@@@@@@@@@@@@@@@@@@@@@@@ - function logootIntegrate : ' . $article);
$dbr = wfGetDB(DB_SLAVE);
$dbr->immediateBegin();
if (is_string($article)) {
//if there is a space in the title, repalce by '_'
$article = str_replace(" ", "_", $article);
if (strpos($article, ":") === false) {
$pageid = $dbr->selectField('page', 'page_id', array('page_title' => $article));
} else {
//if there is a namespace
preg_match("/^(.+?)_*:_*(.*)\$/S", $article, $tmp);
$articleWithoutNS = $tmp[2];
$NS = $tmp[1];
if (in_array($NS, $wgCanonicalNamespaceNames)) {
foreach ($wgCanonicalNamespaceNames as $key => $value) {
if ($NS == $value) {
$indexNS = $key;
}
}
}
$pageid = $dbr->selectField('page', 'page_id', array('page_title' => $articleWithoutNS, 'page_namespace' => $indexNS));
}
// get the page namespace
$pageNameSpace = $dbr->selectField('page', 'page_namespace', array('page_id' => $pageid));
/*the ns must not be a pullfeed, pushfeed, changeset or patch namespace.
If the page name is the same in different ns we can get the wrong
* page id
*/
if ($pageNameSpace == PULLFEED || $pageNameSpace == PUSHFEED || $pageNameSpace == PATCH || $pageNameSpace == CHANGESET) {
$pageid = 0;
}
$lastRev = Revision::loadFromPageId($dbr, $pageid);
if (is_null($lastRev)) {
$rev_id = 0;
} else {
$rev_id = $lastRev->getId();
}
wfDebugLog('p2p', ' -> pageId : ' . $pageid);
wfDebugLog('p2p', ' -> rev_id : ' . $rev_id);
$title = Title::newFromText($article);
$article = new Article($title);
} else {
$rev_id = $article->getRevIdFetched();
}
$listOp = array();
//$blobInfo = BlobInfo::loadBlobInfo($rev_id);
$model = manager::loadModel($rev_id);
$logoot = manager::getNewEngine($model, DSMWSiteId::getInstance()->getSiteId());
// new logootEngine($model);
foreach ($operations as $operation) {
wfDebugLog('p2p', ' - operation : ' . $operation);
wfDebugLog('testlog', ' - operation : ' . $operation);
if (!$operation instanceof LogootOperation) {
$operation = operationToLogootOp($operation);
}
if ($operation != false && is_object($operation)) {
$listOp[] = $operation;
wfDebugLog('testlog', ' -> Operation: ' . $operation->getLogootPosition()->toString());
//$blobInfo->integrateBlob($operation);
}
}
//end foreach operations
$p = new LogootPatch($rev_id, $listOp);
$logoot->integrate($p);
$modelAfterIntegrate = $logoot->getModel();
//$revId = utils::getNewArticleRevId();
$status = $article->doEdit($modelAfterIntegrate->getText(), $summary = "");
$revId = $status->value['revision']->getId();
manager::storeModel($revId, $sessionId = session_id(), $modelAfterIntegrate, $blobCB = 0);
return array($revId, $p);
}
示例11: buildRssNs
public function buildRssNs($aParams)
{
global $wgRequest, $wgSitename, $wgLang, $wgDBprefix;
$dbr = wfGetDB(DB_SLAVE);
$_showLimit = 10;
if (isset($aParams['ns'])) {
$ns = $aParams['ns'] + 0;
} else {
$ns = $wgRequest->getInt('ns', 0);
}
$aNamespaces = $wgLang->getNamespaces();
$channel = RSSCreator::createChannel($wgSitename . ' - ' . wfMessage('bs-ns')->plain() . ' ' . $aNamespaces[$ns], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], wfMessage('bs-rssstandards-desc-ns')->plain());
$res = $dbr->query("select page_id from " . $wgDBprefix . "page where page_namespace = " . $ns);
$entryIds = array();
while ($row = $dbr->fetchRow($res)) {
$entryIds[] = $row['page_id'];
}
if (count($entryIds)) {
$query = "SELECT Min(r.rev_id) as rid, r.rev_page, r.rev_timestamp, r.rev_user_text FROM " . $wgDBprefix . "revision as r WHERE r.rev_page In (" . join(",", $entryIds) . ") GROUP BY r.rev_page, r.rev_timestamp, r.rev_user_text ORDER BY rid DESC";
$res = $dbr->query($query);
$numberOfEntries = $dbr->numRows($res);
$query .= ' LIMIT ' . $_showLimit;
$res = $dbr->query($query);
while ($row = $dbr->fetchRow($res)) {
$title = Title::newFromID($row['rev_page']);
$article = new Article($title);
if (!$title->userCan('read')) {
$numberOfEntries--;
continue;
}
$_title = str_replace("_", " ", $title->getText());
$_link = $title->getFullURL();
$_tmpText = preg_replace("#\\[<a\\ href\\=\"(.*)action\\=edit(.*)\"\\ title\\=\"(.*)\">(.*)<\\/a>\\]#", "", $this->mCore->parseWikiText($article->getContent(), $this->getTitle()));
if (class_exists('SecureFileStore')) {
$_description = SecureFileStore::secureFilesInText($_tmpText);
} else {
$_description = $_tmpText;
}
unset($_tmpText);
$item = RSSItemCreator::createItem($_title, $_link, $_description);
if ($item) {
$item->setPubDate(wfTimestamp(TS_UNIX, $row['rev_timestamp']));
$item->setComments($title->getTalkPage()->getFullURL());
$item->setGUID($title->getFullURL("oldid=" . $article->getRevIdFetched()), 'true');
$channel->addItem($item);
}
}
}
$dbr->freeResult($res);
return $channel->buildOutput();
}
示例12: writeOutput
//.........这里部分代码省略.........
if ($this->getRequest()->getVal('fromajax') == 'true') {
$this->getOutput()->setArticleBodyOnly(true);
}
$text = "";
$r = Revision::newFromTitle($t);
if ($r) {
$text = $r->getText();
}
$text .= "\n\n{$formattedComment}\n\n";
$this->getOutput()->setStatusCode(409);
//echo "updating with text:<br/> $text";
//exit;
$tmp = "";
if ($this->getUser()->isBlocked()) {
$this->getOutput()->blockedPage();
return;
}
if (!$this->getUser()->getID() && $wgWhitelistEdit) {
$this->userNotLoggedInPage();
return;
}
if (wfReadOnly()) {
$this->getOutput()->readOnlyPage();
return;
}
if ($target == "Spam-Blacklist") {
$this->getOutput()->readOnlyPage();
return;
}
if ($this->getUser()->pingLimiter()) {
$this->getOutput()->rateLimited();
return;
}
$editPage = new EditPage($article);
$contentModel = $t->getContentModel();
$handler = ContentHandler::getForModelID($contentModel);
$contentFormat = $handler->getDefaultFormat();
$content = ContentHandler::makeContent($text, $t, $contentModel, $contentFormat);
$status = Status::newGood();
if (!wfRunHooks('EditFilterMergedContent', array($this->getContext(), $content, &$status, '', $wgUser, false))) {
return;
}
if (!$status->isGood()) {
$errors = $status->getErrorsArray(true);
foreach ($errors as $error) {
if (is_array($error)) {
$error = count($error) ? $error[0] : '';
}
if (preg_match('@^spamprotection@', $error)) {
$message = 'Error: found spam link';
$this->getOutput()->addHTML($message);
return;
}
}
$message = 'EditFilterMergedContent returned an error -- cannot post comment';
return;
}
$matches = array();
$preg = "/http:\\/\\/[^] \n'\">]*/";
$mod = str_ireplace('http://www.wikihow.com', '', $comment);
preg_match_all($preg, $mod, $matches);
if (sizeof($matches[0]) > 2) {
$this->getOutput()->showErrorPage("postcomment", "postcomment_urls_limit");
return;
}
if (trim(strip_tags($comment)) == "") {
$this->getOutput()->showErrorPage("postcomment", "postcomment_nopostingtoadd");
return;
}
if (!$t->userCan('edit')) {
$this->getOutput()->showErrorPage("postcomment", "postcomment_discussionprotected");
return;
}
$watch = false;
if ($this->getUser()->getID() > 0) {
$watch = $this->getUser()->isWatched($t);
}
$fc = new FancyCaptcha();
$pass_captcha = $fc->passCaptcha();
if (!$pass_captcha && $this->getUser()->getID() == 0) {
$this->getOutput()->addHTML("Sorry, please enter the correct word. Click <a onclick='window.location.reload(true);'>here</a> to get a new one.<br/><br/>");
return;
}
$article->doEdit($text, "");
if ($this->getRequest()->getVal('jsonresponse') == 'true') {
$this->revId = $article->getRevIdFetched();
}
// Notify users of usertalk updates
if ($t->getNamespace() == NS_USER_TALK) {
AuthorEmailNotification::notifyUserTalk($t->getArticleID(), $this->getUser()->getID(), $comment);
}
$this->getOutput()->setStatusCode(200);
if ($this->getRequest()->getVal('fromajax') == 'true') {
$this->getOutput()->redirect('');
$this->getContext()->setTitle($t);
$formattedComment = $wgParser->preSaveTransform($formattedComment, $t, $this->getUser(), new ParserOptions());
$this->getOutput()->addHTML($this->getOutput()->parse("\n" . $formattedComment));
return;
}
}
示例13: execute
//.........这里部分代码省略.........
$watch = $titleObj->userIsWatching();
}
// Deprecated parameters
if ($params['watch']) {
$watch = true;
} elseif ($params['unwatch']) {
$watch = false;
}
if ($watch) {
$reqArr['wpWatchthis'] = '';
}
$req = new FauxRequest($reqArr, true);
$ep->importFormData($req);
// Run hooks
// Handle CAPTCHA parameters
global $wgRequest;
if (!is_null($params['captchaid'])) {
$wgRequest->setVal('wpCaptchaId', $params['captchaid']);
}
if (!is_null($params['captchaword'])) {
$wgRequest->setVal('wpCaptchaWord', $params['captchaword']);
}
$r = array();
if (!wfRunHooks('APIEditBeforeSave', array($ep, $ep->textbox1, &$r))) {
if (count($r)) {
$r['result'] = "Failure";
$this->getResult()->addValue(null, $this->getModuleName(), $r);
return;
} else {
$this->dieUsageMsg(array('hookaborted'));
}
}
// Do the actual save
$oldRevId = $articleObj->getRevIdFetched();
$result = null;
// Fake $wgRequest for some hooks inside EditPage
// FIXME: This interface SUCKS
$oldRequest = $wgRequest;
$wgRequest = $req;
$retval = $ep->internalAttemptSave($result, $wgUser->isAllowed('bot') && $params['bot']);
$wgRequest = $oldRequest;
switch ($retval) {
case EditPage::AS_HOOK_ERROR:
case EditPage::AS_HOOK_ERROR_EXPECTED:
$this->dieUsageMsg(array('hookaborted'));
case EditPage::AS_IMAGE_REDIRECT_ANON:
$this->dieUsageMsg(array('noimageredirect-anon'));
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
$this->dieUsageMsg(array('noimageredirect-logged'));
case EditPage::AS_SPAM_ERROR:
$this->dieUsageMsg(array('spamdetected', $result['spam']));
case EditPage::AS_FILTERING:
$this->dieUsageMsg(array('filtered'));
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
$this->dieUsageMsg(array('blockedtext'));
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
global $wgMaxArticleSize;
$this->dieUsageMsg(array('contenttoobig', $wgMaxArticleSize));
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg(array('noedit-anon'));
case EditPage::AS_READ_ONLY_PAGE_LOGGED:
$this->dieUsageMsg(array('noedit'));
case EditPage::AS_READ_ONLY_PAGE:
$this->dieReadOnly();
case EditPage::AS_RATE_LIMITED:
示例14: delete
/**
* @param Article $article - Article object to work on
* @param string $token - Delete token (same as edit token)
* @param integer $revid - revision to delete
* @param string $reason - Reason for the deletion. Autogenerated if NULL
* @return Title::getUserPermissionsErrors()-like array
*/
public function delete(&$article, $token, $revid, &$reason)
{
global $wgUser;
$title = $article->getTitle();
$errors = self::getPermissionsError($title, $token);
if (count($errors)) {
return $errors;
}
if ($article->getRevIdFetched() == $revid) {
return array(array('cannotdelete', $title->getPrefixedText()));
}
// Auto-generate a summary, if necessary
if (is_null($reason)) {
$reason = 'delete revision ' . $revid . ' of page ' . $title->getPrefixedText();
}
// We have to handle the revision deletion by hand
if ($this->doDeleteRevision(&$article, $revid, $reason)) {
return array();
}
return array(array('cannotdelete', $title->getPrefixedText()));
}
示例15: patrolledGood
/**
* Grab the last good patrol
* - return true if the last edit on the article was patrolled
*/
public static function patrolledGood($title)
{
// start with basic check to make sure we're dealing
// with a real article
if (!$title) {
return false;
}
// get the last revision
$a = new Article($title);
$last_rev_id = $a->getRevIdFetched();
// get the last good revision
$goodRev = self::newFromTitle($title);
$last_good_rev = $goodRev->latestGood();
return $last_rev_id == $last_good_rev;
}