public function execute()
 {
     global $wgUser;
     $this->getMain()->setCacheMode('anon-public-user-private');
     // Before doing anything at all, let's check permissions
     if (!$wgUser->isAllowed('codereview-use')) {
         $this->dieUsage('You don\'t have permission to view code revisions', 'permissiondenied');
     }
     $params = $this->extractRequestParams();
     $this->props = array_flip($params['prop']);
     $repo = CodeRepository::newFromName($params['repo']);
     if (!$repo) {
         $this->dieUsage("Invalid repo ``{$params['repo']}''", 'invalidrepo');
     }
     $data = array();
     $listview = new CodeRevisionListView($repo);
     if (isset($params['path']) && $params['path'] !== '') {
         $listview->mPath = CodeRevisionListView::pathsToArray($params['path']);
     }
     $pager = $listview->getPager();
     $revsSet = count($params['revs']);
     if ($revsSet) {
         $db = wfGetDB(DB_SLAVE);
         $query = $pager->getQueryInfo();
         $query['conds']['cr_id'] = $params['revs'];
         $revisions = $db->select($query['tables'], $query['fields'], $query['conds'], __METHOD__, $query['options'], $query['join_conds']);
     } else {
         if (!is_null($params['start'])) {
             $pager->setOffset($params['start']);
         }
         $limit = $params['limit'];
         $pager->setLimit($limit);
         $pager->doQuery();
         $revisions = $pager->getResult();
     }
     $count = 0;
     $start = 0;
     $defaultSort = $pager->getDefaultSort();
     $result = $this->getResult();
     foreach ($revisions as $row) {
         if (!$revsSet && $count == $limit) {
             $this->setContinueEnumParameter('start', $start);
             break;
         }
         $data[] = $this->formatRow($row, $repo, $result);
         $start = $row->{$defaultSort};
         $count++;
     }
     $result->setIndexedTagName($data, 'revision');
     $result->addValue('query', $this->getModuleName(), $data);
 }
 function __construct($repo, $tag)
 {
     $this->mTag = $tag;
     if ($this->mTag) {
         $this->filters[] = wfMsg('code-revfilter-ct_tag', $this->mTag);
     }
     parent::__construct($repo);
 }
 function execute()
 {
     global $wgOut, $wgUser;
     $linkInfo = $this->linkStatus();
     if ($wgUser->isAllowed('codereview-link-user')) {
         $repo = $this->mRepo->getName();
         $page = SpecialPage::getTitleFor('Code', "{$repo}/author/{$this->mAuthor}/link");
         $linkInfo .= ' (' . $this->skin->link($page, wfMsg('code-author-' . ($this->mUser ? 'un' : '') . 'link')) . ')';
     }
     $repoLink = $this->skin->link(SpecialPage::getTitleFor('Code', $this->mRepo->getName()), htmlspecialchars($this->mRepo->getName()));
     $fields = array('code-rev-repo' => $repoLink, 'code-rev-author' => $this->mAuthor);
     $wgOut->addHTML($this->formatMetaData($fields) . $linkInfo);
     parent::execute();
 }
