[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PHUIFeedStoryView extends AphrontView { 4 5 private $title; 6 private $image; 7 private $imageHref; 8 private $appIcon; 9 private $phid; 10 private $epoch; 11 private $viewed; 12 private $href; 13 private $pontification = null; 14 private $tokenBar = array(); 15 private $projects = array(); 16 private $actions = array(); 17 private $chronologicalKey; 18 private $tags; 19 20 public function setTags($tags) { 21 $this->tags = $tags; 22 return $this; 23 } 24 25 public function getTags() { 26 return $this->tags; 27 } 28 29 public function setChronologicalKey($chronological_key) { 30 $this->chronologicalKey = $chronological_key; 31 return $this; 32 } 33 34 public function getChronologicalKey() { 35 return $this->chronologicalKey; 36 } 37 38 public function setTitle($title) { 39 $this->title = $title; 40 return $this; 41 } 42 43 public function getTitle() { 44 return $this->title; 45 } 46 47 public function setEpoch($epoch) { 48 $this->epoch = $epoch; 49 return $this; 50 } 51 52 public function setImage($image) { 53 $this->image = $image; 54 return $this; 55 } 56 57 public function setImageHref($image_href) { 58 $this->imageHref = $image_href; 59 return $this; 60 } 61 62 public function setAppIcon($icon) { 63 $this->appIcon = $icon; 64 return $this; 65 } 66 67 public function setViewed($viewed) { 68 $this->viewed = $viewed; 69 return $this; 70 } 71 72 public function getViewed() { 73 return $this->viewed; 74 } 75 76 public function setHref($href) { 77 $this->href = $href; 78 return $this; 79 } 80 81 public function setTokenBar(array $tokens) { 82 $this->tokenBar = $tokens; 83 return $this; 84 } 85 86 public function addProject($project) { 87 $this->projects[] = $project; 88 return $this; 89 } 90 91 public function addAction(PHUIIconView $action) { 92 $this->actions[] = $action; 93 return $this; 94 } 95 96 public function setPontification($text, $title = null) { 97 if ($title) { 98 $title = phutil_tag('h3', array(), $title); 99 } 100 $copy = phutil_tag( 101 'div', 102 array( 103 'class' => 'phui-feed-story-bigtext-post', 104 ), 105 array( 106 $title, 107 $text, 108 )); 109 $this->appendChild($copy); 110 return $this; 111 } 112 113 public function getHref() { 114 return $this->href; 115 } 116 117 public function renderNotification($user) { 118 $classes = array( 119 'phabricator-notification', 120 ); 121 122 if (!$this->viewed) { 123 $classes[] = 'phabricator-notification-unread'; 124 } 125 if ($this->epoch) { 126 if ($user) { 127 $foot = phabricator_datetime($this->epoch, $user); 128 $foot = phutil_tag( 129 'span', 130 array( 131 'class' => 'phabricator-notification-date', 132 ), 133 $foot); 134 } else { 135 $foot = null; 136 } 137 } else { 138 $foot = pht('No time specified.'); 139 } 140 141 return javelin_tag( 142 'div', 143 array( 144 'class' => implode(' ', $classes), 145 'sigil' => 'notification', 146 'meta' => array( 147 'href' => $this->getHref(), 148 ), 149 ), 150 array($this->title, $foot)); 151 } 152 153 public function render() { 154 155 require_celerity_resource('phui-feed-story-css'); 156 Javelin::initBehavior('phabricator-hovercards'); 157 158 $body = null; 159 $foot = null; 160 $image_style = null; 161 $actor = ''; 162 163 if ($this->image) { 164 $actor = new PHUIIconView(); 165 $actor->setImage($this->image); 166 $actor->addClass('phui-feed-story-actor-image'); 167 if ($this->imageHref) { 168 $actor->setHref($this->imageHref); 169 } 170 } 171 172 if ($this->epoch) { 173 // TODO: This is really bad; when rendering through Conduit and via 174 // renderText() we don't have a user. 175 if ($this->user) { 176 $foot = phabricator_datetime($this->epoch, $this->user); 177 } else { 178 $foot = null; 179 } 180 } else { 181 $foot = pht('No time specified.'); 182 } 183 184 if ($this->chronologicalKey) { 185 $foot = phutil_tag( 186 'a', 187 array( 188 'href' => '/feed/'.$this->chronologicalKey.'/', 189 ), 190 $foot); 191 } 192 193 $icon = null; 194 if ($this->appIcon) { 195 $icon = new PHUIIconView(); 196 $icon->setSpriteIcon($this->appIcon); 197 $icon->setSpriteSheet(PHUIIconView::SPRITE_APPS); 198 } 199 200 $action_list = array(); 201 $icons = null; 202 foreach ($this->actions as $action) { 203 $action_list[] = phutil_tag( 204 'li', 205 array( 206 'class' => 'phui-feed-story-action-item', 207 ), 208 $action); 209 } 210 if (!empty($action_list)) { 211 $icons = phutil_tag( 212 'ul', 213 array( 214 'class' => 'phui-feed-story-action-list', 215 ), 216 $action_list); 217 } 218 219 $head = phutil_tag( 220 'div', 221 array( 222 'class' => 'phui-feed-story-head', 223 ), 224 array( 225 $actor, 226 nonempty($this->title, pht('Untitled Story')), 227 $icons, 228 )); 229 230 if (!empty($this->tokenBar)) { 231 $tokenview = phutil_tag( 232 'div', 233 array( 234 'class' => 'phui-feed-token-bar', 235 ), 236 $this->tokenBar); 237 $this->appendChild($tokenview); 238 } 239 240 $body_content = $this->renderChildren(); 241 if ($body_content) { 242 $body = phutil_tag( 243 'div', 244 array( 245 'class' => 'phui-feed-story-body phabricator-remarkup', 246 ), 247 $body_content); 248 } 249 250 $tags = null; 251 if ($this->tags) { 252 $tags = array( 253 " \xC2\xB7 ", 254 $this->tags, 255 ); 256 } 257 258 $foot = phutil_tag( 259 'div', 260 array( 261 'class' => 'phui-feed-story-foot', 262 ), 263 array( 264 $icon, 265 $foot, 266 $tags, 267 )); 268 269 $classes = array('phui-feed-story'); 270 271 return id(new PHUIBoxView()) 272 ->addClass(implode(' ', $classes)) 273 ->setBorder(true) 274 ->addMargin(PHUI::MARGIN_MEDIUM_BOTTOM) 275 ->appendChild(array($head, $body, $foot)); 276 } 277 278 public function setAppIconFromPHID($phid) { 279 switch (phid_get_type($phid)) { 280 case PholioMockPHIDType::TYPECONST: 281 $this->setAppIcon('pholio-dark'); 282 break; 283 case PhabricatorMacroMacroPHIDType::TYPECONST: 284 $this->setAppIcon('macro-dark'); 285 break; 286 case ManiphestTaskPHIDType::TYPECONST: 287 $this->setAppIcon('maniphest-dark'); 288 break; 289 case DifferentialRevisionPHIDType::TYPECONST: 290 $this->setAppIcon('differential-dark'); 291 break; 292 case PhabricatorCalendarEventPHIDType::TYPECONST: 293 $this->setAppIcon('calendar-dark'); 294 break; 295 } 296 } 297 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |