Provide a rudimentary "Attached Files" curtain UI panel
[phabricator.git] / src / applications / files / controller / PhabricatorFileIconSetSelectController.php
blob379f9fa86e3405bf389f7f73a8f02a41466e8f61
1 <?php
3 final class PhabricatorFileIconSetSelectController
4 extends PhabricatorFileController {
6 public function handleRequest(AphrontRequest $request) {
7 $key = $request->getURIData('key');
9 $set = PhabricatorIconSet::getIconSetByKey($key);
10 if (!$set) {
11 return new Aphront404Response();
14 $v_icon = $request->getStr('icon');
15 if ($request->isFormPost()) {
16 $icon = $set->getIcon($v_icon);
18 if ($icon) {
19 $payload = array(
20 'value' => $icon->getKey(),
21 'display' => $set->renderIconForControl($icon),
24 return id(new AphrontAjaxResponse())
25 ->setContent($payload);
29 require_celerity_resource('phui-icon-set-selector-css');
30 Javelin::initBehavior('phabricator-tooltips');
32 $ii = 0;
33 $buttons = array();
34 $breakpoint = ceil(sqrt(count($set->getIcons())));
35 foreach ($set->getIcons() as $icon) {
36 $label = $icon->getLabel();
38 $view = id(new PHUIIconView())
39 ->setIcon($icon->getIcon());
41 $classes = array();
42 $classes[] = 'icon-button';
44 $is_selected = ($icon->getKey() == $v_icon);
46 if ($is_selected) {
47 $classes[] = 'selected';
50 $is_disabled = $icon->getIsDisabled();
51 if ($is_disabled && !$is_selected) {
52 continue;
55 $aural = javelin_tag(
56 'span',
57 array(
58 'aural' => true,
60 pht('Choose "%s" Icon', $label));
62 $buttons[] = javelin_tag(
63 'button',
64 array(
65 'class' => implode(' ', $classes),
66 'name' => 'icon',
67 'value' => $icon->getKey(),
68 'type' => 'submit',
69 'sigil' => 'has-tooltip',
70 'meta' => array(
71 'tip' => $label,
74 array(
75 $aural,
76 $view,
77 ));
79 if ((++$ii % $breakpoint) == 0) {
80 $buttons[] = phutil_tag('br');
84 $buttons = phutil_tag(
85 'div',
86 array(
87 'class' => 'icon-grid',
89 $buttons);
91 $dialog_title = $set->getSelectIconTitleText();
93 return $this->newDialog()
94 ->setTitle($dialog_title)
95 ->appendChild($buttons)
96 ->addCancelButton('/');