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


PHP RecentChange::newFromConds方法代码示例

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


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

示例1: showDiffPage

    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol, $wgRequest, $wgTitle, $wgLanguageCode;
        $fname = 'DifferenceEngine::showDiffPage';
        wfProfileIn($fname);
        # 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
[Process]
Type=Diff text
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Special namespace={$special}

[File]
Extension=wiki
URL={$url1}

[File 2]
Extension=wiki
URL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})";
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missingarticle', "<nowiki>{$t}</nowiki>");
            wfProfileOut($fname);
            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 && false) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut($fname);
            return;
        }
        $wgOut->suppressQuickbar();
        if (!$this->mOldPage) {
            $this->mOldPage = $this->mNewPage;
        }
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsg('difference'));
        $wgOut->setRobotpolicy('noindex,nofollow');
        if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
            $wgOut->loginToUse();
            $wgOut->output();
            wfProfileOut($fname);
            exit;
        }
        $sk = $wgUser->getSkin();
        if ($this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') && $this->mTitle->userCanEdit()) {
            $rollback = $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $wgUser->isAllowed('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
            } 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'];
                } else {
                    // None found
                    $rcid = 0;
                }
            }
            // Build the link
            if ($rcid) {
                //XXCHANGED for recent changes patrolling
                $show_namespace = $wgRequest->getVal('show_namespace');
//.........这里部分代码省略.........
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:DifferenceEngine.php

示例2: showDiffPage


//.........这里部分代码省略.........
            $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 {
                // 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) {
                $wgOut->preventClickjacking();
                $token = $wgUser->editToken($rcid);
                $patrol = ' <span class="patrollink">[' . $sk->link($this->mTitle, wfMsgHtml('markaspatrolleddiff'), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token), array('known', 'noclasses')) . ']</span>';
            } else {
                $patrol = '';
            }
        } else {
            $patrol = '';
        }
        # Carry over 'diffonly' param via navigation links
        if ($diffOnly != $wgUser->getBoolOption('diffonly')) {
            $query['diffonly'] = $diffOnly;
        }
        # Make "previous revision link"
        $query['diff'] = 'prev';
        $query['oldid'] = $this->mOldid;
        # Cascade unhide param in links for easy deletion browsing
        if ($this->unhide) {
            $query['unhide'] = 1;
        }
        if (!$this->mOldRev->getPrevious()) {
            $prevlink = '&#160;';
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:67,代码来源:DifferenceEngine.php

示例3: getMarkPatrolledLinkInfo

 /**
  * Returns an array of meta data needed to build a "mark as patrolled" link and
  * adds the mediawiki.page.patrol.ajax to the output.
  *
  * @return array|false An array of meta data for a patrol link (rcid & token)
  *  or false if no link is needed
  */
 protected function getMarkPatrolledLinkInfo()
 {
     global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $user = $this->getUser();
     // Prepare a change patrol link, if applicable
     if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
         // Look for an unpatrolled change corresponding to this diff
         $db = wfGetDB(DB_SLAVE);
         $change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__);
         if ($change && !$change->getPerformer()->equals($user)) {
             $rcid = $change->getAttribute('rc_id');
         } else {
             // None found or the page has been created by the current user.
             // If the user could patrol this it already would be patrolled
             $rcid = 0;
         }
         // Build the link
         if ($rcid) {
             $this->getOutput()->preventClickjacking();
             if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
                 $this->getOutput()->addModules('mediawiki.page.patrol.ajax');
             }
             $token = $user->getEditToken($rcid);
             return array('rcid' => $rcid, 'token' => $token);
         }
     }
     // No mark as patrolled link applicable
     return false;
 }
开发者ID:guochangjiang,项目名称:mediawiki,代码行数:36,代码来源:DifferenceEngine.php

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

