Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14747027
D17160.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D17160.diff
View Options
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
@@ -2654,6 +2654,13 @@
'PhabricatorFactSimpleSpec' => 'applications/fact/spec/PhabricatorFactSimpleSpec.php',
'PhabricatorFactSpec' => 'applications/fact/spec/PhabricatorFactSpec.php',
'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php',
+ 'PhabricatorFavoritesApplication' => 'applications/favorites/application/PhabricatorFavoritesApplication.php',
+ 'PhabricatorFavoritesConstants' => 'applications/favorites/constants/PhabricatorFavoritesConstants.php',
+ 'PhabricatorFavoritesController' => 'applications/favorites/controller/PhabricatorFavoritesController.php',
+ 'PhabricatorFavoritesMainController' => 'applications/favorites/controller/PhabricatorFavoritesMainController.php',
+ 'PhabricatorFavoritesManageProfileMenuItem' => 'applications/favorites/menuitem/PhabricatorFavoritesManageProfileMenuItem.php',
+ 'PhabricatorFavoritesMenuItemController' => 'applications/favorites/controller/PhabricatorFavoritesMenuItemController.php',
+ 'PhabricatorFavoritesProfileMenuEngine' => 'applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php',
'PhabricatorFaxContentSource' => 'infrastructure/contentsource/PhabricatorFaxContentSource.php',
'PhabricatorFeedApplication' => 'applications/feed/application/PhabricatorFeedApplication.php',
'PhabricatorFeedBuilder' => 'applications/feed/builder/PhabricatorFeedBuilder.php',
@@ -7650,6 +7657,13 @@
'PhabricatorFactSimpleSpec' => 'PhabricatorFactSpec',
'PhabricatorFactSpec' => 'Phobject',
'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator',
+ 'PhabricatorFavoritesApplication' => 'PhabricatorApplication',
+ 'PhabricatorFavoritesConstants' => 'PhabricatorFavoritesController',
+ 'PhabricatorFavoritesController' => 'PhabricatorController',
+ 'PhabricatorFavoritesMainController' => 'PhabricatorFavoritesController',
+ 'PhabricatorFavoritesManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
+ 'PhabricatorFavoritesMenuItemController' => 'PhabricatorFavoritesController',
+ 'PhabricatorFavoritesProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
'PhabricatorFaxContentSource' => 'PhabricatorContentSource',
'PhabricatorFeedApplication' => 'PhabricatorApplication',
'PhabricatorFeedBuilder' => 'Phobject',
diff --git a/src/applications/favorites/application/PhabricatorFavoritesApplication.php b/src/applications/favorites/application/PhabricatorFavoritesApplication.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/application/PhabricatorFavoritesApplication.php
@@ -0,0 +1,39 @@
+<?php
+
+final class PhabricatorFavoritesApplication extends PhabricatorApplication {
+
+ public function getBaseURI() {
+ return '/favorites/';
+ }
+
+ public function getName() {
+ return pht('Favorites');
+ }
+
+ public function getShortDescription() {
+ return pht('Favorite Items');
+ }
+
+ public function getIcon() {
+ return 'fa-star-o';
+ }
+
+ public function getRoutes() {
+ return array(
+ '/favorites/' => array(
+ '' => 'PhabricatorFavoritesMainController',
+ '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting(
+ 'PhabricatorFavoritesMenuItemController'),
+ ),
+ );
+ }
+
+ public function isLaunchable() {
+ return false;
+ }
+
+ public function getApplicationOrder() {
+ return 9;
+ }
+
+}
diff --git a/src/applications/favorites/constants/PhabricatorFavoritesConstants.php b/src/applications/favorites/constants/PhabricatorFavoritesConstants.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/constants/PhabricatorFavoritesConstants.php
@@ -0,0 +1,8 @@
+<?php
+
+final class PhabricatorFavoritesConstants
+ extends PhabricatorFavoritesController {
+
+ const ITEM_MANAGE = 'favorites.manage';
+
+}
diff --git a/src/applications/favorites/controller/PhabricatorFavoritesController.php b/src/applications/favorites/controller/PhabricatorFavoritesController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/controller/PhabricatorFavoritesController.php
@@ -0,0 +1,3 @@
+<?php
+
+abstract class PhabricatorFavoritesController extends PhabricatorController {}
diff --git a/src/applications/favorites/controller/PhabricatorFavoritesMainController.php b/src/applications/favorites/controller/PhabricatorFavoritesMainController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/controller/PhabricatorFavoritesMainController.php
@@ -0,0 +1,58 @@
+<?php
+
+final class PhabricatorFavoritesMainController
+ extends PhabricatorFavoritesController {
+
+ public function shouldAllowPublic() {
+ return false;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $menu = id(new PHUIObjectItemListView())
+ ->setUser($viewer);
+
+ $menu->addItem(
+ id(new PHUIObjectItemView())
+ ->setHeader(pht('Personal Menu Items'))
+ ->setHref($this->getApplicationURI('personal/item/configure/'))
+ ->setImageURI($viewer->getProfileImageURI())
+ ->addAttribute(pht('Edit favorites for your personal account.')));
+
+ $icon = id(new PHUIIconView())
+ ->setIcon('fa-globe')
+ ->setBackground('bg-blue');
+
+ $menu->addItem(
+ id(new PHUIObjectItemView())
+ ->setHeader(pht('Global Menu Items'))
+ ->setHref($this->getApplicationURI('global/item/configure/'))
+ ->setImageIcon($icon)
+ ->addAttribute(pht('Edit global default favorites for all users.')));
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(pht('Manage'));
+ $crumbs->setBorder(true);
+
+ $box = id(new PHUIObjectBoxView())
+ ->setObjectList($menu);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader(pht('Manage Favorites'))
+ ->setHeaderIcon('fa-star-o');
+
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter(array(
+ $box,
+ ));
+
+ return $this->newPage()
+ ->setTitle(pht('Manage'))
+ ->setCrumbs($crumbs)
+ ->appendChild($view);
+
+ }
+
+}
diff --git a/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php b/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php
@@ -0,0 +1,29 @@
+<?php
+
+final class PhabricatorFavoritesMenuItemController
+ extends PhabricatorFavoritesController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $type = $request->getURIData('type');
+ $custom_phid = null;
+ if ($type == 'personal') {
+ $custom_phid = $viewer->getPHID();
+ }
+
+ $application = 'PhabricatorFavoritesApplication';
+ $favorites = id(new PhabricatorApplicationQuery())
+ ->setViewer($viewer)
+ ->withClasses(array($application))
+ ->withInstalled(true)
+ ->executeOne();
+
+ $engine = id(new PhabricatorFavoritesProfileMenuEngine())
+ ->setProfileObject($favorites)
+ ->setCustomPHID($custom_phid)
+ ->setController($this);
+
+ return $engine->buildResponse();
+ }
+
+}
diff --git a/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php b/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php
@@ -0,0 +1,36 @@
+<?php
+
+final class PhabricatorFavoritesProfileMenuEngine
+ extends PhabricatorProfileMenuEngine {
+
+ protected function isMenuEngineConfigurable() {
+ return true;
+ }
+
+ protected function getItemURI($path) {
+ $object = $this->getProfileObject();
+ $custom = $this->getCustomPHID();
+
+ if ($custom) {
+ return "/favorites/personal/item/{$path}";
+ } else {
+ return "/favorites/global/item/{$path}";
+ }
+ }
+
+ protected function getBuiltinProfileItems($object) {
+ $items = array();
+
+ $custom = $this->getCustomPHID();
+
+ if ($custom) {
+ $items[] = $this->newItem()
+ ->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_MANAGE)
+ ->setMenuItemKey(
+ PhabricatorFavoritesManageProfileMenuItem::MENUITEMKEY);
+ }
+
+ return $items;
+ }
+
+}
diff --git a/src/applications/favorites/menuitem/PhabricatorFavoritesManageProfileMenuItem.php b/src/applications/favorites/menuitem/PhabricatorFavoritesManageProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/favorites/menuitem/PhabricatorFavoritesManageProfileMenuItem.php
@@ -0,0 +1,65 @@
+<?php
+
+final class PhabricatorFavoritesManageProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'favorites.manage';
+
+ public function getMenuItemTypeName() {
+ return pht('Manage Favorites');
+ }
+
+ private function getDefaultName() {
+ return pht('Manage');
+ }
+
+ public function canHideMenuItem(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return false;
+ }
+
+ public function canMakeDefault(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return false;
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $name = $config->getMenuItemProperty('name');
+
+ if (strlen($name)) {
+ return $name;
+ }
+
+ return $this->getDefaultName();
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setPlaceholder($this->getDefaultName())
+ ->setValue($config->getMenuItemProperty('name')),
+ );
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+
+ $name = $this->getDisplayName($config);
+ $icon = 'fa-pencil';
+ $href = '/favorites/personal/item/configure/';
+
+ $item = $this->newItem()
+ ->setHref($href)
+ ->setName($name)
+ ->setIcon($icon);
+
+ return array(
+ $item,
+ );
+ }
+
+}
diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
--- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php
+++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
@@ -748,9 +748,11 @@
return new Aphront404Response();
}
+ $custom_phid = $this->getCustomPHID();
$configuration = PhabricatorProfileMenuItemConfiguration::initializeNewItem(
$object,
- $item_type);
+ $item_type,
+ $custom_phid);
$viewer = $this->getViewer();
@@ -765,6 +767,7 @@
->setMenuEngine($this)
->setProfileObject($object)
->setNewMenuItemConfiguration($configuration)
+ ->setCustomPHID($custom_phid)
->setController($controller)
->buildResponse();
}
@@ -778,6 +781,7 @@
->setMenuEngine($this)
->setProfileObject($object)
->setController($controller)
+ ->setCustomPHID($this->getCustomPHID())
->buildResponse();
}
@@ -810,6 +814,7 @@
->setProfileObject($object)
->setNewMenuItemConfiguration($configuration)
->setController($controller)
+ ->setCustomPHID($this->getCustomPHID())
->buildResponse();
}
diff --git a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
--- a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
+++ b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
@@ -34,13 +34,15 @@
public static function initializeNewItem(
$profile_object,
- PhabricatorProfileMenuItem $item) {
+ PhabricatorProfileMenuItem $item,
+ $custom_phid) {
return self::initializeNewBuiltin()
->setProfilePHID($profile_object->getPHID())
->setMenuItemKey($item->getMenuItemKey())
->attachMenuItem($item)
- ->attachProfileObject($profile_object);
+ ->attachProfileObject($profile_object)
+ ->setCustomPHID($custom_phid);
}
protected function getConfiguration() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 9:58 AM (4 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7029504
Default Alt Text
D17160.diff (12 KB)
Attached To
Mode
D17160: Basic Favorites application
Attached
Detach File
Event Timeline
Log In to Comment