public function renderExample() { $badges1 = array(); $badges1[] = id(new PHUIBadgeView())->setIcon('fa-users')->setHeader(pht('Phacility High Command'))->setHref('/')->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('3 Members'); $badges1[] = id(new PHUIBadgeView())->setIcon('fa-lock')->setHeader(pht('Blessed Committers'))->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('12 Members'); $badges1[] = id(new PHUIBadgeView())->setIcon('fa-camera-retro')->setHeader(pht('Design'))->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('2 Members'); $badges1[] = id(new PHUIBadgeView())->setIcon('fa-lock')->setHeader(pht('Blessed Reviewers'))->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('3 Members'); $badges1[] = id(new PHUIBadgeView())->setIcon('fa-umbrella')->setHeader(pht('Wikipedia'))->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('22 Members'); $badges2 = array(); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-user')->setHeader(pht('Phabricator User'))->setSubhead(pht('Confirmed your account.'))->setQuality(PHUIBadgeView::POOR)->setSource(pht('People (automatic)'))->addByline(pht('Dec 31, 1969'))->addByline('212 Issued (100%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-code')->setHeader(pht('Code Contributor'))->setSubhead(pht('Wrote code that was acceptable'))->setQuality(PHUIBadgeView::COMMON)->setSource('Diffusion (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('200 Awarded (98%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-bug')->setHeader(pht('Task Master'))->setSubhead(pht('Closed over 100 tasks'))->setQuality(PHUIBadgeView::UNCOMMON)->setSource('Maniphest (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('56 Awarded (43%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-star')->setHeader(pht('Code Weaver'))->setSubhead(pht('Landed 1,000 Commits'))->setQuality(PHUIBadgeView::RARE)->setSource('Diffusion (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('42 Awarded (20%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-users')->setHeader(pht('Security Team'))->setSubhead(pht('<script>alert(1);</script>'))->setQuality(PHUIBadgeView::EPIC)->setSource('Projects (automatic)')->addByline(pht('Dec 31, 1969'))->addByline('21 Awarded (10%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-user')->setHeader(pht('Adminstrator'))->setSubhead(pht('Drew the short stick'))->setQuality(PHUIBadgeView::LEGENDARY)->setSource(pht('People (automatic)'))->addByline(pht('Dec 31, 1969'))->addByline('3 Awarded (1.4%)'); $badges2[] = id(new PHUIBadgeView())->setIcon('fa-compass')->setHeader(pht('Lead Developer'))->setSubhead(pht('Lead Developer of Phabricator'))->setQuality(PHUIBadgeView::HEIRLOOM)->setSource(pht('Direct Award (epriestley)'))->addByline(pht('Dec 31, 1969'))->addByline('1 Awarded (0.4%)'); $badges3 = array(); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-book')->setHeader(pht('Documenter')); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-star')->setHeader(pht('Contributor')); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-bug')->setHeader(pht('Bugmeister')); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-heart')->setHeader(pht('Funder'))->setQuality(PHUIBadgeView::UNCOMMON); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-user')->setHeader(pht('Administrator'))->setQuality(PHUIBadgeView::RARE); $badges3[] = id(new PHUIBadgeMiniView())->setIcon('fa-camera-retro')->setHeader(pht('Designer'))->setQuality(PHUIBadgeView::EPIC); $flex1 = new PHUIBadgeBoxView(); $flex1->addItems($badges1); $box1 = id(new PHUIObjectBoxView())->setHeaderText(pht('Project Membership'))->appendChild($flex1); $flex2 = new PHUIBadgeBoxView(); $flex2->addItems($badges2); $box2 = id(new PHUIObjectBoxView())->setHeaderText(pht('Achievements'))->appendChild($flex2); $flex3 = new PHUIBadgeBoxView(); $flex3->addItems($badges3); $flex3->setCollapsed(true); $flex3->addClass('ml'); $box3 = id(new PHUIObjectBoxView())->setHeaderText(pht('PHUIBadgeMiniView'))->appendChild($flex3); return array($box1, $box2, $box3); }
public function render() { $events = $this->getEventGroup(); // Move events with icons first. $icon_keys = array(); foreach ($this->getEventGroup() as $key => $event) { if ($event->icon) { $icon_keys[] = $key; } } $events = array_select_keys($events, $icon_keys) + $events; $force_icon = (bool) $icon_keys; $menu = null; $items = array(); $has_menu = false; if (!$this->getIsPreview() && !$this->getHideCommentOptions()) { foreach ($this->getEventGroup() as $event) { $items[] = $event->getMenuItems($this->anchor); if ($event->hasChildren()) { $has_menu = true; } } $items = array_mergev($items); } if ($items || $has_menu) { $icon = id(new PHUIIconView())->setIcon('fa-caret-down'); $aural = javelin_tag('span', array('aural' => true), pht('Comment Actions')); if ($items) { $sigil = 'phui-dropdown-menu'; Javelin::initBehavior('phui-dropdown-menu'); } else { $sigil = null; } $action_list = id(new PhabricatorActionListView())->setUser($this->getUser()); foreach ($items as $item) { $action_list->addAction($item); } $menu = javelin_tag($items ? 'a' : 'span', array('href' => '#', 'class' => 'phui-timeline-menu', 'sigil' => $sigil, 'aria-haspopup' => 'true', 'aria-expanded' => 'false', 'meta' => $action_list->getDropdownMenuMetadata()), array($aural, $icon)); $has_menu = true; } // Render "extra" information (timestamp, etc). $extra = $this->renderExtra($events); $show_badges = false; $group_titles = array(); $group_items = array(); $group_children = array(); foreach ($events as $event) { if ($event->shouldRenderEventTitle()) { $group_titles[] = $event->renderEventTitle($force_icon, $has_menu, $extra); // Don't render this information more than once. $extra = null; } if ($event->hasChildren()) { $group_children[] = $event->renderChildren(); $show_badges = true; } } $image_uri = $this->userHandle->getImageURI(); $wedge = phutil_tag('div', array('class' => 'phui-timeline-wedge phui-timeline-border', 'style' => nonempty($image_uri) ? '' : 'display: none;'), ''); $image = null; $badges = null; if ($image_uri) { $image = phutil_tag($this->userHandle->getURI() ? 'a' : 'div', array('style' => 'background-image: url(' . $image_uri . ')', 'class' => 'phui-timeline-image', 'href' => $this->userHandle->getURI()), ''); if ($this->badges && $show_badges) { $flex = new PHUIBadgeBoxView(); $flex->addItems($this->badges); $flex->setCollapsed(true); $badges = phutil_tag('div', array('class' => 'phui-timeline-badges'), $flex); } } $content_classes = array(); $content_classes[] = 'phui-timeline-content'; $classes = array(); $classes[] = 'phui-timeline-event-view'; if ($group_children) { $classes[] = 'phui-timeline-major-event'; $content = phutil_tag('div', array('class' => 'phui-timeline-inner-content'), array($group_titles, $menu, phutil_tag('div', array('class' => 'phui-timeline-core-content'), $group_children))); } else { $classes[] = 'phui-timeline-minor-event'; $content = $group_titles; } $content = phutil_tag('div', array('class' => 'phui-timeline-group phui-timeline-border'), $content); $content = phutil_tag('div', array('class' => implode(' ', $content_classes)), array($image, $badges, $wedge, $content)); $outer_classes = $this->classes; $outer_classes[] = 'phui-timeline-shell'; $color = null; foreach ($this->getEventGroup() as $event) { if ($event->color) { $color = $event->color; break; } } if ($color) { $outer_classes[] = 'phui-timeline-' . $color; } $sigil = null; $meta = null; if ($this->getTransactionPHID()) { $sigil = 'transaction'; $meta = array('phid' => $this->getTransactionPHID(), 'anchor' => $this->anchor); } $major_event = null; if ($this->reallyMajorEvent) { $major_event = phutil_tag('div', array('class' => 'phui-timeline-event-view ' . 'phui-timeline-spacer ' . 'phui-timeline-spacer-bold', '')); } return array(javelin_tag('div', array('class' => implode(' ', $outer_classes), 'id' => $this->anchor ? 'anchor-' . $this->anchor : null, 'sigil' => $sigil, 'meta' => $meta), phutil_tag('div', array('class' => implode(' ', $classes)), $content)), $major_event); }
protected function getTagContent() { if ($this->actionList || $this->actionListID) { $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIcon('fa-bars')->addClass('phui-mobile-menu'); if ($this->actionList) { $action_button->setDropdownMenu($this->actionList); } else { if ($this->actionListID) { $action_button->setDropdownMenuID($this->actionListID); } } $this->addActionLink($action_button); } $image = null; if ($this->image) { $image_href = null; if ($this->imageURL) { $image_href = $this->imageURL; } else { if ($this->imageEditURL) { $image_href = $this->imageEditURL; } } $image = phutil_tag('span', array('class' => 'phui-header-image', 'style' => 'background-image: url(' . $this->image . ')')); if ($image_href) { $edit_view = null; if ($this->imageEditURL) { $edit_view = phutil_tag('span', array('class' => 'phui-header-image-edit'), pht('Edit')); } $image = phutil_tag('a', array('href' => $image_href, 'class' => 'phui-header-image-href'), array($image, $edit_view)); } } $viewer = $this->getUser(); $left = array(); $right = array(); $space_header = null; if ($viewer) { $space_header = id(new PHUISpacesNamespaceContextView())->setUser($viewer)->setObject($this->policyObject); } if ($this->actionLinks) { $actions = array(); foreach ($this->actionLinks as $button) { $button->setColor(PHUIButtonView::GREY); $button->addClass(PHUI::MARGIN_SMALL_LEFT); $button->addClass('phui-header-action-link'); $actions[] = $button; } $right[] = phutil_tag('div', array('class' => 'phui-header-action-links'), $actions); } if ($this->buttonBar) { $right[] = phutil_tag('div', array('class' => 'phui-header-action-links'), $this->buttonBar); } if ($this->actionItems) { $action_list = array(); if ($this->actionItems) { foreach ($this->actionItems as $item) { $action_list[] = phutil_tag('li', array('class' => 'phui-header-action-item'), $item); } } $right[] = phutil_tag('ul', array('class' => 'phui-header-action-list'), $action_list); } $icon = null; if ($this->headerIcon) { $icon = id(new PHUIIconView())->setIcon($this->headerIcon)->addClass('phui-header-icon'); } $header_content = $this->header; $href = $this->getHref(); if ($href !== null) { $header_content = phutil_tag('a', array('href' => $href), $header_content); } $left[] = phutil_tag('span', array('class' => 'phui-header-header'), array($space_header, $icon, $header_content)); if ($this->subheader || $this->badges) { $badges = null; if ($this->badges) { $badges = new PHUIBadgeBoxView(); $badges->addItems($this->badges); $badges->setCollapsed(true); } $left[] = phutil_tag('div', array('class' => 'phui-header-subheader'), array($badges, $this->subheader)); } if ($this->properties || $this->policyObject || $this->tags) { $property_list = array(); foreach ($this->properties as $type => $property) { switch ($type) { case self::PROPERTY_STATUS: $property_list[] = $property; break; default: throw new Exception(pht('Incorrect Property Passed')); break; } } if ($this->policyObject) { $property_list[] = $this->renderPolicyProperty($this->policyObject); } if ($this->tags) { $property_list[] = $this->tags; } $left[] = phutil_tag('div', array('class' => 'phui-header-subheader'), $property_list); } // We here at @phabricator $header_image = null; if ($image) { $header_image = phutil_tag('div', array('class' => 'phui-header-col1'), $image); } // All really love $header_left = phutil_tag('div', array('class' => 'phui-header-col2'), $left); // Tables and Pokemon. $header_right = phutil_tag('div', array('class' => 'phui-header-col3'), $right); $header_row = phutil_tag('div', array('class' => 'phui-header-row'), array($header_image, $header_left, $header_right)); return phutil_tag('h1', array('class' => 'phui-header-view'), $header_row); }
protected function getTagContent() { $image = null; if ($this->image) { $image = phutil_tag($this->imageURL ? 'a' : 'span', array('href' => $this->imageURL, 'class' => 'phui-header-image', 'style' => 'background-image: url(' . $this->image . ')'), ' '); } $viewer = $this->getUser(); $left = array(); $right = array(); if ($viewer) { $left[] = id(new PHUISpacesNamespaceContextView())->setUser($viewer)->setObject($this->policyObject); } if ($this->objectName) { $left[] = array(phutil_tag('a', array('href' => '/' . $this->objectName), $this->objectName), ' '); } if ($this->actionLinks) { $actions = array(); foreach ($this->actionLinks as $button) { $button->setColor(PHUIButtonView::SIMPLE); $button->addClass(PHUI::MARGIN_SMALL_LEFT); $button->addClass('phui-header-action-link'); $actions[] = $button; } $right[] = phutil_tag('div', array('class' => 'phui-header-action-links'), $actions); } if ($this->buttonBar) { $right[] = phutil_tag('div', array('class' => 'phui-header-action-links'), $this->buttonBar); } if ($this->actionIcons || $this->tags) { $action_list = array(); if ($this->actionIcons) { foreach ($this->actionIcons as $icon) { $action_list[] = phutil_tag('li', array('class' => 'phui-header-action-icon'), $icon); } } if ($this->tags) { $action_list[] = phutil_tag('li', array('class' => 'phui-header-action-tag'), array_interleave(' ', $this->tags)); } $right[] = phutil_tag('ul', array('class' => 'phui-header-action-list'), $action_list); } if ($this->headerIcon) { $icon = id(new PHUIIconView())->setIconFont($this->headerIcon); $left[] = $icon; } $left[] = phutil_tag('span', array('class' => 'phui-header-header'), $this->header); if ($this->subheader || $this->badges) { $badges = null; if ($this->badges) { $badges = new PHUIBadgeBoxView(); $badges->addItems($this->badges); $badges->setCollapsed(true); } $left[] = phutil_tag('div', array('class' => 'phui-header-subheader'), array($badges, $this->subheader)); } if ($this->properties || $this->policyObject) { $property_list = array(); foreach ($this->properties as $type => $property) { switch ($type) { case self::PROPERTY_STATUS: $property_list[] = $property; break; default: throw new Exception(pht('Incorrect Property Passed')); break; } } if ($this->policyObject) { $property_list[] = $this->renderPolicyProperty($this->policyObject); } $left[] = phutil_tag('div', array('class' => 'phui-header-subheader'), $property_list); } // We here at @phabricator $header_image = null; if ($image) { $header_image = phutil_tag('div', array('class' => 'phui-header-col1'), $image); } // All really love $header_left = phutil_tag('div', array('class' => 'phui-header-col2'), $left); // Tables and Pokemon. $header_right = phutil_tag('div', array('class' => 'phui-header-col3'), $right); $header_row = phutil_tag('div', array('class' => 'phui-header-row'), array($header_image, $header_left, $header_right)); return phutil_tag('h1', array('class' => 'phui-header-view'), $header_row); }