PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

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