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


PHP RecentChange::newFromId方法代码示例

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


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

示例1: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'rcid', 'revid');
     if (isset($params['rcid'])) {
         $rc = RecentChange::newFromId($params['rcid']);
         if (!$rc) {
             $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
         }
     } else {
         $rev = Revision::newFromId($params['revid']);
         if (!$rev) {
             $this->dieUsageMsg(array('nosuchrevid', $params['revid']));
         }
         $rc = $rev->getRecentChange();
         if (!$rc) {
             $this->dieUsage('The revision ' . $params['revid'] . " can't be patrolled as it's too old", 'notpatrollable');
         }
     }
     $retval = $rc->doMarkPatrolled($this->getUser());
     if ($retval) {
         $this->dieUsageMsg(reset($retval));
     }
     $result = array('rcid' => intval($rc->getAttribute('rc_id')));
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:30,代码来源:ApiPatrol.php

示例2: record

 /**
  * Record a log event for a change being patrolled
  *
  * @param mixed $rc Change identifier or RecentChange object
  * @param bool $auto Was this patrol event automatic?
  * @param User $user User performing the action or null to use $wgUser
  *
  * @return bool
  */
 public static function record($rc, $auto = false, User $user = null)
 {
     global $wgLogAutopatrol;
     // do not log autopatrolled edits if setting disables it
     if ($auto && !$wgLogAutopatrol) {
         return false;
     }
     if (!$rc instanceof RecentChange) {
         $rc = RecentChange::newFromId($rc);
         if (!is_object($rc)) {
             return false;
         }
     }
     if (!$user) {
         global $wgUser;
         $user = $wgUser;
     }
     $entry = new ManualLogEntry('patrol', 'patrol');
     $entry->setTarget($rc->getTitle());
     $entry->setParameters(self::buildParams($rc, $auto));
     $entry->setPerformer($user);
     $logid = $entry->insert();
     if (!$auto) {
         $entry->publish($logid, 'udp');
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:36,代码来源:PatrolLog.php

示例3: onView

 public function onView()
 {
     $rc = RecentChange::newFromId($this->getRequest()->getInt('rcid'));
     if (is_null($rc)) {
         throw new ErrorPageError('markedaspatrollederror', 'markedaspatrollederrortext');
     }
     $errors = $rc->doMarkPatrolled($this->getUser());
     if (in_array(array('rcpatroldisabled'), $errors)) {
         throw new ErrorPageError('rcpatroldisabled', 'rcpatroldisabledtext');
     }
     if (in_array(array('hookaborted'), $errors)) {
         // The hook itself has handled any output
         return;
     }
     # It would be nice to see where the user had actually come from, but for now just guess
     $returnto = $rc->getAttribute('rc_type') == RC_NEW ? 'Newpages' : 'Recentchanges';
     $return = SpecialPage::getTitleFor($returnto);
     if (in_array(array('markedaspatrollederror-noautopatrol'), $errors)) {
         $this->getOutput()->setPageTitle(wfMsg('markedaspatrollederror'));
         $this->getOutput()->addWikiMsg('markedaspatrollederror-noautopatrol');
         $this->getOutput()->returnToMain(null, $return);
         return;
     }
     if (!empty($errors)) {
         $this->getOutput()->showPermissionsErrorPage($errors);
         return;
     }
     # Inform the user
     $this->getOutput()->setPageTitle(wfMsg('markedaspatrolled'));
     $this->getOutput()->addWikiMsg('markedaspatrolledtext', $rc->getTitle()->getPrefixedText());
     $this->getOutput()->returnToMain(null, $return);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:32,代码来源:MarkpatrolledAction.php

示例4: record

 /**
  * Record a log event for a change being patrolled
  *
  * @param $rc Mixed: change identifier or RecentChange object
  * @param $auto Boolean: was this patrol event automatic?
  */
 public static function record($rc, $auto = false)
 {
     if (!$rc instanceof RecentChange) {
         $rc = RecentChange::newFromId($rc);
         if (!is_object($rc)) {
             return false;
         }
     }
     $title = Title::makeTitleSafe($rc->getAttribute('rc_namespace'), $rc->getAttribute('rc_title'));
     if (is_object($title)) {
         $params = self::buildParams($rc, $auto);
         $log = new LogPage('patrol', false, $auto ? "skipUDP" : "UDP");
         # False suppresses RC entries
         $log->addEntry('patrol', $title, '', $params);
         return true;
     }
     return false;
 }
开发者ID:rocLv,项目名称:conference,代码行数:24,代码来源:PatrolLog.php

示例5: onView

 public function onView()
 {
     $request = $this->getRequest();
     $rcId = $request->getInt('rcid');
     $rc = RecentChange::newFromId($rcId);
     if (is_null($rc)) {
         throw new ErrorPageError('markedaspatrollederror', 'markedaspatrollederrortext');
     }
     $user = $this->getUser();
     if (!$user->matchEditToken($request->getVal('token'), $rcId)) {
         throw new ErrorPageError('sessionfailure-title', 'sessionfailure');
     }
     $errors = $rc->doMarkPatrolled($user);
     if (in_array(['rcpatroldisabled'], $errors)) {
         throw new ErrorPageError('rcpatroldisabled', 'rcpatroldisabledtext');
     }
     if (in_array(['hookaborted'], $errors)) {
         // The hook itself has handled any output
         return;
     }
     # It would be nice to see where the user had actually come from, but for now just guess
     if ($rc->getAttribute('rc_type') == RC_NEW) {
         $returnTo = 'Newpages';
     } elseif ($rc->getAttribute('rc_log_type') == 'upload') {
         $returnTo = 'Newfiles';
     } else {
         $returnTo = 'Recentchanges';
     }
     $return = SpecialPage::getTitleFor($returnTo);
     if (in_array(['markedaspatrollederror-noautopatrol'], $errors)) {
         $this->getOutput()->setPageTitle($this->msg('markedaspatrollederror'));
         $this->getOutput()->addWikiMsg('markedaspatrollederror-noautopatrol');
         $this->getOutput()->returnToMain(null, $return);
         return;
     }
     if (count($errors)) {
         throw new PermissionsError('patrol', $errors);
     }
     # Inform the user
     $this->getOutput()->setPageTitle($this->msg('markedaspatrolled'));
     $this->getOutput()->addWikiMsg('markedaspatrolledtext', $rc->getTitle()->getPrefixedText());
     $this->getOutput()->returnToMain(null, $return);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:43,代码来源:MarkpatrolledAction.php

示例6: processIndividual

 protected function processIndividual($type, $params, $id)
 {
     $idResult = array($type => $id);
     // validate the ID
     $valid = false;
     switch ($type) {
         case 'rcid':
             $valid = RecentChange::newFromId($id);
             break;
         case 'revid':
             $valid = Revision::newFromId($id);
             break;
         case 'logid':
             $valid = self::validateLogId($id);
             break;
     }
     if (!$valid) {
         $idResult['status'] = 'error';
         $idResult += $this->parseMsg(array("nosuch{$type}", $id));
         return $idResult;
     }
     $status = ChangeTags::updateTagsWithChecks($params['add'], $params['remove'], $type === 'rcid' ? $id : null, $type === 'revid' ? $id : null, $type === 'logid' ? $id : null, null, $params['reason'], $this->getUser());
     if (!$status->isOK()) {
         if ($status->hasMessage('actionthrottledtext')) {
             $idResult['status'] = 'skipped';
         } else {
             $idResult['status'] = 'failure';
             $idResult['errors'] = $this->getErrorFormatter()->arrayFromStatus($status, 'error');
         }
     } else {
         $idResult['status'] = 'success';
         if (is_null($status->value->logId)) {
             $idResult['noop'] = '';
         } else {
             $idResult['actionlogid'] = $status->value->logId;
             $idResult['added'] = $status->value->addedTags;
             ApiResult::setIndexedTagName($idResult['added'], 't');
             $idResult['removed'] = $status->value->removedTags;
             ApiResult::setIndexedTagName($idResult['removed'], 't');
         }
     }
     return $idResult;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:43,代码来源:ApiTag.php

示例7: record

 /**
  * Record a log event for a change being patrolled
  *
  * @param $rc Mixed: change identifier or RecentChange object
  * @param $auto Boolean: was this patrol event automatic?
  *
  * @return bool
  */
 public static function record($rc, $auto = false)
 {
     if (!$rc instanceof RecentChange) {
         $rc = RecentChange::newFromId($rc);
         if (!is_object($rc)) {
             return false;
         }
     }
     $title = Title::makeTitleSafe($rc->getAttribute('rc_namespace'), $rc->getAttribute('rc_title'));
     if ($title) {
         $entry = new ManualLogEntry('patrol', 'patrol');
         $entry->setTarget($title);
         $entry->setParameters(self::buildParams($rc, $auto));
         $entry->setPerformer(User::newFromName($rc->getAttribute('rc_user_text'), false));
         $logid = $entry->insert();
         if (!$auto) {
             $entry->publish($logid, 'udp');
         }
         return true;
     }
     return false;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:30,代码来源:PatrolLog.php

示例8: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'rcid', 'revid');
     if (isset($params['rcid'])) {
         $rc = RecentChange::newFromId($params['rcid']);
         if (!$rc) {
             $this->dieUsageMsg(['nosuchrcid', $params['rcid']]);
         }
     } else {
         $rev = Revision::newFromId($params['revid']);
         if (!$rev) {
             $this->dieUsageMsg(['nosuchrevid', $params['revid']]);
         }
         $rc = $rev->getRecentChange();
         if (!$rc) {
             $this->dieUsage('The revision ' . $params['revid'] . " can't be patrolled as it's too old", 'notpatrollable');
         }
     }
     $user = $this->getUser();
     $tags = $params['tags'];
     // Check if user can add tags
     if (!is_null($tags)) {
         $ableToTag = ChangeTags::canAddTagsAccompanyingChange($tags, $user);
         if (!$ableToTag->isOK()) {
             $this->dieStatus($ableToTag);
         }
     }
     $retval = $rc->doMarkPatrolled($user, false, $tags);
     if ($retval) {
         $this->dieUsageMsg(reset($retval));
     }
     $result = ['rcid' => intval($rc->getAttribute('rc_id'))];
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:39,代码来源:ApiPatrol.php

示例9: markPatrolledLink

 /**
  * Get a link to mark the change as patrolled, or '' if there's either no
  * revision to patrol or the user is not allowed to to it.
  * Side effect: this method will call OutputPage::preventClickjacking()
  * when a link is builded.
  *
  * @return String
  */
 protected function markPatrolledLink()
 {
     global $wgUseRCPatrol;
     if ($this->mMarkPatrolledLink === null) {
         // Prepare a change patrol link, if applicable
         if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $this->getUser())) {
             // If we've been given an explicit change identifier, use it; saves time
             if ($this->mRcidMarkPatrolled) {
                 $rcid = $this->mRcidMarkPatrolled;
                 $rc = RecentChange::newFromId($rcid);
                 // Already patrolled?
                 $rcid = is_object($rc) && !$rc->getAttribute('rc_patrolled') ? $rcid : 0;
             } else {
                 // Look for an unpatrolled change corresponding to this diff
                 $db = wfGetDB(DB_SLAVE);
                 $change = RecentChange::newFromConds(array('rc_user_text' => $this->mNewRev->getRawUserText(), 'rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_last_oldid' => $this->mOldid, 'rc_patrolled' => 0), __METHOD__);
                 if ($change instanceof RecentChange) {
                     $rcid = $change->mAttribs['rc_id'];
                     $this->mRcidMarkPatrolled = $rcid;
                 } else {
                     // None found
                     $rcid = 0;
                 }
             }
             // Build the link
             if ($rcid) {
                 $this->getOutput()->preventClickjacking();
                 $token = $this->getUser()->getEditToken($rcid);
                 $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown($this->mNewPage, $this->msg('markaspatrolleddiff')->escaped(), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token)) . ']</span>';
             } else {
                 $this->mMarkPatrolledLink = '';
             }
         } else {
             $this->mMarkPatrolledLink = '';
         }
     }
     return $this->mMarkPatrolledLink;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:46,代码来源:DifferenceEngine.php

示例10: markpatrolled

 /**
  * Mark this particular edit/page as patrolled
  */
 public function markpatrolled()
 {
     global $wgOut, $wgUser, $wgRequest;
     $wgOut->setRobotPolicy('noindex,nofollow');
     # If we haven't been given an rc_id value, we can't do anything
     $rcid = (int) $wgRequest->getVal('rcid');
     if (!$wgUser->matchEditToken($wgRequest->getVal('token'), $rcid)) {
         $wgOut->showErrorPage('sessionfailure-title', 'sessionfailure');
         return;
     }
     $rc = RecentChange::newFromId($rcid);
     if (is_null($rc)) {
         $wgOut->showErrorPage('markedaspatrollederror', 'markedaspatrollederrortext');
         return;
     }
     # It would be nice to see where the user had actually come from, but for now just guess
     $returnto = $rc->getAttribute('rc_type') == RC_NEW ? 'Newpages' : 'Recentchanges';
     $return = SpecialPage::getTitleFor($returnto);
     $errors = $rc->doMarkPatrolled();
     if (in_array(array('rcpatroldisabled'), $errors)) {
         $wgOut->showErrorPage('rcpatroldisabled', 'rcpatroldisabledtext');
         return;
     }
     if (in_array(array('hookaborted'), $errors)) {
         // The hook itself has handled any output
         return;
     }
     if (in_array(array('markedaspatrollederror-noautopatrol'), $errors)) {
         $wgOut->setPageTitle(wfMsg('markedaspatrollederror'));
         $wgOut->addWikiMsg('markedaspatrollederror-noautopatrol');
         $wgOut->returnToMain(false, $return);
         return;
     }
     if (!empty($errors)) {
         $wgOut->showPermissionsErrorPage($errors);
         return;
     }
     # Inform the user
     $wgOut->setPageTitle(wfMsg('markedaspatrolled'));
     $wgOut->addWikiMsg('markedaspatrolledtext', $rc->getTitle()->getPrefixedText());
     $wgOut->returnToMain(false, $return);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:45,代码来源:Article.php

示例11: showDiffPage

    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol, $wgEnableHtmlDiff;
        wfProfileIn(__METHOD__);
        # If external diffs are enabled both globally and for the user,
        # we'll use the application/x-external-editor interface to call
        # an external diff tool like kompare, kdiff3, etc.
        if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
            global $wgInputEncoding, $wgServer, $wgScript, $wgLang;
            $wgOut->disable();
            header("Content-type: application/x-external-editor; charset=" . $wgInputEncoding);
            $url1 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mOldid);
            $url2 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mNewid);
            $special = $wgLang->getNsText(NS_SPECIAL);
            $control = <<<CONTROL
\t\t\t[Process]
\t\t\tType=Diff text
\t\t\tEngine=MediaWiki
\t\t\tScript={$wgServer}{$wgScript}
\t\t\tSpecial namespace={$special}

\t\t\t[File]
\t\t\tExtension=wiki
\t\t\tURL={$url1}

\t\t\t[File 2]
\t\t\tExtension=wiki
\t\t\tURL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText();
            $d = wfMsgExt('missingarticle-diff', array('escape'), $this->mOldid, $this->mNewid);
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missing-article', "<nowiki>{$t}</nowiki>", $d);
            wfProfileOut(__METHOD__);
            return;
        }
        wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
        if ($this->mNewRev->isCurrent()) {
            $wgOut->setArticleFlag(true);
        }
        # mOldid is false if the difference engine is called with a "vague" query for
        # a diff between a version V and its previous version V' AND the version V
        # is the first version of that article. In that case, V' does not exist.
        if ($this->mOldid === false) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut(__METHOD__);
            return;
        }
        $wgOut->suppressQuickbar();
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsgExt('difference', array('parseinline')));
        $wgOut->setRobotPolicy('noindex,nofollow');
        if (!$this->mOldPage->userCanRead() || !$this->mNewPage->userCanRead()) {
            $wgOut->loginToUse();
            $wgOut->output();
            $wgOut->disable();
            wfProfileOut(__METHOD__);
            return;
        }
        $sk = $wgUser->getSkin();
        // Check if page is editable
        $editable = $this->mNewRev->getTitle()->userCan('edit');
        if ($editable && $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback')) {
            $rollback = '&nbsp;&nbsp;&nbsp;' . $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $this->mTitle->userCan('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
                $rc = RecentChange::newFromId($rcid);
                // Already patrolled?
                $rcid = is_object($rc) && !$rc->getAttribute('rc_patrolled') ? $rcid : 0;
            } else {
                // Look for an unpatrolled change corresponding to this diff
                $db = wfGetDB(DB_SLAVE);
                $change = RecentChange::newFromConds(array('rc_user_text' => $this->mNewRev->getRawUserText(), 'rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_last_oldid' => $this->mOldid, 'rc_patrolled' => 0), __METHOD__);
                if ($change instanceof RecentChange) {
                    $rcid = $change->mAttribs['rc_id'];
                    $this->mRcidMarkPatrolled = $rcid;
                } else {
                    // None found
                    $rcid = 0;
                }
            }
//.........这里部分代码省略.........
开发者ID:stereosupersonic,项目名称:fiusm.com,代码行数:101,代码来源:DifferenceEngine.php

示例12: getRevFromRC

 /**
  * Turn a RecentChange id into a revision ID.
  * Note: if the requested revision is a rolled back revision, don't return it.
  */
 public static function getRevFromRC($pageid, $rcid)
 {
     $rc = RecentChange::newFromId($rcid, true);
     if ($rc) {
         // Check if there was a rollback on any of the more
         // recent changes to the article. If there was a
         // rollback, just return 0 so that it looks to any
         // calling function like there is no associated
         // revision ID to assign.
         $rollbackCommentPrefix = wfMsgForContent('rollback_comment_prefix');
         $dbr = self::getDB('read');
         $res = $dbr->select('recentchanges', array('rc_comment'), array('rc_cur_id' => $pageid, 'rc_id > ' . $rcid), __METHOD__);
         foreach ($res as $row) {
             $isRollback = strpos($row->rc_comment, $rollbackCommentPrefix) === 0;
             if ($isRollback) {
                 return 0;
             }
         }
         return $rc->getAttribute('rc_this_oldid');
     } else {
         return 0;
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:27,代码来源:GoodRevision.class.php

示例13: markpatrolled

 /**
  * Mark this particular edit as patrolled
  */
 function markpatrolled()
 {
     global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUser;
     $wgOut->setRobotPolicy('noindex,nofollow');
     # Check RC patrol config. option
     if (!$wgUseRCPatrol) {
         $wgOut->errorPage('rcpatroldisabled', 'rcpatroldisabledtext');
         return;
     }
     # Check permissions
     if (!$wgUser->isAllowed('patrol')) {
         $wgOut->permissionRequired('patrol');
         return;
     }
     # If we haven't been given an rc_id value, we can't do anything
     $rcid = $wgRequest->getVal('rcid');
     if (!$rcid) {
         $wgOut->errorPage('markedaspatrollederror', 'markedaspatrollederrortext');
         return;
     }
     # Handle the 'MarkPatrolled' hook
     if (!wfRunHooks('MarkPatrolled', array($rcid, &$wgUser, false))) {
         return;
     }
     $return = SpecialPage::getTitleFor('Recentchanges');
     # If it's left up to us, check that the user is allowed to patrol this edit
     # If the user has the "autopatrol" right, then we'll assume there are no
     # other conditions stopping them doing so
     if (!$wgUser->isAllowed('autopatrol')) {
         $rc = RecentChange::newFromId($rcid);
         # Graceful error handling, as we've done before here...
         # (If the recent change doesn't exist, then it doesn't matter whether
         # the user is allowed to patrol it or not; nothing is going to happen
         if (is_object($rc) && $wgUser->getName() == $rc->getAttribute('rc_user_text')) {
             # The user made this edit, and can't patrol it
             # Tell them so, and then back off
             $wgOut->setPageTitle(wfMsg('markedaspatrollederror'));
             $wgOut->addWikiText(wfMsgNoTrans('markedaspatrollederror-noautopatrol'));
             $wgOut->returnToMain(false, $return);
             return;
         }
     }
     # Mark the edit as patrolled
     RecentChange::markPatrolled($rcid);
     wfRunHooks('MarkPatrolledComplete', array(&$rcid, &$wgUser, false));
     # Inform the user
     $wgOut->setPageTitle(wfMsg('markedaspatrolled'));
     $wgOut->addWikiText(wfMsgNoTrans('markedaspatrolledtext'));
     $wgOut->returnToMain(false, $return);
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:53,代码来源:Article.php

示例14: getMarkPatrolledLink

 static function getMarkPatrolledLink()
 {
     global $wgRequest, $wgUser;
     // Append a [Mark as Patrolled] link in certain cases
     $markPatrolledLink = '';
     $rcid = $wgRequest->getInt('rcid');
     $fromRC = $wgRequest->getInt('fromrc');
     if ($wgUser && $rcid > 0 && $fromRC && $wgUser->isAllowed('patrol')) {
         $rc = RecentChange::newFromId($rcid);
         if ($rc) {
             $oldRevId = $rc->getAttribute('rc_last_oldid');
             $newRevId = $rc->getAttribute('rc_this_oldid');
             $diff = new DifferenceEngine(null, $oldRevId, $newRevId);
             if ($diff->loadRevisionData()) {
                 $markPatrolledLink = $diff->markPatrolledLink();
             } else {
                 throw new MWException("wikiHow internal error: we know there is an rcid ({$rcid}) and newrevid ({$newRevId}), but couldn't find the revision");
             }
         }
     }
     return $markPatrolledLink;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:22,代码来源:WikihowArticle.class.php

示例15: showDiffPage

    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
        wfProfileIn(__METHOD__);
        # Allow frames except in certain special cases
        $wgOut->allowClickjacking();
        # If external diffs are enabled both globally and for the user,
        # we'll use the application/x-external-editor interface to call
        # an external diff tool like kompare, kdiff3, etc.
        if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
            global $wgCanonicalServer, $wgScript, $wgLang;
            $wgOut->disable();
            header("Content-type: application/x-external-editor; charset=UTF-8");
            $url1 = $this->mTitle->getCanonical(array('action' => 'raw', 'oldid' => $this->mOldid));
            $url2 = $this->mTitle->getCanonical(array('action' => 'raw', 'oldid' => $this->mNewid));
            $special = $wgLang->getNsText(NS_SPECIAL);
            $control = <<<CONTROL
\t\t\t[Process]
\t\t\tType=Diff text
\t\t\tEngine=MediaWiki
\t\t\tScript={$wgCanonicalServer}{$wgScript}
\t\t\tSpecial namespace={$special}

\t\t\t[File]
\t\t\tExtension=wiki
\t\t\tURL={$url1}

\t\t\t[File 2]
\t\t\tExtension=wiki
\t\t\tURL={$url2}
CONTROL;
            echo $control;
            wfProfileOut(__METHOD__);
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            // Sounds like a deleted revision... Let's see what we can do.
            $t = $this->mTitle->getPrefixedText();
            $d = wfMsgExt('missingarticle-diff', array('escape'), $this->deletedIdMarker($this->mOldid), $this->deletedIdMarker($this->mNewid));
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missing-article', "<nowiki>{$t}</nowiki>", "<span class='plainlinks'>{$d}</span>");
            wfProfileOut(__METHOD__);
            return;
        }
        wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
        if ($this->mNewRev->isCurrent()) {
            $wgOut->setArticleFlag(true);
        }
        # mOldid is false if the difference engine is called with a "vague" query for
        # a diff between a version V and its previous version V' AND the version V
        # is the first version of that article. In that case, V' does not exist.
        if ($this->mOldid === false) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut(__METHOD__);
            return;
        }
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        if ($this->mNewPage->equals($this->mOldPage)) {
            $wgOut->setSubtitle(wfMsgExt('difference', array('parseinline')));
        } else {
            $wgOut->setSubtitle(wfMsgExt('difference-multipage', array('parseinline')));
        }
        $wgOut->setRobotPolicy('noindex,nofollow');
        if (!$this->mOldPage->userCanRead() || !$this->mNewPage->userCanRead()) {
            $wgOut->loginToUse();
            $wgOut->output();
            $wgOut->disable();
            wfProfileOut(__METHOD__);
            return;
        }
        $sk = $wgUser->getSkin();
        if (method_exists($sk, 'suppressQuickbar')) {
            $sk->suppressQuickbar();
        }
        // Check if page is editable
        $editable = $this->mNewRev->getTitle()->userCan('edit');
        if ($editable && $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback')) {
            $wgOut->preventClickjacking();
            $rollback = '&#160;&#160;&#160;' . $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $this->mTitle->userCan('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
                $rc = RecentChange::newFromId($rcid);
                // Already patrolled?
                $rcid = is_object($rc) && !$rc->getAttribute('rc_patrolled') ? $rcid : 0;
            } else {
//.........这里部分代码省略.........
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:101,代码来源:DifferenceEngine.php


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