Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorMacroViewController
|
|
|
|
extends PhabricatorMacroController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2013-03-22 21:07:20 +01:00
|
|
|
$macro = id(new PhabricatorMacroQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
if (!$macro) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2013-03-22 21:07:20 +01:00
|
|
|
$file = $macro->getFile();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
|
|
|
$title_short = pht('Macro "%s"', $macro->getName());
|
|
|
|
$title_long = pht('Image Macro "%s"', $macro->getName());
|
|
|
|
|
2013-04-10 22:08:36 +02:00
|
|
|
$actions = $this->buildActionView($macro);
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2013-04-10 22:08:36 +02:00
|
|
|
$crumbs->setActionList($actions);
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setHref($this->getApplicationURI('/view/'.$macro->getID().'/'))
|
|
|
|
->setName($title_short));
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$properties = $this->buildPropertyView($macro, $actions);
|
|
|
|
if ($file) {
|
|
|
|
$file_view = new PHUIPropertyListView();
|
|
|
|
$file_view->addImageContent(
|
|
|
|
phutil_tag(
|
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $file->getViewURI(),
|
|
|
|
'class' => 'phabricator-image-macro-hero',
|
|
|
|
)));
|
|
|
|
}
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
|
|
|
$xactions = id(new PhabricatorMacroTransactionQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withObjectPHIDs(array($macro->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
|
|
->setViewer($user);
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
if ($xaction->getComment()) {
|
|
|
|
$engine->addObject(
|
|
|
|
$xaction->getComment(),
|
|
|
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$engine->process();
|
|
|
|
|
|
|
|
$timeline = id(new PhabricatorApplicationTransactionView())
|
2012-12-20 23:48:23 +01:00
|
|
|
->setUser($user)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($macro->getPHID())
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setTransactions($xactions)
|
|
|
|
->setMarkupEngine($engine);
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-10-16 19:35:52 +02:00
|
|
|
->setUser($user)
|
|
|
|
->setPolicyObject($macro)
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setHeader($title_long);
|
|
|
|
|
|
|
|
if ($macro->getIsDisabled()) {
|
|
|
|
$header->addTag(
|
|
|
|
id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE)
|
|
|
|
->setName(pht('Macro Disabled'))
|
2012-12-11 23:01:35 +01:00
|
|
|
->setBackgroundColor(PhabricatorTagView::COLOR_BLACK));
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
|
|
|
|
2013-11-22 01:09:04 +01:00
|
|
|
$comment_header = $is_serious
|
|
|
|
? pht('Add Comment')
|
|
|
|
: pht('Grovel in Awe');
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
$submit_button_name = $is_serious
|
|
|
|
? pht('Add Comment')
|
|
|
|
: pht('Lavish Praise');
|
|
|
|
|
2012-12-21 14:57:14 +01:00
|
|
|
$draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID());
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setUser($user)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($macro->getPHID())
|
2012-12-21 14:57:14 +01:00
|
|
|
->setDraft($draft)
|
2013-11-22 01:09:04 +01:00
|
|
|
->setHeaderText($comment_header)
|
2012-12-21 14:51:33 +01:00
|
|
|
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
|
|
|
|
->setSubmitButtonName($submit_button_name);
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
2013-10-11 16:53:56 +02:00
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
|
|
if ($file_view) {
|
|
|
|
$object_box->addPropertyList($file_view);
|
|
|
|
}
|
2013-09-29 00:55:38 +02:00
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box,
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
$timeline,
|
2013-11-22 01:09:04 +01:00
|
|
|
$add_comment_form,
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title_short,
|
2013-05-18 01:01:19 +02:00
|
|
|
'device' => true,
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionView(PhabricatorFileImageMacro $macro) {
|
2013-10-16 19:35:52 +02:00
|
|
|
|
|
|
|
$can_manage = $this->hasApplicationCapability(
|
|
|
|
PhabricatorMacroCapabilityManage::CAPABILITY);
|
|
|
|
|
2013-07-12 20:39:47 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($request->getUser())
|
|
|
|
->setObject($macro)
|
|
|
|
->setObjectURI($request->getRequestURI())
|
|
|
|
->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setName(pht('Edit Macro'))
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setHref($this->getApplicationURI('/edit/'.$macro->getID().'/'))
|
2013-10-16 19:35:52 +02:00
|
|
|
->setDisabled(!$can_manage)
|
|
|
|
->setWorkflow(!$can_manage)
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setIcon('edit'));
|
|
|
|
|
2013-09-28 01:01:37 +02:00
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Edit Audio'))
|
|
|
|
->setHref($this->getApplicationURI('/audio/'.$macro->getID().'/'))
|
2013-10-16 19:35:52 +02:00
|
|
|
->setDisabled(!$can_manage)
|
|
|
|
->setWorkflow(!$can_manage)
|
2013-09-28 01:01:37 +02:00
|
|
|
->setIcon('herald'));
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
if ($macro->getIsDisabled()) {
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setName(pht('Restore Macro'))
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setHref($this->getApplicationURI('/disable/'.$macro->getID().'/'))
|
|
|
|
->setWorkflow(true)
|
2013-10-16 19:35:52 +02:00
|
|
|
->setDisabled(!$can_manage)
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setIcon('undo'));
|
|
|
|
} else {
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setName(pht('Disable Macro'))
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setHref($this->getApplicationURI('/disable/'.$macro->getID().'/'))
|
|
|
|
->setWorkflow(true)
|
2013-10-16 19:35:52 +02:00
|
|
|
->setDisabled(!$can_manage)
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
->setIcon('delete'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(
|
|
|
|
PhabricatorFileImageMacro $macro,
|
2013-10-11 16:53:56 +02:00
|
|
|
PhabricatorActionListView $actions) {
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
2013-07-08 22:41:10 +02:00
|
|
|
->setUser($this->getRequest()->getUser())
|
2013-10-11 16:53:56 +02:00
|
|
|
->setObject($macro)
|
|
|
|
->setActionList($actions);
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
2013-09-28 01:01:37 +02:00
|
|
|
switch ($macro->getAudioBehavior()) {
|
|
|
|
case PhabricatorFileImageMacro::AUDIO_BEHAVIOR_ONCE:
|
|
|
|
$view->addProperty(pht('Audio Behavior'), pht('Play Once'));
|
|
|
|
break;
|
|
|
|
case PhabricatorFileImageMacro::AUDIO_BEHAVIOR_LOOP:
|
|
|
|
$view->addProperty(pht('Audio Behavior'), pht('Loop'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$audio_phid = $macro->getAudioPHID();
|
|
|
|
if ($audio_phid) {
|
|
|
|
$this->loadHandles(array($audio_phid));
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Audio'),
|
|
|
|
$this->getHandle($audio_phid)->renderLink());
|
|
|
|
}
|
|
|
|
|
2013-07-08 22:41:10 +02:00
|
|
|
$view->invokeWillRenderEvent();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|