Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
index 214819100e..a207f57f3a 100644
--- a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
@@ -1,79 +1,80 @@
<?php
final class PhabricatorApplicationProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'application';
public function getMenuItemTypeIcon() {
return 'fa-globe';
}
public function getMenuItemTypeName() {
return pht('Application');
}
public function canAddToObject($object) {
return true;
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$app = $this->getApplication($config);
if ($app) {
return $app->getName();
} else {
return pht('(Uninstalled Application)');
}
return $app->getName();
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorDatasourceEditField())
->setKey('application')
->setLabel(pht('Application'))
+ ->setIsRequired(true)
->setDatasource(new PhabricatorApplicationDatasource())
->setSingleValue($config->getMenuItemProperty('application')),
);
}
private function getApplication(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$phid = $config->getMenuItemProperty('application');
$app = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
return $app;
}
protected function newNavigationMenuItems(
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())
->setName($app->getName())
->setIcon($app->getIcon());
return array(
$item,
);
}
}
diff --git a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
index 9074b1b117..9b9d1dff7c 100644
--- a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
@@ -1,112 +1,113 @@
<?php
final class PhabricatorDashboardProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'dashboard';
private $dashboard;
public function getMenuItemTypeIcon() {
return 'fa-dashboard';
}
public function getMenuItemTypeName() {
return pht('Dashboard');
}
public function canAddToObject($object) {
return true;
}
public function attachDashboard($dashboard) {
$this->dashboard = $dashboard;
return $this;
}
public function getDashboard() {
$dashboard = $this->dashboard;
if (!$dashboard) {
return null;
} else if ($dashboard->isArchived()) {
return null;
}
return $dashboard;
}
public function willBuildNavigationItems(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();
$dashboards = mpull($dashboards, null, 'getPHID');
foreach ($items as $item) {
$dashboard_phid = $item->getMenuItemProperty('dashboardPHID');
$dashboard = idx($dashboards, $dashboard_phid, null);
$item->getMenuItem()->attachDashboard($dashboard);
}
}
public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) {
$dashboard = $this->getDashboard();
if (!$dashboard) {
return pht('(Restricted/Invalid Dashboard)');
}
if (strlen($this->getName($config))) {
return $this->getName($config);
} else {
return $dashboard->getName();
}
}
public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) {
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField())
->setKey('dashboardPHID')
->setLabel(pht('Dashboard'))
+ ->setIsRequired(true)
->setDatasource(new PhabricatorDashboardDatasource())
->setSingleValue($config->getMenuItemProperty('dashboardPHID')),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config) {
$dashboard = $this->getDashboard();
if (!$dashboard) {
return array();
}
$icon = $dashboard->getIcon();
$name = $this->getDisplayName($config);
$href = $dashboard->getViewURI();
$item = $this->newItem()
->setHref($href)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
index 374fe10366..071efa80dd 100644
--- a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
@@ -1,122 +1,123 @@
<?php
final class PhabricatorEditEngineProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = 'editengine';
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) {
$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) = explode('/', $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 PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField())
->setKey('formKey')
->setLabel(pht('Form'))
+ ->setIsRequired(true)
->setDatasource(new PhabricatorEditEngineDatasource())
->setSingleValue($config->getMenuItemProperty('formKey')),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config) {
$form = $this->getForm();
if (!$form) {
return array();
}
$engine = $form->getEngine();
$form_key = $form->getIdentifier();
$icon = $form->getIcon();
$name = $this->getDisplayName($config);
$href = $engine->getEditURI(null, "form/{$form_key}/");
$item = $this->newItem()
->setHref($href)
->setName($name)
->setIcon($icon);
return array(
$item,
);
}
}
diff --git a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
index 002a3fcace..e47d97677f 100644
--- a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
@@ -1,113 +1,114 @@
<?php
final class PhabricatorProjectProfileMenuItem
extends PhabricatorProfileMenuItem {
const MENUITEMKEY = '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) {
$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 PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField())
->setKey('project')
->setLabel(pht('Project'))
+ ->setIsRequired(true)
->setDatasource(new PhabricatorProjectDatasource())
->setSingleValue($config->getMenuItemProperty('project')),
);
}
private function getName(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $this->getProject();
if (!$project) {
return array();
}
$picture = $project->getProfileImageURI();
$name = $this->getDisplayName($config);
$href = $project->getURI();
$item = $this->newItem()
->setHref($href)
->setName($name)
->setProfileImage($picture);
return array(
$item,
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 29, 1:43 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
187751
Default Alt Text
(12 KB)

Event Timeline