public function handleRequest(AphrontRequest $request)
 {
     $response = $this->loadDiffusionContext();
     if ($response) {
         return $response;
     }
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     $tag_limit = 10;
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             $tags = array();
             break;
         default:
             $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => $drequest->getCommit(), 'limit' => $tag_limit + 1)));
             break;
     }
     $has_more_tags = count($tags) > $tag_limit;
     $tags = array_slice($tags, 0, $tag_limit);
     $tag_links = array();
     foreach ($tags as $tag) {
         $tag_links[] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'commit' => $tag->getName()))), $tag->getName());
     }
     if ($has_more_tags) {
         $tag_links[] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'tags'))), pht("More Tags…"));
     }
     return id(new AphrontAjaxResponse())->setContent($tag_links ? implode(', ', $tag_links) : pht('None'));
 }
 public function updateTransactionMailBody(PhabricatorMetaMTAMailBody $body, PhabricatorApplicationTransactionEditor $editor, array $xactions)
 {
     $params = array('commit' => $this->getObject()->getCommitIdentifier(), 'callsign' => $this->getObject()->getRepository()->getCallsign());
     $tags_raw = id(new ConduitCall('diffusion.tagsquery', $params))->setUser($this->getViewer())->execute();
     $tags = DiffusionRepositoryTag::newFromConduit($tags_raw);
     if (!$tags) {
         return;
     }
     $tag_names = mpull($tags, 'getName');
     sort($tag_names);
     $body->addTextSection(pht('TAGS'), implode(', ', $tag_names));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $response = $this->loadDiffusionContext();
     if ($response) {
         return $response;
     }
     $viewer = $this->getViewer();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     $pager = id(new PHUIPagerView())->readFromRequest($request);
     $params = array('limit' => $pager->getPageSize() + 1, 'offset' => $pager->getOffset());
     if (strlen($drequest->getSymbolicCommit())) {
         $is_commit = true;
         $params['commit'] = $drequest->getSymbolicCommit();
     } else {
         $is_commit = false;
     }
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             $tags = array();
             break;
         default:
             $conduit_result = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', $params);
             $tags = DiffusionRepositoryTag::newFromConduit($conduit_result);
             break;
     }
     $tags = $pager->sliceResults($tags);
     $content = null;
     $header = id(new PHUIHeaderView())->setHeader(pht('Tags'))->setHeaderIcon('fa-tags');
     if (!$tags) {
         $content = $this->renderStatusMessage(pht('No Tags'), $is_commit ? pht('This commit has no tags.') : pht('This repository has no tags.'));
     } else {
         $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->needCommitData(true)->execute();
         $view = id(new DiffusionTagListView())->setTags($tags)->setUser($viewer)->setCommits($commits)->setDiffusionRequest($drequest);
         $phids = $view->getRequiredHandlePHIDs();
         $handles = $this->loadViewerHandles($phids);
         $view->setHandles($handles);
         $content = $view;
     }
     $crumbs = $this->buildCrumbs(array('tags' => true, 'commit' => $drequest->getSymbolicCommit()));
     $crumbs->setBorder(true);
     $box = id(new PHUIObjectBoxView())->setHeaderText($repository->getDisplayName())->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTable($view);
     $pager_box = $this->renderTablePagerBox($pager);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($box, $pager_box));
     return $this->newPage()->setTitle(array(pht('Tags'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild($view);
 }
 public function processRequest()
 {
     $drequest = $this->getDiffusionRequest();
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $repository = $drequest->getRepository();
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'offset');
     $pager->setOffset($request->getInt('offset'));
     $params = array('limit' => $pager->getPageSize() + 1, 'offset' => $pager->getOffset());
     if ($drequest->getSymbolicCommit()) {
         $is_commit = true;
         $params['commit'] = $drequest->getSymbolicCommit();
     } else {
         $is_commit = false;
     }
     $tags = array();
     try {
         $conduit_result = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', $params);
         $tags = DiffusionRepositoryTag::newFromConduit($conduit_result);
     } catch (ConduitException $ex) {
         if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
             throw $ex;
         }
     }
     $tags = $pager->sliceResults($tags);
     $content = null;
     if (!$tags) {
         $content = $this->renderStatusMessage(pht('No Tags'), $is_commit ? pht('This commit has no tags.') : pht('This repository has no tags.'));
     } else {
         $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->needCommitData(true)->execute();
         $view = id(new DiffusionTagListView())->setTags($tags)->setUser($viewer)->setCommits($commits)->setDiffusionRequest($drequest);
         $phids = $view->getRequiredHandlePHIDs();
         $handles = $this->loadViewerHandles($phids);
         $view->setHandles($handles);
         $panel = id(new AphrontPanelView())->setNoBackground(true)->appendChild($view)->appendChild($pager);
         $content = $panel;
     }
     $crumbs = $this->buildCrumbs(array('tags' => true, 'commit' => $drequest->getSymbolicCommit()));
     return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(pht('Tags'), $repository->getCallsign() . ' Repository'), 'device' => false));
 }
 protected function buildPropertyView(DiffusionRequest $drequest, PhabricatorActionListView $actions)
 {
     $viewer = $this->getRequest()->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setActionList($actions);
     $stable_commit = $drequest->getStableCommit();
     $callsign = $drequest->getRepository()->getCallsign();
     $view->addProperty(pht('Commit'), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'commit', 'commit' => $stable_commit))), $drequest->getRepository()->formatCommitName($stable_commit)));
     if ($drequest->getSymbolicType() == 'tag') {
         $symbolic = $drequest->getSymbolicCommit();
         $view->addProperty(pht('Tag'), $symbolic);
         $tags = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('names' => array($symbolic), 'needMessages' => true));
         $tags = DiffusionRepositoryTag::newFromConduit($tags);
         $tags = mpull($tags, null, 'getName');
         $tag = idx($tags, $symbolic);
         if ($tag && strlen($tag->getMessage())) {
             $view->addSectionHeader(pht('Tag Content'));
             $view->addTextContent($this->markupText($tag->getMessage()));
         }
     }
     return $view;
 }
 protected function buildPropertyView(DiffusionRequest $drequest, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setActionList($actions);
     $stable_commit = $drequest->getStableCommit();
     $callsign = $drequest->getRepository()->getCallsign();
     $view->addProperty(pht('Commit'), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'commit', 'commit' => $stable_commit))), $drequest->getRepository()->formatCommitName($stable_commit)));
     if ($drequest->getSymbolicType() == 'tag') {
         $symbolic = $drequest->getSymbolicCommit();
         $view->addProperty(pht('Tag'), $symbolic);
         $tags = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('names' => array($symbolic), 'needMessages' => true));
         $tags = DiffusionRepositoryTag::newFromConduit($tags);
         $tags = mpull($tags, null, 'getName');
         $tag = idx($tags, $symbolic);
         if ($tag && strlen($tag->getMessage())) {
             $view->addSectionHeader(pht('Tag Content'));
             $view->addTextContent($this->markupText($tag->getMessage()));
         }
     }
     $repository = $drequest->getRepository();
     $owners = 'PhabricatorOwnersApplication';
     if (PhabricatorApplication::isClassInstalled($owners)) {
         $package_query = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withControl($repository->getPHID(), array($drequest->getPath()));
         $package_query->execute();
         $packages = $package_query->getControllingPackagesForPath($repository->getPHID(), $drequest->getPath());
         if ($packages) {
             $ownership = id(new PHUIStatusListView())->setUser($viewer);
             foreach ($packages as $package) {
                 $icon = 'fa-list-alt';
                 $color = 'grey';
                 $item = id(new PHUIStatusItemView())->setIcon($icon, $color)->setTarget($viewer->renderHandle($package->getPHID()));
                 $ownership->addItem($item);
             }
         } else {
             $ownership = phutil_tag('em', array(), pht('None'));
         }
         $view->addProperty(pht('Packages'), $ownership);
     }
     return $view;
 }
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $drequest = $this->getDiffusionRequest();
     $viewer = $request->getUser();
     $repository = $drequest->getRepository();
     $pager = new PHUIPagerView();
     $pager->setURI($request->getRequestURI(), 'offset');
     $pager->setOffset($request->getInt('offset'));
     $params = array('limit' => $pager->getPageSize() + 1, 'offset' => $pager->getOffset());
     if ($drequest->getSymbolicCommit()) {
         $is_commit = true;
         $params['commit'] = $drequest->getSymbolicCommit();
     } else {
         $is_commit = false;
     }
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             $tags = array();
             break;
         default:
             $conduit_result = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', $params);
             $tags = DiffusionRepositoryTag::newFromConduit($conduit_result);
             break;
     }
     $tags = $pager->sliceResults($tags);
     $content = null;
     if (!$tags) {
         $content = $this->renderStatusMessage(pht('No Tags'), $is_commit ? pht('This commit has no tags.') : pht('This repository has no tags.'));
     } else {
         $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->needCommitData(true)->execute();
         $view = id(new DiffusionTagListView())->setTags($tags)->setUser($viewer)->setCommits($commits)->setDiffusionRequest($drequest);
         $phids = $view->getRequiredHandlePHIDs();
         $handles = $this->loadViewerHandles($phids);
         $view->setHandles($handles);
         $panel = id(new PHUIObjectBoxView())->setHeaderText(pht('Tags'))->appendChild($view);
         $content = $panel;
     }
     $crumbs = $this->buildCrumbs(array('tags' => true, 'commit' => $drequest->getSymbolicCommit()));
     return $this->buildApplicationPage(array($crumbs, $content, $pager), array('title' => array(pht('Tags'), pht('%s Repository', $repository->getCallsign()))));
 }
 public function processRequest()
 {
     $request = $this->getDiffusionRequest();
     $tag_limit = 10;
     $tags = array();
     try {
         $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => $request->getCommit(), 'limit' => $tag_limit + 1)));
     } catch (ConduitException $ex) {
         if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
             throw $ex;
         }
     }
     $has_more_tags = count($tags) > $tag_limit;
     $tags = array_slice($tags, 0, $tag_limit);
     $tag_links = array();
     foreach ($tags as $tag) {
         $tag_links[] = phutil_tag('a', array('href' => $request->generateURI(array('action' => 'browse', 'commit' => $tag->getName()))), $tag->getName());
     }
     if ($has_more_tags) {
         $tag_links[] = phutil_tag('a', array('href' => $request->generateURI(array('action' => 'tags'))), pht("More Tags…"));
     }
     return id(new AphrontAjaxResponse())->setContent($tag_links ? implode(', ', $tag_links) : pht('None'));
 }
 private function buildTagListTable(DiffusionRequest $drequest)
 {
     $viewer = $this->getRequest()->getUser();
     $repository = $drequest->getRepository();
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             // no tags in SVN
             return null;
     }
     $tag_limit = 15;
     $tags = array();
     $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => null, 'limit' => $tag_limit + 1)));
     if (!$tags) {
         return null;
     }
     $more_tags = count($tags) > $tag_limit;
     $tags = array_slice($tags, 0, $tag_limit);
     $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->withRepository($repository)->needCommitData(true)->execute();
     $view = id(new DiffusionTagListView())->setUser($viewer)->setDiffusionRequest($drequest)->setTags($tags)->setCommits($commits);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = $this->loadViewerHandles($phids);
     $view->setHandles($handles);
     $panel = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $header->setHeader(pht('Tags'));
     if ($more_tags) {
         $header->setSubHeader(pht('Showing the %d most recent tags.', $tag_limit));
     }
     $icon = id(new PHUIIconView())->setIconFont('fa-tag');
     $button = new PHUIButtonView();
     $button->setText(pht('Show All Tags'));
     $button->setTag('a');
     $button->setIcon($icon);
     $button->setHref($drequest->generateURI(array('action' => 'tags')));
     $header->addActionLink($button);
     $panel->setHeader($header);
     $panel->setTable($view);
     return $panel;
 }
 protected function buildPropertyView(DiffusionRequest $drequest)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer);
     if ($drequest->getSymbolicType() == 'tag') {
         $symbolic = $drequest->getSymbolicCommit();
         $view->addProperty(pht('Tag'), $symbolic);
         $tags = $this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('names' => array($symbolic), 'needMessages' => true));
         $tags = DiffusionRepositoryTag::newFromConduit($tags);
         $tags = mpull($tags, null, 'getName');
         $tag = idx($tags, $symbolic);
         if ($tag && strlen($tag->getMessage())) {
             $view->addSectionHeader(pht('Tag Content'), 'fa-tag');
             $view->addTextContent($this->markupText($tag->getMessage()));
         }
     }
     if ($view->hasAnyProperties()) {
         return $view;
     }
     return null;
 }
 private function buildTagListTable(DiffusionRequest $drequest)
 {
     $viewer = $this->getRequest()->getUser();
     $tag_limit = 15;
     $tags = array();
     try {
         $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => null, 'limit' => $tag_limit + 1)));
     } catch (ConduitException $e) {
         if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') {
             throw $e;
         }
     }
     if (!$tags) {
         return null;
     }
     $more_tags = count($tags) > $tag_limit;
     $tags = array_slice($tags, 0, $tag_limit);
     $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->withRepository($drequest->getRepository())->needCommitData(true)->execute();
     $view = id(new DiffusionTagListView())->setUser($viewer)->setDiffusionRequest($drequest)->setTags($tags)->setCommits($commits);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = $this->loadViewerHandles($phids);
     $view->setHandles($handles);
     $panel = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $header->setHeader(pht('Tags'));
     if ($more_tags) {
         $header->setSubHeader(pht('Showing the %d most recent tags.', $tag_limit));
     }
     $icon = id(new PHUIIconView())->setIconFont('fa-tag');
     $button = new PHUIButtonView();
     $button->setText(pht('Show All Tags'));
     $button->setTag('a');
     $button->setIcon($icon);
     $button->setHref($drequest->generateURI(array('action' => 'tags')));
     $header->addActionLink($button);
     $panel->setHeader($header);
     $panel->appendChild($view);
     return $panel;
 }