예제 #1
0
 public function render()
 {
     require_celerity_resource('phui-feed-story-css');
     Javelin::initBehavior('phabricator-hovercards');
     $body = null;
     $foot = null;
     $image_style = null;
     $actor = '';
     if ($this->image) {
         $actor = new PHUIIconView();
         $actor->setImage($this->image);
         $actor->addClass('phui-feed-story-actor-image');
         if ($this->imageHref) {
             $actor->setHref($this->imageHref);
         }
     }
     if ($this->epoch) {
         // TODO: This is really bad; when rendering through Conduit and via
         // renderText() we don't have a user.
         if ($this->user) {
             $foot = phabricator_datetime($this->epoch, $this->user);
         } else {
             $foot = null;
         }
     } else {
         $foot = pht('No time specified.');
     }
     if ($this->chronologicalKey) {
         $foot = phutil_tag('a', array('href' => '/feed/' . $this->chronologicalKey . '/'), $foot);
     }
     $icon = null;
     if ($this->appIcon) {
         $icon = new PHUIIconView();
         $icon->setSpriteIcon($this->appIcon);
         $icon->setSpriteSheet(PHUIIconView::SPRITE_APPS);
     }
     $action_list = array();
     $icons = null;
     foreach ($this->actions as $action) {
         $action_list[] = phutil_tag('li', array('class' => 'phui-feed-story-action-item'), $action);
     }
     if (!empty($action_list)) {
         $icons = phutil_tag('ul', array('class' => 'phui-feed-story-action-list'), $action_list);
     }
     $head = phutil_tag('div', array('class' => 'phui-feed-story-head'), array($actor, nonempty($this->title, pht('Untitled Story')), $icons));
     if (!empty($this->tokenBar)) {
         $tokenview = phutil_tag('div', array('class' => 'phui-feed-token-bar'), $this->tokenBar);
         $this->appendChild($tokenview);
     }
     $body_content = $this->renderChildren();
     if ($body_content) {
         $body = phutil_tag('div', array('class' => 'phui-feed-story-body'), $body_content);
     }
     $tags = null;
     if ($this->tags) {
         $tags = array(" · ", $this->tags);
     }
     $foot = phutil_tag('div', array('class' => 'phui-feed-story-foot'), array($icon, $foot, $tags));
     $classes = array('phui-feed-story');
     return id(new PHUIBoxView())->addClass(implode(' ', $classes))->setBorder(true)->addMargin(PHUI::MARGIN_MEDIUM_BOTTOM)->appendChild(array($head, $body, $foot));
 }