[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PHUICalendarListView extends AphrontTagView { 4 5 private $events = array(); 6 private $blankState; 7 8 public function addEvent(AphrontCalendarEventView $event) { 9 $this->events[] = $event; 10 return $this; 11 } 12 13 public function showBlankState($state) { 14 $this->blankState = $state; 15 return $this; 16 } 17 18 public function getTagName() { 19 return 'div'; 20 } 21 22 public function getTagAttributes() { 23 require_celerity_resource('phui-calendar-css'); 24 require_celerity_resource('phui-calendar-list-css'); 25 return array('class' => 'phui-calendar-day-list'); 26 } 27 28 protected function getTagContent() { 29 if (!$this->blankState && empty($this->events)) { 30 return ''; 31 } 32 33 $events = msort($this->events, 'getEpochStart'); 34 35 $singletons = array(); 36 $allday = false; 37 foreach ($events as $event) { 38 $color = $event->getColor(); 39 40 if ($event->getAllDay()) { 41 $timelabel = pht('All Day'); 42 } else { 43 $timelabel = phabricator_time( 44 $event->getEpochStart(), 45 $this->getUser()); 46 } 47 48 $dot = phutil_tag( 49 'span', 50 array( 51 'class' => 'phui-calendar-list-dot', 52 ), 53 ''); 54 $title = phutil_tag( 55 'span', 56 array( 57 'class' => 'phui-calendar-list-title', 58 ), 59 $this->renderEventLink($event, $allday)); 60 $time = phutil_tag( 61 'span', 62 array( 63 'class' => 'phui-calendar-list-time', 64 ), 65 $timelabel); 66 67 $singletons[] = phutil_tag( 68 'li', 69 array( 70 'class' => 'phui-calendar-list-item phui-calendar-'.$color, 71 ), 72 array( 73 $dot, 74 $title, 75 $time, 76 )); 77 } 78 79 if (empty($singletons)) { 80 $singletons[] = phutil_tag( 81 'li', 82 array( 83 'class' => 'phui-calendar-list-item-empty', 84 ), 85 pht('Clear sailing ahead.')); 86 } 87 88 $list = phutil_tag( 89 'ul', 90 array( 91 'class' => 'phui-calendar-list', 92 ), 93 $singletons); 94 95 return $list; 96 } 97 98 private function renderEventLink($event) { 99 100 Javelin::initBehavior('phabricator-tooltips'); 101 102 if ($event->getMultiDay()) { 103 $tip = pht('%s, Until: %s', $event->getName(), 104 phabricator_date($event->getEpochEnd(), $this->getUser())); 105 } else { 106 $tip = pht('%s, Until: %s', $event->getName(), 107 phabricator_time($event->getEpochEnd(), $this->getUser())); 108 } 109 110 $description = $event->getDescription(); 111 if (strlen($description) == 0) { 112 $description = pht('(%s)', $event->getName()); 113 } 114 115 $anchor = javelin_tag( 116 'a', 117 array( 118 'sigil' => 'has-tooltip', 119 'class' => 'phui-calendar-item-link', 120 'href' => '/calendar/event/view/'.$event->getEventID().'/', 121 'meta' => array( 122 'tip' => $tip, 123 'size' => 200, 124 ), 125 ), 126 $description); 127 128 return $anchor; 129 } 130 }
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 |