[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorProjectEditIconController 4 extends PhabricatorProjectController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = idx($data, 'id'); 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 if ($this->id) { 17 $project = id(new PhabricatorProjectQuery()) 18 ->setViewer($viewer) 19 ->withIDs(array($this->id)) 20 ->requireCapabilities( 21 array( 22 PhabricatorPolicyCapability::CAN_VIEW, 23 PhabricatorPolicyCapability::CAN_EDIT, 24 )) 25 ->executeOne(); 26 if (!$project) { 27 return new Aphront404Response(); 28 } 29 $cancel_uri = $this->getApplicationURI('edit/'.$project->getID().'/'); 30 $project_icon = $project->getIcon(); 31 } else { 32 $this->requireApplicationCapability( 33 ProjectCreateProjectsCapability::CAPABILITY); 34 35 $cancel_uri = '/project/'; 36 $project_icon = $request->getStr('value'); 37 } 38 39 require_celerity_resource('project-icon-css'); 40 Javelin::initBehavior('phabricator-tooltips'); 41 42 $project_icons = PhabricatorProjectIcon::getIconMap(); 43 44 if ($request->isFormPost()) { 45 $v_icon = $request->getStr('icon'); 46 47 return id(new AphrontAjaxResponse())->setContent( 48 array( 49 'value' => $v_icon, 50 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon), 51 )); 52 } 53 54 $ii = 0; 55 $buttons = array(); 56 foreach ($project_icons as $icon => $label) { 57 $view = id(new PHUIIconView()) 58 ->setIconFont($icon); 59 60 $aural = javelin_tag( 61 'span', 62 array( 63 'aural' => true, 64 ), 65 pht('Choose "%s" Icon', $label)); 66 67 if ($icon == $project_icon) { 68 $class_extra = ' selected'; 69 } else { 70 $class_extra = null; 71 } 72 73 $buttons[] = javelin_tag( 74 'button', 75 array( 76 'class' => 'icon-button'.$class_extra, 77 'name' => 'icon', 78 'value' => $icon, 79 'type' => 'submit', 80 'sigil' => 'has-tooltip', 81 'meta' => array( 82 'tip' => $label, 83 ), 84 ), 85 array( 86 $aural, 87 $view, 88 )); 89 if ((++$ii % 4) == 0) { 90 $buttons[] = phutil_tag('br'); 91 } 92 } 93 94 $buttons = phutil_tag( 95 'div', 96 array( 97 'class' => 'icon-grid', 98 ), 99 $buttons); 100 101 return $this->newDialog() 102 ->setTitle(pht('Choose Project Icon')) 103 ->appendChild($buttons) 104 ->addCancelButton($cancel_uri); 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |