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();
|
|
|
|
|
|
|
|
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
|
|
|
|
if (!$macro) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$file = id(new PhabricatorFile())->loadOneWhere(
|
|
|
|
'phid = %s',
|
|
|
|
$macro->getFilePHID());
|
|
|
|
|
|
|
|
$title_short = pht('Macro "%s"', $macro->getName());
|
|
|
|
$title_long = pht('Image Macro "%s"', $macro->getName());
|
|
|
|
|
|
|
|
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
|
|
|
$macro->getPHID());
|
|
|
|
|
|
|
|
$this->loadHandles($subscribers);
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setHref($this->getApplicationURI('/view/'.$macro->getID().'/'))
|
|
|
|
->setName($title_short));
|
|
|
|
|
|
|
|
$actions = $this->buildActionView($macro);
|
|
|
|
$properties = $this->buildPropertyView($macro, $file, $subscribers);
|
|
|
|
|
|
|
|
$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)
|
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);
|
|
|
|
|
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
|
|
->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');
|
|
|
|
|
|
|
|
$add_comment_header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader(
|
|
|
|
$is_serious
|
|
|
|
? pht('Add Comment')
|
|
|
|
: pht('Grovel in Awe'));
|
|
|
|
|
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)
|
2012-12-21 14:57:14 +01:00
|
|
|
->setDraft($draft)
|
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
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$header,
|
|
|
|
$actions,
|
|
|
|
$properties,
|
|
|
|
$timeline,
|
|
|
|
$add_comment_header,
|
|
|
|
$add_comment_form,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title_short,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionView(PhabricatorFileImageMacro $macro) {
|
|
|
|
$view = new PhabricatorActionListView();
|
|
|
|
$view->setUser($this->getRequest()->getUser());
|
|
|
|
$view->setObject($macro);
|
|
|
|
$view->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().'/'))
|
|
|
|
->setIcon('edit'));
|
|
|
|
|
|
|
|
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)
|
|
|
|
->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)
|
|
|
|
->setIcon('delete'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(
|
|
|
|
PhabricatorFileImageMacro $macro,
|
|
|
|
PhabricatorFile $file = null,
|
|
|
|
array $subscribers) {
|
|
|
|
|
|
|
|
$view = new PhabricatorPropertyListView();
|
|
|
|
|
|
|
|
if ($subscribers) {
|
|
|
|
$sub_view = array();
|
|
|
|
foreach ($subscribers as $subscriber) {
|
|
|
|
$sub_view[] = $this->getHandle($subscriber)->renderLink();
|
|
|
|
}
|
|
|
|
$sub_view = implode(', ', $sub_view);
|
|
|
|
} else {
|
|
|
|
$sub_view = '<em>'.pht('None').'</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Subscribers'),
|
|
|
|
$sub_view);
|
|
|
|
|
|
|
|
if ($file) {
|
|
|
|
$view->addTextContent(
|
2013-01-18 03:39:02 +01:00
|
|
|
phutil_tag(
|
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
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $file->getViewURI(),
|
|
|
|
'class' => 'phabricator-image-macro-hero',
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|