@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide a "PHUIFormIconSetControl"

Summary:
Ref T9992. This is a step on the path to getting EditEngine working in Badges, Projects and Calendar.

This doesn't add a new `EditField` for icons yet, just standardizes the old stuff. New stuff is more general and I saved 150 lines of code.

I put the endpoint in Files because the similar "choose a profile picture" endpoint will definitely go there, and this endpoint might eventually feature, like, "draw your own icon~~" or something.

Test Plan:
- Created events, projects and badges with custom icons.
- Edited events, projects and badges, changing their icons.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9992

Differential Revision: https://secure.phabricator.com/D14799

+505 -650
+11 -11
resources/celerity/map.php
··· 7 7 */ 8 8 return array( 9 9 'names' => array( 10 - 'core.pkg.css' => '6d8c526d', 10 + 'core.pkg.css' => '8378907a', 11 11 'core.pkg.js' => 'c60f35d8', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => '2de124c9', ··· 131 131 'rsrc/css/phui/phui-document.css' => 'a4a1c3b9', 132 132 'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23', 133 133 'rsrc/css/phui/phui-fontkit.css' => '9cda225e', 134 - 'rsrc/css/phui/phui-form-view.css' => 'c1d2ef29', 134 + 'rsrc/css/phui/phui-form-view.css' => 'cf7da606', 135 135 'rsrc/css/phui/phui-form.css' => 'afdb2c6e', 136 136 'rsrc/css/phui/phui-header-view.css' => '55bb32dd', 137 137 'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6', ··· 464 464 'rsrc/js/core/behavior-active-nav.js' => 'e379b58e', 465 465 'rsrc/js/core/behavior-audio-source.js' => '59b251eb', 466 466 'rsrc/js/core/behavior-autofocus.js' => '7319e029', 467 - 'rsrc/js/core/behavior-choose-control.js' => '6153c708', 467 + 'rsrc/js/core/behavior-choose-control.js' => 'dfaafb14', 468 468 'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2', 469 469 'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae', 470 470 'rsrc/js/core/behavior-device.js' => 'a205cf28', ··· 570 570 'javelin-behavior-audio-source' => '59b251eb', 571 571 'javelin-behavior-audit-preview' => 'd835b03a', 572 572 'javelin-behavior-bulk-job-reload' => 'edf8a145', 573 - 'javelin-behavior-choose-control' => '6153c708', 573 + 'javelin-behavior-choose-control' => 'dfaafb14', 574 574 'javelin-behavior-comment-actions' => 'bb0d2d0c', 575 575 'javelin-behavior-config-reorder-fields' => 'b6993408', 576 576 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', ··· 805 805 'phui-font-icon-base-css' => 'ecbbb4c2', 806 806 'phui-fontkit-css' => '9cda225e', 807 807 'phui-form-css' => 'afdb2c6e', 808 - 'phui-form-view-css' => 'c1d2ef29', 808 + 'phui-form-view-css' => 'cf7da606', 809 809 'phui-header-view-css' => '55bb32dd', 810 810 'phui-icon-view-css' => 'b0a6b1b6', 811 811 'phui-image-mask-css' => '5a8b09c8', ··· 1266 1266 'javelin-stratcom', 1267 1267 'javelin-dom', 1268 1268 ), 1269 - '6153c708' => array( 1270 - 'javelin-behavior', 1271 - 'javelin-stratcom', 1272 - 'javelin-dom', 1273 - 'javelin-workflow', 1274 - ), 1275 1269 '61cbc29a' => array( 1276 1270 'javelin-magical-init', 1277 1271 'javelin-util', ··· 1889 1883 ), 1890 1884 'df5e11d2' => array( 1891 1885 'javelin-install', 1886 + ), 1887 + 'dfaafb14' => array( 1888 + 'javelin-behavior', 1889 + 'javelin-stratcom', 1890 + 'javelin-dom', 1891 + 'javelin-workflow', 1892 1892 ), 1893 1893 'e10f8e18' => array( 1894 1894 'javelin-behavior',
+14 -14
src/__phutil_library_map__.php
··· 114 114 'AphrontException' => 'aphront/exception/AphrontException.php', 115 115 'AphrontFileResponse' => 'aphront/response/AphrontFileResponse.php', 116 116 'AphrontFormCheckboxControl' => 'view/form/control/AphrontFormCheckboxControl.php', 117 - 'AphrontFormChooseButtonControl' => 'view/form/control/AphrontFormChooseButtonControl.php', 118 117 'AphrontFormControl' => 'view/form/control/AphrontFormControl.php', 119 118 'AphrontFormDateControl' => 'view/form/control/AphrontFormDateControl.php', 120 119 'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php', ··· 1474 1473 'PHUIFeedStoryView' => 'view/phui/PHUIFeedStoryView.php', 1475 1474 'PHUIFormDividerControl' => 'view/form/control/PHUIFormDividerControl.php', 1476 1475 'PHUIFormFreeformDateControl' => 'view/form/control/PHUIFormFreeformDateControl.php', 1476 + 'PHUIFormIconSetControl' => 'view/form/control/PHUIFormIconSetControl.php', 1477 1477 'PHUIFormInsetView' => 'view/form/PHUIFormInsetView.php', 1478 1478 'PHUIFormLayoutView' => 'view/form/PHUIFormLayoutView.php', 1479 1479 'PHUIFormMultiSubmitControl' => 'view/form/control/PHUIFormMultiSubmitControl.php', ··· 1774 1774 'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php', 1775 1775 'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php', 1776 1776 'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php', 1777 - 'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php', 1778 1777 'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php', 1779 1778 'PhabricatorBadgesEditor' => 'applications/badges/editor/PhabricatorBadgesEditor.php', 1780 - 'PhabricatorBadgesIcon' => 'applications/badges/icon/PhabricatorBadgesIcon.php', 1779 + 'PhabricatorBadgesIconSet' => 'applications/badges/icon/PhabricatorBadgesIconSet.php', 1781 1780 'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php', 1782 1781 'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php', 1783 1782 'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php', ··· 1833 1832 'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php', 1834 1833 'PhabricatorCalendarEventDragController' => 'applications/calendar/controller/PhabricatorCalendarEventDragController.php', 1835 1834 'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php', 1836 - 'PhabricatorCalendarEventEditIconController' => 'applications/calendar/controller/PhabricatorCalendarEventEditIconController.php', 1837 1835 'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php', 1838 1836 'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php', 1839 1837 'PhabricatorCalendarEventInvitee' => 'applications/calendar/storage/PhabricatorCalendarEventInvitee.php', ··· 1852 1850 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 1853 1851 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 1854 1852 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 1855 - 'PhabricatorCalendarIcon' => 'applications/calendar/icon/PhabricatorCalendarIcon.php', 1853 + 'PhabricatorCalendarIconSet' => 'applications/calendar/icon/PhabricatorCalendarIconSet.php', 1856 1854 'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php', 1857 1855 'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php', 1858 1856 'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php', ··· 2263 2261 'PhabricatorFileEditor' => 'applications/files/editor/PhabricatorFileEditor.php', 2264 2262 'PhabricatorFileFilePHIDType' => 'applications/files/phid/PhabricatorFileFilePHIDType.php', 2265 2263 'PhabricatorFileHasObjectEdgeType' => 'applications/files/edge/PhabricatorFileHasObjectEdgeType.php', 2264 + 'PhabricatorFileIconSetSelectController' => 'applications/files/controller/PhabricatorFileIconSetSelectController.php', 2266 2265 'PhabricatorFileImageMacro' => 'applications/macro/storage/PhabricatorFileImageMacro.php', 2267 2266 'PhabricatorFileImageTransform' => 'applications/files/transform/PhabricatorFileImageTransform.php', 2268 2267 'PhabricatorFileInfoController' => 'applications/files/controller/PhabricatorFileInfoController.php', ··· 2359 2358 'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php', 2360 2359 'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php', 2361 2360 'PhabricatorIconRemarkupRule' => 'applications/macro/markup/PhabricatorIconRemarkupRule.php', 2361 + 'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php', 2362 + 'PhabricatorIconSetIcon' => 'applications/files/iconset/PhabricatorIconSetIcon.php', 2362 2363 'PhabricatorImageMacroRemarkupRule' => 'applications/macro/markup/PhabricatorImageMacroRemarkupRule.php', 2363 2364 'PhabricatorImageTransformer' => 'applications/files/PhabricatorImageTransformer.php', 2364 2365 'PhabricatorImagemagickSetupCheck' => 'applications/config/check/PhabricatorImagemagickSetupCheck.php', ··· 2809 2810 'PhabricatorProjectDatasource' => 'applications/project/typeahead/PhabricatorProjectDatasource.php', 2810 2811 'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php', 2811 2812 'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php', 2812 - 'PhabricatorProjectEditIconController' => 'applications/project/controller/PhabricatorProjectEditIconController.php', 2813 2813 'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php', 2814 2814 'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php', 2815 2815 'PhabricatorProjectFeedController' => 'applications/project/controller/PhabricatorProjectFeedController.php', 2816 2816 'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php', 2817 - 'PhabricatorProjectIcon' => 'applications/project/icon/PhabricatorProjectIcon.php', 2817 + 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php', 2818 2818 'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php', 2819 2819 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 2820 2820 'PhabricatorProjectLogicalAndDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAndDatasource.php', ··· 3973 3973 'AphrontException' => 'Exception', 3974 3974 'AphrontFileResponse' => 'AphrontResponse', 3975 3975 'AphrontFormCheckboxControl' => 'AphrontFormControl', 3976 - 'AphrontFormChooseButtonControl' => 'AphrontFormControl', 3977 3976 'AphrontFormControl' => 'AphrontView', 3978 3977 'AphrontFormDateControl' => 'AphrontFormControl', 3979 3978 'AphrontFormDateControlValue' => 'Phobject', ··· 5527 5526 'PHUIFeedStoryView' => 'AphrontView', 5528 5527 'PHUIFormDividerControl' => 'AphrontFormControl', 5529 5528 'PHUIFormFreeformDateControl' => 'AphrontFormControl', 5529 + 'PHUIFormIconSetControl' => 'AphrontFormControl', 5530 5530 'PHUIFormInsetView' => 'AphrontView', 5531 5531 'PHUIFormLayoutView' => 'AphrontView', 5532 5532 'PHUIFormMultiSubmitControl' => 'AphrontFormControl', ··· 5873 5873 'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO', 5874 5874 'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability', 5875 5875 'PhabricatorBadgesEditController' => 'PhabricatorBadgesController', 5876 - 'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController', 5877 5876 'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController', 5878 5877 'PhabricatorBadgesEditor' => 'PhabricatorApplicationTransactionEditor', 5879 - 'PhabricatorBadgesIcon' => 'Phobject', 5878 + 'PhabricatorBadgesIconSet' => 'PhabricatorIconSet', 5880 5879 'PhabricatorBadgesListController' => 'PhabricatorBadgesController', 5881 5880 'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver', 5882 5881 'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType', ··· 5944 5943 'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController', 5945 5944 'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController', 5946 5945 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', 5947 - 'PhabricatorCalendarEventEditIconController' => 'PhabricatorCalendarController', 5948 5946 'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor', 5949 5947 'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand', 5950 5948 'PhabricatorCalendarEventInvitee' => array( ··· 5966 5964 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController', 5967 5965 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 5968 5966 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 5969 - 'PhabricatorCalendarIcon' => 'Phobject', 5967 + 'PhabricatorCalendarIconSet' => 'PhabricatorIconSet', 5970 5968 'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule', 5971 5969 'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 5972 5970 'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec', ··· 6452 6450 'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor', 6453 6451 'PhabricatorFileFilePHIDType' => 'PhabricatorPHIDType', 6454 6452 'PhabricatorFileHasObjectEdgeType' => 'PhabricatorEdgeType', 6453 + 'PhabricatorFileIconSetSelectController' => 'PhabricatorFileController', 6455 6454 'PhabricatorFileImageMacro' => array( 6456 6455 'PhabricatorFileDAO', 6457 6456 'PhabricatorSubscribableInterface', ··· 6563 6562 'PhabricatorIDsSearchField' => 'PhabricatorSearchField', 6564 6563 'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter', 6565 6564 'PhabricatorIconRemarkupRule' => 'PhutilRemarkupRule', 6565 + 'PhabricatorIconSet' => 'Phobject', 6566 + 'PhabricatorIconSetIcon' => 'Phobject', 6566 6567 'PhabricatorImageMacroRemarkupRule' => 'PhutilRemarkupRule', 6567 6568 'PhabricatorImageTransformer' => 'Phobject', 6568 6569 'PhabricatorImagemagickSetupCheck' => 'PhabricatorSetupCheck', ··· 7095 7096 'PhabricatorProjectDatasource' => 'PhabricatorTypeaheadDatasource', 7096 7097 'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField', 7097 7098 'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController', 7098 - 'PhabricatorProjectEditIconController' => 'PhabricatorProjectController', 7099 7099 'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController', 7100 7100 'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase', 7101 7101 'PhabricatorProjectFeedController' => 'PhabricatorProjectController', 7102 7102 'PhabricatorProjectHeraldAction' => 'HeraldAction', 7103 - 'PhabricatorProjectIcon' => 'Phobject', 7103 + 'PhabricatorProjectIconSet' => 'PhabricatorIconSet', 7104 7104 'PhabricatorProjectListController' => 'PhabricatorProjectController', 7105 7105 'PhabricatorProjectLogicalAndDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7106 7106 'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
-4
src/applications/badges/application/PhabricatorBadgesApplication.php
··· 49 49 => 'PhabricatorBadgesArchiveController', 50 50 'view/(?:(?P<id>\d+)/)?' 51 51 => 'PhabricatorBadgesViewController', 52 - 'icon/(?P<id>[1-9]\d*)/' 53 - => 'PhabricatorBadgesEditIconController', 54 - 'icon/' 55 - => 'PhabricatorBadgesEditIconController', 56 52 'recipients/(?P<id>[1-9]\d*)/' 57 53 => 'PhabricatorBadgesEditRecipientsController', 58 54 'recipients/(?P<id>[1-9]\d*)/remove/'
+2 -11
src/applications/badges/controller/PhabricatorBadgesEditController.php
··· 111 111 } 112 112 } 113 113 114 - if ($is_new) { 115 - $icon_uri = $this->getApplicationURI('icon/'); 116 - } else { 117 - $icon_uri = $this->getApplicationURI('icon/'.$badge->getID().'/'); 118 - } 119 - $icon_display = PhabricatorBadgesIcon::renderIconForChooser($v_icon); 120 - 121 114 $policies = id(new PhabricatorPolicyQuery()) 122 115 ->setViewer($viewer) 123 116 ->setObject($badge) ··· 137 130 ->setLabel(pht('Flavor Text')) 138 131 ->setValue($v_flav)) 139 132 ->appendChild( 140 - id(new AphrontFormChooseButtonControl()) 133 + id(new PHUIFormIconSetControl()) 141 134 ->setLabel(pht('Icon')) 142 135 ->setName('icon') 143 - ->setDisplayValue($icon_display) 144 - ->setButtonText(pht('Choose Icon...')) 145 - ->setChooseURI($icon_uri) 136 + ->setIconSet(new PhabricatorBadgesIconSet()) 146 137 ->setValue($v_icon)) 147 138 ->appendChild( 148 139 id(new AphrontFormSelectControl())
-101
src/applications/badges/controller/PhabricatorBadgesEditIconController.php
··· 1 - <?php 2 - 3 - final class PhabricatorBadgesEditIconController 4 - extends PhabricatorBadgesController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - $id = $request->getURIData('id'); 9 - 10 - if ($id) { 11 - $badge = id(new PhabricatorBadgesQuery()) 12 - ->setViewer($viewer) 13 - ->withIDs(array($id)) 14 - ->requireCapabilities( 15 - array( 16 - PhabricatorPolicyCapability::CAN_VIEW, 17 - PhabricatorPolicyCapability::CAN_EDIT, 18 - )) 19 - ->executeOne(); 20 - if (!$badge) { 21 - return new Aphront404Response(); 22 - } 23 - $cancel_uri = 24 - $this->getApplicationURI('view/'.$badge->getID().'/'); 25 - $badge_icon = $badge->getIcon(); 26 - } else { 27 - $this->requireApplicationCapability( 28 - PhabricatorBadgesCreateCapability::CAPABILITY); 29 - 30 - $cancel_uri = '/badges/'; 31 - $badge_icon = $request->getStr('value'); 32 - } 33 - 34 - require_celerity_resource('project-icon-css'); 35 - Javelin::initBehavior('phabricator-tooltips'); 36 - 37 - $badge_icons = PhabricatorBadgesIcon::getIconMap(); 38 - 39 - if ($request->isFormPost()) { 40 - $v_icon = $request->getStr('icon'); 41 - 42 - return id(new AphrontAjaxResponse())->setContent( 43 - array( 44 - 'value' => $v_icon, 45 - 'display' => PhabricatorBadgesIcon::renderIconForChooser($v_icon), 46 - )); 47 - } 48 - 49 - $ii = 0; 50 - $buttons = array(); 51 - foreach ($badge_icons as $icon => $label) { 52 - $view = id(new PHUIIconView()) 53 - ->setIconFont($icon); 54 - 55 - $aural = javelin_tag( 56 - 'span', 57 - array( 58 - 'aural' => true, 59 - ), 60 - pht('Choose "%s" Icon', $label)); 61 - 62 - if ($icon == $badge_icon) { 63 - $class_extra = ' selected'; 64 - } else { 65 - $class_extra = null; 66 - } 67 - 68 - $buttons[] = javelin_tag( 69 - 'button', 70 - array( 71 - 'class' => 'icon-button'.$class_extra, 72 - 'name' => 'icon', 73 - 'value' => $icon, 74 - 'type' => 'submit', 75 - 'sigil' => 'has-tooltip', 76 - 'meta' => array( 77 - 'tip' => $label, 78 - ), 79 - ), 80 - array( 81 - $aural, 82 - $view, 83 - )); 84 - if ((++$ii % 4) == 0) { 85 - $buttons[] = phutil_tag('br'); 86 - } 87 - } 88 - 89 - $buttons = phutil_tag( 90 - 'div', 91 - array( 92 - 'class' => 'icon-grid', 93 - ), 94 - $buttons); 95 - 96 - return $this->newDialog() 97 - ->setTitle(pht('Choose Badge Icon')) 98 - ->appendChild($buttons) 99 - ->addCancelButton($cancel_uri); 100 - } 101 - }
+2 -2
src/applications/badges/controller/PhabricatorBadgesViewController.php
··· 85 85 ->setObject($badge); 86 86 87 87 $quality = idx($badge->getQualityNameMap(), $badge->getQuality()); 88 - $icon = idx($badge->getIconNameMap(), $badge->getIcon()); 89 88 90 89 $view->addProperty( 91 90 pht('Quality'), ··· 93 92 94 93 $view->addProperty( 95 94 pht('Icon'), 96 - $icon); 95 + id(new PhabricatorBadgesIconSet()) 96 + ->getIconLabel($badge->getIcon())); 97 97 98 98 $view->addProperty( 99 99 pht('Flavor'),
-53
src/applications/badges/icon/PhabricatorBadgesIcon.php
··· 1 - <?php 2 - 3 - final class PhabricatorBadgesIcon extends Phobject { 4 - 5 - public static function getIconMap() { 6 - return 7 - array( 8 - 'fa-star' => pht('Superstar'), 9 - 'fa-user' => pht('Average Person'), 10 - 'fa-bug' => pht('Ladybug'), 11 - 'fa-users' => pht('Triplets'), 12 - 13 - 'fa-book' => pht('Nominomicon'), 14 - 'fa-rocket' => pht('Escape Route'), 15 - 'fa-life-ring' => pht('Foam Circle'), 16 - 'fa-birthday-cake' => pht('Cake Day'), 17 - 18 - 'fa-camera-retro' => pht('Leica Enthusiast'), 19 - 'fa-beer' => pht('Liquid Lunch'), 20 - 'fa-gift' => pht('Free Stuff'), 21 - 'fa-eye' => pht('Eye See You'), 22 - 23 - 'fa-heart' => pht('Love is Love'), 24 - 'fa-trophy' => pht('Winner at Things'), 25 - 'fa-umbrella' => pht('Rain Defender'), 26 - 'fa-graduation-cap' => pht('In Debt'), 27 - 28 - ); 29 - } 30 - 31 - public static function getLabel($key) { 32 - $map = self::getIconMap(); 33 - return $map[$key]; 34 - } 35 - 36 - public static function getAPIName($key) { 37 - return substr($key, 3); 38 - } 39 - 40 - public static function renderIconForChooser($icon) { 41 - $badge_icons = self::getIconMap(); 42 - 43 - return phutil_tag( 44 - 'span', 45 - array(), 46 - array( 47 - id(new PHUIIconView())->setIconFont($icon), 48 - ' ', 49 - idx($badge_icons, $icon, pht('Unknown Icon')), 50 - )); 51 - } 52 - 53 - }
+45
src/applications/badges/icon/PhabricatorBadgesIconSet.php
··· 1 + <?php 2 + 3 + final class PhabricatorBadgesIconSet 4 + extends PhabricatorIconSet { 5 + 6 + const ICONSETKEY = 'badges'; 7 + 8 + public function getSelectIconTitleText() { 9 + return pht('Choose Badge Icon'); 10 + } 11 + 12 + protected function newIcons() { 13 + $map = array( 14 + 'fa-star' => pht('Superstar'), 15 + 'fa-user' => pht('Average Person'), 16 + 'fa-bug' => pht('Ladybug'), 17 + 'fa-users' => pht('Triplets'), 18 + 19 + 'fa-book' => pht('Nominomicon'), 20 + 'fa-rocket' => pht('Escape Route'), 21 + 'fa-life-ring' => pht('Foam Circle'), 22 + 'fa-birthday-cake' => pht('Cake Day'), 23 + 24 + 'fa-camera-retro' => pht('Leica Enthusiast'), 25 + 'fa-beer' => pht('Liquid Lunch'), 26 + 'fa-gift' => pht('Free Stuff'), 27 + 'fa-eye' => pht('Eye See You'), 28 + 29 + 'fa-heart' => pht('Love is Love'), 30 + 'fa-trophy' => pht('Winner at Things'), 31 + 'fa-umbrella' => pht('Rain Defender'), 32 + 'fa-graduation-cap' => pht('In Debt'), 33 + ); 34 + 35 + $icons = array(); 36 + foreach ($map as $key => $label) { 37 + $icons[] = id(new PhabricatorIconSetIcon()) 38 + ->setKey($key) 39 + ->setLabel($label); 40 + } 41 + 42 + return $icons; 43 + } 44 + 45 + }
-4
src/applications/badges/storage/PhabricatorBadgesBadge.php
··· 54 54 ); 55 55 } 56 56 57 - public static function getIconNameMap() { 58 - return PhabricatorBadgesIcon::getIconMap(); 59 - } 60 - 61 57 public static function initializeNewBadge(PhabricatorUser $actor) { 62 58 $app = id(new PhabricatorApplicationQuery()) 63 59 ->setViewer($actor)
+5 -3
src/applications/badges/storage/PhabricatorBadgesTransaction.php
··· 78 78 $this->renderHandleLink($author_phid), 79 79 $new); 80 80 } else { 81 - $icon_map = PhabricatorBadgesBadge::getIconNameMap(); 82 - $icon_new = idx($icon_map, $new, $new); 83 - $icon_old = idx($icon_map, $old, $old); 81 + $set = new PhabricatorBadgesIconSet(); 82 + 83 + $icon_old = $set->getIconLabel($old); 84 + $icon_new = $set->getIconLabel($new); 85 + 84 86 return pht( 85 87 '%s updated the icon for this badge from "%s" to "%s".', 86 88 $this->renderHandleLink($author_phid),
-4
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 46 46 '(?:query/(?P<queryKey>[^/]+)/(?:(?P<year>\d+)/'. 47 47 '(?P<month>\d+)/)?(?:(?P<day>\d+)/)?)?' 48 48 => 'PhabricatorCalendarEventListController', 49 - 'icon/(?P<id>[1-9]\d*)/' 50 - => 'PhabricatorCalendarEventEditIconController', 51 - 'icon/' 52 - => 'PhabricatorCalendarEventEditIconController', 53 49 'event/' => array( 54 50 'create/' 55 51 => 'PhabricatorCalendarEventEditController',
+3 -10
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 499 499 ->setUser($viewer) 500 500 ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); 501 501 502 - if ($this->isCreate()) { 503 - $icon_uri = $this->getApplicationURI('icon/'); 504 - } else { 505 - $icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/'); 506 - } 507 - $icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon); 508 - $icon = id(new AphrontFormChooseButtonControl()) 502 + 503 + $icon = id(new PHUIFormIconSetControl()) 509 504 ->setLabel(pht('Icon')) 510 505 ->setName('icon') 511 - ->setDisplayValue($icon_display) 512 - ->setButtonText(pht('Choose Icon...')) 513 - ->setChooseURI($icon_uri) 506 + ->setIconSet(new PhabricatorCalendarIconSet()) 514 507 ->setValue($icon); 515 508 516 509 $form = id(new AphrontFormView())
-97
src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php
··· 1 - <?php 2 - 3 - final class PhabricatorCalendarEventEditIconController 4 - extends PhabricatorCalendarController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getUser(); 8 - $id = $request->getURIData('id'); 9 - 10 - if ($id) { 11 - $event = id(new PhabricatorCalendarEventQuery()) 12 - ->setViewer($viewer) 13 - ->withIDs(array($id)) 14 - ->requireCapabilities( 15 - array( 16 - PhabricatorPolicyCapability::CAN_VIEW, 17 - PhabricatorPolicyCapability::CAN_EDIT, 18 - )) 19 - ->executeOne(); 20 - if (!$event) { 21 - return new Aphront404Response(); 22 - } 23 - $cancel_uri = $this->getApplicationURI('/E'.$event->getID()); 24 - $event_icon = $event->getIcon(); 25 - } else { 26 - $cancel_uri = '/calendar/'; 27 - $event_icon = $request->getStr('value'); 28 - } 29 - 30 - require_celerity_resource('calendar-icon-css'); 31 - Javelin::initBehavior('phabricator-tooltips'); 32 - 33 - $calendar_icons = PhabricatorCalendarIcon::getIconMap(); 34 - 35 - if ($request->isFormPost()) { 36 - $v_icon = $request->getStr('icon'); 37 - 38 - return id(new AphrontAjaxResponse())->setContent( 39 - array( 40 - 'value' => $v_icon, 41 - 'display' => PhabricatorCalendarIcon::renderIconForChooser($v_icon), 42 - )); 43 - } 44 - 45 - $ii = 0; 46 - $buttons = array(); 47 - foreach ($calendar_icons as $icon => $label) { 48 - $view = id(new PHUIIconView()) 49 - ->setIconFont($icon); 50 - 51 - $aural = javelin_tag( 52 - 'span', 53 - array( 54 - 'aural' => true, 55 - ), 56 - pht('Choose "%s" Icon', $label)); 57 - 58 - if ($icon == $event_icon) { 59 - $class_extra = ' selected'; 60 - } else { 61 - $class_extra = null; 62 - } 63 - 64 - $buttons[] = javelin_tag( 65 - 'button', 66 - array( 67 - 'class' => 'icon-button'.$class_extra, 68 - 'name' => 'icon', 69 - 'value' => $icon, 70 - 'type' => 'submit', 71 - 'sigil' => 'has-tooltip', 72 - 'meta' => array( 73 - 'tip' => $label, 74 - ), 75 - ), 76 - array( 77 - $aural, 78 - $view, 79 - )); 80 - if ((++$ii % 4) == 0) { 81 - $buttons[] = phutil_tag('br'); 82 - } 83 - } 84 - 85 - $buttons = phutil_tag( 86 - 'div', 87 - array( 88 - 'class' => 'icon-grid', 89 - ), 90 - $buttons); 91 - 92 - return $this->newDialog() 93 - ->setTitle(pht('Choose Calendar Event Icon')) 94 - ->appendChild($buttons) 95 - ->addCancelButton($cancel_uri); 96 - } 97 - }
+2 -3
src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
··· 360 360 361 361 $properties->invokeWillRenderEvent(); 362 362 363 - $icon_display = PhabricatorCalendarIcon::renderIconForChooser( 364 - $event->getIcon()); 365 363 $properties->addProperty( 366 364 pht('Icon'), 367 - $icon_display); 365 + id(new PhabricatorCalendarIconSet()) 366 + ->getIconLabel($event->getIcon())); 368 367 369 368 if (strlen($event->getDescription())) { 370 369 $description = PhabricatorMarkupEngine::renderOneObject(
-49
src/applications/calendar/icon/PhabricatorCalendarIcon.php
··· 1 - <?php 2 - 3 - final class PhabricatorCalendarIcon extends Phobject { 4 - 5 - public static function getIconMap() { 6 - return 7 - array( 8 - 'fa-calendar' => pht('Default'), 9 - 'fa-glass' => pht('Party'), 10 - 'fa-plane' => pht('Travel'), 11 - 'fa-plus-square' => pht('Health / Appointment'), 12 - 'fa-rocket' => pht('Sabatical / Leave'), 13 - 'fa-home' => pht('Working From Home'), 14 - 'fa-tree' => pht('Holiday'), 15 - 'fa-gamepad' => pht('Staycation'), 16 - 'fa-coffee' => pht('Coffee Meeting'), 17 - 'fa-film' => pht('Movie'), 18 - 'fa-users' => pht('Meeting'), 19 - 'fa-cutlery' => pht('Meal'), 20 - 'fa-paw' => pht('Pet Activity'), 21 - 'fa-institution' => pht('Official Business'), 22 - 'fa-bus' => pht('Field Trip'), 23 - 'fa-microphone' => pht('Conference'), 24 - ); 25 - } 26 - 27 - public static function getLabel($key) { 28 - $map = self::getIconMap(); 29 - return $map[$key]; 30 - } 31 - 32 - public static function getAPIName($key) { 33 - return substr($key, 3); 34 - } 35 - 36 - public static function renderIconForChooser($icon) { 37 - $calendar_icons = self::getIconMap(); 38 - 39 - return phutil_tag( 40 - 'span', 41 - array(), 42 - array( 43 - id(new PHUIIconView())->setIconFont($icon), 44 - ' ', 45 - idx($calendar_icons, $icon, pht('Unknown Icon')), 46 - )); 47 - } 48 - 49 - }
+45
src/applications/calendar/icon/PhabricatorCalendarIconSet.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarIconSet 4 + extends PhabricatorIconSet { 5 + 6 + const ICONSETKEY = 'calendar.event'; 7 + 8 + public function getSelectIconTitleText() { 9 + return pht('Choose Event Icon'); 10 + } 11 + 12 + protected function newIcons() { 13 + $map = array( 14 + 'fa-calendar' => pht('Default'), 15 + 'fa-glass' => pht('Party'), 16 + 'fa-plane' => pht('Travel'), 17 + 'fa-plus-square' => pht('Health / Appointment'), 18 + 19 + 'fa-rocket' => pht('Sabatical / Leave'), 20 + 'fa-home' => pht('Working From Home'), 21 + 'fa-tree' => pht('Holiday'), 22 + 'fa-gamepad' => pht('Staycation'), 23 + 24 + 'fa-coffee' => pht('Coffee Meeting'), 25 + 'fa-film' => pht('Movie'), 26 + 'fa-users' => pht('Meeting'), 27 + 'fa-cutlery' => pht('Meal'), 28 + 29 + 'fa-paw' => pht('Pet Activity'), 30 + 'fa-institution' => pht('Official Business'), 31 + 'fa-bus' => pht('Field Trip'), 32 + 'fa-microphone' => pht('Conference'), 33 + ); 34 + 35 + $icons = array(); 36 + foreach ($map as $key => $label) { 37 + $icons[] = id(new PhabricatorIconSetIcon()) 38 + ->setKey($key) 39 + ->setLabel($label); 40 + } 41 + 42 + return $icons; 43 + } 44 + 45 + }
+4 -2
src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
··· 156 156 $this->renderHandleLink($author_phid)); 157 157 } 158 158 case self::TYPE_ICON: 159 + $set = new PhabricatorCalendarIconSet(); 159 160 return pht( 160 161 '%s set this event\'s icon to %s.', 161 162 $this->renderHandleLink($author_phid), 162 - PhabricatorCalendarIcon::getLabel($new)); 163 + $set->getIconLabel($new)); 163 164 break; 164 165 case self::TYPE_CANCEL: 165 166 if ($new) { ··· 356 357 $this->renderHandleLink($object_phid)); 357 358 } 358 359 case self::TYPE_ICON: 360 + $set = new PhabricatorCalendarIconSet(); 359 361 return pht( 360 362 '%s set the icon for %s to %s.', 361 363 $this->renderHandleLink($author_phid), 362 364 $this->renderHandleLink($object_phid), 363 - PhabricatorCalendarIcon::getLabel($new)); 365 + $set->getIconLabel($new)); 364 366 case self::TYPE_CANCEL: 365 367 if ($new) { 366 368 return pht(
+3
src/applications/files/application/PhabricatorFilesApplication.php
··· 83 83 'PhabricatorFileTransformListController', 84 84 'uploaddialog/' => 'PhabricatorFileUploadDialogController', 85 85 'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController', 86 + 'iconset/(?P<key>[^/]+)/' => array( 87 + 'select/' => 'PhabricatorFileIconSetSelectController', 88 + ), 86 89 ) + $this->getResourceSubroutes(), 87 90 ); 88 91 }
+91
src/applications/files/controller/PhabricatorFileIconSetSelectController.php
··· 1 + <?php 2 + 3 + final class PhabricatorFileIconSetSelectController 4 + extends PhabricatorFileController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $key = $request->getURIData('key'); 8 + 9 + $set = PhabricatorIconSet::getIconSetByKey($key); 10 + if (!$set) { 11 + return new Aphront404Response(); 12 + } 13 + 14 + $v_icon = $request->getStr('icon'); 15 + if ($request->isFormPost()) { 16 + $icon = $set->getIcon($v_icon); 17 + 18 + if ($icon) { 19 + $payload = array( 20 + 'value' => $icon->getKey(), 21 + 'display' => $set->renderIconForControl($icon), 22 + ); 23 + 24 + return id(new AphrontAjaxResponse()) 25 + ->setContent($payload); 26 + } 27 + } 28 + 29 + require_celerity_resource('project-icon-css'); 30 + Javelin::initBehavior('phabricator-tooltips'); 31 + 32 + $ii = 0; 33 + $buttons = array(); 34 + foreach ($set->getIcons() as $icon) { 35 + $label = $icon->getLabel(); 36 + 37 + $view = id(new PHUIIconView()) 38 + ->setIconFont($icon->getIcon()); 39 + 40 + $aural = javelin_tag( 41 + 'span', 42 + array( 43 + 'aural' => true, 44 + ), 45 + pht('Choose "%s" Icon', $label)); 46 + 47 + $classes = array(); 48 + $classes[] = 'icon-button'; 49 + 50 + if ($icon->getKey() == $v_icon) { 51 + $classes[] = 'selected'; 52 + } 53 + 54 + $buttons[] = javelin_tag( 55 + 'button', 56 + array( 57 + 'class' => implode(' ', $classes), 58 + 'name' => 'icon', 59 + 'value' => $icon->getKey(), 60 + 'type' => 'submit', 61 + 'sigil' => 'has-tooltip', 62 + 'meta' => array( 63 + 'tip' => $label, 64 + ), 65 + ), 66 + array( 67 + $aural, 68 + $view, 69 + )); 70 + 71 + if ((++$ii % 4) == 0) { 72 + $buttons[] = phutil_tag('br'); 73 + } 74 + } 75 + 76 + $buttons = phutil_tag( 77 + 'div', 78 + array( 79 + 'class' => 'icon-grid', 80 + ), 81 + $buttons); 82 + 83 + $dialog_title = $set->getSelectIconTitleText(); 84 + 85 + return $this->newDialog() 86 + ->setTitle($dialog_title) 87 + ->appendChild($buttons) 88 + ->addCancelButton('/'); 89 + } 90 + 91 + }
+70
src/applications/files/iconset/PhabricatorIconSet.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorIconSet 4 + extends Phobject { 5 + 6 + final public function getIconSetKey() { 7 + return $this->getPhobjectClassConstant('ICONSETKEY'); 8 + } 9 + 10 + public function getChooseButtonText() { 11 + return pht('Choose Icon...'); 12 + } 13 + 14 + public function getSelectIconTitleText() { 15 + return pht('Choose Icon'); 16 + } 17 + 18 + public function getSelectURI() { 19 + $key = $this->getIconSetKey(); 20 + return "/file/iconset/{$key}/select/"; 21 + } 22 + 23 + final public function getIcons() { 24 + $icons = $this->newIcons(); 25 + 26 + // TODO: Validate icons. 27 + $icons = mpull($icons, null, 'getKey'); 28 + 29 + return $icons; 30 + } 31 + 32 + final public function getIcon($key) { 33 + $icons = $this->getIcons(); 34 + return idx($icons, $key); 35 + } 36 + 37 + final public function getIconLabel($key) { 38 + $icon = $this->getIcon($key); 39 + 40 + if ($icon) { 41 + return $icon->getLabel(); 42 + } 43 + 44 + return $key; 45 + } 46 + 47 + final public function renderIconForControl(PhabricatorIconSetIcon $icon) { 48 + return phutil_tag( 49 + 'span', 50 + array(), 51 + array( 52 + id(new PHUIIconView())->setIconFont($icon->getIcon()), 53 + ' ', 54 + $icon->getLabel(), 55 + )); 56 + } 57 + 58 + final public static function getIconSetByKey($key) { 59 + $sets = self::getAllIconSets(); 60 + return idx($sets, $key); 61 + } 62 + 63 + final public static function getAllIconSets() { 64 + return id(new PhutilClassMapQuery()) 65 + ->setAncestorClass(__CLASS__) 66 + ->setUniqueMethod('getIconSetKey') 67 + ->execute(); 68 + } 69 + 70 + }
+40
src/applications/files/iconset/PhabricatorIconSetIcon.php
··· 1 + <?php 2 + 3 + final class PhabricatorIconSetIcon 4 + extends Phobject { 5 + 6 + private $key; 7 + private $icon; 8 + private $label; 9 + 10 + public function setKey($key) { 11 + $this->key = $key; 12 + return $this; 13 + } 14 + 15 + public function getKey() { 16 + return $this->key; 17 + } 18 + 19 + public function setIcon($icon) { 20 + $this->icon = $icon; 21 + return $this; 22 + } 23 + 24 + public function getIcon() { 25 + if ($this->icon === null) { 26 + return $this->getKey(); 27 + } 28 + return $this->icon; 29 + } 30 + 31 + public function setLabel($label) { 32 + $this->label = $label; 33 + return $this; 34 + } 35 + 36 + public function getLabel() { 37 + return $this->label; 38 + } 39 + 40 + }
-4
src/applications/project/application/PhabricatorProjectApplication.php
··· 59 59 => 'PhabricatorProjectViewController', 60 60 'picture/(?P<id>[1-9]\d*)/' 61 61 => 'PhabricatorProjectEditPictureController', 62 - 'icon/(?P<id>[1-9]\d*)/' 63 - => 'PhabricatorProjectEditIconController', 64 - 'icon/' 65 - => 'PhabricatorProjectEditIconController', 66 62 'create/' => 'PhabricatorProjectEditDetailsController', 67 63 'board/(?P<id>[1-9]\d*)/'. 68 64 '(?P<filter>filter/)?'.
+1 -1
src/applications/project/conduit/ProjectConduitAPIMethod.php
··· 26 26 $project_slugs = $project->getSlugs(); 27 27 $project_slugs = array_values(mpull($project_slugs, 'getSlug')); 28 28 29 - $project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon()); 29 + $project_icon = substr($project->getIcon(), 3); 30 30 31 31 $result[$project->getPHID()] = array( 32 32 'id' => $project->getID(),
+3 -11
src/applications/project/controller/PhabricatorProjectEditDetailsController.php
··· 188 188 ->setError($e_name)); 189 189 $field_list->appendFieldsToForm($form); 190 190 191 - $shades = PhabricatorProjectIcon::getColorMap(); 191 + $shades = PhabricatorProjectIconSet::getColorMap(); 192 192 193 - if ($is_new) { 194 - $icon_uri = $this->getApplicationURI('icon/'); 195 - } else { 196 - $icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/'); 197 - } 198 - $icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon); 199 193 list($can_lock, $lock_message) = $this->explainApplicationCapability( 200 194 ProjectCanLockProjectsCapability::CAPABILITY, 201 195 pht('You can update the Lock Project setting.'), ··· 203 197 204 198 $form 205 199 ->appendChild( 206 - id(new AphrontFormChooseButtonControl()) 200 + id(new PHUIFormIconSetControl()) 207 201 ->setLabel(pht('Icon')) 208 202 ->setName('icon') 209 - ->setDisplayValue($icon_display) 210 - ->setButtonText(pht('Choose Icon...')) 211 - ->setChooseURI($icon_uri) 203 + ->setIconSet(new PhabricatorProjectIconSet()) 212 204 ->setValue($v_icon)) 213 205 ->appendChild( 214 206 id(new AphrontFormSelectControl())
-100
src/applications/project/controller/PhabricatorProjectEditIconController.php
··· 1 - <?php 2 - 3 - final class PhabricatorProjectEditIconController 4 - extends PhabricatorProjectController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - $id = $request->getURIData('id'); 9 - 10 - if ($id) { 11 - $project = id(new PhabricatorProjectQuery()) 12 - ->setViewer($viewer) 13 - ->withIDs(array($id)) 14 - ->requireCapabilities( 15 - array( 16 - PhabricatorPolicyCapability::CAN_VIEW, 17 - PhabricatorPolicyCapability::CAN_EDIT, 18 - )) 19 - ->executeOne(); 20 - if (!$project) { 21 - return new Aphront404Response(); 22 - } 23 - $cancel_uri = $this->getApplicationURI('profile/'.$project->getID().'/'); 24 - $project_icon = $project->getIcon(); 25 - } else { 26 - $this->requireApplicationCapability( 27 - ProjectCreateProjectsCapability::CAPABILITY); 28 - 29 - $cancel_uri = '/project/'; 30 - $project_icon = $request->getStr('value'); 31 - } 32 - 33 - require_celerity_resource('project-icon-css'); 34 - Javelin::initBehavior('phabricator-tooltips'); 35 - 36 - $project_icons = PhabricatorProjectIcon::getIconMap(); 37 - 38 - if ($request->isFormPost()) { 39 - $v_icon = $request->getStr('icon'); 40 - 41 - return id(new AphrontAjaxResponse())->setContent( 42 - array( 43 - 'value' => $v_icon, 44 - 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon), 45 - )); 46 - } 47 - 48 - $ii = 0; 49 - $buttons = array(); 50 - foreach ($project_icons as $icon => $label) { 51 - $view = id(new PHUIIconView()) 52 - ->setIconFont($icon); 53 - 54 - $aural = javelin_tag( 55 - 'span', 56 - array( 57 - 'aural' => true, 58 - ), 59 - pht('Choose "%s" Icon', $label)); 60 - 61 - if ($icon == $project_icon) { 62 - $class_extra = ' selected'; 63 - } else { 64 - $class_extra = null; 65 - } 66 - 67 - $buttons[] = javelin_tag( 68 - 'button', 69 - array( 70 - 'class' => 'icon-button'.$class_extra, 71 - 'name' => 'icon', 72 - 'value' => $icon, 73 - 'type' => 'submit', 74 - 'sigil' => 'has-tooltip', 75 - 'meta' => array( 76 - 'tip' => $label, 77 - ), 78 - ), 79 - array( 80 - $aural, 81 - $view, 82 - )); 83 - if ((++$ii % 4) == 0) { 84 - $buttons[] = phutil_tag('br'); 85 - } 86 - } 87 - 88 - $buttons = phutil_tag( 89 - 'div', 90 - array( 91 - 'class' => 'icon-grid', 92 - ), 93 - $buttons); 94 - 95 - return $this->newDialog() 96 - ->setTitle(pht('Choose Project Icon')) 97 - ->appendChild($buttons) 98 - ->addCancelButton($cancel_uri); 99 - } 100 - }
-59
src/applications/project/icon/PhabricatorProjectIcon.php
··· 1 - <?php 2 - 3 - final class PhabricatorProjectIcon extends Phobject { 4 - 5 - public static function getIconMap() { 6 - return 7 - array( 8 - 'fa-briefcase' => pht('Briefcase'), 9 - 'fa-tags' => pht('Tag'), 10 - 'fa-folder' => pht('Folder'), 11 - 'fa-users' => pht('Team'), 12 - 'fa-bug' => pht('Bug'), 13 - 'fa-trash-o' => pht('Garbage'), 14 - 'fa-calendar' => pht('Deadline'), 15 - 'fa-flag-checkered' => pht('Goal'), 16 - 'fa-envelope' => pht('Communication'), 17 - 'fa-truck' => pht('Release'), 18 - 'fa-lock' => pht('Policy'), 19 - 'fa-umbrella' => pht('An Umbrella'), 20 - 'fa-cloud' => pht('The Cloud'), 21 - 'fa-building' => pht('Company'), 22 - 'fa-credit-card' => pht('Accounting'), 23 - 'fa-flask' => pht('Experimental'), 24 - ); 25 - } 26 - 27 - public static function getColorMap() { 28 - $shades = PHUITagView::getShadeMap(); 29 - $shades = array_select_keys( 30 - $shades, 31 - array(PhabricatorProject::DEFAULT_COLOR)) + $shades; 32 - unset($shades[PHUITagView::COLOR_DISABLED]); 33 - 34 - return $shades; 35 - } 36 - 37 - public static function getLabel($key) { 38 - $map = self::getIconMap(); 39 - return $map[$key]; 40 - } 41 - 42 - public static function getAPIName($key) { 43 - return substr($key, 3); 44 - } 45 - 46 - public static function renderIconForChooser($icon) { 47 - $project_icons = self::getIconMap(); 48 - 49 - return phutil_tag( 50 - 'span', 51 - array(), 52 - array( 53 - id(new PHUIIconView())->setIconFont($icon), 54 - ' ', 55 - idx($project_icons, $icon, pht('Unknown Icon')), 56 - )); 57 - } 58 - 59 - }
+55
src/applications/project/icon/PhabricatorProjectIconSet.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectIconSet 4 + extends PhabricatorIconSet { 5 + 6 + const ICONSETKEY = 'projects'; 7 + 8 + public function getSelectIconTitleText() { 9 + return pht('Choose Project Icon'); 10 + } 11 + 12 + protected function newIcons() { 13 + $map = array( 14 + 'fa-briefcase' => pht('Briefcase'), 15 + 'fa-tags' => pht('Tag'), 16 + 'fa-folder' => pht('Folder'), 17 + 'fa-users' => pht('Team'), 18 + 19 + 'fa-bug' => pht('Bug'), 20 + 'fa-trash-o' => pht('Garbage'), 21 + 'fa-calendar' => pht('Deadline'), 22 + 'fa-flag-checkered' => pht('Goal'), 23 + 24 + 'fa-envelope' => pht('Communication'), 25 + 'fa-truck' => pht('Release'), 26 + 'fa-lock' => pht('Policy'), 27 + 'fa-umbrella' => pht('An Umbrella'), 28 + 29 + 'fa-cloud' => pht('The Cloud'), 30 + 'fa-building' => pht('Company'), 31 + 'fa-credit-card' => pht('Accounting'), 32 + 'fa-flask' => pht('Experimental'), 33 + ); 34 + 35 + $icons = array(); 36 + foreach ($map as $key => $label) { 37 + $icons[] = id(new PhabricatorIconSetIcon()) 38 + ->setKey($key) 39 + ->setLabel($label); 40 + } 41 + 42 + return $icons; 43 + } 44 + 45 + public static function getColorMap() { 46 + $shades = PHUITagView::getShadeMap(); 47 + $shades = array_select_keys( 48 + $shades, 49 + array(PhabricatorProject::DEFAULT_COLOR)) + $shades; 50 + unset($shades[PHUITagView::COLOR_DISABLED]); 51 + 52 + return $shades; 53 + } 54 + 55 + }
+6 -5
src/applications/project/query/PhabricatorProjectSearchEngine.php
··· 128 128 private function getIconOptions() { 129 129 $options = array(); 130 130 131 - foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) { 132 - $options[$icon] = array( 131 + $set = new PhabricatorProjectIconSet(); 132 + foreach ($set->getIcons() as $icon) { 133 + $options[$icon->getKey()] = array( 133 134 id(new PHUIIconView()) 134 - ->setIconFont($icon), 135 + ->setIconFont($icon->getIcon()), 135 136 ' ', 136 - $name, 137 + $icon->getLabel(), 137 138 ); 138 139 } 139 140 ··· 143 144 private function getColorOptions() { 144 145 $options = array(); 145 146 146 - foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) { 147 + foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) { 147 148 $options[$color] = array( 148 149 id(new PHUITagView()) 149 150 ->setType(PHUITagView::TYPE_SHADE)
+6 -2
src/applications/project/storage/PhabricatorProjectTransaction.php
··· 147 147 break; 148 148 149 149 case self::TYPE_ICON: 150 + $set = new PhabricatorProjectIconSet(); 151 + 150 152 return pht( 151 153 "%s set this project's icon to %s.", 152 154 $author_handle, 153 - PhabricatorProjectIcon::getLabel($new)); 155 + $set->getIconLabel($new)); 154 156 break; 155 157 156 158 case self::TYPE_COLOR: ··· 301 303 } 302 304 303 305 case self::TYPE_ICON: 306 + $set = new PhabricatorProjectIconSet(); 307 + 304 308 return pht( 305 309 '%s set the icon for %s to %s.', 306 310 $author_handle, 307 311 $object_handle, 308 - PhabricatorProjectIcon::getLabel($new)); 312 + $set->getIconLabel($new)); 309 313 310 314 case self::TYPE_COLOR: 311 315 return pht(
-96
src/view/form/control/AphrontFormChooseButtonControl.php
··· 1 - <?php 2 - 3 - final class AphrontFormChooseButtonControl extends AphrontFormControl { 4 - 5 - private $displayValue; 6 - private $buttonText; 7 - private $chooseURI; 8 - 9 - public function setDisplayValue($display_value) { 10 - $this->displayValue = $display_value; 11 - return $this; 12 - } 13 - 14 - public function getDisplayValue() { 15 - return $this->displayValue; 16 - } 17 - 18 - public function setButtonText($text) { 19 - $this->buttonText = $text; 20 - return $this; 21 - } 22 - 23 - public function setChooseURI($choose_uri) { 24 - $this->chooseURI = $choose_uri; 25 - return $this; 26 - } 27 - 28 - protected function getCustomControlClass() { 29 - return 'aphront-form-control-choose-button'; 30 - } 31 - 32 - protected function renderInput() { 33 - Javelin::initBehavior('choose-control'); 34 - 35 - $input_id = celerity_generate_unique_node_id(); 36 - $display_id = celerity_generate_unique_node_id(); 37 - 38 - $display_value = $this->displayValue; 39 - $button = javelin_tag( 40 - 'a', 41 - array( 42 - 'href' => '#', 43 - 'class' => 'button grey', 44 - 'sigil' => 'aphront-form-choose-button', 45 - ), 46 - nonempty($this->buttonText, pht('Choose...'))); 47 - 48 - $display_cell = phutil_tag( 49 - 'td', 50 - array( 51 - 'class' => 'aphront-form-choose-display-cell', 52 - 'id' => $display_id, 53 - ), 54 - $display_value); 55 - 56 - $button_cell = phutil_tag( 57 - 'td', 58 - array( 59 - 'class' => 'aphront-form-choose-button-cell', 60 - ), 61 - $button); 62 - 63 - $row = phutil_tag( 64 - 'tr', 65 - array(), 66 - array($display_cell, $button_cell)); 67 - 68 - $layout = javelin_tag( 69 - 'table', 70 - array( 71 - 'class' => 'aphront-form-choose-table', 72 - 'sigil' => 'aphront-form-choose', 73 - 'meta' => array( 74 - 'uri' => $this->chooseURI, 75 - 'inputID' => $input_id, 76 - 'displayID' => $display_id, 77 - ), 78 - ), 79 - $row); 80 - 81 - $hidden_input = phutil_tag( 82 - 'input', 83 - array( 84 - 'type' => 'hidden', 85 - 'name' => $this->getName(), 86 - 'value' => $this->getValue(), 87 - 'id' => $input_id, 88 - )); 89 - 90 - return array( 91 - $hidden_input, 92 - $layout, 93 - ); 94 - } 95 - 96 - }
+93
src/view/form/control/PHUIFormIconSetControl.php
··· 1 + <?php 2 + 3 + final class PHUIFormIconSetControl 4 + extends AphrontFormControl { 5 + 6 + private $iconSet; 7 + 8 + public function setIconSet(PhabricatorIconSet $icon_set) { 9 + $this->iconSet = $icon_set; 10 + return $this; 11 + } 12 + 13 + public function getIconSet() { 14 + return $this->iconSet; 15 + } 16 + 17 + protected function getCustomControlClass() { 18 + return 'phui-form-iconset-control'; 19 + } 20 + 21 + protected function renderInput() { 22 + Javelin::initBehavior('choose-control'); 23 + 24 + $set = $this->getIconSet(); 25 + 26 + $input_id = celerity_generate_unique_node_id(); 27 + $display_id = celerity_generate_unique_node_id(); 28 + 29 + $button = javelin_tag( 30 + 'a', 31 + array( 32 + 'href' => '#', 33 + 'class' => 'button grey', 34 + 'sigil' => 'phui-form-iconset-button', 35 + ), 36 + $set->getChooseButtonText()); 37 + 38 + $icon = $set->getIcon($this->getValue()); 39 + if ($icon) { 40 + $display = $set->renderIconForControl($icon); 41 + } else { 42 + $display = null; 43 + } 44 + 45 + $display_cell = phutil_tag( 46 + 'td', 47 + array( 48 + 'class' => 'phui-form-iconset-display-cell', 49 + 'id' => $display_id, 50 + ), 51 + $display); 52 + 53 + $button_cell = phutil_tag( 54 + 'td', 55 + array( 56 + 'class' => 'phui-form-iconset-button-cell', 57 + ), 58 + $button); 59 + 60 + $row = phutil_tag( 61 + 'tr', 62 + array(), 63 + array($display_cell, $button_cell)); 64 + 65 + $layout = javelin_tag( 66 + 'table', 67 + array( 68 + 'class' => 'phui-form-iconset-table', 69 + 'sigil' => 'phui-form-iconset', 70 + 'meta' => array( 71 + 'uri' => $set->getSelectURI(), 72 + 'inputID' => $input_id, 73 + 'displayID' => $display_id, 74 + ), 75 + ), 76 + $row); 77 + 78 + $hidden_input = phutil_tag( 79 + 'input', 80 + array( 81 + 'type' => 'hidden', 82 + 'name' => $this->getName(), 83 + 'value' => $this->getValue(), 84 + 'id' => $input_id, 85 + )); 86 + 87 + return array( 88 + $hidden_input, 89 + $layout, 90 + ); 91 + } 92 + 93 + }
+2 -2
webroot/rsrc/css/phui/phui-form-view.css
··· 519 519 width: 180px; 520 520 } 521 521 522 - .aphront-form-choose-table td { 522 + .phui-form-iconset-table td { 523 523 vertical-align: middle; 524 524 padding: 4px 0; 525 525 } 526 526 527 - .aphront-form-choose-table .aphront-form-choose-button-cell { 527 + .phui-form-iconset-table .phui-form-iconset-button-cell { 528 528 padding: 4px 8px; 529 529 } 530 530
+2 -2
webroot/rsrc/js/core/behavior-choose-control.js
··· 10 10 11 11 JX.Stratcom.listen( 12 12 'click', 13 - 'aphront-form-choose-button', 13 + 'phui-form-iconset-button', 14 14 function(e) { 15 15 e.kill(); 16 16 17 - var data = e.getNodeData('aphront-form-choose'); 17 + var data = e.getNodeData('phui-form-iconset'); 18 18 19 19 var params = { 20 20 value: JX.$(data.inputID).value