PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

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