public function buildView() { if (!$this->user) { throw new Exception('Call setUser() before buildView()!'); } $user = $this->user; $stories = $this->stories; $handles = array(); if ($stories) { $handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs')); $object_phids = array_mergev(mpull($stories, 'getRequiredObjectPHIDs')); $handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles(); } $null_view = new AphrontNullView(); require_celerity_resource('phabricator-feed-css'); $last_date = null; foreach ($stories as $story) { $story->setHandles($handles); $story->setFramed($this->framed); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); if ($date !== $last_date) { if ($last_date !== null) { $null_view->appendChild('<div class="phabricator-feed-story-date-separator"></div>'); } $last_date = $date; $null_view->appendChild(phutil_render_tag('div', array('class' => 'phabricator-feed-story-date'), phutil_escape_html($date))); } $view = $story->renderView(); $view->setViewer($user); $null_view->appendChild($view); } return id(new AphrontNullView())->appendChild('<div class="phabricator-feed-frame">' . $null_view->render() . '</div>'); }
public function render() { require_celerity_resource('sprite-docs-css'); $conpherence = $this->getConpherence(); $widget_data = $conpherence->getWidgetData(); $files = $widget_data['files']; $files_authors = $widget_data['files_authors']; $files_html = array(); foreach ($files as $file) { $icon_class = $file->getDisplayIconForMimeType(); $icon_view = phutil_tag('div', array('class' => 'file-icon sprite-docs ' . $icon_class), ''); $file_view = id(new PhabricatorFileLinkView())->setFilePHID($file->getPHID())->setFileName(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(28)->truncateString($file->getName()))->setFileViewable($file->isViewableImage())->setFileViewURI($file->getBestURI())->setCustomClass('file-title'); $who_done_it_text = ''; // system generated files don't have authors if ($file->getAuthorPHID()) { $who_done_it_text = pht('By %s ', $files_authors[$file->getPHID()]->renderLink()); } $date_text = phabricator_relative_date($file->getDateCreated(), $this->getUser()); $who_done_it = phutil_tag('div', array('class' => 'file-uploaded-by'), pht('%s%s.', $who_done_it_text, $date_text)); $files_html[] = phutil_tag('div', array('class' => 'file-entry'), array($icon_view, $file_view, $who_done_it)); } if (empty($files)) { $files_html[] = javelin_tag('div', array('class' => 'no-files', 'sigil' => 'no-files'), pht('No files.')); } return phutil_tag('div', array('class' => 'file-list'), $files_html); }
public function buildView() { if (!$this->user) { throw new PhutilInvalidStateException('setUser'); } $user = $this->user; $stories = $this->stories; $null_view = new AphrontNullView(); require_celerity_resource('phabricator-feed-css'); $last_date = null; foreach ($stories as $story) { $story->setHovercard($this->hovercards); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); if ($date !== $last_date) { if ($last_date !== null) { $null_view->appendChild(phutil_tag_div('phabricator-feed-story-date-separator')); } $last_date = $date; $header = new PHUIHeaderView(); $header->setHeader($date); $header->setHeaderIcon('fa-calendar msr'); $null_view->appendChild($header); } try { $view = $story->renderView(); $view->setUser($user); $view = $view->render(); } catch (Exception $ex) { // If rendering failed for any reason, don't fail the entire feed, // just this one story. $view = id(new PHUIFeedStoryView())->setUser($user)->setChronologicalKey($story->getChronologicalKey())->setEpoch($story->getEpoch())->setTitle(pht('Feed Story Failed to Render (%s)', get_class($story)))->appendChild(pht('%s: %s', get_class($ex), $ex->getMessage())); } $null_view->appendChild($view); } $box = id(new PHUIObjectBoxView())->appendChild($null_view); if (empty($stories)) { $nodatastring = pht('No Stories.'); if ($this->noDataString) { $nodatastring = $this->noDataString; } $view = id(new PHUIBoxView())->addClass('mlt mlb msr msl')->appendChild($nodatastring); $box->appendChild($view); } return $box; }
public function buildView() { if (!$this->user) { throw new Exception('Call setUser() before buildView()!'); } $user = $this->user; $stories = $this->stories; $null_view = new AphrontNullView(); require_celerity_resource('phabricator-feed-css'); $last_date = null; foreach ($stories as $story) { $story->setFramed($this->framed); $story->setHovercard($this->hovercards); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); if ($date !== $last_date) { if ($last_date !== null) { $null_view->appendChild(phutil_tag_div('phabricator-feed-story-date-separator')); } $last_date = $date; $header = new PHUIActionHeaderView(); $header->setHeaderTitle($date); $null_view->appendChild($header); } try { $view = $story->renderView(); $view->setUser($user); $view = $view->render(); } catch (Exception $ex) { // If rendering failed for any reason, don't fail the entire feed, // just this one story. $view = id(new PHUIFeedStoryView())->setUser($user)->setChronologicalKey($story->getChronologicalKey())->setEpoch($story->getEpoch())->setTitle(pht('Feed Story Failed to Render (%s)', get_class($story)))->appendChild(pht('%s: %s', get_class($ex), $ex->getMessage())); } $null_view->appendChild($view); } return id(new AphrontNullView())->appendChild($null_view->render()); }
function phabricator_on_relative_date($epoch, $user) { return phabricator_relative_date($epoch, $user, true); }