Page MenuHomePhabricator

D14799.id.diff
No OneTemporary

D14799.id.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -7,7 +7,7 @@
*/
return array(
'names' => array(
- 'core.pkg.css' => '6d8c526d',
+ 'core.pkg.css' => '8378907a',
'core.pkg.js' => 'c60f35d8',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '2de124c9',
@@ -131,7 +131,7 @@
'rsrc/css/phui/phui-document.css' => 'a4a1c3b9',
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
- 'rsrc/css/phui/phui-form-view.css' => 'c1d2ef29',
+ 'rsrc/css/phui/phui-form-view.css' => 'cf7da606',
'rsrc/css/phui/phui-form.css' => 'afdb2c6e',
'rsrc/css/phui/phui-header-view.css' => '55bb32dd',
'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6',
@@ -464,7 +464,7 @@
'rsrc/js/core/behavior-active-nav.js' => 'e379b58e',
'rsrc/js/core/behavior-audio-source.js' => '59b251eb',
'rsrc/js/core/behavior-autofocus.js' => '7319e029',
- 'rsrc/js/core/behavior-choose-control.js' => '6153c708',
+ 'rsrc/js/core/behavior-choose-control.js' => 'dfaafb14',
'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2',
'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae',
'rsrc/js/core/behavior-device.js' => 'a205cf28',
@@ -570,7 +570,7 @@
'javelin-behavior-audio-source' => '59b251eb',
'javelin-behavior-audit-preview' => 'd835b03a',
'javelin-behavior-bulk-job-reload' => 'edf8a145',
- 'javelin-behavior-choose-control' => '6153c708',
+ 'javelin-behavior-choose-control' => 'dfaafb14',
'javelin-behavior-comment-actions' => 'bb0d2d0c',
'javelin-behavior-config-reorder-fields' => 'b6993408',
'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a',
@@ -805,7 +805,7 @@
'phui-font-icon-base-css' => 'ecbbb4c2',
'phui-fontkit-css' => '9cda225e',
'phui-form-css' => 'afdb2c6e',
- 'phui-form-view-css' => 'c1d2ef29',
+ 'phui-form-view-css' => 'cf7da606',
'phui-header-view-css' => '55bb32dd',
'phui-icon-view-css' => 'b0a6b1b6',
'phui-image-mask-css' => '5a8b09c8',
@@ -1266,12 +1266,6 @@
'javelin-stratcom',
'javelin-dom',
),
- '6153c708' => array(
- 'javelin-behavior',
- 'javelin-stratcom',
- 'javelin-dom',
- 'javelin-workflow',
- ),
'61cbc29a' => array(
'javelin-magical-init',
'javelin-util',
@@ -1890,6 +1884,12 @@
'df5e11d2' => array(
'javelin-install',
),
+ 'dfaafb14' => array(
+ 'javelin-behavior',
+ 'javelin-stratcom',
+ 'javelin-dom',
+ 'javelin-workflow',
+ ),
'e10f8e18' => array(
'javelin-behavior',
'javelin-dom',
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -114,7 +114,6 @@
'AphrontException' => 'aphront/exception/AphrontException.php',
'AphrontFileResponse' => 'aphront/response/AphrontFileResponse.php',
'AphrontFormCheckboxControl' => 'view/form/control/AphrontFormCheckboxControl.php',
- 'AphrontFormChooseButtonControl' => 'view/form/control/AphrontFormChooseButtonControl.php',
'AphrontFormControl' => 'view/form/control/AphrontFormControl.php',
'AphrontFormDateControl' => 'view/form/control/AphrontFormDateControl.php',
'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php',
@@ -1474,6 +1473,7 @@
'PHUIFeedStoryView' => 'view/phui/PHUIFeedStoryView.php',
'PHUIFormDividerControl' => 'view/form/control/PHUIFormDividerControl.php',
'PHUIFormFreeformDateControl' => 'view/form/control/PHUIFormFreeformDateControl.php',
+ 'PHUIFormIconSetControl' => 'view/form/control/PHUIFormIconSetControl.php',
'PHUIFormInsetView' => 'view/form/PHUIFormInsetView.php',
'PHUIFormLayoutView' => 'view/form/PHUIFormLayoutView.php',
'PHUIFormMultiSubmitControl' => 'view/form/control/PHUIFormMultiSubmitControl.php',
@@ -1774,10 +1774,9 @@
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
- 'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
'PhabricatorBadgesEditor' => 'applications/badges/editor/PhabricatorBadgesEditor.php',
- 'PhabricatorBadgesIcon' => 'applications/badges/icon/PhabricatorBadgesIcon.php',
+ 'PhabricatorBadgesIconSet' => 'applications/badges/icon/PhabricatorBadgesIconSet.php',
'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php',
'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php',
'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php',
@@ -1833,7 +1832,6 @@
'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php',
'PhabricatorCalendarEventDragController' => 'applications/calendar/controller/PhabricatorCalendarEventDragController.php',
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
- 'PhabricatorCalendarEventEditIconController' => 'applications/calendar/controller/PhabricatorCalendarEventEditIconController.php',
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php',
'PhabricatorCalendarEventInvitee' => 'applications/calendar/storage/PhabricatorCalendarEventInvitee.php',
@@ -1852,7 +1850,7 @@
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
- 'PhabricatorCalendarIcon' => 'applications/calendar/icon/PhabricatorCalendarIcon.php',
+ 'PhabricatorCalendarIconSet' => 'applications/calendar/icon/PhabricatorCalendarIconSet.php',
'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php',
'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php',
'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php',
@@ -2263,6 +2261,7 @@
'PhabricatorFileEditor' => 'applications/files/editor/PhabricatorFileEditor.php',
'PhabricatorFileFilePHIDType' => 'applications/files/phid/PhabricatorFileFilePHIDType.php',
'PhabricatorFileHasObjectEdgeType' => 'applications/files/edge/PhabricatorFileHasObjectEdgeType.php',
+ 'PhabricatorFileIconSetSelectController' => 'applications/files/controller/PhabricatorFileIconSetSelectController.php',
'PhabricatorFileImageMacro' => 'applications/macro/storage/PhabricatorFileImageMacro.php',
'PhabricatorFileImageTransform' => 'applications/files/transform/PhabricatorFileImageTransform.php',
'PhabricatorFileInfoController' => 'applications/files/controller/PhabricatorFileInfoController.php',
@@ -2359,6 +2358,8 @@
'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php',
'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php',
'PhabricatorIconRemarkupRule' => 'applications/macro/markup/PhabricatorIconRemarkupRule.php',
+ 'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php',
+ 'PhabricatorIconSetIcon' => 'applications/files/iconset/PhabricatorIconSetIcon.php',
'PhabricatorImageMacroRemarkupRule' => 'applications/macro/markup/PhabricatorImageMacroRemarkupRule.php',
'PhabricatorImageTransformer' => 'applications/files/PhabricatorImageTransformer.php',
'PhabricatorImagemagickSetupCheck' => 'applications/config/check/PhabricatorImagemagickSetupCheck.php',
@@ -2809,12 +2810,11 @@
'PhabricatorProjectDatasource' => 'applications/project/typeahead/PhabricatorProjectDatasource.php',
'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php',
- 'PhabricatorProjectEditIconController' => 'applications/project/controller/PhabricatorProjectEditIconController.php',
'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php',
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
'PhabricatorProjectFeedController' => 'applications/project/controller/PhabricatorProjectFeedController.php',
'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php',
- 'PhabricatorProjectIcon' => 'applications/project/icon/PhabricatorProjectIcon.php',
+ 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
'PhabricatorProjectLogicalAndDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAndDatasource.php',
@@ -3973,7 +3973,6 @@
'AphrontException' => 'Exception',
'AphrontFileResponse' => 'AphrontResponse',
'AphrontFormCheckboxControl' => 'AphrontFormControl',
- 'AphrontFormChooseButtonControl' => 'AphrontFormControl',
'AphrontFormControl' => 'AphrontView',
'AphrontFormDateControl' => 'AphrontFormControl',
'AphrontFormDateControlValue' => 'Phobject',
@@ -5527,6 +5526,7 @@
'PHUIFeedStoryView' => 'AphrontView',
'PHUIFormDividerControl' => 'AphrontFormControl',
'PHUIFormFreeformDateControl' => 'AphrontFormControl',
+ 'PHUIFormIconSetControl' => 'AphrontFormControl',
'PHUIFormInsetView' => 'AphrontView',
'PHUIFormLayoutView' => 'AphrontView',
'PHUIFormMultiSubmitControl' => 'AphrontFormControl',
@@ -5873,10 +5873,9 @@
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
- 'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditor' => 'PhabricatorApplicationTransactionEditor',
- 'PhabricatorBadgesIcon' => 'Phobject',
+ 'PhabricatorBadgesIconSet' => 'PhabricatorIconSet',
'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
@@ -5944,7 +5943,6 @@
'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
- 'PhabricatorCalendarEventEditIconController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand',
'PhabricatorCalendarEventInvitee' => array(
@@ -5966,7 +5964,7 @@
'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
- 'PhabricatorCalendarIcon' => 'Phobject',
+ 'PhabricatorCalendarIconSet' => 'PhabricatorIconSet',
'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec',
@@ -6452,6 +6450,7 @@
'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorFileFilePHIDType' => 'PhabricatorPHIDType',
'PhabricatorFileHasObjectEdgeType' => 'PhabricatorEdgeType',
+ 'PhabricatorFileIconSetSelectController' => 'PhabricatorFileController',
'PhabricatorFileImageMacro' => array(
'PhabricatorFileDAO',
'PhabricatorSubscribableInterface',
@@ -6563,6 +6562,8 @@
'PhabricatorIDsSearchField' => 'PhabricatorSearchField',
'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter',
'PhabricatorIconRemarkupRule' => 'PhutilRemarkupRule',
+ 'PhabricatorIconSet' => 'Phobject',
+ 'PhabricatorIconSetIcon' => 'Phobject',
'PhabricatorImageMacroRemarkupRule' => 'PhutilRemarkupRule',
'PhabricatorImageTransformer' => 'Phobject',
'PhabricatorImagemagickSetupCheck' => 'PhabricatorSetupCheck',
@@ -7095,12 +7096,11 @@
'PhabricatorProjectDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController',
- 'PhabricatorProjectEditIconController' => 'PhabricatorProjectController',
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
'PhabricatorProjectFeedController' => 'PhabricatorProjectController',
'PhabricatorProjectHeraldAction' => 'HeraldAction',
- 'PhabricatorProjectIcon' => 'Phobject',
+ 'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
'PhabricatorProjectListController' => 'PhabricatorProjectController',
'PhabricatorProjectLogicalAndDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php
--- a/src/applications/badges/application/PhabricatorBadgesApplication.php
+++ b/src/applications/badges/application/PhabricatorBadgesApplication.php
@@ -49,10 +49,6 @@
=> 'PhabricatorBadgesArchiveController',
'view/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesViewController',
- 'icon/(?P<id>[1-9]\d*)/'
- => 'PhabricatorBadgesEditIconController',
- 'icon/'
- => 'PhabricatorBadgesEditIconController',
'recipients/(?P<id>[1-9]\d*)/'
=> 'PhabricatorBadgesEditRecipientsController',
'recipients/(?P<id>[1-9]\d*)/remove/'
diff --git a/src/applications/badges/controller/PhabricatorBadgesEditController.php b/src/applications/badges/controller/PhabricatorBadgesEditController.php
--- a/src/applications/badges/controller/PhabricatorBadgesEditController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditController.php
@@ -111,13 +111,6 @@
}
}
- if ($is_new) {
- $icon_uri = $this->getApplicationURI('icon/');
- } else {
- $icon_uri = $this->getApplicationURI('icon/'.$badge->getID().'/');
- }
- $icon_display = PhabricatorBadgesIcon::renderIconForChooser($v_icon);
-
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->setObject($badge)
@@ -137,12 +130,10 @@
->setLabel(pht('Flavor Text'))
->setValue($v_flav))
->appendChild(
- id(new AphrontFormChooseButtonControl())
+ id(new PHUIFormIconSetControl())
->setLabel(pht('Icon'))
->setName('icon')
- ->setDisplayValue($icon_display)
- ->setButtonText(pht('Choose Icon...'))
- ->setChooseURI($icon_uri)
+ ->setIconSet(new PhabricatorBadgesIconSet())
->setValue($v_icon))
->appendChild(
id(new AphrontFormSelectControl())
diff --git a/src/applications/badges/controller/PhabricatorBadgesEditIconController.php b/src/applications/badges/controller/PhabricatorBadgesEditIconController.php
deleted file mode 100644
--- a/src/applications/badges/controller/PhabricatorBadgesEditIconController.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-final class PhabricatorBadgesEditIconController
- extends PhabricatorBadgesController {
-
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $id = $request->getURIData('id');
-
- if ($id) {
- $badge = id(new PhabricatorBadgesQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->executeOne();
- if (!$badge) {
- return new Aphront404Response();
- }
- $cancel_uri =
- $this->getApplicationURI('view/'.$badge->getID().'/');
- $badge_icon = $badge->getIcon();
- } else {
- $this->requireApplicationCapability(
- PhabricatorBadgesCreateCapability::CAPABILITY);
-
- $cancel_uri = '/badges/';
- $badge_icon = $request->getStr('value');
- }
-
- require_celerity_resource('project-icon-css');
- Javelin::initBehavior('phabricator-tooltips');
-
- $badge_icons = PhabricatorBadgesIcon::getIconMap();
-
- if ($request->isFormPost()) {
- $v_icon = $request->getStr('icon');
-
- return id(new AphrontAjaxResponse())->setContent(
- array(
- 'value' => $v_icon,
- 'display' => PhabricatorBadgesIcon::renderIconForChooser($v_icon),
- ));
- }
-
- $ii = 0;
- $buttons = array();
- foreach ($badge_icons as $icon => $label) {
- $view = id(new PHUIIconView())
- ->setIconFont($icon);
-
- $aural = javelin_tag(
- 'span',
- array(
- 'aural' => true,
- ),
- pht('Choose "%s" Icon', $label));
-
- if ($icon == $badge_icon) {
- $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 Badge Icon'))
- ->appendChild($buttons)
- ->addCancelButton($cancel_uri);
- }
-}
diff --git a/src/applications/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php
--- a/src/applications/badges/controller/PhabricatorBadgesViewController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php
@@ -85,7 +85,6 @@
->setObject($badge);
$quality = idx($badge->getQualityNameMap(), $badge->getQuality());
- $icon = idx($badge->getIconNameMap(), $badge->getIcon());
$view->addProperty(
pht('Quality'),
@@ -93,7 +92,8 @@
$view->addProperty(
pht('Icon'),
- $icon);
+ id(new PhabricatorBadgesIconSet())
+ ->getIconLabel($badge->getIcon()));
$view->addProperty(
pht('Flavor'),
diff --git a/src/applications/badges/icon/PhabricatorBadgesIcon.php b/src/applications/badges/icon/PhabricatorBadgesIcon.php
deleted file mode 100644
--- a/src/applications/badges/icon/PhabricatorBadgesIcon.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-final class PhabricatorBadgesIcon extends Phobject {
-
- public static function getIconMap() {
- return
- array(
- 'fa-star' => pht('Superstar'),
- 'fa-user' => pht('Average Person'),
- 'fa-bug' => pht('Ladybug'),
- 'fa-users' => pht('Triplets'),
-
- 'fa-book' => pht('Nominomicon'),
- 'fa-rocket' => pht('Escape Route'),
- 'fa-life-ring' => pht('Foam Circle'),
- 'fa-birthday-cake' => pht('Cake Day'),
-
- 'fa-camera-retro' => pht('Leica Enthusiast'),
- 'fa-beer' => pht('Liquid Lunch'),
- 'fa-gift' => pht('Free Stuff'),
- 'fa-eye' => pht('Eye See You'),
-
- 'fa-heart' => pht('Love is Love'),
- 'fa-trophy' => pht('Winner at Things'),
- 'fa-umbrella' => pht('Rain Defender'),
- 'fa-graduation-cap' => pht('In Debt'),
-
- );
- }
-
- public static function getLabel($key) {
- $map = self::getIconMap();
- return $map[$key];
- }
-
- public static function getAPIName($key) {
- return substr($key, 3);
- }
-
- public static function renderIconForChooser($icon) {
- $badge_icons = self::getIconMap();
-
- return phutil_tag(
- 'span',
- array(),
- array(
- id(new PHUIIconView())->setIconFont($icon),
- ' ',
- idx($badge_icons, $icon, pht('Unknown Icon')),
- ));
- }
-
-}
diff --git a/src/applications/badges/icon/PhabricatorBadgesIconSet.php b/src/applications/badges/icon/PhabricatorBadgesIconSet.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/icon/PhabricatorBadgesIconSet.php
@@ -0,0 +1,45 @@
+<?php
+
+final class PhabricatorBadgesIconSet
+ extends PhabricatorIconSet {
+
+ const ICONSETKEY = 'badges';
+
+ public function getSelectIconTitleText() {
+ return pht('Choose Badge Icon');
+ }
+
+ protected function newIcons() {
+ $map = array(
+ 'fa-star' => pht('Superstar'),
+ 'fa-user' => pht('Average Person'),
+ 'fa-bug' => pht('Ladybug'),
+ 'fa-users' => pht('Triplets'),
+
+ 'fa-book' => pht('Nominomicon'),
+ 'fa-rocket' => pht('Escape Route'),
+ 'fa-life-ring' => pht('Foam Circle'),
+ 'fa-birthday-cake' => pht('Cake Day'),
+
+ 'fa-camera-retro' => pht('Leica Enthusiast'),
+ 'fa-beer' => pht('Liquid Lunch'),
+ 'fa-gift' => pht('Free Stuff'),
+ 'fa-eye' => pht('Eye See You'),
+
+ 'fa-heart' => pht('Love is Love'),
+ 'fa-trophy' => pht('Winner at Things'),
+ 'fa-umbrella' => pht('Rain Defender'),
+ 'fa-graduation-cap' => pht('In Debt'),
+ );
+
+ $icons = array();
+ foreach ($map as $key => $label) {
+ $icons[] = id(new PhabricatorIconSetIcon())
+ ->setKey($key)
+ ->setLabel($label);
+ }
+
+ return $icons;
+ }
+
+}
diff --git a/src/applications/badges/storage/PhabricatorBadgesBadge.php b/src/applications/badges/storage/PhabricatorBadgesBadge.php
--- a/src/applications/badges/storage/PhabricatorBadgesBadge.php
+++ b/src/applications/badges/storage/PhabricatorBadgesBadge.php
@@ -54,10 +54,6 @@
);
}
- public static function getIconNameMap() {
- return PhabricatorBadgesIcon::getIconMap();
- }
-
public static function initializeNewBadge(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
->setViewer($actor)
diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
--- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php
+++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
@@ -78,9 +78,11 @@
$this->renderHandleLink($author_phid),
$new);
} else {
- $icon_map = PhabricatorBadgesBadge::getIconNameMap();
- $icon_new = idx($icon_map, $new, $new);
- $icon_old = idx($icon_map, $old, $old);
+ $set = new PhabricatorBadgesIconSet();
+
+ $icon_old = $set->getIconLabel($old);
+ $icon_new = $set->getIconLabel($new);
+
return pht(
'%s updated the icon for this badge from "%s" to "%s".',
$this->renderHandleLink($author_phid),
diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php
--- a/src/applications/calendar/application/PhabricatorCalendarApplication.php
+++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php
@@ -46,10 +46,6 @@
'(?:query/(?P<queryKey>[^/]+)/(?:(?P<year>\d+)/'.
'(?P<month>\d+)/)?(?:(?P<day>\d+)/)?)?'
=> 'PhabricatorCalendarEventListController',
- 'icon/(?P<id>[1-9]\d*)/'
- => 'PhabricatorCalendarEventEditIconController',
- 'icon/'
- => 'PhabricatorCalendarEventEditIconController',
'event/' => array(
'create/'
=> 'PhabricatorCalendarEventEditController',
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
@@ -499,18 +499,11 @@
->setUser($viewer)
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
- if ($this->isCreate()) {
- $icon_uri = $this->getApplicationURI('icon/');
- } else {
- $icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/');
- }
- $icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon);
- $icon = id(new AphrontFormChooseButtonControl())
+
+ $icon = id(new PHUIFormIconSetControl())
->setLabel(pht('Icon'))
->setName('icon')
- ->setDisplayValue($icon_display)
- ->setButtonText(pht('Choose Icon...'))
- ->setChooseURI($icon_uri)
+ ->setIconSet(new PhabricatorCalendarIconSet())
->setValue($icon);
$form = id(new AphrontFormView())
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php
deleted file mode 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-final class PhabricatorCalendarEventEditIconController
- extends PhabricatorCalendarController {
-
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $id = $request->getURIData('id');
-
- if ($id) {
- $event = id(new PhabricatorCalendarEventQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->executeOne();
- if (!$event) {
- return new Aphront404Response();
- }
- $cancel_uri = $this->getApplicationURI('/E'.$event->getID());
- $event_icon = $event->getIcon();
- } else {
- $cancel_uri = '/calendar/';
- $event_icon = $request->getStr('value');
- }
-
- require_celerity_resource('calendar-icon-css');
- Javelin::initBehavior('phabricator-tooltips');
-
- $calendar_icons = PhabricatorCalendarIcon::getIconMap();
-
- if ($request->isFormPost()) {
- $v_icon = $request->getStr('icon');
-
- return id(new AphrontAjaxResponse())->setContent(
- array(
- 'value' => $v_icon,
- 'display' => PhabricatorCalendarIcon::renderIconForChooser($v_icon),
- ));
- }
-
- $ii = 0;
- $buttons = array();
- foreach ($calendar_icons as $icon => $label) {
- $view = id(new PHUIIconView())
- ->setIconFont($icon);
-
- $aural = javelin_tag(
- 'span',
- array(
- 'aural' => true,
- ),
- pht('Choose "%s" Icon', $label));
-
- if ($icon == $event_icon) {
- $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 Calendar Event Icon'))
- ->appendChild($buttons)
- ->addCancelButton($cancel_uri);
- }
-}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -360,11 +360,10 @@
$properties->invokeWillRenderEvent();
- $icon_display = PhabricatorCalendarIcon::renderIconForChooser(
- $event->getIcon());
$properties->addProperty(
pht('Icon'),
- $icon_display);
+ id(new PhabricatorCalendarIconSet())
+ ->getIconLabel($event->getIcon()));
if (strlen($event->getDescription())) {
$description = PhabricatorMarkupEngine::renderOneObject(
diff --git a/src/applications/calendar/icon/PhabricatorCalendarIcon.php b/src/applications/calendar/icon/PhabricatorCalendarIcon.php
deleted file mode 100644
--- a/src/applications/calendar/icon/PhabricatorCalendarIcon.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-final class PhabricatorCalendarIcon extends Phobject {
-
- public static function getIconMap() {
- return
- array(
- 'fa-calendar' => pht('Default'),
- 'fa-glass' => pht('Party'),
- 'fa-plane' => pht('Travel'),
- 'fa-plus-square' => pht('Health / Appointment'),
- 'fa-rocket' => pht('Sabatical / Leave'),
- 'fa-home' => pht('Working From Home'),
- 'fa-tree' => pht('Holiday'),
- 'fa-gamepad' => pht('Staycation'),
- 'fa-coffee' => pht('Coffee Meeting'),
- 'fa-film' => pht('Movie'),
- 'fa-users' => pht('Meeting'),
- 'fa-cutlery' => pht('Meal'),
- 'fa-paw' => pht('Pet Activity'),
- 'fa-institution' => pht('Official Business'),
- 'fa-bus' => pht('Field Trip'),
- 'fa-microphone' => pht('Conference'),
- );
- }
-
- public static function getLabel($key) {
- $map = self::getIconMap();
- return $map[$key];
- }
-
- public static function getAPIName($key) {
- return substr($key, 3);
- }
-
- public static function renderIconForChooser($icon) {
- $calendar_icons = self::getIconMap();
-
- return phutil_tag(
- 'span',
- array(),
- array(
- id(new PHUIIconView())->setIconFont($icon),
- ' ',
- idx($calendar_icons, $icon, pht('Unknown Icon')),
- ));
- }
-
-}
diff --git a/src/applications/calendar/icon/PhabricatorCalendarIconSet.php b/src/applications/calendar/icon/PhabricatorCalendarIconSet.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/icon/PhabricatorCalendarIconSet.php
@@ -0,0 +1,45 @@
+<?php
+
+final class PhabricatorCalendarIconSet
+ extends PhabricatorIconSet {
+
+ const ICONSETKEY = 'calendar.event';
+
+ public function getSelectIconTitleText() {
+ return pht('Choose Event Icon');
+ }
+
+ protected function newIcons() {
+ $map = array(
+ 'fa-calendar' => pht('Default'),
+ 'fa-glass' => pht('Party'),
+ 'fa-plane' => pht('Travel'),
+ 'fa-plus-square' => pht('Health / Appointment'),
+
+ 'fa-rocket' => pht('Sabatical / Leave'),
+ 'fa-home' => pht('Working From Home'),
+ 'fa-tree' => pht('Holiday'),
+ 'fa-gamepad' => pht('Staycation'),
+
+ 'fa-coffee' => pht('Coffee Meeting'),
+ 'fa-film' => pht('Movie'),
+ 'fa-users' => pht('Meeting'),
+ 'fa-cutlery' => pht('Meal'),
+
+ 'fa-paw' => pht('Pet Activity'),
+ 'fa-institution' => pht('Official Business'),
+ 'fa-bus' => pht('Field Trip'),
+ 'fa-microphone' => pht('Conference'),
+ );
+
+ $icons = array();
+ foreach ($map as $key => $label) {
+ $icons[] = id(new PhabricatorIconSetIcon())
+ ->setKey($key)
+ ->setLabel($label);
+ }
+
+ return $icons;
+ }
+
+}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
@@ -156,10 +156,11 @@
$this->renderHandleLink($author_phid));
}
case self::TYPE_ICON:
+ $set = new PhabricatorCalendarIconSet();
return pht(
'%s set this event\'s icon to %s.',
$this->renderHandleLink($author_phid),
- PhabricatorCalendarIcon::getLabel($new));
+ $set->getIconLabel($new));
break;
case self::TYPE_CANCEL:
if ($new) {
@@ -356,11 +357,12 @@
$this->renderHandleLink($object_phid));
}
case self::TYPE_ICON:
+ $set = new PhabricatorCalendarIconSet();
return pht(
'%s set the icon for %s to %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid),
- PhabricatorCalendarIcon::getLabel($new));
+ $set->getIconLabel($new));
case self::TYPE_CANCEL:
if ($new) {
return pht(
diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php
--- a/src/applications/files/application/PhabricatorFilesApplication.php
+++ b/src/applications/files/application/PhabricatorFilesApplication.php
@@ -83,6 +83,9 @@
'PhabricatorFileTransformListController',
'uploaddialog/' => 'PhabricatorFileUploadDialogController',
'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController',
+ 'iconset/(?P<key>[^/]+)/' => array(
+ 'select/' => 'PhabricatorFileIconSetSelectController',
+ ),
) + $this->getResourceSubroutes(),
);
}
diff --git a/src/applications/files/controller/PhabricatorFileIconSetSelectController.php b/src/applications/files/controller/PhabricatorFileIconSetSelectController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/controller/PhabricatorFileIconSetSelectController.php
@@ -0,0 +1,91 @@
+<?php
+
+final class PhabricatorFileIconSetSelectController
+ extends PhabricatorFileController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $key = $request->getURIData('key');
+
+ $set = PhabricatorIconSet::getIconSetByKey($key);
+ if (!$set) {
+ return new Aphront404Response();
+ }
+
+ $v_icon = $request->getStr('icon');
+ if ($request->isFormPost()) {
+ $icon = $set->getIcon($v_icon);
+
+ if ($icon) {
+ $payload = array(
+ 'value' => $icon->getKey(),
+ 'display' => $set->renderIconForControl($icon),
+ );
+
+ return id(new AphrontAjaxResponse())
+ ->setContent($payload);
+ }
+ }
+
+ require_celerity_resource('project-icon-css');
+ Javelin::initBehavior('phabricator-tooltips');
+
+ $ii = 0;
+ $buttons = array();
+ foreach ($set->getIcons() as $icon) {
+ $label = $icon->getLabel();
+
+ $view = id(new PHUIIconView())
+ ->setIconFont($icon->getIcon());
+
+ $aural = javelin_tag(
+ 'span',
+ array(
+ 'aural' => true,
+ ),
+ pht('Choose "%s" Icon', $label));
+
+ $classes = array();
+ $classes[] = 'icon-button';
+
+ if ($icon->getKey() == $v_icon) {
+ $classes[] = 'selected';
+ }
+
+ $buttons[] = javelin_tag(
+ 'button',
+ array(
+ 'class' => implode(' ', $classes),
+ 'name' => 'icon',
+ 'value' => $icon->getKey(),
+ '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);
+
+ $dialog_title = $set->getSelectIconTitleText();
+
+ return $this->newDialog()
+ ->setTitle($dialog_title)
+ ->appendChild($buttons)
+ ->addCancelButton('/');
+ }
+
+}
diff --git a/src/applications/files/iconset/PhabricatorIconSet.php b/src/applications/files/iconset/PhabricatorIconSet.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/iconset/PhabricatorIconSet.php
@@ -0,0 +1,70 @@
+<?php
+
+abstract class PhabricatorIconSet
+ extends Phobject {
+
+ final public function getIconSetKey() {
+ return $this->getPhobjectClassConstant('ICONSETKEY');
+ }
+
+ public function getChooseButtonText() {
+ return pht('Choose Icon...');
+ }
+
+ public function getSelectIconTitleText() {
+ return pht('Choose Icon');
+ }
+
+ public function getSelectURI() {
+ $key = $this->getIconSetKey();
+ return "/file/iconset/{$key}/select/";
+ }
+
+ final public function getIcons() {
+ $icons = $this->newIcons();
+
+ // TODO: Validate icons.
+ $icons = mpull($icons, null, 'getKey');
+
+ return $icons;
+ }
+
+ final public function getIcon($key) {
+ $icons = $this->getIcons();
+ return idx($icons, $key);
+ }
+
+ final public function getIconLabel($key) {
+ $icon = $this->getIcon($key);
+
+ if ($icon) {
+ return $icon->getLabel();
+ }
+
+ return $key;
+ }
+
+ final public function renderIconForControl(PhabricatorIconSetIcon $icon) {
+ return phutil_tag(
+ 'span',
+ array(),
+ array(
+ id(new PHUIIconView())->setIconFont($icon->getIcon()),
+ ' ',
+ $icon->getLabel(),
+ ));
+ }
+
+ final public static function getIconSetByKey($key) {
+ $sets = self::getAllIconSets();
+ return idx($sets, $key);
+ }
+
+ final public static function getAllIconSets() {
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getIconSetKey')
+ ->execute();
+ }
+
+}
diff --git a/src/applications/files/iconset/PhabricatorIconSetIcon.php b/src/applications/files/iconset/PhabricatorIconSetIcon.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/iconset/PhabricatorIconSetIcon.php
@@ -0,0 +1,40 @@
+<?php
+
+final class PhabricatorIconSetIcon
+ extends Phobject {
+
+ private $key;
+ private $icon;
+ private $label;
+
+ public function setKey($key) {
+ $this->key = $key;
+ return $this;
+ }
+
+ public function getKey() {
+ return $this->key;
+ }
+
+ public function setIcon($icon) {
+ $this->icon = $icon;
+ return $this;
+ }
+
+ public function getIcon() {
+ if ($this->icon === null) {
+ return $this->getKey();
+ }
+ return $this->icon;
+ }
+
+ public function setLabel($label) {
+ $this->label = $label;
+ return $this;
+ }
+
+ public function getLabel() {
+ return $this->label;
+ }
+
+}
diff --git a/src/applications/project/application/PhabricatorProjectApplication.php b/src/applications/project/application/PhabricatorProjectApplication.php
--- a/src/applications/project/application/PhabricatorProjectApplication.php
+++ b/src/applications/project/application/PhabricatorProjectApplication.php
@@ -59,10 +59,6 @@
=> 'PhabricatorProjectViewController',
'picture/(?P<id>[1-9]\d*)/'
=> 'PhabricatorProjectEditPictureController',
- 'icon/(?P<id>[1-9]\d*)/'
- => 'PhabricatorProjectEditIconController',
- 'icon/'
- => 'PhabricatorProjectEditIconController',
'create/' => 'PhabricatorProjectEditDetailsController',
'board/(?P<id>[1-9]\d*)/'.
'(?P<filter>filter/)?'.
diff --git a/src/applications/project/conduit/ProjectConduitAPIMethod.php b/src/applications/project/conduit/ProjectConduitAPIMethod.php
--- a/src/applications/project/conduit/ProjectConduitAPIMethod.php
+++ b/src/applications/project/conduit/ProjectConduitAPIMethod.php
@@ -26,7 +26,7 @@
$project_slugs = $project->getSlugs();
$project_slugs = array_values(mpull($project_slugs, 'getSlug'));
- $project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon());
+ $project_icon = substr($project->getIcon(), 3);
$result[$project->getPHID()] = array(
'id' => $project->getID(),
diff --git a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
--- a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
@@ -188,14 +188,8 @@
->setError($e_name));
$field_list->appendFieldsToForm($form);
- $shades = PhabricatorProjectIcon::getColorMap();
+ $shades = PhabricatorProjectIconSet::getColorMap();
- if ($is_new) {
- $icon_uri = $this->getApplicationURI('icon/');
- } else {
- $icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/');
- }
- $icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
list($can_lock, $lock_message) = $this->explainApplicationCapability(
ProjectCanLockProjectsCapability::CAPABILITY,
pht('You can update the Lock Project setting.'),
@@ -203,12 +197,10 @@
$form
->appendChild(
- id(new AphrontFormChooseButtonControl())
+ id(new PHUIFormIconSetControl())
->setLabel(pht('Icon'))
->setName('icon')
- ->setDisplayValue($icon_display)
- ->setButtonText(pht('Choose Icon...'))
- ->setChooseURI($icon_uri)
+ ->setIconSet(new PhabricatorProjectIconSet())
->setValue($v_icon))
->appendChild(
id(new AphrontFormSelectControl())
diff --git a/src/applications/project/controller/PhabricatorProjectEditIconController.php b/src/applications/project/controller/PhabricatorProjectEditIconController.php
deleted file mode 100644
--- a/src/applications/project/controller/PhabricatorProjectEditIconController.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-
-final class PhabricatorProjectEditIconController
- extends PhabricatorProjectController {
-
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $id = $request->getURIData('id');
-
- if ($id) {
- $project = id(new PhabricatorProjectQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->executeOne();
- if (!$project) {
- return new Aphront404Response();
- }
- $cancel_uri = $this->getApplicationURI('profile/'.$project->getID().'/');
- $project_icon = $project->getIcon();
- } else {
- $this->requireApplicationCapability(
- ProjectCreateProjectsCapability::CAPABILITY);
-
- $cancel_uri = '/project/';
- $project_icon = $request->getStr('value');
- }
-
- 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_icon) {
- $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($cancel_uri);
- }
-}
diff --git a/src/applications/project/icon/PhabricatorProjectIcon.php b/src/applications/project/icon/PhabricatorProjectIcon.php
deleted file mode 100644
--- a/src/applications/project/icon/PhabricatorProjectIcon.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-final class PhabricatorProjectIcon extends Phobject {
-
- public static function getIconMap() {
- return
- array(
- 'fa-briefcase' => pht('Briefcase'),
- 'fa-tags' => pht('Tag'),
- 'fa-folder' => pht('Folder'),
- 'fa-users' => pht('Team'),
- 'fa-bug' => pht('Bug'),
- 'fa-trash-o' => pht('Garbage'),
- 'fa-calendar' => pht('Deadline'),
- 'fa-flag-checkered' => pht('Goal'),
- 'fa-envelope' => pht('Communication'),
- 'fa-truck' => pht('Release'),
- 'fa-lock' => pht('Policy'),
- 'fa-umbrella' => pht('An Umbrella'),
- 'fa-cloud' => pht('The Cloud'),
- 'fa-building' => pht('Company'),
- 'fa-credit-card' => pht('Accounting'),
- 'fa-flask' => pht('Experimental'),
- );
- }
-
- public static function getColorMap() {
- $shades = PHUITagView::getShadeMap();
- $shades = array_select_keys(
- $shades,
- array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
- unset($shades[PHUITagView::COLOR_DISABLED]);
-
- return $shades;
- }
-
- public static function getLabel($key) {
- $map = self::getIconMap();
- return $map[$key];
- }
-
- public static function getAPIName($key) {
- return substr($key, 3);
- }
-
- public static function renderIconForChooser($icon) {
- $project_icons = self::getIconMap();
-
- return phutil_tag(
- 'span',
- array(),
- array(
- id(new PHUIIconView())->setIconFont($icon),
- ' ',
- idx($project_icons, $icon, pht('Unknown Icon')),
- ));
- }
-
-}
diff --git a/src/applications/project/icon/PhabricatorProjectIconSet.php b/src/applications/project/icon/PhabricatorProjectIconSet.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/icon/PhabricatorProjectIconSet.php
@@ -0,0 +1,55 @@
+<?php
+
+final class PhabricatorProjectIconSet
+ extends PhabricatorIconSet {
+
+ const ICONSETKEY = 'projects';
+
+ public function getSelectIconTitleText() {
+ return pht('Choose Project Icon');
+ }
+
+ protected function newIcons() {
+ $map = array(
+ 'fa-briefcase' => pht('Briefcase'),
+ 'fa-tags' => pht('Tag'),
+ 'fa-folder' => pht('Folder'),
+ 'fa-users' => pht('Team'),
+
+ 'fa-bug' => pht('Bug'),
+ 'fa-trash-o' => pht('Garbage'),
+ 'fa-calendar' => pht('Deadline'),
+ 'fa-flag-checkered' => pht('Goal'),
+
+ 'fa-envelope' => pht('Communication'),
+ 'fa-truck' => pht('Release'),
+ 'fa-lock' => pht('Policy'),
+ 'fa-umbrella' => pht('An Umbrella'),
+
+ 'fa-cloud' => pht('The Cloud'),
+ 'fa-building' => pht('Company'),
+ 'fa-credit-card' => pht('Accounting'),
+ 'fa-flask' => pht('Experimental'),
+ );
+
+ $icons = array();
+ foreach ($map as $key => $label) {
+ $icons[] = id(new PhabricatorIconSetIcon())
+ ->setKey($key)
+ ->setLabel($label);
+ }
+
+ return $icons;
+ }
+
+ public static function getColorMap() {
+ $shades = PHUITagView::getShadeMap();
+ $shades = array_select_keys(
+ $shades,
+ array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
+ unset($shades[PHUITagView::COLOR_DISABLED]);
+
+ return $shades;
+ }
+
+}
diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php
--- a/src/applications/project/query/PhabricatorProjectSearchEngine.php
+++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php
@@ -128,12 +128,13 @@
private function getIconOptions() {
$options = array();
- foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) {
- $options[$icon] = array(
+ $set = new PhabricatorProjectIconSet();
+ foreach ($set->getIcons() as $icon) {
+ $options[$icon->getKey()] = array(
id(new PHUIIconView())
- ->setIconFont($icon),
+ ->setIconFont($icon->getIcon()),
' ',
- $name,
+ $icon->getLabel(),
);
}
@@ -143,7 +144,7 @@
private function getColorOptions() {
$options = array();
- foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) {
+ foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) {
$options[$color] = array(
id(new PHUITagView())
->setType(PHUITagView::TYPE_SHADE)
diff --git a/src/applications/project/storage/PhabricatorProjectTransaction.php b/src/applications/project/storage/PhabricatorProjectTransaction.php
--- a/src/applications/project/storage/PhabricatorProjectTransaction.php
+++ b/src/applications/project/storage/PhabricatorProjectTransaction.php
@@ -147,10 +147,12 @@
break;
case self::TYPE_ICON:
+ $set = new PhabricatorProjectIconSet();
+
return pht(
"%s set this project's icon to %s.",
$author_handle,
- PhabricatorProjectIcon::getLabel($new));
+ $set->getIconLabel($new));
break;
case self::TYPE_COLOR:
@@ -301,11 +303,13 @@
}
case self::TYPE_ICON:
+ $set = new PhabricatorProjectIconSet();
+
return pht(
'%s set the icon for %s to %s.',
$author_handle,
$object_handle,
- PhabricatorProjectIcon::getLabel($new));
+ $set->getIconLabel($new));
case self::TYPE_COLOR:
return pht(
diff --git a/src/view/form/control/AphrontFormChooseButtonControl.php b/src/view/form/control/PHUIFormIconSetControl.php
rename from src/view/form/control/AphrontFormChooseButtonControl.php
rename to src/view/form/control/PHUIFormIconSetControl.php
--- a/src/view/form/control/AphrontFormChooseButtonControl.php
+++ b/src/view/form/control/PHUIFormIconSetControl.php
@@ -1,62 +1,59 @@
<?php
-final class AphrontFormChooseButtonControl extends AphrontFormControl {
+final class PHUIFormIconSetControl
+ extends AphrontFormControl {
- private $displayValue;
- private $buttonText;
- private $chooseURI;
+ private $iconSet;
- public function setDisplayValue($display_value) {
- $this->displayValue = $display_value;
+ public function setIconSet(PhabricatorIconSet $icon_set) {
+ $this->iconSet = $icon_set;
return $this;
}
- public function getDisplayValue() {
- return $this->displayValue;
- }
-
- public function setButtonText($text) {
- $this->buttonText = $text;
- return $this;
- }
-
- public function setChooseURI($choose_uri) {
- $this->chooseURI = $choose_uri;
- return $this;
+ public function getIconSet() {
+ return $this->iconSet;
}
protected function getCustomControlClass() {
- return 'aphront-form-control-choose-button';
+ return 'phui-form-iconset-control';
}
protected function renderInput() {
Javelin::initBehavior('choose-control');
+ $set = $this->getIconSet();
+
$input_id = celerity_generate_unique_node_id();
$display_id = celerity_generate_unique_node_id();
- $display_value = $this->displayValue;
$button = javelin_tag(
'a',
array(
'href' => '#',
'class' => 'button grey',
- 'sigil' => 'aphront-form-choose-button',
+ 'sigil' => 'phui-form-iconset-button',
),
- nonempty($this->buttonText, pht('Choose...')));
+ $set->getChooseButtonText());
+
+ $icon = $set->getIcon($this->getValue());
+ if ($icon) {
+ $display = $set->renderIconForControl($icon);
+ } else {
+ $display = null;
+ }
$display_cell = phutil_tag(
'td',
array(
- 'class' => 'aphront-form-choose-display-cell',
+ 'class' => 'phui-form-iconset-display-cell',
'id' => $display_id,
),
- $display_value);
+ $display);
$button_cell = phutil_tag(
'td',
array(
- 'class' => 'aphront-form-choose-button-cell',
+ 'class' => 'phui-form-iconset-button-cell',
),
$button);
@@ -68,10 +65,10 @@
$layout = javelin_tag(
'table',
array(
- 'class' => 'aphront-form-choose-table',
- 'sigil' => 'aphront-form-choose',
+ 'class' => 'phui-form-iconset-table',
+ 'sigil' => 'phui-form-iconset',
'meta' => array(
- 'uri' => $this->chooseURI,
+ 'uri' => $set->getSelectURI(),
'inputID' => $input_id,
'displayID' => $display_id,
),
diff --git a/webroot/rsrc/css/phui/phui-form-view.css b/webroot/rsrc/css/phui/phui-form-view.css
--- a/webroot/rsrc/css/phui/phui-form-view.css
+++ b/webroot/rsrc/css/phui/phui-form-view.css
@@ -519,12 +519,12 @@
width: 180px;
}
-.aphront-form-choose-table td {
+.phui-form-iconset-table td {
vertical-align: middle;
padding: 4px 0;
}
-.aphront-form-choose-table .aphront-form-choose-button-cell {
+.phui-form-iconset-table .phui-form-iconset-button-cell {
padding: 4px 8px;
}
diff --git a/webroot/rsrc/js/core/behavior-choose-control.js b/webroot/rsrc/js/core/behavior-choose-control.js
--- a/webroot/rsrc/js/core/behavior-choose-control.js
+++ b/webroot/rsrc/js/core/behavior-choose-control.js
@@ -10,11 +10,11 @@
JX.Stratcom.listen(
'click',
- 'aphront-form-choose-button',
+ 'phui-form-iconset-button',
function(e) {
e.kill();
- var data = e.getNodeData('aphront-form-choose');
+ var data = e.getNodeData('phui-form-iconset');
var params = {
value: JX.$(data.inputID).value

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 5, 7:41 AM (1 w, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713596
Default Alt Text
D14799.id.diff (54 KB)

Event Timeline