public static function getColorMap() { $shades = PHUITagView::getShadeMap(); $shades = array_select_keys($shades, array(PhabricatorProject::DEFAULT_COLOR)) + $shades; unset($shades[PHUITagView::COLOR_DISABLED]); return $shades; }
public function setTagColor($color) { static $colors; if (!$colors) { $colors = array_fuse(array_keys(PHUITagView::getShadeMap())); } if (isset($colors[$color])) { $this->tagColor = $color; } return $this; }
public function getTitleForFeed() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $author_handle = $this->renderHandleLink($author_phid); $object_handle = $this->renderHandleLink($object_phid); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_NAME: if ($old === null) { return pht('%s created %s.', $author_handle, $object_handle); } else { return pht('%s renamed %s from "%s" to "%s".', $author_handle, $object_handle, $old, $new); } case self::TYPE_STATUS: if ($old == 0) { return pht('%s archived %s.', $author_handle, $object_handle); } else { return pht('%s activated %s.', $author_handle, $object_handle); } case self::TYPE_IMAGE: // TODO: Some day, it would be nice to show the images. if (!$old) { return pht('%s set the image for %s to %s.', $author_handle, $object_handle, $this->renderHandleLink($new)); } else { if (!$new) { return pht('%s removed the image for %s.', $author_handle, $object_handle); } else { return pht('%s updated the image for %s from %s to %s.', $author_handle, $object_handle, $this->renderHandleLink($old), $this->renderHandleLink($new)); } } case self::TYPE_ICON: return pht('%s set the icon for %s to %s.', $author_handle, $object_handle, PhabricatorProjectIcon::getLabel($new)); case self::TYPE_COLOR: return pht('%s set the color for %s to %s.', $author_handle, $object_handle, PHUITagView::getShadeName($new)); case self::TYPE_LOCKED: if ($new) { return pht('%s locked %s membership.', $author_handle, $object_handle); } else { return pht('%s unlocked %s membership.', $author_handle, $object_handle); } case self::TYPE_SLUGS: $add = array_diff($new, $old); $rem = array_diff($old, $new); if ($add && $rem) { return pht('%s changed %s hashtag(s), added %d: %s; removed %d: %s.', $author_handle, $object_handle, count($add), $this->renderSlugList($add), count($rem), $this->renderSlugList($rem)); } else { if ($add) { return pht('%s added %d %s hashtag(s): %s.', $author_handle, count($add), $object_handle, $this->renderSlugList($add)); } else { if ($rem) { return pht('%s removed %d %s hashtag(s): %s.', $author_handle, count($rem), $object_handle, $this->renderSlugList($rem)); } } } } return parent::getTitleForFeed(); }
public function renderExample() { $intro = array(); $intro[] = 'Hey, '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_PERSON)->setName('@alincoln')->setHref('#'); $intro[] = ' how is stuff?'; $intro[] = hsprintf('<br /><br />'); $intro[] = 'Did you hear that '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_PERSON)->setName('@gwashington')->setDotColor(PHUITagView::COLOR_RED)->setHref('#'); $intro[] = ' is away, '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_PERSON)->setName('@tjefferson')->setDotColor(PHUITagView::COLOR_ORANGE)->setHref('#'); $intro[] = ' has some errands, and '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_PERSON)->setName('@rreagan')->setDotColor(PHUITagView::COLOR_GREY)->setHref('#'); $intro[] = ' is gone?'; $intro[] = hsprintf('<br /><br />'); $intro[] = 'Take a look at '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setName('D123')->setHref('#'); $intro[] = ' when you get a chance.'; $intro[] = hsprintf('<br /><br />'); $intro[] = 'Hmm? '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setName('D123')->setClosed(true)->setHref('#'); $intro[] = ' is '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLACK)->setName('Abandoned'); $intro[] = '.'; $intro[] = hsprintf('<br /><br />'); $intro[] = 'I hope someone is going to '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setName('T123: Water The Dog')->setHref('#'); $intro[] = ' -- that task is '; $intro[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_RED)->setName('High Priority'); $intro[] = '!'; $intro = id(new PHUIBoxView())->appendChild($intro)->addPadding(PHUI::PADDING_LARGE); $header1 = id(new PHUIHeaderView())->setHeader('Colors'); $colors = PHUITagView::getColors(); $tags = array(); foreach ($colors as $color) { $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor($color)->setName(ucwords($color)); $tags[] = hsprintf('<br /><br />'); } $content1 = id(new PHUIBoxView())->appendChild($tags)->addPadding(PHUI::PADDING_LARGE); $tags = array(); $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_GREEN)->setDotColor(PHUITagView::COLOR_RED)->setName(pht('Christmas')); $tags[] = hsprintf('<br /><br />'); $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setBackgroundColor(PHUITagView::COLOR_ORANGE)->setDotColor(PHUITagView::COLOR_BLACK)->setName(pht('Halloween')); $tags[] = hsprintf('<br /><br />'); $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_INDIGO)->setDotColor(PHUITagView::COLOR_YELLOW)->setName(pht('Easter')); $content2 = id(new PHUIBoxView())->appendChild($tags)->addPadding(PHUI::PADDING_LARGE); $icons = array(); $icons[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_GREEN)->setIcon('fa-check white')->setName(pht('Passed')); $icons[] = hsprintf('<br /><br />'); $icons[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_RED)->setIcon('fa-times white')->setName(pht('Failed')); $icons[] = hsprintf('<br /><br />'); $icons[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setIcon('fa-refresh white')->setName(pht('Running')); $icons[] = hsprintf('<br /><br />'); $icons[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_GREY)->setIcon('fa-pause white')->setName(pht('Paused')); $icons[] = hsprintf('<br /><br />'); $icons[] = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLACK)->setIcon('fa-stop white')->setName(pht('Stopped')); $content3 = id(new PHUIBoxView())->appendChild($icons)->addPadding(PHUI::PADDING_LARGE); $shades = PHUITagView::getShades(); $tags = array(); foreach ($shades as $shade) { $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setShade($shade)->setIcon('fa-tags')->setName(ucwords($shade))->setHref('#'); $tags[] = hsprintf(' '); $tags[] = id(new PHUITagView())->setType(PHUITagView::TYPE_OBJECT)->setShade($shade)->setSlimShady(true)->setIcon('fa-tags')->setName(ucwords($shade))->setHref('#'); $tags[] = hsprintf('<br /><br />'); } $content4 = id(new PHUIBoxView())->appendChild($tags)->addPadding(PHUI::PADDING_LARGE); $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Inline'))->appendChild($intro); $box1 = id(new PHUIObjectBoxView())->setHeaderText(pht('Colors'))->appendChild($content1); $box2 = id(new PHUIObjectBoxView())->setHeaderText(pht('Holidays'))->appendChild($content2); $box3 = id(new PHUIObjectBoxView())->setHeaderText(pht('Icons'))->appendChild($content3); $box4 = id(new PHUIObjectBoxView())->setHeaderText(pht('Shades'))->appendChild($content4); return array($box, $box1, $box2, $box3, $box4); }
public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); $author_handle = $this->renderHandleLink($this->getAuthorPHID()); switch ($this->getTransactionType()) { case PhabricatorProjectTransaction::TYPE_NAME: if ($old === null) { return pht('%s created this project.', $author_handle); } else { return pht('%s renamed this project from "%s" to "%s".', $author_handle, $old, $new); } case PhabricatorProjectTransaction::TYPE_STATUS: if ($old == 0) { return pht('%s closed this project.', $author_handle); } else { return pht('%s reopened this project.', $author_handle); } case PhabricatorProjectTransaction::TYPE_IMAGE: // TODO: Some day, it would be nice to show the images. if (!$old) { return pht('%s set this project\'s image to %s.', $author_handle, $this->renderHandleLink($new)); } else { if (!$new) { return pht('%s removed this project\'s image.', $author_handle); } else { return pht('%s updated this project\'s image from %s to %s.', $author_handle, $this->renderHandleLink($old), $this->renderHandleLink($new)); } } case PhabricatorProjectTransaction::TYPE_ICON: return pht('%s set this project\'s icon to %s.', $author_handle, PhabricatorProjectIcon::getLabel($new)); case PhabricatorProjectTransaction::TYPE_COLOR: return pht('%s set this project\'s color to %s.', $author_handle, PHUITagView::getShadeName($new)); case PhabricatorProjectTransaction::TYPE_SLUGS: $add = array_diff($new, $old); $rem = array_diff($old, $new); if ($add && $rem) { return pht('%s changed project hashtag(s), added %d: %s; removed %d: %s', $author_handle, count($add), $this->renderSlugList($add), count($rem), $this->renderSlugList($rem)); } else { if ($add) { return pht('%s added %d project hashtag(s): %s', $author_handle, count($add), $this->renderSlugList($add)); } else { if ($rem) { return pht('%s removed %d project hashtag(s): %s', $author_handle, count($rem), $this->renderSlugList($rem)); } } } case PhabricatorProjectTransaction::TYPE_MEMBERS: $add = array_diff($new, $old); $rem = array_diff($old, $new); if ($add && $rem) { return pht('%s changed project member(s), added %d: %s; removed %d: %s', $author_handle, count($add), $this->renderHandleList($add), count($rem), $this->renderHandleList($rem)); } else { if ($add) { if (count($add) == 1 && head($add) == $this->getAuthorPHID()) { return pht('%s joined this project.', $author_handle); } else { return pht('%s added %d project member(s): %s', $author_handle, count($add), $this->renderHandleList($add)); } } else { if ($rem) { if (count($rem) == 1 && head($rem) == $this->getAuthorPHID()) { return pht('%s left this project.', $author_handle); } else { return pht('%s removed %d project member(s): %s', $author_handle, count($rem), $this->renderHandleList($rem)); } } } } } return parent::getTitle(); }