public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getApplicationURI('edit/' . $project->getID() . '/');
     require_celerity_resource('project-icon-css');
     Javelin::initBehavior('phabricator-tooltips');
     $project_icons = PhabricatorProjectIcon::getIconMap();
     if ($request->isFormPost()) {
         $v_icon = $request->getStr('icon');
         return id(new AphrontAjaxResponse())->setContent(array('value' => $v_icon, 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon)));
     }
     $ii = 0;
     $buttons = array();
     foreach ($project_icons as $icon => $label) {
         $view = id(new PHUIIconView())->setIconFont($icon);
         $aural = javelin_tag('span', array('aural' => true), pht('Choose "%s" Icon', $label));
         if ($icon == $project->getIcon()) {
             $class_extra = ' selected';
         } else {
             $class_extra = null;
         }
         $buttons[] = javelin_tag('button', array('class' => 'icon-button' . $class_extra, 'name' => 'icon', 'value' => $icon, 'type' => 'submit', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $label)), array($aural, $view));
         if (++$ii % 4 == 0) {
             $buttons[] = phutil_tag('br');
         }
     }
     $buttons = phutil_tag('div', array('class' => 'icon-grid'), $buttons);
     return $this->newDialog()->setTitle(pht('Choose Project Icon'))->appendChild($buttons)->addCancelButton($edit_uri);
 }
 private function getIconOptions()
 {
     $options = array();
     foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) {
         $options[$icon] = array(id(new PHUIIconView())->setIconFont($icon), ' ', $name);
     }
     return $options;
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $phids = $saved->getParameter('memberPHIDs', array());
     $member_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
     $status = $saved->getParameter('status');
     $name_match = $saved->getParameter('name');
     $icons = array_fuse($saved->getParameter('icons', array()));
     $colors = array_fuse($saved->getParameter('colors', array()));
     $icon_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Icons'));
     foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) {
         $image = id(new PHUIIconView())->setIconFont($icon);
         $icon_control->addCheckbox('icons[]', $icon, array($image, ' ', $name), isset($icons[$icon]));
     }
     $color_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Colors'));
     foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) {
         $tag = id(new PHUITagView())->setType(PHUITagView::TYPE_SHADE)->setShade($color)->setName($name);
         $color_control->addCheckbox('colors[]', $color, $tag, isset($colors[$color]));
     }
     $form->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel(pht('Name'))->setValue($name_match))->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('members')->setLabel(pht('Members'))->setValue($member_handles))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setOptions($this->getStatusOptions())->setValue($status))->appendChild($icon_control)->appendChild($color_control);
     $this->appendCustomFieldsToForm($form, $saved);
 }
 public static function renderIconForChooser($icon)
 {
     $project_icons = PhabricatorProjectIcon::getIconMap();
     return phutil_tag('span', array(), array(id(new PHUIIconView())->setIconFont($icon), ' ', idx($project_icons, $icon, pht('Unknown Icon'))));
 }