/**
  * Handle the 'approvefile' action, defined for ApprovedRevs -
  * mark the revision as approved, log it, and show a message to
  * the user.
  */
 public static function setFileAsApproved($action, $article)
 {
     // Return "true" if the call failed (meaning, pass on handling
     // of the hook to others), and "false" otherwise.
     if ($action != 'approvefile') {
         return true;
     }
     $title = $article->getTitle();
     if (!ApprovedRevs::fileIsApprovable($title)) {
         return true;
     }
     if (!ApprovedRevs::userCanApprove($title)) {
         return true;
     }
     global $wgRequest;
     if (!$wgRequest->getCheck('ts') || !$wgRequest->getCheck('sha1')) {
         die('check query string');
         return true;
     }
     $revisionID = $wgRequest->getVal('ts');
     ApprovedRevs::setApprovedFileInDB($title, $wgRequest->getVal('ts'), $wgRequest->getVal('sha1'));
     global $wgOut;
     $wgOut->addHTML("\t\t" . Xml::element('div', array('class' => 'successbox'), wfMessage('approvedrevs-approvesuccess')->text()) . "\n");
     $wgOut->addHTML("\t\t" . Xml::element('p', array('style' => 'clear: both')) . "\n");
     // show the revision, instead of the history page
     $article->doPurge();
     $article->view();
     return false;
 }
 function formatResult($skin, $result)
 {
     $title = Title::makeTitle(NS_FILE, $result->title);
     if (!self::$repo) {
         self::$repo = RepoGroup::singleton();
     }
     $pageLink = Linker::link($title);
     #
     #	Unapproved Files
     #
     if ($this->mMode == 'unapproved') {
         global $egApprovedRevsShowApproveLatest;
         if ($egApprovedRevsShowApproveLatest && ApprovedRevs::userCanApprove($title)) {
             $approveLink = ' (' . Xml::element('a', array('href' => $title->getLocalUrl(array('action' => 'approvefile', 'ts' => $result->latest_ts, 'sha1' => $result->latest_sha1))), wfMessage('approvedrevs-approve')->text()) . ')';
         } else {
             $approveLink = '';
         }
         return "{$pageLink}{$approveLink}";
         #
         #   Invalid Files
         #
     } elseif ($this->mMode == 'invalid') {
         if (!ApprovedRevs::fileIsApprovable($title)) {
             // if showing invalid files only, don't show files that have real approvability
             return '';
         }
         return $pageLink;
         #
         #	All Files with an approved revision
         #
     } elseif ($this->mMode == 'allapproved') {
         // main mode (pages with an approved revision)
         global $wgUser, $wgOut, $wgLang;
         $additionalInfo = Xml::element('span', array('class' => $result->approved_sha1 == $result->latest_sha1 && $result->approved_ts == $result->latest_ts ? 'approvedRevIsLatest' : 'approvedRevNotLatest'), wfMessage('approvedrevs-revisionnumber', substr($result->approved_sha1, 0, 8))->parse());
         // Get data on the most recent approval from the
         // 'approval' log, and display it if it's there.
         $sk = $wgUser->getSkin();
         $loglist = new LogEventsList($sk, $wgOut);
         $pager = new LogPager($loglist, 'approval', '', $title);
         $pager->mLimit = 1;
         $pager->doQuery();
         $result = $pager->getResult();
         $row = $result->fetchObject();
         if (!empty($row)) {
             $timestamp = $wgLang->timeanddate(wfTimestamp(TS_MW, $row->log_timestamp), true);
             $date = $wgLang->date(wfTimestamp(TS_MW, $row->log_timestamp), true);
             $time = $wgLang->time(wfTimestamp(TS_MW, $row->log_timestamp), true);
             $userLink = $sk->userLink($row->log_user, $row->user_name);
             $additionalInfo .= ', ' . wfMessage('approvedrevs-approvedby', $userLink, $timestamp, $row->user_name, $date, $time)->text();
         }
         return "{$pageLink} ({$additionalInfo})";
         #
         # Not Latest Files:
         # [[My File.jpg]] (revision 2ba82e7f approved; revision 6ac914dc latest)
     } else {
         $approved_file = self::$repo->findFileFromKey($result->approved_sha1, array('time' => $result->approved_ts));
         $latest_file = self::$repo->findFileFromKey($result->latest_sha1, array('time' => $result->latest_ts));
         $approvedLink = Xml::element('a', array('href' => $approved_file->getUrl()), wfMessage('approvedrevs-approvedfile')->text());
         $latestLink = Xml::element('a', array('href' => $latest_file->getUrl()), wfMessage('approvedrevs-latestfile')->text());
         return "{$pageLink} ({$approvedLink} | {$latestLink})";
     }
 }