function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgLang;
     if (!$this->mRepo) {
         $view = new CodeRepoListView();
         $view->execute();
         return;
     }
     // Check for batch change requests.
     $editToken = $wgRequest->getVal('wpBatchChangeEditToken');
     $revisions = $wgRequest->getArray('wpRevisionSelected');
     if ($wgRequest->wasPosted() && count($revisions) && $wgUser->matchEditToken($editToken)) {
         $this->doBatchChange();
         return;
     }
     // Get the total count across all pages
     $dbr = wfGetDB(DB_SLAVE);
     $revCount = $this->getRevCount($dbr);
     $pager = $this->getPager();
     $pathForm = $this->showForm($pager);
     // Build batch change interface as needed
     $this->batchForm = $wgUser->isAllowed('codereview-set-status') || $wgUser->isAllowed('codereview-add-tag');
     $navBar = $pager->getNavigationBar();
     $wgOut->addHTML($pathForm);
     $wgOut->addHTML($navBar . '<table><tr><td>' . $pager->getLimitForm() . '</td>');
     if ($revCount !== -1) {
         $wgOut->addHTML('<td>&#160;<strong>' . wfMsgHtml('code-rev-total', $wgLang->formatNum($revCount)) . '</strong></td>');
     }
     $wgOut->addHTML('</tr></table>' . Xml::openElement('form', array('action' => $pager->getTitle()->getLocalURL(), 'method' => 'post')) . $pager->getBody() . $navBar);
     if ($this->batchForm) {
         $wgOut->addHTML($this->buildBatchInterface($pager));
     }
     $wgOut->addHTML(Xml::closeElement('form') . $pathForm);
 }
Example #2
0
 function execute()
 {
     if (!$this->mRepo) {
         $view = new CodeRepoListView();
         $view->execute();
         return;
     }
     $this->showForm();
     # Show notes if we have at least a starting revision
     if ($this->mStartRev) {
         $this->showReleaseNotes();
     }
 }
Example #3
0
 public function execute($subpage)
 {
     global $wgOut, $wgUser;
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     $this->setHeaders();
     // Base styles used for all code review UI actions.
     $wgOut->addModules('ext.codereview');
     $wgOut->addModules('ext.codereview.tooltips');
     $wgOut->addModuleStyles('ext.codereview.styles');
     $view = $this->getViewFrom($subpage);
     if ($view) {
         $view->execute();
     } else {
         $wgOut->addWikiMsg('nosuchactiontext');
         $wgOut->returnToMain(null, $this->getTitle());
         return;
     }
     // Add subtitle for easy navigation
     if ($view instanceof CodeView) {
         $repo = $view->getRepo();
         if ($repo) {
             $wgOut->setSubtitle(wfMsgExt('codereview-subtitle', 'parse', CodeRepoListView::getNavItem($repo)));
         }
     }
 }
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);
 }