示例5: showPatrolFooter

 /**
  * If patrol is possible, output a patrol UI box. This is called from the
  * footer section of ordinary page views. If patrol is not possible or not
  * desired, does nothing.
  * Side effect: When the patrol link is build, this method will call
  * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
  *
  * @return bool
  */
 public function showPatrolFooter()
 {
     global $wgUseNPPatrol, $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $outputPage = $this->getContext()->getOutput();
     $user = $this->getContext()->getUser();
     $cache = wfGetMainCache();
     $rc = false;
     if (!$this->getTitle()->quickUserCan('patrol', $user) || !($wgUseRCPatrol || $wgUseNPPatrol)) {
         // Patrolling is disabled or the user isn't allowed to
         return false;
     }
     // New page patrol: Get the timestamp of the oldest revison which
     // the revision table holds for the given page. Then we look
     // whether it's within the RC lifespan and if it is, we try
     // to get the recentchanges row belonging to that entry
     // (with rc_new = 1).
     if ($this->mRevision && !RecentChange::isInRCLifespan($this->mRevision->getTimestamp(), 21600)) {
         // The current revision is already older than what could be in the RC table
         // 6h tolerance because the RC might not be cleaned out regularly
         return false;
     }
     // Check for cached results
     $key = wfMemcKey('NotPatrollablePage', $this->getTitle()->getArticleID());
     if ($cache->get($key)) {
         return false;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $oldestRevisionTimestamp = $dbr->selectField('revision', 'MIN( rev_timestamp )', array('rev_page' => $this->getTitle()->getArticleID()), __METHOD__);
     if ($oldestRevisionTimestamp && RecentChange::isInRCLifespan($oldestRevisionTimestamp, 21600)) {
         // 6h tolerance because the RC might not be cleaned out regularly
         $rc = RecentChange::newFromConds(array('rc_new' => 1, 'rc_timestamp' => $oldestRevisionTimestamp, 'rc_namespace' => $this->getTitle()->getNamespace(), 'rc_cur_id' => $this->getTitle()->getArticleID()), __METHOD__, array('USE INDEX' => 'new_name_timestamp'));
     } else {
         // Cache the information we gathered above in case we can't patrol
         // Don't cache in case we can patrol as this could change
         $cache->set($key, '1');
     }
     if (!$rc) {
         // Don't cache: This can be hit if the page gets accessed very fast after
         // its creation or in case we have high slave lag. In case the revision is
         // too old, we will already return above.
         return false;
     }
     if ($rc->getAttribute('rc_patrolled')) {
         // Patrolled RC entry around
         // Cache the information we gathered above in case we can't patrol
         // Don't cache in case we can patrol as this could change
         $cache->set($key, '1');
         return false;
     }
     if ($rc->getPerformer()->equals($user)) {
         // Don't show a patrol link for own creations. If the user could
         // patrol them, they already would be patrolled
         return false;
     }
     $rcid = $rc->getAttribute('rc_id');
     $token = $user->getEditToken($rcid);
     $outputPage->preventClickjacking();
     if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
         $outputPage->addModules('mediawiki.page.patrol.ajax');
     }
     $link = Linker::linkKnown($this->getTitle(), wfMessage('markaspatrolledtext')->escaped(), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token));
     $outputPage->addHTML("<div class='patrollink'>" . wfMessage('markaspatrolledlink')->rawParams($link)->escaped() . '</div>');
     return true;
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:73,代码来源:Article.php

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

