Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionDiffController.php
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | public function processRequest() { | ||||
| } | } | ||||
| $crumbs->addCrumb( | $crumbs->addCrumb( | ||||
| id(new PhabricatorCrumbView()) | id(new PhabricatorCrumbView()) | ||||
| ->setName(pht('History')) | ->setName(pht('History')) | ||||
| ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); | ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); | ||||
| $title = "Version $l vs $r"; | $title = pht("Version %s vs %s", $l, $r); | ||||
| $header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
| ->setHeader($title); | ->setHeader($title); | ||||
| $crumbs->addCrumb( | $crumbs->addCrumb( | ||||
| id(new PhabricatorCrumbView()) | id(new PhabricatorCrumbView()) | ||||
| ->setName($title) | ->setName($title) | ||||
| ->setHref($request->getRequestURI())); | ->setHref($request->getRequestURI())); | ||||
| Show All 12 Lines | if ($l + 1 == $r) { | ||||
| $uri = $request->getRequestURI(); | $uri = $request->getRequestURI(); | ||||
| if ($nav_l) { | if ($nav_l) { | ||||
| $link_l = phutil_tag( | $link_l = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $uri->alter('l', $l - 1)->alter('r', $r - 1), | 'href' => $uri->alter('l', $l - 1)->alter('r', $r - 1), | ||||
| 'class' => 'button', | |||||
| ), | ), | ||||
| pht("\xC2\xAB Previous Change")); | pht("\xC2\xAB Previous Change")); | ||||
| } else { | } else { | ||||
| $link_l = pht('Original Change'); | $link_l = phutil_tag( | ||||
| 'a', | |||||
| array( | |||||
| 'href' => '#', | |||||
| 'class' => 'button grey disabled', | |||||
| ), | |||||
| pht('Original Change')); | |||||
| } | } | ||||
| $link_r = null; | $link_r = null; | ||||
| if ($nav_r) { | if ($nav_r) { | ||||
| $link_r = phutil_tag( | $link_r = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $uri->alter('l', $l + 1)->alter('r', $r + 1), | 'href' => $uri->alter('l', $l + 1)->alter('r', $r + 1), | ||||
| 'class' => 'button', | |||||
| ), | ), | ||||
| pht("Next Change \xC2\xBB")); | pht("Next Change \xC2\xBB")); | ||||
| } else { | } else { | ||||
| $link_r = pht('Most Recent Change'); | $link_r = phutil_tag( | ||||
| 'a', | |||||
| array( | |||||
| 'href' => '#', | |||||
| 'class' => 'button grey disabled', | |||||
| ), | |||||
| pht('Most Recent Change')); | |||||
| } | } | ||||
| $navigation_table = hsprintf( | $navigation_table = hsprintf( | ||||
| '<table class="phriction-history-nav-table"> | '<table class="phriction-history-nav-table"> | ||||
| <tr> | <tr> | ||||
| <td class="nav-prev">%s</td> | <td class="nav-prev">%s</td> | ||||
| <td class="nav-next">%s</td> | <td class="nav-next">%s</td> | ||||
| </tr> | </tr> | ||||
| </table>', | </table>', | ||||
| $link_l, | $link_l, | ||||
| $link_r); | $link_r); | ||||
| } | } | ||||
| $output = hsprintf( | $output = hsprintf( | ||||
| '<br><div class="phriction-document-history-diff">'. | '<br><div class="phriction-document-history-diff">'. | ||||
| '%s<br /><br />%s'. | '%s%s'. | ||||
| '<table class="phriction-revert-table">'. | '<table class="phriction-revert-table">'. | ||||
| '<tr><td>%s</td><td>%s</td>'. | '<tr><td>%s</td><td>%s</td>'. | ||||
| '</table>'. | '</table>'. | ||||
| '%s'. | '%s'. | ||||
| '</div>', | '</div>', | ||||
| $comparison_table->render(), | $comparison_table->render(), | ||||
| $navigation_table, | $navigation_table, | ||||
| $revert_l, | $revert_l, | ||||
| $revert_r, | $revert_r, | ||||
| $output); | $output); | ||||
| $object_box = id(new PHUIObjectBoxView()) | |||||
| ->setHeader($header) | |||||
| ->appendChild($output); | |||||
| return $this->buildApplicationPage( | return $this->buildApplicationPage( | ||||
| array( | array( | ||||
| $crumbs, | $crumbs, | ||||
| $header, | $object_box, | ||||
| $output, | |||||
| ), | ), | ||||
| array( | array( | ||||
| 'title' => pht('Document History'), | 'title' => pht('Document History'), | ||||
| 'device' => true, | 'device' => true, | ||||
| )); | )); | ||||
| } | } | ||||
| Show All 15 Lines | if (isset($hidden_statuses[$content->getChangeType()])) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| if ($content->getID() == $current->getID()) { | if ($content->getID() == $current->getID()) { | ||||
| return phutil_tag( | return phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => '/phriction/edit/'.$document_id.'/', | 'href' => '/phriction/edit/'.$document_id.'/', | ||||
| 'class' => 'button', | 'class' => 'button grey', | ||||
| ), | ), | ||||
| pht('Edit Current Version')); | pht('Edit Current Version')); | ||||
| } | } | ||||
| return phutil_tag( | return phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => '/phriction/edit/'.$document_id.'/?revert='.$version, | 'href' => '/phriction/edit/'.$document_id.'/?revert='.$version, | ||||
| 'class' => 'button', | 'class' => 'button grey', | ||||
| ), | ), | ||||
| pht('Revert to Version %s...', $version)); | pht('Revert to Version %s...', $version)); | ||||
| } | } | ||||
| private function renderComparisonTable(array $content) { | private function renderComparisonTable(array $content) { | ||||
| assert_instances_of($content, 'PhrictionContent'); | assert_instances_of($content, 'PhrictionContent'); | ||||
| $user = $this->getRequest()->getUser(); | $user = $this->getRequest()->getUser(); | ||||
| $phids = mpull($content, 'getAuthorPHID'); | $phids = mpull($content, 'getAuthorPHID'); | ||||
| $handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
| $list = new PHUIObjectItemListView(); | $list = new PHUIObjectItemListView(); | ||||
| $list->setFlush(true); | |||||
| $first = true; | $first = true; | ||||
| foreach ($content as $c) { | foreach ($content as $c) { | ||||
| $author = $handles[$c->getAuthorPHID()]->renderLink(); | $author = $handles[$c->getAuthorPHID()]->renderLink(); | ||||
| $item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
| ->setHeader(pht('%s by %s, %s', | ->setHeader(pht('%s by %s, %s', | ||||
| PhrictionChangeType::getChangeTypeLabel($c->getChangeType()), | PhrictionChangeType::getChangeTypeLabel($c->getChangeType()), | ||||
| $author, | $author, | ||||
| Show All 23 Lines | |||||