Beispiel #1
0
 /**
  * Returns the latest revision.
  * Has support for the Approvedrevs extension, and will 
  * return the latest approved revision where appropriate.
  * 
  * @since 0.2
  * 
  * @param Title $title
  * 
  * @return integer
  */
 public static function getRevisionToPush(Title $title)
 {
     if (defined('APPROVED_REVS_VERSION')) {
         $revId = ApprovedRevs::getApprovedRevID($title);
         return $revId ? $revId : $title->getLatestRevID();
     } else {
         return $title->getLatestRevID();
     }
 }
 /**
  * @param WikiPage $article
  * @param User $user
  * @param $content
  * @param $summary
  * @param Bool $isMinor
  * @param Bool $isWatch
  * @param $section
  * @param $flags
  * @param Revision $revision
  * @param $status
  * @param $baseRevId
  *
  * @return bool
  */
 public static function onPageContentSaveComplete(WikiPage $article, User $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status, $baseRevId)
 {
     if (is_null($revision)) {
         // Ignore null edits
         return true;
     }
     $title = $article->getTitle();
     $oldRevisionId = $revision->getParentId();
     if ($oldRevisionId !== null && ApprovedRevs::isAssignedToProject($title) && ApprovedRevs::getApprovedRevID($title) === $oldRevisionId) {
         if ($user->isAllowed('auto-reapproval-on-save')) {
             ApprovedRevs::performAutoReapproval($title, $revision->getId());
         } else {
             ApprovedRevs::logUnapprovedSave($title, $user, $revision->getId());
         }
     }
     return true;
 }
 /**
  * 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')) . '&#160;' . Xml::element('a', array('href' => $article->getTitle()->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMsg('approvedrevs-viewlatestrev')));
             }
             $wgOut->addHTML('</span>');
         }
     }
     return true;
 }
 /**
  * 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()) . '&#160;' . Xml::element('a', array('href' => $title->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMessage('approvedrevs-viewlatestrev')->text()));
     }
     $wgOut->addHTML('</span>');
     return true;
 }
 /**
  * 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')) . '&#160;' . Xml::element('a', array('href' => $title->getLocalUrl(array('oldid' => $article->getRevIdFetched()))), wfMsg('approvedrevs-viewlatestrev')));
     }
     $wgOut->addHTML('</span>');
     return true;
 }