示例7: getRecentChange

 /**
  * Get the RC object belonging to the current revision, if there's one
  *
  * @param int $flags (optional) $flags include:
  *      Revision::READ_LATEST  : Select the data from the master
  *
  * @since 1.22
  * @return RecentChange|null
  */
 public function getRecentChange($flags = 0)
 {
     $dbr = wfGetDB(DB_SLAVE);
     list($dbType, ) = DBAccessObjectUtils::getDBOptions($flags);
     return RecentChange::newFromConds(array('rc_user_text' => $this->getUserText(Revision::RAW), 'rc_timestamp' => $dbr->timestamp($this->getTimestamp()), 'rc_this_oldid' => $this->getId()), __METHOD__, $dbType);
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:15,代码来源:Revision.php

示例8: showDiffPage

    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
        $fname = 'DifferenceEngine::showDiffPage';
        wfProfileIn($fname);
        # 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
[Process]
Type=Diff text
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Special namespace={$special}

[File]
Extension=wiki
URL={$url1}

[File 2]
Extension=wiki
URL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})";
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missingarticle', "<nowiki>{$t}</nowiki>");
            wfProfileOut($fname);
            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($fname);
            return;
        }
        $wgOut->suppressQuickbar();
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsg('difference'));
        $wgOut->setRobotpolicy('noindex,nofollow');
        if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
            $wgOut->loginToUse();
            $wgOut->output();
            wfProfileOut($fname);
            exit;
        }
        $sk = $wgUser->getSkin();
        if ($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 && $wgUser->isAllowed('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
            } 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'];
                } else {
                    // None found
                    $rcid = 0;
                }
            }
            // Build the link
            if ($rcid) {
                $patrol = ' [' . $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolleddiff'), "action=markpatrolled&rcid={$rcid}") . ']';
            } else {
                $patrol = '';
            }
        } else {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:101,代码来源:DifferenceEngine.php

示例9: getRecentChange

 /**
  * Get the RC object belonging to the current revision, if there's one
  *
  * @since 1.22
  * @return RecentChange|null
  */
 public function getRecentChange()
 {
     $dbr = wfGetDB(DB_SLAVE);
     return RecentChange::newFromConds(array('rc_user_text' => $this->getUserText(Revision::RAW), 'rc_timestamp' => $dbr->timestamp($this->getTimestamp()), 'rc_this_oldid' => $this->getId()), __METHOD__);
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:11,代码来源:Revision.php

示例10: 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: When the patrol link is build, this method will call
  * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
  *
  * @return string
  */
 protected function markPatrolledLink()
 {
     global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $user = $this->getUser();
     if ($this->mMarkPatrolledLink === null) {
         // Prepare a change patrol link, if applicable
         if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
             // Look for an unpatrolled change corresponding to this diff
             $db = wfGetDB(DB_SLAVE);
             $change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__, array('USE INDEX' => 'rc_timestamp'));
             if ($change && $change->getPerformer()->getName() !== $user->getName()) {
                 $rcid = $change->getAttribute('rc_id');
             } else {
                 // None found or the page has been created by the current user.
                 // If the user could patrol this it already would be patrolled
                 $rcid = 0;
             }
             // Build the link
             if ($rcid) {
                 $this->getOutput()->preventClickjacking();
                 if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
                     $this->getOutput()->addModules('mediawiki.page.patrol.ajax');
                 }
                 $token = $user->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:whysasse,项目名称:kmwiki,代码行数:42,代码来源:DifferenceEngine.php

示例11: showPatrolFooter

 /**
  * If patrol is possible, output a patrol UI box. This is called from the
  * footer section of ordinary page views. If patrol is not possible or not
  * desired, does nothing.
  * Side effect: When the patrol link is build, this method will call
  * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
  *
  * @return bool
  */
 public function showPatrolFooter()
 {
     global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $outputPage = $this->getContext()->getOutput();
     $user = $this->getContext()->getUser();
     $title = $this->getTitle();
     $rc = false;
     if (!$title->quickUserCan('patrol', $user) || !($wgUseRCPatrol || $wgUseNPPatrol || $wgUseFilePatrol && $title->inNamespace(NS_FILE))) {
         // Patrolling is disabled or the user isn't allowed to
         return false;
     }
     if ($this->mRevision && !RecentChange::isInRCLifespan($this->mRevision->getTimestamp(), 21600)) {
         // The current revision is already older than what could be in the RC table
         // 6h tolerance because the RC might not be cleaned out regularly
         return false;
     }
     // Check for cached results
     $key = wfMemcKey('unpatrollable-page', $title->getArticleID());
     $cache = ObjectCache::getMainWANInstance();
     if ($cache->get($key)) {
         return false;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $oldestRevisionTimestamp = $dbr->selectField('revision', 'MIN( rev_timestamp )', ['rev_page' => $title->getArticleID()], __METHOD__);
     // New page patrol: Get the timestamp of the oldest revison which
     // the revision table holds for the given page. Then we look
     // whether it's within the RC lifespan and if it is, we try
     // to get the recentchanges row belonging to that entry
     // (with rc_new = 1).
     $recentPageCreation = false;
     if ($oldestRevisionTimestamp && RecentChange::isInRCLifespan($oldestRevisionTimestamp, 21600)) {
         // 6h tolerance because the RC might not be cleaned out regularly
         $recentPageCreation = true;
         $rc = RecentChange::newFromConds(['rc_new' => 1, 'rc_timestamp' => $oldestRevisionTimestamp, 'rc_namespace' => $title->getNamespace(), 'rc_cur_id' => $title->getArticleID()], __METHOD__);
         if ($rc) {
             // Use generic patrol message for new pages
             $markPatrolledMsg = wfMessage('markaspatrolledtext');
         }
     }
     // File patrol: Get the timestamp of the latest upload for this page,
     // check whether it is within the RC lifespan and if it is, we try
     // to get the recentchanges row belonging to that entry
     // (with rc_type = RC_LOG, rc_log_type = upload).
     $recentFileUpload = false;
     if ((!$rc || $rc->getAttribute('rc_patrolled')) && $wgUseFilePatrol && $title->getNamespace() === NS_FILE) {
         // Retrieve timestamp of most recent upload
         $newestUploadTimestamp = $dbr->selectField('image', 'MAX( img_timestamp )', ['img_name' => $title->getDBkey()], __METHOD__);
         if ($newestUploadTimestamp && RecentChange::isInRCLifespan($newestUploadTimestamp, 21600)) {
             // 6h tolerance because the RC might not be cleaned out regularly
             $recentFileUpload = true;
             $rc = RecentChange::newFromConds(['rc_type' => RC_LOG, 'rc_log_type' => 'upload', 'rc_timestamp' => $newestUploadTimestamp, 'rc_namespace' => NS_FILE, 'rc_cur_id' => $title->getArticleID()], __METHOD__, ['USE INDEX' => 'rc_timestamp']);
             if ($rc) {
                 // Use patrol message specific to files
                 $markPatrolledMsg = wfMessage('markaspatrolledtext-file');
             }
         }
     }
     if (!$recentPageCreation && !$recentFileUpload) {
         // Page creation and latest upload (for files) is too old to be in RC
         // We definitely can't patrol so cache the information
         // When a new file version is uploaded, the cache is cleared
         $cache->set($key, '1');
         return false;
     }
     if (!$rc) {
         // Don't cache: This can be hit if the page gets accessed very fast after
         // its creation / latest upload or in case we have high slave lag. In case
         // the revision is too old, we will already return above.
         return false;
     }
     if ($rc->getAttribute('rc_patrolled')) {
         // Patrolled RC entry around
         // Cache the information we gathered above in case we can't patrol
         // Don't cache in case we can patrol as this could change
         $cache->set($key, '1');
         return false;
     }
     if ($rc->getPerformer()->equals($user)) {
         // Don't show a patrol link for own creations/uploads. If the user could
         // patrol them, they already would be patrolled
         return false;
     }
     $rcid = $rc->getAttribute('rc_id');
     $token = $user->getEditToken($rcid);
     $outputPage->preventClickjacking();
     if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
         $outputPage->addModules('mediawiki.page.patrol.ajax');
     }
     $link = Linker::linkKnown($title, $markPatrolledMsg->escaped(), [], ['action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token]);
     $outputPage->addHTML("<div class='patrollink' data-mw='interface'>" . wfMessage('markaspatrolledlink')->rawParams($link)->escaped() . '</div>');
     return true;
//.........这里部分代码省略.........
开发者ID:claudinec,项目名称:galan-wiki,代码行数:101,代码来源:Article.php

示例12: getMarkPatrolledLinkInfo

 /**
  * Returns an array of meta data needed to build a "mark as patrolled" link and
  * adds the mediawiki.page.patrol.ajax to the output.
  *
  * @return array|false An array of meta data for a patrol link (rcid & token)
  *  or false if no link is needed
  */
 protected function getMarkPatrolledLinkInfo()
 {
     global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $user = $this->getUser();
     // Prepare a change patrol link, if applicable
     if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
         // Look for an unpatrolled change corresponding to this diff
         $db = wfGetDB(DB_REPLICA);
         $change = RecentChange::newFromConds(['rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0], __METHOD__);
         if ($change && !$change->getPerformer()->equals($user)) {
             $rcid = $change->getAttribute('rc_id');
         } else {
             // None found or the page has been created by the current user.
             // If the user could patrol this it already would be patrolled
             $rcid = 0;
         }
         // Allow extensions to possibly change the rcid here
         // For example the rcid might be set to zero due to the user
         // being the same as the performer of the change but an extension
         // might still want to show it under certain conditions
         Hooks::run('DifferenceEngineMarkPatrolledRCID', [&$rcid, $this, $change, $user]);
         // Build the link
         if ($rcid) {
             $this->getOutput()->preventClickjacking();
             if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
                 $this->getOutput()->addModules('mediawiki.page.patrol.ajax');
             }
             $token = $user->getEditToken($rcid);
             return ['rcid' => $rcid, 'token' => $token];
         }
     }
     // No mark as patrolled link applicable
     return false;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:41,代码来源:DifferenceEngine.php

示例13: markPatrolledLink

 public function markPatrolledLink()
 {
     global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
     $user = $this->getUser();
     if ($this->mMarkPatrolledLink === null) {
         // Prepare a change patrol link, if applicable
         if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
             // Look for an unpatrolled change corresponding to this diff
             $db = wfGetDB(DB_SLAVE);
             $change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__, array('USE INDEX' => 'rc_timestamp'));
             if ($change && $change->getPerformer()->getName() !== $user->getName()) {
                 $rcid = $change->getAttribute('rc_id');
             } else {
                 // None found or the page has been created by the current user.
                 // If the user could patrol this it already would be patrolled
                 $rcid = 0;
             }
             // WIKIHOW - we might want to change the rcid here
             // for example the rcid might be set to zero due to the user being the same
             // as the performer of the change but on wikihow we still want to show it
             // under certain conditions
             wfRunHooks('DifferenceEngineMarkPatrolledRCID', array(&$rcid, $this, $change, $user));
             // Build the link
             if ($rcid) {
                 $this->getOutput()->preventClickjacking();
                 if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
                     $this->getOutput()->addModules('mediawiki.page.patrol.ajax');
                 }
                 $token = $user->getEditToken($rcid);
                 $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown($this->mNewPage, $this->msg('markaspatrolleddiff')->escaped(), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token)) . ']</span>';
                 // WIKIHOW - added this hook to change the markpatrolled link
                 wfRunHooks('DifferenceEngineMarkPatrolledLink', array($this, &$this->mMarkPatrolledLink, $rcid, $token));
             } else {
                 $this->mMarkPatrolledLink = '';
             }
         } else {
             $this->mMarkPatrolledLink = '';
         }
     }
     return $this->mMarkPatrolledLink;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:41,代码来源:DifferenceEngine.php

示例14: getCategorizeRecentChangeForRevId

 /**
  * @param int $revId
  *
  * @return RecentChange|null
  */
 private function getCategorizeRecentChangeForRevId($revId)
 {
     return RecentChange::newFromConds(['rc_type' => RC_CATEGORIZE, 'rc_this_oldid' => $revId], __METHOD__);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:9,代码来源:CategoryMembershipChangeJobTest.php


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