Changeset View
Changeset View
Standalone View
Standalone View
src/view/layout/PhabricatorActionView.php
<?php | <?php | ||||
final class PhabricatorActionView extends AphrontView { | final class PhabricatorActionView extends AphrontTagView { | ||||
private $name; | private $name; | ||||
private $icon; | private $icon; | ||||
private $iconSheet; | private $iconSheet; | ||||
private $href; | private $href; | ||||
private $disabled; | private $disabled; | ||||
private $workflow; | private $workflow; | ||||
private $renderAsForm; | private $renderAsForm; | ||||
private $download; | private $download; | ||||
private $objectURI; | private $objectURI; | ||||
private $sigils = array(); | private $isContainer; | ||||
private $metadata; | private $groupKey; | ||||
btrahan: delete me too as fatal fixing | |||||
public function setMetadata($metadata) { | private $actionSigils; | ||||
$this->metadata = $metadata; | private $actionMetadata; | ||||
private $actionWorkflow; | |||||
public function setGroupKey($group_key) { | |||||
$this->groupKey = $group_key; | |||||
return $this; | |||||
} | |||||
public function getGroupKey() { | |||||
return $this->groupKey; | |||||
} | |||||
public function setIsContainer($is_container) { | |||||
$this->isContainer = $is_container; | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getMetadata() { | public function getIsContainer() { | ||||
return $this->metadata; | return $this->isContainer; | ||||
} | } | ||||
Not Done Inline Actionsdeleting these two functions will fix the first fatal. (This diff changes this class to extend AphrontTagView, which has setMetadata defined already as "final" whereas AphrontView had no such definition. In object oriented programming, methods marked "final" cannot be overridden by inheriting classes. I peeked and getMetadata is also final in AphrontTagView so minimally those two have to go. Once you remove them you may have even more fatals but they should be mechanical to remove like this.) btrahan: deleting these two functions will fix the first fatal.
(This diff changes this class to… | |||||
public function setObjectURI($object_uri) { | public function setObjectURI($object_uri) { | ||||
$this->objectURI = $object_uri; | $this->objectURI = $object_uri; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getObjectURI() { | public function getObjectURI() { | ||||
return $this->objectURI; | return $this->objectURI; | ||||
} | } | ||||
public function setDownload($download) { | public function setDownload($download) { | ||||
$this->download = $download; | $this->download = $download; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getDownload() { | public function getDownload() { | ||||
return $this->download; | return $this->download; | ||||
} | } | ||||
public function setHref($href) { | public function setHref($href) { | ||||
$this->href = $href; | $this->href = $href; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addSigil($sigil) { | |||||
$this->sigils[] = $sigil; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* If the user is not logged in and the action is relatively complicated, | * If the user is not logged in and the action is relatively complicated, | ||||
* give them a generic login link that will re-direct to the page they're | * give them a generic login link that will re-direct to the page they're | ||||
* viewing. | * viewing. | ||||
*/ | */ | ||||
public function getHref() { | public function getHref() { | ||||
if (($this->workflow || $this->renderAsForm) && !$this->download) { | if (($this->workflow || $this->renderAsForm) && !$this->download) { | ||||
if (!$this->user || !$this->user->isLoggedIn()) { | if (!$this->user || !$this->user->isLoggedIn()) { | ||||
Show All 20 Lines | public function setName($name) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setDisabled($disabled) { | public function setDisabled($disabled) { | ||||
$this->disabled = $disabled; | $this->disabled = $disabled; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setWorkflow($workflow) { | |||||
$this->workflow = $workflow; | |||||
return $this; | |||||
} | |||||
public function setRenderAsForm($form) { | public function setRenderAsForm($form) { | ||||
$this->renderAsForm = $form; | $this->renderAsForm = $form; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function getTagName() { | ||||
return 'li'; | |||||
} | |||||
protected function willRender() { | |||||
// Before rendering, move attribute that we want to put on the actual link | |||||
// off this object. This is kind of sketchy, but we don't have any other | |||||
// similar use cases yet. | |||||
$this->actionSigils = $this->getSigils(); | |||||
$this->setSigils(array()); | |||||
$this->actionWorkflow = $this->getWorkflow(); | |||||
$this->setWorkflow(false); | |||||
$this->actionMetadata = $this->getMetadata(); | |||||
$this->clearMetadata(); | |||||
} | |||||
public function getTagAttributes() { | |||||
$classes = array(); | |||||
$classes[] = 'phabricator-action-view'; | |||||
if ($this->disabled) { | |||||
$classes[] = 'phabricator-action-view-disabled'; | |||||
} | |||||
return array( | |||||
'class' => $classes, | |||||
); | |||||
} | |||||
public function getTagContent() { | |||||
$icon = null; | $icon = null; | ||||
if ($this->icon) { | if ($this->icon) { | ||||
$sheet = nonempty($this->iconSheet, PHUIIconView::SPRITE_ICONS); | $sheet = nonempty($this->iconSheet, PHUIIconView::SPRITE_ICONS); | ||||
$suffix = ''; | $suffix = ''; | ||||
if ($this->disabled) { | if ($this->disabled) { | ||||
$suffix = '-grey'; | $suffix = '-grey'; | ||||
} | } | ||||
$icon = id(new PHUIIconView()) | $icon = id(new PHUIIconView()) | ||||
->addClass('phabricator-action-view-icon') | ->addClass('phabricator-action-view-icon') | ||||
->setSpriteIcon($this->icon.$suffix) | ->setSpriteIcon($this->icon.$suffix) | ||||
->setSpriteSheet($sheet); | ->setSpriteSheet($sheet); | ||||
} | } | ||||
if ($this->href) { | if ($this->href) { | ||||
$sigils = array(); | $sigils = $this->actionSigils; | ||||
if ($this->workflow) { | |||||
if ($this->actionWorkflow) { | |||||
$sigils[] = 'workflow'; | $sigils[] = 'workflow'; | ||||
} | } | ||||
if ($this->download) { | if ($this->download) { | ||||
$sigils[] = 'download'; | $sigils[] = 'download'; | ||||
} | } | ||||
if ($this->sigils) { | |||||
$sigils = array_merge($sigils, $this->sigils); | |||||
} | |||||
$sigils = $sigils ? implode(' ', $sigils) : null; | $sigils = $sigils ? implode(' ', $sigils) : null; | ||||
if ($this->renderAsForm) { | if ($this->renderAsForm) { | ||||
if (!$this->user) { | if (!$this->user) { | ||||
throw new Exception( | throw new Exception( | ||||
'Call setUser() when rendering an action as a form.'); | 'Call setUser() when rendering an action as a form.'); | ||||
} | } | ||||
$item = javelin_tag( | $item = javelin_tag( | ||||
'button', | 'button', | ||||
array( | array( | ||||
'class' => 'phabricator-action-view-item', | 'class' => 'phabricator-action-view-item', | ||||
), | ), | ||||
$this->name); | $this->name); | ||||
$item = phabricator_form( | $item = phabricator_form( | ||||
$this->user, | $this->user, | ||||
array( | array( | ||||
'action' => $this->getHref(), | 'action' => $this->getHref(), | ||||
'method' => 'POST', | 'method' => 'POST', | ||||
'sigil' => $sigils, | 'sigil' => $sigils, | ||||
'meta' => $this->metadata, | 'meta' => $this->actionMetadata, | ||||
Not Done Inline Actionschange to $this->getMetadata() since the local member variable is now deleted btrahan: change to $this->getMetadata() since the local member variable is now deleted | |||||
), | ), | ||||
$item); | $item); | ||||
} else { | } else { | ||||
$item = javelin_tag( | $item = javelin_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $this->getHref(), | 'href' => $this->getHref(), | ||||
'class' => 'phabricator-action-view-item', | 'class' => 'phabricator-action-view-item', | ||||
'sigil' => $sigils, | 'sigil' => $sigils, | ||||
'meta' => $this->metadata, | 'meta' => $this->actionMetadata, | ||||
Not Done Inline Actionsas above btrahan: as above | |||||
), | ), | ||||
$this->name); | $this->name); | ||||
} | } | ||||
} else { | } else { | ||||
$item = phutil_tag( | $item = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'phabricator-action-view-item', | 'class' => 'phabricator-action-view-item', | ||||
), | ), | ||||
$this->name); | $this->name); | ||||
} | } | ||||
$classes = array(); | return array($icon, $item); | ||||
$classes[] = 'phabricator-action-view'; | |||||
if ($this->disabled) { | |||||
$classes[] = 'phabricator-action-view-disabled'; | |||||
} | |||||
return phutil_tag( | |||||
'li', | |||||
array( | |||||
'class' => implode(' ', $classes), | |||||
), | |||||
array($icon, $item)); | |||||
} | } | ||||
public static function getAvailableIcons() { | public static function getAvailableIcons() { | ||||
$manifest = PHUIIconView::getSheetManifest(PHUIIconView::SPRITE_ICONS); | $manifest = PHUIIconView::getSheetManifest(PHUIIconView::SPRITE_ICONS); | ||||
$results = array(); | $results = array(); | ||||
$prefix = 'icons-'; | $prefix = 'icons-'; | ||||
foreach ($manifest as $sprite) { | foreach ($manifest as $sprite) { | ||||
Show All 13 Lines |
delete me too as fatal fixing