mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 03:02:43 +01:00
2a6b2dbbfd
Summary: Ref T10054. Take specialization off the objects and put it on Engine subclasses instead. One reason for this is that certain objects (like users) might have multiple different sets of panels in the future (e.g., their user profile and their home page). Test Plan: - No user-visible changes. - PanelEngine no longer has any hardcoded "project" stuff. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15018
94 lines
2.2 KiB
PHP
94 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorLinkProfilePanel
|
|
extends PhabricatorProfilePanel {
|
|
|
|
const PANELKEY = 'link';
|
|
|
|
public function getPanelTypeIcon() {
|
|
return 'fa-link';
|
|
}
|
|
|
|
public function getPanelTypeName() {
|
|
return pht('Link');
|
|
}
|
|
|
|
public function canAddToObject($object) {
|
|
return true;
|
|
}
|
|
|
|
public function getDisplayName(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
return $this->getLinkName($config);
|
|
}
|
|
|
|
public function buildEditEngineFields(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
return array(
|
|
id(new PhabricatorTextEditField())
|
|
->setKey('name')
|
|
->setLabel(pht('Name'))
|
|
->setIsRequired(true)
|
|
->setValue($this->getLinkName($config)),
|
|
id(new PhabricatorTextEditField())
|
|
->setKey('uri')
|
|
->setLabel(pht('URI'))
|
|
->setIsRequired(true)
|
|
->setValue($this->getLinkURI($config)),
|
|
id(new PhabricatorIconSetEditField())
|
|
->setKey('icon')
|
|
->setLabel(pht('Icon'))
|
|
->setIconSet(new PhabricatorProfilePanelIconSet())
|
|
->setValue($this->getLinkIcon($config)),
|
|
);
|
|
}
|
|
|
|
private function getLinkName(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
return $config->getPanelProperty('name');
|
|
}
|
|
|
|
private function getLinkIcon(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
return $config->getPanelProperty('icon', 'link');
|
|
}
|
|
|
|
private function getLinkURI(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
return $config->getPanelProperty('uri');
|
|
}
|
|
|
|
private function isValidLinkURI($uri) {
|
|
return PhabricatorEnv::isValidURIForLink($uri);
|
|
}
|
|
|
|
protected function newNavigationMenuItems(
|
|
PhabricatorProfilePanelConfiguration $config) {
|
|
|
|
$icon = $this->getLinkIcon($config);
|
|
$name = $this->getLinkName($config);
|
|
$href = $this->getLinkURI($config);
|
|
|
|
if (!$this->isValidLinkURI($href)) {
|
|
$href = '#';
|
|
}
|
|
|
|
$icon_object = id(new PhabricatorProfilePanelIconSet())
|
|
->getIcon($icon);
|
|
if ($icon_object) {
|
|
$icon_class = $icon_object->getIcon();
|
|
} else {
|
|
$icon_class = 'fa-link';
|
|
}
|
|
|
|
$item = $this->newItem()
|
|
->setHref($href)
|
|
->setName($name)
|
|
->setIcon($icon_class);
|
|
|
|
return array(
|
|
$item,
|
|
);
|
|
}
|
|
|
|
}
|