Example #4
0
 function execute()
 {
     global $wgOut, $wgLang;
     if (!$this->mRepo) {
         $view = new CodeRepoListView();
         $view->execute();
         return;
     }
     if (!$this->mRev) {
         if ($this->mRevId !== 0) {
             $wgOut->addWikiMsg('code-rev-not-found', $this->mRevId);
         }
         $view = new CodeRevisionListView($this->mRepo->getName());
         $view->execute();
         return;
     }
     if ($this->mStatus == '') {
         $this->mStatus = $this->mRev->getStatus();
     }
     $redirectOnPost = $this->checkPostings();
     if ($redirectOnPost) {
         $wgOut->redirect($redirectOnPost);
         return;
     }
     $pageTitle = $this->mRepo->getName() . wfMsg('word-separator') . $this->mRev->getIdString();
     $htmlTitle = $this->mRev->getIdString() . wfMsg('word-separator') . $this->mRepo->getName();
     $wgOut->setPageTitle(wfMsgHtml('code-rev-title', $pageTitle));
     $wgOut->setHTMLTitle(wfMsgHtml('code-rev-title', $htmlTitle));
     $repoLink = $this->skin->link(SpecialPage::getTitleFor('Code', $this->mRepo->getName()), htmlspecialchars($this->mRepo->getName()));
     $revText = $this->navigationLinks();
     $paths = '';
     $modifiedPaths = $this->mRev->getModifiedPaths();
     foreach ($modifiedPaths as $row) {
         // Don't output NOOP paths
         if (strtolower($row->cp_action) == 'n') {
             continue;
         }
         $paths .= $this->formatPathLine($row->cp_path, $row->cp_action);
     }
     if ($paths) {
         $paths = "<div class='mw-codereview-paths mw-content-ltr'><ul>\n{$paths}</ul></div>\n";
     }
     $comments = $this->formatComments();
     $commentsLink = "";
     if ($comments) {
         $commentsLink = " (<a href=\"#code-comments\">" . wfMsgHtml('code-comments') . "</a>)\n";
     }
     $fields = array('code-rev-repo' => $repoLink, 'code-rev-rev' => $revText, 'code-rev-date' => $wgLang->timeanddate($this->mRev->getTimestamp(), true), 'code-rev-author' => $this->authorLink($this->mRev->getAuthor()), 'code-rev-status' => $this->statusForm() . $commentsLink, 'code-rev-tags' => $this->tagForm(), 'code-rev-message' => Html::rawElement('div', array('class' => 'mw-codereview-message'), $this->formatMessage($this->mRev->getMessage())), 'code-rev-paths' => $paths);
     $special = SpecialPage::getTitleFor('Code', $this->mRepo->getName() . '/' . $this->mRev->getId());
     $html = '';
     if ($this->mPath != '') {
         $links = array();
         foreach (explode('|', $this->mPath) as $path) {
             $links[] = $this->skin->link(SpecialPage::getTitleFor('Code', $this->mRepo->getName()), $path, array(), array('path' => $path));
         }
         $html .= wfMsgExt('code-browsing-path', array('parse', 'replaceafter'), $wgLang->commaList($links));
     }
     # Output form
     $html .= Xml::openElement('form', array('action' => $special->getLocalUrl(), 'method' => 'post'));
     if ($this->canPostComments()) {
         $html .= $this->addActionButtons();
     }
     $html .= $this->formatMetaData($fields);
     # Output diff
     if ($this->mRev->isDiffable()) {
         $diffHtml = $this->formatDiff();
         $html .= "<h2>" . wfMsgHtml('code-rev-diff') . ' <small>[' . $this->skin->makeLinkObj($special, wfMsgHtml('code-rev-purge-link'), 'action=purge') . ']</small></h2>' . "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n";
         $html .= $this->formatImgDiff();
     }
     # Show sign-offs
     $userCanSignoff = $this->canSignoff();
     $signOffs = $this->mRev->getSignoffs();
     if (count($signOffs) || $userCanSignoff) {
         $html .= "<h2 id='code-signoffs'>" . wfMsgHtml('code-signoffs') . "</h2>\n" . $this->formatSignoffs($signOffs, $userCanSignoff);
     }
     # Show code relations
     $userCanAssociate = $this->canAssociate();
     $references = $this->mRev->getFollowupRevisions();
     if (count($references) || $userCanAssociate) {
         $html .= "<h2 id='code-references'>" . wfMsgHtml('code-references') . "</h2>\n" . $this->formatReferences($references, $userCanAssociate, 'References');
     }
     $referenced = $this->mRev->getFollowedUpRevisions();
     if (count($referenced) || $userCanAssociate) {
         $html .= "<h2 id='code-referenced'>" . wfMsgHtml('code-referenced') . "</h2>\n" . $this->formatReferences($referenced, $userCanAssociate, 'Referenced');
     }
     # Add revision comments
     if ($comments) {
         $html .= "<h2 id='code-comments'>" . wfMsgHtml('code-comments') . "</h2>\n" . $comments;
     }
     if ($this->canPostComments()) {
         $html .= $this->addActionButtons();
     }
     $changes = $this->formatPropChanges();
     if ($changes) {
         $html .= "<h2 id='code-changes'>" . wfMsgHtml('code-prop-changes') . "</h2>\n" . $changes;
     }
     $html .= xml::closeElement('form');
     $wgOut->addHTML($html);
 }
 function __construct($repo, $status)
 {
     parent::__construct($repo);
     $this->mStatus = $status;
 }