PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/applications/uiexample/examples/PHUITagExample.php

http://github.com/facebook/phabricator
PHP | 231 lines | 202 code | 29 blank | 0 comment | 0 complexity | dcc23e6145e3abb64cfcaf7c2904aa95 MD5 | raw file
Possible License(s): JSON, MPL-2.0-no-copyleft-exception, Apache-2.0, BSD-3-Clause, LGPL-2.0, MIT, LGPL-2.1, LGPL-3.0
  1. <?php
  2. final class PHUITagExample extends PhabricatorUIExample {
  3. public function getName() {
  4. return pht('Tags');
  5. }
  6. public function getDescription() {
  7. return pht(
  8. 'Use %s to render various tags.',
  9. phutil_tag('tt', array(), 'PHUITagView'));
  10. }
  11. public function renderExample() {
  12. $intro = array();
  13. $intro[] = 'Hey, ';
  14. $intro[] = id(new PHUITagView())
  15. ->setType(PHUITagView::TYPE_PERSON)
  16. ->setName('@alincoln')
  17. ->setHref('#');
  18. $intro[] = ' how is stuff?';
  19. $intro[] = hsprintf('<br /><br />');
  20. $intro[] = 'Did you hear that ';
  21. $intro[] = id(new PHUITagView())
  22. ->setType(PHUITagView::TYPE_PERSON)
  23. ->setName('@gwashington')
  24. ->setDotColor(PHUITagView::COLOR_RED)
  25. ->setHref('#');
  26. $intro[] = ' is away, ';
  27. $intro[] = id(new PHUITagView())
  28. ->setType(PHUITagView::TYPE_PERSON)
  29. ->setName('@tjefferson')
  30. ->setDotColor(PHUITagView::COLOR_ORANGE)
  31. ->setHref('#');
  32. $intro[] = ' has some errands, and ';
  33. $intro[] = id(new PHUITagView())
  34. ->setType(PHUITagView::TYPE_PERSON)
  35. ->setName('@rreagan')
  36. ->setDotColor(PHUITagView::COLOR_GREY)
  37. ->setHref('#');
  38. $intro[] = ' is gone?';
  39. $intro[] = hsprintf('<br /><br />');
  40. $intro[] = 'Take a look at ';
  41. $intro[] = id(new PHUITagView())
  42. ->setType(PHUITagView::TYPE_OBJECT)
  43. ->setName('D123')
  44. ->setHref('#');
  45. $intro[] = ' when you get a chance.';
  46. $intro[] = hsprintf('<br /><br />');
  47. $intro[] = 'Hmm? ';
  48. $intro[] = id(new PHUITagView())
  49. ->setType(PHUITagView::TYPE_OBJECT)
  50. ->setName('D123')
  51. ->setClosed(true)
  52. ->setHref('#');
  53. $intro[] = ' is ';
  54. $intro[] = id(new PHUITagView())
  55. ->setType(PHUITagView::TYPE_STATE)
  56. ->setBackgroundColor(PHUITagView::COLOR_BLACK)
  57. ->setName('Abandoned');
  58. $intro[] = '.';
  59. $intro[] = hsprintf('<br /><br />');
  60. $intro[] = 'I hope someone is going to ';
  61. $intro[] = id(new PHUITagView())
  62. ->setType(PHUITagView::TYPE_OBJECT)
  63. ->setName('T123: Water The Dog')
  64. ->setHref('#');
  65. $intro[] = ' -- that task is ';
  66. $intro[] = id(new PHUITagView())
  67. ->setType(PHUITagView::TYPE_STATE)
  68. ->setBackgroundColor(PHUITagView::COLOR_RED)
  69. ->setName('High Priority');
  70. $intro[] = '!';
  71. $intro = id(new PHUIBoxView())
  72. ->appendChild($intro)
  73. ->addPadding(PHUI::PADDING_LARGE);
  74. $header1 = id(new PHUIHeaderView())
  75. ->setHeader('Colors');
  76. $colors = PHUITagView::getColors();
  77. $tags = array();
  78. foreach ($colors as $color) {
  79. $tags[] = id(new PHUITagView())
  80. ->setType(PHUITagView::TYPE_STATE)
  81. ->setBackgroundColor($color)
  82. ->setName(ucwords($color));
  83. $tags[] = hsprintf('<br /><br />');
  84. }
  85. $content1 = id(new PHUIBoxView())
  86. ->appendChild($tags)
  87. ->addPadding(PHUI::PADDING_LARGE);
  88. $tags = array();
  89. $tags[] = id(new PHUITagView())
  90. ->setType(PHUITagView::TYPE_STATE)
  91. ->setBackgroundColor(PHUITagView::COLOR_GREEN)
  92. ->setDotColor(PHUITagView::COLOR_RED)
  93. ->setName(pht('Christmas'));
  94. $tags[] = hsprintf('<br /><br />');
  95. $tags[] = id(new PHUITagView())
  96. ->setType(PHUITagView::TYPE_OBJECT)
  97. ->setBackgroundColor(PHUITagView::COLOR_ORANGE)
  98. ->setDotColor(PHUITagView::COLOR_BLACK)
  99. ->setName(pht('Halloween'));
  100. $tags[] = hsprintf('<br /><br />');
  101. $tags[] = id(new PHUITagView())
  102. ->setType(PHUITagView::TYPE_STATE)
  103. ->setBackgroundColor(PHUITagView::COLOR_INDIGO)
  104. ->setDotColor(PHUITagView::COLOR_YELLOW)
  105. ->setName(pht('Easter'));
  106. $content2 = id(new PHUIBoxView())
  107. ->appendChild($tags)
  108. ->addPadding(PHUI::PADDING_LARGE);
  109. $icons = array();
  110. $icons[] = id(new PHUITagView())
  111. ->setType(PHUITagView::TYPE_STATE)
  112. ->setBackgroundColor(PHUITagView::COLOR_GREEN)
  113. ->setIcon('fa-check white')
  114. ->setName(pht('Passed'));
  115. $icons[] = hsprintf('<br /><br />');
  116. $icons[] = id(new PHUITagView())
  117. ->setType(PHUITagView::TYPE_STATE)
  118. ->setBackgroundColor(PHUITagView::COLOR_RED)
  119. ->setIcon('fa-times white')
  120. ->setName(pht('Failed'));
  121. $icons[] = hsprintf('<br /><br />');
  122. $icons[] = id(new PHUITagView())
  123. ->setType(PHUITagView::TYPE_STATE)
  124. ->setBackgroundColor(PHUITagView::COLOR_BLUE)
  125. ->setIcon('fa-refresh white')
  126. ->setName(pht('Running'));
  127. $icons[] = hsprintf('<br /><br />');
  128. $icons[] = id(new PHUITagView())
  129. ->setType(PHUITagView::TYPE_STATE)
  130. ->setBackgroundColor(PHUITagView::COLOR_GREY)
  131. ->setIcon('fa-pause white')
  132. ->setName(pht('Paused'));
  133. $icons[] = hsprintf('<br /><br />');
  134. $icons[] = id(new PHUITagView())
  135. ->setType(PHUITagView::TYPE_STATE)
  136. ->setBackgroundColor(PHUITagView::COLOR_BLACK)
  137. ->setIcon('fa-stop white')
  138. ->setName(pht('Stopped'));
  139. $content3 = id(new PHUIBoxView())
  140. ->appendChild($icons)
  141. ->addPadding(PHUI::PADDING_LARGE);
  142. $shades = PHUITagView::getShades();
  143. $tags = array();
  144. foreach ($shades as $shade) {
  145. $tags[] = id(new PHUITagView())
  146. ->setType(PHUITagView::TYPE_SHADE)
  147. ->setColor($shade)
  148. ->setIcon('fa-tags')
  149. ->setName(ucwords($shade))
  150. ->setHref('#');
  151. $tags[] = hsprintf('&nbsp;');
  152. $tags[] = id(new PHUITagView())
  153. ->setType(PHUITagView::TYPE_SHADE)
  154. ->setColor($shade)
  155. ->setSlimShady(true)
  156. ->setIcon('fa-tags')
  157. ->setName(ucwords($shade))
  158. ->setHref('#');
  159. $tags[] = hsprintf('<br /><br />');
  160. }
  161. $content4 = id(new PHUIBoxView())
  162. ->appendChild($tags)
  163. ->addPadding(PHUI::PADDING_LARGE);
  164. $outlines = PHUITagView::getOutlines();
  165. $tags = array();
  166. foreach ($outlines as $outline) {
  167. $tags[] = id(new PHUITagView())
  168. ->setType(PHUITagView::TYPE_OUTLINE)
  169. ->setColor($outline)
  170. ->setName($outline);
  171. $tags[] = hsprintf('&nbsp;');
  172. $tags[] = id(new PHUITagView())
  173. ->setType(PHUITagView::TYPE_OUTLINE)
  174. ->setColor($outline)
  175. ->setSlimShady(true)
  176. ->setName($outline);
  177. $tags[] = hsprintf('<br /><br />');
  178. }
  179. $content5 = id(new PHUIBoxView())
  180. ->appendChild($tags)
  181. ->addPadding(PHUI::PADDING_LARGE);
  182. $box = id(new PHUIObjectBoxView())
  183. ->setHeaderText(pht('Inline'))
  184. ->appendChild($intro);
  185. $box1 = id(new PHUIObjectBoxView())
  186. ->setHeaderText(pht('Colors'))
  187. ->appendChild($content1);
  188. $box2 = id(new PHUIObjectBoxView())
  189. ->setHeaderText(pht('Holidays'))
  190. ->appendChild($content2);
  191. $box3 = id(new PHUIObjectBoxView())
  192. ->setHeaderText(pht('Icons'))
  193. ->appendChild($content3);
  194. $box4 = id(new PHUIObjectBoxView())
  195. ->setHeaderText(pht('Shades'))
  196. ->appendChild($content4);
  197. $box5 = id(new PHUIObjectBoxView())
  198. ->setHeaderText(pht('Outlines'))
  199. ->appendChild($content5);
  200. return array($box, $box1, $box2, $box3, $box4, $box5);
  201. }
  202. }