diff --git a/src/applications/countdown/controller/PhabricatorCountdownViewController.php b/src/applications/countdown/controller/PhabricatorCountdownViewController.php index 3e8f28e0cf..db63613df2 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownViewController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownViewController.php @@ -1,133 +1,133 @@ getViewer(); $id = $request->getURIData('id'); $countdown = id(new PhabricatorCountdownQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$countdown) { return new Aphront404Response(); } $countdown_view = id(new PhabricatorCountdownView()) ->setUser($viewer) ->setCountdown($countdown); $id = $countdown->getID(); $title = $countdown->getTitle(); $crumbs = $this ->buildApplicationCrumbs() - ->addTextCrumb("C{$id}") + ->addTextCrumb($countdown->getMonogram()) ->setBorder(true); $epoch = $countdown->getEpoch(); if ($epoch >= PhabricatorTime::getNow()) { $icon = 'fa-clock-o'; $color = ''; $status = pht('Running'); } else { $icon = 'fa-check-square-o'; $color = 'dark'; $status = pht('Launched'); } $header = id(new PHUIHeaderView()) ->setHeader($title) ->setUser($viewer) ->setPolicyObject($countdown) ->setStatus($icon, $color, $status) ->setHeaderIcon('fa-rocket'); $curtain = $this->buildCurtain($countdown); $subheader = $this->buildSubheaderView($countdown); $timeline = $this->buildTransactionTimeline( $countdown, new PhabricatorCountdownTransactionQuery()); $comment_view = id(new PhabricatorCountdownEditEngine()) ->setViewer($viewer) ->buildEditEngineCommentView($countdown); $content = array( $countdown_view, $timeline, $comment_view, ); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setSubheader($subheader) ->setCurtain($curtain) ->setMainColumn($content); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setPageObjectPHIDs( array( $countdown->getPHID(), )) ->appendChild($view); } private function buildCurtain(PhabricatorCountdown $countdown) { $viewer = $this->getViewer(); $id = $countdown->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $countdown, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($countdown); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-pencil') ->setName(pht('Edit Countdown')) ->setHref($this->getApplicationURI("edit/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); return $curtain; } private function buildSubheaderView( PhabricatorCountdown $countdown) { $viewer = $this->getViewer(); $author = $viewer->renderHandle($countdown->getAuthorPHID())->render(); $date = phabricator_datetime($countdown->getDateCreated(), $viewer); $author = phutil_tag('strong', array(), $author); $person = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withPHIDs(array($countdown->getAuthorPHID())) ->needProfileImage(true) ->executeOne(); $image_uri = $person->getProfileImageURI(); $image_href = '/p/'.$person->getUsername(); $content = pht('Authored by %s on %s.', $author, $date); return id(new PHUIHeadThingView()) ->setImage($image_uri) ->setImageHref($image_href) ->setContent($content); } } diff --git a/src/applications/countdown/phid/PhabricatorCountdownCountdownPHIDType.php b/src/applications/countdown/phid/PhabricatorCountdownCountdownPHIDType.php index 573d89c843..7e6278c8ea 100644 --- a/src/applications/countdown/phid/PhabricatorCountdownCountdownPHIDType.php +++ b/src/applications/countdown/phid/PhabricatorCountdownCountdownPHIDType.php @@ -1,73 +1,73 @@ withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $countdown = $objects[$phid]; $name = $countdown->getTitle(); $id = $countdown->getID(); - $handle->setName("C{$id}"); - $handle->setFullName("C{$id}: {$name}"); - $handle->setURI("/countdown/{$id}/"); + $handle->setName($countdown->getMonogram()); + $handle->setFullName(pht('%s: %s', $countdown->getMonogram(), $name)); + $handle->setURI($countdown->getURI()); } } public function canLoadNamedObject($name) { return preg_match('/^C\d*[1-9]\d*$/i', $name); } public function loadNamedObjects( PhabricatorObjectQuery $query, array $names) { $id_map = array(); foreach ($names as $name) { $id = (int)substr($name, 1); $id_map[$id][] = $name; } $objects = id(new PhabricatorCountdownQuery()) ->setViewer($query->getViewer()) ->withIDs(array_keys($id_map)) ->execute(); $results = array(); foreach ($objects as $id => $object) { foreach (idx($id_map, $id, array()) as $name) { $results[$name] = $object; } } return $results; } } diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index 0abf9e453a..00512cb07c 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -1,166 +1,166 @@ newQuery(); if ($map['authorPHIDs']) { $query->withAuthorPHIDs($map['authorPHIDs']); } if ($map['upcoming'] && $map['upcoming'][0] == 'upcoming') { $query->withUpcoming(); } return $query; } protected function buildCustomSearchFields() { return array( id(new PhabricatorUsersSearchField()) ->setLabel(pht('Authors')) ->setKey('authorPHIDs') ->setAliases(array('author', 'authors')), id(new PhabricatorSearchCheckboxesField()) ->setKey('upcoming') ->setOptions( array( 'upcoming' => pht('Show only upcoming countdowns.'), )), ); } protected function getURI($path) { return '/countdown/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'upcoming' => pht('Upcoming'), 'all' => pht('All'), ); if ($this->requireViewer()->getPHID()) { $names['authored'] = pht('Authored'); } return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; case 'authored': return $query->setParameter( 'authorPHIDs', array($this->requireViewer()->getPHID())); case 'upcoming': return $query->setParameter('upcoming', array('upcoming')); } return parent::buildSavedQueryFromBuiltin($query_key); } protected function getRequiredHandlePHIDsForResultList( array $countdowns, PhabricatorSavedQuery $query) { return mpull($countdowns, 'getAuthorPHID'); } protected function renderResultList( array $countdowns, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($countdowns, 'PhabricatorCountdown'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($countdowns as $countdown) { $id = $countdown->getID(); $ended = false; $epoch = $countdown->getEpoch(); if ($epoch <= PhabricatorTime::getNow()) { $ended = true; } $item = id(new PHUIObjectItemView()) ->setUser($viewer) ->setObject($countdown) - ->setObjectName("C{$id}") + ->setObjectName($countdown->getMonogram()) ->setHeader($countdown->getTitle()) ->setHref($this->getApplicationURI("{$id}/")) ->addByline( pht( 'Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink())); if ($ended) { $item->addAttribute( pht('Launched on %s', phabricator_datetime($epoch, $viewer))); $item->setDisabled(true); } else { $time_left = ($epoch - PhabricatorTime::getNow()); $num = round($time_left / (60 * 60 * 24)); $noun = pht('Days'); if ($num < 1) { $num = round($time_left / (60 * 60), 1); $noun = pht('Hours'); } $item->setCountdown($num, $noun); $item->addAttribute( phabricator_datetime($epoch, $viewer)); } $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No countdowns found.')); return $result; } protected function getNewUserBody() { $create_button = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Create a Countdown')) ->setHref('/countdown/edit/') ->setColor(PHUIButtonView::GREEN); $icon = $this->getApplication()->getIcon(); $app_name = $this->getApplication()->getName(); $view = id(new PHUIBigInfoView()) ->setIcon($icon) ->setTitle(pht('Welcome to %s', $app_name)) ->setDescription( pht('Keep track of upcoming launch dates with '. 'embeddable counters.')) ->addAction($create_button); return $view; } } diff --git a/src/applications/countdown/view/PhabricatorCountdownView.php b/src/applications/countdown/view/PhabricatorCountdownView.php index 4e975c3626..f88c5a9d9c 100644 --- a/src/applications/countdown/view/PhabricatorCountdownView.php +++ b/src/applications/countdown/view/PhabricatorCountdownView.php @@ -1,90 +1,90 @@ countdown = $countdown; return $this; } public function render() { $countdown = $this->countdown; require_celerity_resource('phabricator-countdown-css'); $header_text = array( - 'C'.$countdown->getID(), + $countdown->getMonogram(), ' ', phutil_tag( 'a', array( - 'href' => '/countdown/'.$countdown->getID(), + 'href' => $countdown->getURI(), ), $countdown->getTitle()), ); $header = id(new PHUIHeaderView()) ->setHeader($header_text); $ths = array( phutil_tag('th', array(), pht('Days')), phutil_tag('th', array(), pht('Hours')), phutil_tag('th', array(), pht('Minutes')), phutil_tag('th', array(), pht('Seconds')), ); $dashes = array( javelin_tag('td', array('sigil' => 'phabricator-timer-days'), '-'), javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), '-'), javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), '-'), javelin_tag('td', array('sigil' => 'phabricator-timer-seconds'), '-'), ); $epoch = $countdown->getEpoch(); $launch_date = phabricator_datetime($epoch, $this->getUser()); $foot = phutil_tag( 'td', array( 'colspan' => '4', 'class' => 'phabricator-timer-foot', ), $launch_date); $description = $countdown->getDescription(); if (strlen($description)) { $description = new PHUIRemarkupView($this->getUser(), $description); $description = phutil_tag( 'div', array( 'class' => 'countdown-description phabricator-remarkup', ), $description); } $container = celerity_generate_unique_node_id(); $content = phutil_tag( 'div', array('class' => 'phabricator-timer', 'id' => $container), array( $description, phutil_tag('table', array('class' => 'phabricator-timer-table'), array( phutil_tag('tr', array(), $ths), phutil_tag('tr', array(), $dashes), phutil_tag('tr', array(), $foot), )), )); Javelin::initBehavior('countdown-timer', array( 'timestamp' => $countdown->getEpoch(), 'container' => $container, )); return id(new PHUIObjectBoxView()) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->addClass('phabricator-timer-view') ->appendChild($content); } }