function formatResult($skin, $result) { $title = Title::makeTitle(NS_FILE, $result->title); if (!self::$repo) { self::$repo = RepoGroup::singleton(); } $pageLink = Linker::link($title); # # Unapproved Files and undesignated Files # if ($this->mMode == 'unapproved' || $this->mMode == 'undesignated') { global $egApprovedRevsShowApproveLatest; $nsApproved = ApprovedRevs::titleInNamespacePermissions($title); $cats = ApprovedRevs::getTitleApprovableCategories($title); $catsApproved = ApprovedRevs::titleInCategoryPermissions($title); $pgApproved = ApprovedRevs::titleInPagePermissions($title); $magicApproved = ApprovedRevs::pageHasMagicWord($title); if ($this->mMode == 'undesignated' && ($nsApproved || $catsApproved || $pgApproved || $magicApproved)) { // if showing undesignated pages only, don't show pages that have real approvability return ''; } 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}"; # # Not Latest Files: # [[My File.jpg]] (revision 2ba82h7f approved; revision 2ba82h7f latest) } elseif ($this->mMode == 'notlatestfiles') { $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})"; # # All Files with an approved revision # } else { // 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})"; } }