Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php b/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
index da8498891e..6d47a4c219 100644
--- a/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
+++ b/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
@@ -1,117 +1,117 @@
<?php
final class PhabricatorDashboardPortalMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'portal';
public function getMenuItemTypeIcon() {
return 'fa-pencil';
}
public function getDefaultName() {
return pht('Manage Portal');
}
public function getMenuItemTypeName() {
return pht('Manage Portal');
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
if (!$viewer->isLoggedIn()) {
return array();
}
- $href = $this->getItemViewURI($config);
+ $uri = $this->getItemViewURI($config);
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$engine = $this->getEngine();
$portal = $engine->getProfileObject();
$controller = $engine->getController();
$header = id(new PHUIHeaderView())
->setHeader(pht('Manage Portal'));
$edit_uri = urisprintf(
'/portal/edit/%d/',
$portal->getID());
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$portal,
PhabricatorPolicyCapability::CAN_EDIT);
$curtain = $controller->newCurtainView($portal)
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Portal'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref($edit_uri));
$timeline = $controller->newTimelineView()
->setShouldTerminate(true);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(
array(
$timeline,
));
return $view;
}
}
diff --git a/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php b/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
index e077ac7ba4..dbf1586366 100644
--- a/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
+++ b/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
@@ -1,70 +1,70 @@
<?php
final class PhabricatorHomeLauncherProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'home.launcher.menu';
public function getMenuItemTypeName() {
return pht('More Applications');
}
private function getDefaultName() {
return pht('More Applications');
}
public function getMenuItemTypeIcon() {
return 'fa-ellipsis-h';
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-ellipsis-h';
- $href = '/applications/';
+ $uri = '/applications/';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php b/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
index f4f3cb8733..a002b59da5 100644
--- a/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
+++ b/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
@@ -1,73 +1,73 @@
<?php
final class PhabricatorHomeProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'home.dashboard';
public function getMenuItemTypeName() {
return pht('Built-in Homepage');
}
private function getDefaultName() {
return pht('Home');
}
public function getMenuItemTypeIcon() {
return 'fa-home';
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$name = $config->getMenuItemProperty('name');
if (strlen($name)) {
return $name;
}
return $this->getDefaultName();
}
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
return id(new PHUIHomeView())
->setViewer($viewer);
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-home';
- $href = $this->getItemViewURI($config);
+ $uri = $this->getItemViewURI($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
index 0e4da29b61..71f3aa1392 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
@@ -1,59 +1,59 @@
<?php
final class PhabricatorPeopleBadgesProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.badges';
public function getMenuItemTypeName() {
return pht('Badges');
}
private function getDefaultName() {
return pht('Badges');
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/badges/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/badges/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-trophy');
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
index f1d8be1828..b6c1c446cc 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
@@ -1,59 +1,59 @@
<?php
final class PhabricatorPeopleCommitsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.commits';
public function getMenuItemTypeName() {
return pht('Commits');
}
private function getDefaultName() {
return pht('Commits');
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/commits/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/commits/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-code');
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
index d7d36b4ed5..61508ff515 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
@@ -1,56 +1,56 @@
<?php
final class PhabricatorPeopleDetailsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.details';
public function getMenuItemTypeName() {
return pht('User Details');
}
private function getDefaultName() {
return pht('User Details');
}
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->getMenuProperty('name')),
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
- $href = urisprintf(
+ $uri = urisprintf(
'/p/%s/',
$user->getUsername());
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName(pht('Profile'))
->setIcon('fa-user');
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
index 78d3dca49d..43d2271a79 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
@@ -1,59 +1,59 @@
<?php
final class PhabricatorPeopleManageProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.manage';
public function getMenuItemTypeName() {
return pht('Manage User');
}
private function getDefaultName() {
return pht('Manage');
}
public function canHideMenuItem(
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/manage/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/manage/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gears');
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
index 938b7cf60a..3e3fc62bf0 100644
--- a/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
@@ -1,83 +1,49 @@
<?php
final class PhabricatorPeoplePictureProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.picture';
public function getMenuItemTypeName() {
return pht('User Picture');
}
private function getDefaultName() {
return pht('User Picture');
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return false;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->getDefaultName();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array();
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
- require_celerity_resource('people-picture-menu-item-css');
$picture = $user->getProfileImageURI();
$name = $user->getUsername();
- $classes = array();
- $classes[] = 'people-menu-image';
- if ($user->getIsDisabled()) {
- $classes[] = 'phui-image-disabled';
- }
+ $item = $this->newItemView()
+ ->setDisabled($user->getIsDisabled());
- $href = urisprintf(
- '/p/%s/',
- $user->getUsername());
-
- $photo = phutil_tag(
- 'img',
- array(
- 'src' => $picture,
- 'class' => implode(' ', $classes),
- ));
-
- $can_edit = PhabricatorPolicyFilter::hasCapability(
- $this->getViewer(),
- $user,
- PhabricatorPolicyCapability::CAN_EDIT);
-
- if ($can_edit) {
- $id = $user->getID();
- $href = "/people/picture/{$id}/";
- }
-
- $view = phutil_tag_div('people-menu-image-container', $photo);
- $view = phutil_tag(
- 'a',
- array(
- 'href' => $href,
- ),
- $view);
-
- $item = $this->newItem()
- ->appendChild($view);
+ $item->newProfileImage($picture);
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
index 499fc1d7f4..cfa760fcd6 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
@@ -1,59 +1,59 @@
<?php
final class PhabricatorPeopleRevisionsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.revisions';
public function getMenuItemTypeName() {
return pht('Revisions');
}
private function getDefaultName() {
return pht('Revisions');
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/revisions/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/revisions/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gear');
return array(
$item,
);
}
}
diff --git a/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
index c2a5036521..5dea58cb29 100644
--- a/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
@@ -1,59 +1,59 @@
<?php
final class PhabricatorPeopleTasksProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'people.tasks';
public function getMenuItemTypeName() {
return pht('Tasks');
}
private function getDefaultName() {
return pht('Tasks');
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/tasks/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/tasks/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-anchor');
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
index 536165e3ef..a3021e0239 100644
--- a/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
@@ -1,73 +1,73 @@
<?php
final class PhabricatorProjectDetailsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.details';
public function getMenuItemTypeName() {
return pht('Project Details');
}
private function getDefaultName() {
return pht('Project Details');
}
public function getMenuItemTypeIcon() {
return 'fa-file-text-o';
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return false;
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
$name = $project->getName();
$icon = $project->getDisplayIconIcon();
- $href = "/project/profile/{$id}/";
+ $uri = "/project/profile/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
index b20bc777ae..9b8a769318 100644
--- a/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
@@ -1,73 +1,73 @@
<?php
final class PhabricatorProjectManageProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.manage';
public function getMenuItemTypeName() {
return pht('Manage Project');
}
private function getDefaultName() {
return pht('Manage');
}
public function getMenuItemTypeIcon() {
return 'fa-cog';
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return false;
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
$name = $this->getDisplayName($config);
$icon = 'fa-gears';
- $href = "/project/manage/{$id}/";
+ $uri = "/project/manage/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
index b13543312d..11a57d3a5b 100644
--- a/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
@@ -1,63 +1,63 @@
<?php
final class PhabricatorProjectMembersProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.members';
public function getMenuItemTypeName() {
return pht('Project Members');
}
private function getDefaultName() {
return pht('Members');
}
public function getMenuItemTypeIcon() {
return 'fa-users';
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
$name = $this->getDisplayName($config);
$icon = 'fa-group';
- $href = "/project/members/{$id}/";
+ $uri = "/project/members/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
index b5c203402d..5a58b3af41 100644
--- a/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
@@ -1,73 +1,51 @@
<?php
final class PhabricatorProjectPictureProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.picture';
public function getMenuItemTypeName() {
return pht('Project Picture');
}
private function getDefaultName() {
return pht('Project Picture');
}
public function getMenuItemTypeIcon() {
return 'fa-image';
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return false;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->getDefaultName();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array();
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
- require_celerity_resource('people-picture-menu-item-css');
-
$picture = $project->getProfileImageURI();
- $href = $project->getProfileURI();
-
- $classes = array();
- $classes[] = 'people-menu-image';
- if ($project->isArchived()) {
- $classes[] = 'phui-image-disabled';
- }
-
- $photo = phutil_tag(
- 'img',
- array(
- 'src' => $picture,
- 'class' => implode(' ', $classes),
- ));
- $view = phutil_tag_div('people-menu-image-container', $photo);
- $view = phutil_tag(
- 'a',
- array(
- 'href' => $href,
- ),
- $view);
+ $item = $this->newItemView()
+ ->setDisabled($project->isArchived());
- $item = $this->newItem()
- ->appendChild($view);
+ $item->newProfileImage($picture);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
index b64b4bb7a0..d8c7ee82b1 100644
--- a/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
@@ -1,176 +1,176 @@
<?php
final class PhabricatorProjectPointsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.points';
public function getMenuItemTypeName() {
return pht('Project Points');
}
private function getDefaultName() {
return pht('Points Bar');
}
public function shouldEnableForObject($object) {
$viewer = $this->getViewer();
// Only render this element for milestones.
if (!$object->isMilestone()) {
return false;
}
// Don't show if points aren't configured.
if (!ManiphestTaskPoints::getIsEnabled()) {
return false;
}
// Points are only available if Maniphest is installed.
$class = 'PhabricatorManiphestApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return false;
}
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->getDefaultName();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorInstructionsEditField())
->setValue(
pht(
'This is a progress bar which shows how many points of work '.
'are complete within the milestone. It has no configurable '.
'settings.')),
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$project = $config->getProfileObject();
$limit = 250;
$tasks = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withEdgeLogicPHIDs(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
PhabricatorQueryConstraint::OPERATOR_AND,
array($project->getPHID()))
->setLimit($limit + 1)
->execute();
$error = array();
if (count($tasks) > $limit) {
$error[] =
pht(
'Too many tasks (%s).',
new PhutilNumber($limit));
}
if (!$tasks) {
$error[] = pht('This milestone has no tasks.');
}
$statuses = array();
$points_done = 0;
$points_total = 0;
$no_points = 0;
foreach ($tasks as $task) {
$points = $task->getPoints();
if ($points === null) {
$no_points++;
continue;
}
if (!$points) {
continue;
}
$status = $task->getStatus();
if (empty($statuses[$status])) {
$statuses[$status] = 0;
}
$statuses[$status] += $points;
if (ManiphestTaskStatus::isClosedStatus($status)) {
$points_done += $points;
}
$points_total += $points;
}
if ($no_points == count($tasks)) {
$error[] = pht('No tasks have points assigned.');
}
if (!$points_total) {
$error[] = pht('No tasks have positive points.');
}
$label = pht(
'%s of %s %s',
new PhutilNumber($points_done),
new PhutilNumber($points_total),
ManiphestTaskPoints::getPointsLabel());
$bar = id(new PHUISegmentBarView())
->setLabel($label);
$map = ManiphestTaskStatus::getTaskStatusMap();
$statuses = array_select_keys($statuses, array_keys($map));
foreach ($statuses as $status => $points) {
if (!$points) {
continue;
}
if (!ManiphestTaskStatus::isClosedStatus($status)) {
continue;
}
$color = ManiphestTaskStatus::getStatusColor($status);
if (!$color) {
$color = 'sky';
}
$tooltip = pht(
'%s %s',
new PhutilNumber($points),
ManiphestTaskStatus::getTaskStatusName($status));
$bar->newSegment()
->setWidth($points / $points_total)
->setColor($color)
->setTooltip($tooltip);
}
if ($error) {
$bar->setLabel(head($error));
}
$bar = phutil_tag(
'div',
array(
'class' => 'phui-profile-segment-bar',
),
$bar);
- $item = $this->newItem()
- ->appendChild($bar);
+ $item = $this->newItemView()
+ ->newProgressBar($bar);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
index da43e30bb8..b1782e8f1c 100644
--- a/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
@@ -1,70 +1,70 @@
<?php
final class PhabricatorProjectSubprojectsProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.subprojects';
public function getMenuItemTypeName() {
return pht('Project Subprojects');
}
private function getDefaultName() {
return pht('Subprojects');
}
public function getMenuItemTypeIcon() {
return 'fa-sitemap';
}
public function shouldEnableForObject($object) {
if ($object->isMilestone()) {
return false;
}
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
$name = $this->getDisplayName($config);
$icon = 'fa-sitemap';
- $href = "/project/subprojects/{$id}/";
+ $uri = "/project/subprojects/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
index 1485f1ef8a..34152f85e7 100644
--- a/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
@@ -1,77 +1,77 @@
<?php
final class PhabricatorProjectWorkboardProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project.workboard';
public function getMenuItemTypeName() {
return pht('Project Workboard');
}
private function getDefaultName() {
return pht('Workboard');
}
public function getMenuItemTypeIcon() {
return 'fa-columns';
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
public function shouldEnableForObject($object) {
$viewer = $this->getViewer();
// Workboards are only available if Maniphest is installed.
$class = 'PhabricatorManiphestApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return false;
}
return true;
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
- $href = $project->getWorkboardURI();
+ $uri = $project->getWorkboardURI();
$name = $this->getDisplayName($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon('fa-columns');
return array(
$item,
);
}
}
diff --git a/src/applications/search/engine/PhabricatorProfileMenuItemView.php b/src/applications/search/engine/PhabricatorProfileMenuItemView.php
index 44e0055a7d..d947afcba6 100644
--- a/src/applications/search/engine/PhabricatorProfileMenuItemView.php
+++ b/src/applications/search/engine/PhabricatorProfileMenuItemView.php
@@ -1,212 +1,232 @@
<?php
final class PhabricatorProfileMenuItemView
extends Phobject {
private $config;
private $uri;
private $name;
private $icon;
+ private $iconImage;
private $disabled;
private $tooltip;
private $actions = array();
private $counts = array();
private $images = array();
private $progressBars = array();
private $isExternalLink;
private $specialType;
public function setMenuItemConfiguration(
PhabricatorProfileMenuItemConfiguration $config) {
$this->config = $config;
return $this;
}
public function getMenuItemConfiguration() {
return $this->config;
}
public function setURI($uri) {
$this->uri = $uri;
return $this;
}
public function getURI() {
return $this->uri;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function setIcon($icon) {
$this->icon = $icon;
return $this;
}
public function getIcon() {
return $this->icon;
}
+ public function setIconImage($icon_image) {
+ $this->iconImage = $icon_image;
+ return $this;
+ }
+
+ public function getIconImage() {
+ return $this->iconImage;
+ }
+
public function setDisabled($disabled) {
$this->disabled = $disabled;
return $this;
}
public function getDisabled() {
return $this->disabled;
}
public function setTooltip($tooltip) {
$this->tooltip = $tooltip;
return $this;
}
public function getTooltip() {
return $this->tooltip;
}
public function newAction($uri) {
$this->actions[] = $uri;
return null;
}
public function newCount($count) {
$this->counts[] = $count;
return null;
}
public function newProfileImage($src) {
$this->images[] = $src;
return null;
}
public function newProgressBar($bar) {
$this->progressBars[] = $bar;
return null;
}
public function setIsExternalLink($is_external) {
$this->isExternalLink = $is_external;
return $this;
}
public function getIsExternalLink() {
return $this->isExternalLink;
}
public function setIsLabel($is_label) {
return $this->setSpecialType('label');
}
public function getIsLabel() {
return $this->isSpecialType('label');
}
public function setIsDivider($is_divider) {
return $this->setSpecialType('divider');
}
public function getIsDivider() {
return $this->isSpecialType('divider');
}
private function setSpecialType($type) {
$this->specialType = $type;
return $this;
}
private function isSpecialType($type) {
return ($this->specialType === $type);
}
public function newListItemView() {
$view = id(new PHUIListItemView())
->setName($this->getName());
$uri = $this->getURI();
if (strlen($uri)) {
if ($this->getIsExternalLink()) {
if (!PhabricatorEnv::isValidURIForLink($uri)) {
$uri = '#';
}
$view->setRel('noreferrer');
}
$view->setHref($uri);
}
$icon = $this->getIcon();
if ($icon) {
$view->setIcon($icon);
}
+ $icon_image = $this->getIconImage();
+ if ($icon_image) {
+ $view->setProfileImage($icon_image);
+ }
+
if ($this->getDisabled()) {
$view->setDisabled(true);
}
if ($this->getIsLabel()) {
$view->setType(PHUIListItemView::TYPE_LABEL);
}
if ($this->getIsDivider()) {
$view
->setType(PHUIListItemView::TYPE_DIVIDER)
->addClass('phui-divider');
}
+ $tooltip = $this->getTooltip();
+ if (strlen($tooltip)) {
+ $view->setTooltip($tooltip);
+ }
+
if ($this->images) {
require_celerity_resource('people-picture-menu-item-css');
foreach ($this->images as $image_src) {
$classes = array();
$classes[] = 'people-menu-image';
if ($this->getDisabled()) {
$classes[] = 'phui-image-disabled';
}
$image = phutil_tag(
'img',
array(
'src' => $image_src,
'class' => implode(' ', $classes),
));
$image = phutil_tag(
'div',
array(
'class' => 'people-menu-image-container',
),
$image);
$view->appendChild($image);
}
}
foreach ($this->counts as $count) {
$view->appendChild(
phutil_tag(
'span',
array(
'class' => 'phui-list-item-count',
),
$count));
}
foreach ($this->actions as $action) {
$view->setActionIcon('fa-pencil', $action);
}
foreach ($this->progressBars as $bar) {
$view->appendChild($bar);
}
return $view;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
index aa42d56cfb..040b877368 100644
--- a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
@@ -1,147 +1,147 @@
<?php
final class PhabricatorApplicationProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'application';
const FIELD_APPLICATION = 'application';
public function getMenuItemTypeIcon() {
return 'fa-globe';
}
public function getMenuItemTypeName() {
return pht('Application');
}
public function canAddToObject($object) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$application = $this->getApplication($config);
if (!$application) {
return pht('(Restricted/Invalid Application)');
}
$name = $this->getName($config);
if (strlen($name)) {
return $name;
}
return $application->getName();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_APPLICATION)
->setLabel(pht('Application'))
->setDatasource(new PhabricatorApplicationDatasource())
->setIsRequired(true)
->setSingleValue($config->getMenuItemProperty('application')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
private function getApplication(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$phid = $config->getMenuItemProperty('application');
$apps = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->execute();
return head($apps);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$app = $this->getApplication($config);
if (!$app) {
return array();
}
$is_installed = PhabricatorApplication::isClassInstalledForViewer(
get_class($app),
$viewer);
if (!$is_installed) {
return array();
}
- $item = $this->newItem()
- ->setHref($app->getApplicationURI())
+ $item = $this->newItemView()
+ ->setURI($app->getApplicationURI())
->setName($this->getDisplayName($config))
->setIcon($app->getIcon());
// Don't show tooltip if they've set a custom name
$name = $config->getMenuItemProperty('name');
if (!strlen($name)) {
$item->setTooltip($app->getShortDescription());
}
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_APPLICATION) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose an application.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
$applications = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withPHIDs(array($new))
->execute();
if (!$applications) {
$errors[] = $this->newInvalidError(
pht(
'Application "%s" is not a valid application which you have '.
'permission to see.',
$new),
$xaction['xaction']);
}
}
}
return $errors;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
index 542c634958..591dee8604 100644
--- a/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
@@ -1,183 +1,176 @@
<?php
final class PhabricatorConpherenceProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'conpherence';
const FIELD_CONPHERENCE = 'conpherence';
private $conpherence;
public function getMenuItemTypeIcon() {
return 'fa-comments';
}
public function getMenuItemTypeName() {
return pht('Conpherence');
}
public function canAddToObject($object) {
$application = new PhabricatorConpherenceApplication();
if (!$application->isInstalled()) {
return false;
}
return true;
}
public function attachConpherence($conpherence) {
$this->conpherence = $conpherence;
return $this;
}
public function getConpherence() {
$conpherence = $this->conpherence;
if (!$conpherence) {
return null;
}
return $conpherence;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$room_phids = array();
foreach ($items as $item) {
$room_phids[] = $item->getMenuItemProperty('conpherence');
}
$rooms = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withPHIDs($room_phids)
->needProfileImage(true)
->execute();
$rooms = mpull($rooms, null, 'getPHID');
foreach ($items as $item) {
$room_phid = $item->getMenuItemProperty('conpherence');
$room = idx($rooms, $room_phid, null);
$item->getMenuItem()->attachConpherence($room);
}
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$room = $this->getConpherence($config);
if (!$room) {
return pht('(Restricted/Invalid Conpherence)');
}
$name = $this->getName($config);
if (strlen($name)) {
return $name;
}
return $room->getTitle();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_CONPHERENCE)
->setLabel(pht('Conpherence Room'))
->setDatasource(new ConpherenceThreadDatasource())
->setIsRequired(true)
->setSingleValue($config->getMenuItemProperty('conpherence')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$room = $this->getConpherence($config);
if (!$room) {
return array();
}
$participants = $room->getParticipants();
$viewer_phid = $viewer->getPHID();
$unread_count = null;
if (isset($participants[$viewer_phid])) {
$data = $room->getDisplayData($viewer);
$unread_count = $data['unread_count'];
}
- $count = null;
+ $item = $this->newItemView()
+ ->setURI('/'.$room->getMonogram())
+ ->setName($this->getDisplayName($config))
+ ->setIcon('fa-comments');
+
if ($unread_count) {
- $count = phutil_tag(
- 'span',
- array(
- 'class' => 'phui-list-item-count',
- ),
- $unread_count);
+ $item->newCount($unread_count);
}
- $item = $this->newItem()
- ->setHref('/'.$room->getMonogram())
- ->setName($this->getDisplayName($config))
- ->setIcon('fa-comments')
- ->appendChild($count);
-
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_CONPHERENCE) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a room.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
$rooms = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withPHIDs(array($new))
->execute();
if (!$rooms) {
$errors[] = $this->newInvalidError(
pht(
'Room "%s" is not a valid room which you have '.
'permission to see.',
$new),
$xaction['xaction']);
}
}
}
return $errors;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
index 7d4f319b61..af913778ee 100644
--- a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
@@ -1,194 +1,238 @@
<?php
final class PhabricatorDashboardProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'dashboard';
const FIELD_DASHBOARD = 'dashboardPHID';
private $dashboard;
+ private $dashboardHandle;
public function getMenuItemTypeIcon() {
return 'fa-dashboard';
}
public function getMenuItemTypeName() {
return pht('Dashboard');
}
public function canAddToObject($object) {
return true;
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
- public function attachDashboard($dashboard) {
+ private function attachDashboard(PhabricatorDashboard $dashboard = null) {
$this->dashboard = $dashboard;
return $this;
}
- public function getDashboard() {
- $dashboard = $this->dashboard;
-
- if (!$dashboard) {
- return null;
- } else if ($dashboard->isArchived()) {
- return null;
- }
-
- return $dashboard;
+ private function getDashboard() {
+ return $this->dashboard;
}
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$dashboard_phid = $config->getMenuItemProperty('dashboardPHID');
// Reload the dashboard to attach panels, which we need for rendering.
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withPHIDs(array($dashboard_phid))
->needPanels(true)
->executeOne();
if (!$dashboard) {
- return null;
+ return $this->newEmptyView(
+ pht('Invalid Dashboard'),
+ pht('This dashboard is invalid and could not be loaded.'));
+ }
+
+ if ($dashboard->isArchived()) {
+ return $this->newEmptyView(
+ pht('Archived Dashboard'),
+ pht('This dashboard has been archived.'));
}
$engine = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard);
return $engine->renderDashboard();
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$dashboard_phids = array();
foreach ($items as $item) {
$dashboard_phids[] = $item->getMenuItemProperty('dashboardPHID');
}
$dashboards = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withPHIDs($dashboard_phids)
->execute();
+ $handles = $viewer->loadHandles($dashboard_phids);
+
$dashboards = mpull($dashboards, null, 'getPHID');
foreach ($items as $item) {
$dashboard_phid = $item->getMenuItemProperty('dashboardPHID');
$dashboard = idx($dashboards, $dashboard_phid, null);
- $item->getMenuItem()->attachDashboard($dashboard);
+
+ $menu_item = $item->getMenuItem();
+
+ $menu_item
+ ->attachDashboard($dashboard)
+ ->setDashboardHandle($handles[$dashboard_phid]);
}
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$dashboard = $this->getDashboard();
if (!$dashboard) {
- return pht('(Restricted/Invalid Dashboard)');
+ if ($this->getDashboardHandle()->getPolicyFiltered()) {
+ return pht('Restricted Dashboard');
+ } else {
+ return pht('Invalid Dashboard');
+ }
+ }
+
+ if ($dashboard->isArchived()) {
+ return pht('Archived Dashboard');
}
if (strlen($this->getName($config))) {
return $this->getName($config);
} else {
return $dashboard->getName();
}
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_DASHBOARD)
->setLabel(pht('Dashboard'))
->setIsRequired(true)
->setDatasource(new PhabricatorDashboardDatasource())
->setSingleValue($config->getMenuItemProperty('dashboardPHID')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
+ $is_disabled = true;
+ $action_uri = null;
+
$dashboard = $this->getDashboard();
- if (!$dashboard) {
- return array();
+ if ($dashboard) {
+ if ($dashboard->isArchived()) {
+ $icon = 'fa-ban';
+ $name = $this->getDisplayName($config);
+ } else {
+ $icon = $dashboard->getIcon();
+ $name = $this->getDisplayName($config);
+ $is_disabled = false;
+ $action_uri = '/dashboard/arrange/'.$dashboard->getID().'/';
+ }
+ } else {
+ $icon = 'fa-ban';
+ if ($this->getDashboardHandle()->getPolicyFiltered()) {
+ $name = pht('Restricted Dashboard');
+ } else {
+ $name = pht('Invalid Dashboard');
+ }
}
- $icon = $dashboard->getIcon();
- $name = $this->getDisplayName($config);
- $href = $this->getItemViewURI($config);
- $action_href = '/dashboard/arrange/'.$dashboard->getID().'/';
+ $uri = $this->getItemViewURI($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon)
- ->setActionIcon('fa-pencil', $action_href);
+ ->setDisabled($is_disabled);
+
+ if ($action_uri) {
+ $item->newAction($action_uri);
+ }
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_DASHBOARD) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a dashboard.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
$dashboards = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withPHIDs(array($new))
->execute();
if (!$dashboards) {
$errors[] = $this->newInvalidError(
pht(
'Dashboard "%s" is not a valid dashboard which you have '.
'permission to see.',
$new),
$xaction['xaction']);
}
}
}
return $errors;
}
+ private function getDashboardHandle() {
+ return $this->dashboardHandle;
+ }
+
+ private function setDashboardHandle(PhabricatorObjectHandle $handle) {
+ $this->dashboardHandle = $handle;
+ return $this;
+ }
+
}
diff --git a/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
index e6a6e608e6..8510418fab 100644
--- a/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
@@ -1,49 +1,48 @@
<?php
final class PhabricatorDividerProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'divider';
public function getMenuItemTypeIcon() {
return 'fa-minus';
}
public function getMenuItemTypeName() {
return pht('Divider');
}
public function canAddToObject($object) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return pht("\xE2\x80\x94");
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorInstructionsEditField())
->setValue(
pht(
'This is a visual divider which you can use to separate '.
'sections in the menu. It does not have any configurable '.
'options.')),
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
- $item = $this->newItem()
- ->setType(PHUIListItemView::TYPE_DIVIDER)
- ->addClass('phui-divider');
+ $item = $this->newItemView()
+ ->setIsDivider(true);
return array(
$item,
);
}
}
diff --git a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
index 88749d247f..71e3d7e8a5 100644
--- a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
@@ -1,177 +1,177 @@
<?php
final class PhabricatorEditEngineProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'editengine';
const FIELD_FORM = 'formKey';
private $form;
public function getMenuItemTypeIcon() {
return 'fa-plus';
}
public function getMenuItemTypeName() {
return pht('Form');
}
public function canAddToObject($object) {
return true;
}
public function attachForm($form) {
$this->form = $form;
return $this;
}
public function getForm() {
$form = $this->form;
if (!$form) {
return null;
}
return $form;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$engines = PhabricatorEditEngine::getAllEditEngines();
$engine_keys = array_keys($engines);
$forms = id(new PhabricatorEditEngineConfigurationQuery())
->setViewer($viewer)
->withEngineKeys($engine_keys)
->withIsDisabled(false)
->execute();
$form_engines = mgroup($forms, 'getEngineKey');
$form_ids = $forms;
$builtin_map = array();
foreach ($form_engines as $engine_key => $form_engine) {
$builtin_map[$engine_key] = mpull($form_engine, null, 'getBuiltinKey');
}
foreach ($items as $item) {
$key = $item->getMenuItemProperty('formKey');
list($engine_key, $form_key) = PhabricatorEditEngine::splitFullKey($key);
if (is_numeric($form_key)) {
$form = idx($form_ids, $form_key, null);
$item->getMenuItem()->attachForm($form);
} else if (isset($builtin_map[$engine_key][$form_key])) {
$form = $builtin_map[$engine_key][$form_key];
$item->getMenuItem()->attachForm($form);
}
}
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$form = $this->getForm();
if (!$form) {
return pht('(Restricted/Invalid Form)');
}
if (strlen($this->getName($config))) {
return $this->getName($config);
} else {
return $form->getName();
}
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_FORM)
->setLabel(pht('Form'))
->setIsRequired(true)
->setDatasource(new PhabricatorEditEngineDatasource())
->setSingleValue($config->getMenuItemProperty('formKey')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$form = $this->getForm();
if (!$form) {
return array();
}
$icon = $form->getIcon();
$name = $this->getDisplayName($config);
- $href = $form->getCreateURI();
- if ($href === null) {
+ $uri = $form->getCreateURI();
+ if ($uri === null) {
return array();
}
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_FORM) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a form.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
list($engine_key, $form_key) = PhabricatorEditEngine::splitFullKey(
$new);
$forms = id(new PhabricatorEditEngineConfigurationQuery())
->setViewer($viewer)
->withEngineKeys(array($engine_key))
->withIdentifiers(array($form_key))
->execute();
if (!$forms) {
$errors[] = $this->newInvalidError(
pht(
'Form "%s" is not a valid form which you have permission to '.
'see.',
$new),
$xaction['xaction']);
}
}
}
return $errors;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
index 605098f216..a152da5898 100644
--- a/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
@@ -1,75 +1,75 @@
<?php
final class PhabricatorLabelProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'label';
const FIELD_NAME = 'name';
public function getMenuItemTypeIcon() {
return 'fa-tag';
}
public function getMenuItemTypeName() {
return pht('Label');
}
public function canAddToObject($object) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->getLabelName($config);
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorTextEditField())
->setKey(self::FIELD_NAME)
->setLabel(pht('Name'))
->setIsRequired(true)
->setValue($this->getLabelName($config)),
);
}
private function getLabelName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$name = $this->getLabelName($config);
- $item = $this->newItem()
+ $item = $this->newItemView()
->setName($name)
- ->setType(PHUIListItemView::TYPE_LABEL);
+ ->setIsLabel(true);
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_NAME) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a label name.'),
$field_key);
}
}
return $errors;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
index 0b6a2f330e..bba3b01060 100644
--- a/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
@@ -1,159 +1,151 @@
<?php
final class PhabricatorLinkProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'link';
const FIELD_URI = 'uri';
const FIELD_NAME = 'name';
const FIELD_TOOLTIP = 'tooltip';
public function getMenuItemTypeIcon() {
return 'fa-link';
}
public function getMenuItemTypeName() {
return pht('Link');
}
public function canAddToObject($object) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->getLinkName($config);
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorTextEditField())
->setKey(self::FIELD_NAME)
->setLabel(pht('Name'))
->setIsRequired(true)
->setValue($this->getLinkName($config)),
id(new PhabricatorTextEditField())
->setKey(self::FIELD_URI)
->setLabel(pht('URI'))
->setIsRequired(true)
->setValue($this->getLinkURI($config)),
id(new PhabricatorTextEditField())
->setKey(self::FIELD_TOOLTIP)
->setLabel(pht('Tooltip'))
->setValue($this->getLinkTooltip($config)),
id(new PhabricatorIconSetEditField())
->setKey('icon')
->setLabel(pht('Icon'))
->setIconSet(new PhabricatorProfileMenuItemIconSet())
->setValue($this->getLinkIcon($config)),
);
}
private function getLinkName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
private function getLinkIcon(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('icon', 'link');
}
private function getLinkURI(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('uri');
}
private function getLinkTooltip(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('tooltip');
}
- private function isValidLinkURI($uri) {
- return PhabricatorEnv::isValidURIForLink($uri);
- }
-
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$icon = $this->getLinkIcon($config);
$name = $this->getLinkName($config);
- $href = $this->getLinkURI($config);
+ $uri = $this->getLinkURI($config);
$tooltip = $this->getLinkTooltip($config);
- if (!$this->isValidLinkURI($href)) {
- $href = '#';
- }
-
$icon_object = id(new PhabricatorProfileMenuItemIconSet())
->getIcon($icon);
if ($icon_object) {
$icon_class = $icon_object->getIcon();
} else {
$icon_class = 'fa-link';
}
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon_class)
->setTooltip($tooltip)
- ->setRel('noreferrer');
+ ->setIsExternalLink(true);
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_NAME) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a link name.'),
$field_key);
}
}
if ($field_key == self::FIELD_URI) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a URI to link to.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
- if (!$this->isValidLinkURI($new)) {
+ if (!PhabricatorEnv::isValidURIForLink($new)) {
$errors[] = $this->newInvalidError(
pht(
'URI "%s" is not a valid link URI. It should be a full, valid '.
'URI beginning with a protocol like "%s".',
$new,
'https://'),
$xaction['xaction']);
}
}
}
return $errors;
}
}
diff --git a/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
index 2d882ae2c8..89ac4a5633 100644
--- a/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
@@ -1,76 +1,76 @@
<?php
final class PhabricatorManageProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'menu.manage';
public function getMenuItemTypeName() {
return pht('Manage Menu');
}
private function getDefaultName() {
return pht('Edit Menu');
}
public function getMenuItemTypeIcon() {
return 'fa-pencil';
}
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(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
if (!$viewer->isLoggedIn()) {
return array();
}
$engine = $this->getEngine();
- $href = $engine->getItemURI('configure/');
+ $uri = $engine->getItemURI('configure/');
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
index 071979d391..bf4c61f1e5 100644
--- a/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
@@ -1,160 +1,160 @@
<?php
final class PhabricatorMotivatorProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'motivator';
public function getMenuItemTypeIcon() {
return 'fa-coffee';
}
public function getMenuItemTypeName() {
return pht('Motivator');
}
public function canAddToObject($object) {
return ($object instanceof PhabricatorHomeApplication);
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$options = $this->getOptions();
$name = idx($options, $config->getMenuItemProperty('source'));
if ($name !== null) {
return pht('Motivator: %s', $name);
} else {
return pht('Motivator');
}
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorInstructionsEditField())
->setValue(
pht(
'Motivate your team with inspirational quotes from great minds. '.
'This menu item shows a new quote every day.')),
id(new PhabricatorSelectEditField())
->setKey('source')
->setLabel(pht('Source'))
->setOptions($this->getOptions()),
);
}
private function getOptions() {
return array(
'catfacts' => pht('Cat Facts'),
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$source = $config->getMenuItemProperty('source');
switch ($source) {
case 'catfacts':
default:
$facts = $this->getCatFacts();
$fact_name = pht('Cat Facts');
$fact_icon = 'fa-paw';
break;
}
$fact_text = $this->selectFact($facts);
- $item = $this->newItem()
+ $item = $this->newItemView()
->setName($fact_name)
->setIcon($fact_icon)
->setTooltip($fact_text)
->setHref('#');
return array(
$item,
);
}
private function getCatFacts() {
return array(
pht('Cats purr when they are happy, upset, or asleep.'),
pht('The first cats evolved on the savannah about 8,000 years ago.'),
pht(
'Cats have a tail, two feet, between one and three ears, and two '.
'other feet.'),
pht('Cats use their keen sense of smell to avoid feeling empathy.'),
pht('The first cats evolved in swamps about 65 years ago.'),
pht(
'You can tell how warm a cat is by examining the coloration: cooler '.
'areas are darker.'),
pht(
'Cat tails are flexible because they contain thousands of tiny '.
'bones.'),
pht(
'A cattail is a wetland plant with an appearance that resembles '.
'the tail of a cat.'),
pht(
'Cats must eat a diet rich in fish to replace the tiny bones in '.
'their tails.'),
pht('Cats are stealthy predators and nearly invisible to radar.'),
pht(
'Cats use a special type of magnetism to help them land on their '.
'feet.'),
pht(
'A cat can run seven times faster than a human, but only for a '.
'short distance.'),
pht(
'The largest recorded cat was nearly 11 inches long from nose to '.
'tail.'),
pht(
'Not all cats can retract their claws, but most of them can.'),
pht(
'In the wild, cats and raccoons sometimes hunt together in packs.'),
pht(
'The Spanish word for cat is "cato". The biggest cat is called '.
'"el cato".'),
pht(
'The Japanese word for cat is "kome", which is also the word for '.
'rice. Japanese cats love to eat rice, so the two are synonymous.'),
pht('Cats have five pointy ends.'),
pht('cat -A can find mice hiding in files.'),
pht('A cat\'s visual, olfactory, and auditory senses, '.
'Contribute to their hunting skills and natural defenses.'),
pht(
'Cats with high self-esteem seek out high perches '.
'to launch their attacks. Watch out!'),
pht('Cats prefer vanilla ice cream.'),
pht('Taco cat spelled backwards is taco cat.'),
pht(
'Cats will often bring you their prey because they feel sorry '.
'for your inability to hunt.'),
pht('Cats spend most of their time plotting to kill their owner.'),
pht('Outside of the CAT scan, cats have made almost no contributions '.
'to modern medicine.'),
pht('In ancient Egypt, the cat-god Horus watched over all cats.'),
pht('The word "catastrophe" has no etymological relationship to the '.
'word "cat".'),
pht('Many cats appear black in low light, suffering a -2 modifier to '.
'luck rolls.'),
pht('The popular trivia game "World of Warcraft" features a race of '.
'cat people called the Khajiit.'),
);
}
private function selectFact(array $facts) {
// This is a simple pseudorandom number generator that avoids touching
// srand(), because it would seed it to a highly predictable value. It
// selects a new fact every day.
$seed = ((int)date('Y') * 366) + (int)date('z');
for ($ii = 0; $ii < 32; $ii++) {
$seed = ((1664525 * $seed) + 1013904223) % (1 << 31);
}
return $facts[$seed % count($facts)];
}
}
diff --git a/src/applications/search/menuitem/PhabricatorProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
index 061afc7fad..118815393d 100644
--- a/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
@@ -1,134 +1,163 @@
<?php
abstract class PhabricatorProfileMenuItem extends Phobject {
private $viewer;
private $engine;
- final public function buildNavigationMenuItems(
- PhabricatorProfileMenuItemConfiguration $config) {
- return $this->newNavigationMenuItems($config);
- }
-
- abstract protected function newNavigationMenuItems(
- PhabricatorProfileMenuItemConfiguration $config);
-
- public function willBuildNavigationItems(array $items) {}
public function getMenuItemTypeIcon() {
return null;
}
abstract public function getMenuItemTypeName();
abstract public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config);
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array();
}
public function canAddToObject($object) {
return false;
}
public function shouldEnableForObject($object) {
return true;
}
public function canHideMenuItem(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return false;
}
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function getViewer() {
return $this->viewer;
}
public function setEngine(PhabricatorProfileMenuEngine $engine) {
$this->engine = $engine;
return $this;
}
public function getEngine() {
return $this->engine;
}
final public function getMenuItemKey() {
return $this->getPhobjectClassConstant('MENUITEMKEY');
}
final public static function getAllMenuItems() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getMenuItemKey')
->execute();
}
- protected function newItem() {
- return new PHUIListItemView();
+ final protected function newItemView() {
+ return new PhabricatorProfileMenuItemView();
}
+ public function willGetMenuItemViewList(array $items) {}
+
+ final public function getMenuItemViewList(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $list = $this->newMenuItemViewList($config);
+
+ if (!is_array($list)) {
+ throw new Exception(
+ pht(
+ 'Expected "newMenuItemViewList()" to return a list (in class "%s"), '.
+ 'but it returned something else ("%s").',
+ get_class($this),
+ phutil_describe_type($list)));
+ }
+
+ assert_instances_of($list, 'PhabricatorProfileMenuItemView');
+
+ foreach ($list as $view) {
+ $view->setMenuItemConfiguration($config);
+ }
+
+ return $list;
+ }
+
+ abstract protected function newMenuItemViewList(
+ PhabricatorProfileMenuItemConfiguration $config);
+
+
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
return null;
}
public function getItemViewURI(
PhabricatorProfileMenuItemConfiguration $config) {
$engine = $this->getEngine();
$key = $config->getItemIdentifier();
return $engine->getItemURI("view/{$key}/");
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
return array();
}
final protected function isEmptyTransaction($value, array $xactions) {
$result = $value;
foreach ($xactions as $xaction) {
$result = $xaction['new'];
}
return !strlen($result);
}
final protected function newError($title, $message, $xaction = null) {
return new PhabricatorApplicationTransactionValidationError(
PhabricatorProfileMenuItemConfigurationTransaction::TYPE_PROPERTY,
$title,
$message,
$xaction);
}
final protected function newRequiredError($message, $type) {
$xaction = id(new PhabricatorProfileMenuItemConfigurationTransaction())
->setMetadataValue('property.key', $type);
return $this->newError(pht('Required'), $message, $xaction)
->setIsMissingFieldError(true);
}
final protected function newInvalidError($message, $xaction = null) {
return $this->newError(pht('Invalid'), $message, $xaction);
}
+ final protected function newEmptyView($title, $message) {
+ return id(new PHUIInfoView())
+ ->setTitle($title)
+ ->setSeverity(PHUIInfoView::SEVERITY_NODATA)
+ ->setErrors(
+ array(
+ $message,
+ ));
+ }
+
}
diff --git a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
index aadabd179a..efb61f06a1 100644
--- a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
@@ -1,160 +1,160 @@
<?php
final class PhabricatorProjectProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'project';
const FIELD_PROJECT = 'project';
private $project;
public function getMenuItemTypeIcon() {
return 'fa-briefcase';
}
public function getMenuItemTypeName() {
return pht('Project');
}
public function canAddToObject($object) {
return true;
}
public function attachProject($project) {
$this->project = $project;
return $this;
}
public function getProject() {
$project = $this->project;
if (!$project) {
return null;
} else if ($project->isArchived()) {
return null;
}
return $project;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$project_phids = array();
foreach ($items as $item) {
$project_phids[] = $item->getMenuItemProperty('project');
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withPHIDs($project_phids)
->needImages(true)
->execute();
$projects = mpull($projects, null, 'getPHID');
foreach ($items as $item) {
$project_phid = $item->getMenuItemProperty('project');
$project = idx($projects, $project_phid, null);
$item->getMenuItem()->attachProject($project);
}
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $this->getProject();
if (!$project) {
return pht('(Restricted/Invalid Project)');
}
if (strlen($this->getName($config))) {
return $this->getName($config);
} else {
return $project->getName();
}
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_PROJECT)
->setLabel(pht('Project'))
->setIsRequired(true)
->setDatasource(new PhabricatorProjectDatasource())
->setSingleValue($config->getMenuItemProperty('project')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $this->getProject();
if (!$project) {
return array();
}
$picture = $project->getProfileImageURI();
$name = $this->getDisplayName($config);
- $href = $project->getURI();
+ $uri = $project->getURI();
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
- ->setProfileImage($picture);
+ ->setIconImage($picture);
return array(
$item,
);
}
public function validateTransactions(
PhabricatorProfileMenuItemConfiguration $config,
$field_key,
$value,
array $xactions) {
$viewer = $this->getViewer();
$errors = array();
if ($field_key == self::FIELD_PROJECT) {
if ($this->isEmptyTransaction($value, $xactions)) {
$errors[] = $this->newRequiredError(
pht('You must choose a project.'),
$field_key);
}
foreach ($xactions as $xaction) {
$new = $xaction['new'];
if (!$new) {
continue;
}
if ($new === $value) {
continue;
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withPHIDs(array($new))
->execute();
if (!$projects) {
$errors[] = $this->newInvalidError(
pht(
'Project "%s" is not a valid project which you have '.
'permission to see.',
$new),
$xaction['xaction']);
}
}
}
return $errors;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 4:34 PM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140537
Default Alt Text
(90 KB)

Event Timeline