2011-05-03 19:45:45 +02:00
|
|
|
<?php
|
|
|
|
|
2012-10-01 23:04:03 +02:00
|
|
|
final class PhabricatorMacroEditController
|
|
|
|
extends PhabricatorMacroController {
|
2011-05-03 19:45:45 +02:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
if ($this->id) {
|
|
|
|
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
|
|
|
|
if (!$macro) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$macro = new PhabricatorFileImageMacro();
|
|
|
|
}
|
|
|
|
|
|
|
|
$errors = array();
|
|
|
|
$e_name = 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
|
|
|
$e_file = true;
|
2012-10-05 03:43:49 +02:00
|
|
|
$file = null;
|
2013-02-21 21:43:39 +01:00
|
|
|
$can_fetch = PhabricatorEnv::getEnvConfig('security.allow-outbound-http');
|
2011-05-03 19:45:45 +02:00
|
|
|
|
|
|
|
$request = $this->getRequest();
|
2011-07-08 06:17:00 +02:00
|
|
|
$user = $request->getUser();
|
2011-05-03 19:45:45 +02:00
|
|
|
if ($request->isFormPost()) {
|
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
|
|
|
$original = clone $macro;
|
|
|
|
|
|
|
|
$new_name = null;
|
|
|
|
if ($request->getBool('name_form') || !$macro->getID()) {
|
|
|
|
$new_name = $request->getStr('name');
|
|
|
|
|
|
|
|
$macro->setName($new_name);
|
|
|
|
|
|
|
|
if (!strlen($macro->getName())) {
|
2013-01-24 04:36:23 +01:00
|
|
|
$errors[] = pht('Macro name is required.');
|
|
|
|
$e_name = pht('Required');
|
2013-01-29 23:22:36 +01:00
|
|
|
} else if (!preg_match('/^[a-z0-9:_-]{3,}$/', $macro->getName())) {
|
|
|
|
$errors[] = pht(
|
|
|
|
'Macro must be at least three characters long and contain only '.
|
|
|
|
'lowercase letters, digits, hyphens, colons and underscores.');
|
2013-01-24 04:36:23 +01:00
|
|
|
$e_name = pht('Invalid');
|
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
|
|
|
} else {
|
|
|
|
$e_name = null;
|
|
|
|
}
|
2011-05-03 19:45:45 +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
|
|
|
$file = null;
|
|
|
|
if ($request->getFileExists('file')) {
|
2011-05-03 19:45:45 +02:00
|
|
|
$file = PhabricatorFile::newFromPHPUpload(
|
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
|
|
|
$_FILES['file'],
|
2011-05-03 19:45:45 +02:00
|
|
|
array(
|
|
|
|
'name' => $request->getStr('name'),
|
2011-07-08 06:17:00 +02:00
|
|
|
'authorPHID' => $user->getPHID(),
|
2011-05-03 19:45:45 +02:00
|
|
|
));
|
2013-02-21 21:43:39 +01:00
|
|
|
} else if ($request->getStr('url')) {
|
|
|
|
try {
|
|
|
|
$file = PhabricatorFile::newFromFileDownload(
|
|
|
|
$request->getStr('url'),
|
|
|
|
array(
|
|
|
|
'name' => $request->getStr('name'),
|
|
|
|
'authorPHID' => $user->getPHID(),
|
|
|
|
));
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$errors[] = pht('Could not fetch URL: %s', $ex->getMessage());
|
|
|
|
}
|
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
|
|
|
} else if ($request->getStr('phid')) {
|
|
|
|
$file = id(new PhabricatorFile())->loadOneWhere(
|
|
|
|
'phid = %s',
|
|
|
|
$request->getStr('phid'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file) {
|
|
|
|
if (!$file->isViewableInBrowser()) {
|
|
|
|
$errors[] = pht('You must upload an image.');
|
|
|
|
$e_file = pht('Invalid');
|
|
|
|
} else {
|
|
|
|
$macro->setFilePHID($file->getPHID());
|
|
|
|
$e_file = null;
|
|
|
|
}
|
|
|
|
}
|
2011-05-03 19:45:45 +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
|
|
|
if (!$macro->getID() && !$file) {
|
2013-01-24 04:36:23 +01:00
|
|
|
$errors[] = pht('You must upload an image to create a 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
|
|
|
$e_file = pht('Required');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$errors) {
|
2011-05-03 19:45:45 +02:00
|
|
|
try {
|
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 = array();
|
|
|
|
|
|
|
|
if ($new_name !== null) {
|
|
|
|
$xactions[] = id(new PhabricatorMacroTransaction())
|
|
|
|
->setTransactionType(PhabricatorMacroTransactionType::TYPE_NAME)
|
|
|
|
->setNewValue($new_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file) {
|
|
|
|
$xactions[] = id(new PhabricatorMacroTransaction())
|
|
|
|
->setTransactionType(PhabricatorMacroTransactionType::TYPE_FILE)
|
|
|
|
->setNewValue($file->getPHID());
|
|
|
|
}
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorMacroEditor())
|
|
|
|
->setActor($user)
|
Add ApplicationTransaction handling for transactions with no effect
Summary:
When a user submits an action with no effect (like an empty comment, an "abandon" on an already-accepted revision, or a "close, resolved" on a closed task) we want to alert them that their action isn't effective. These warnings fall into two general buckets:
- User is submitting two or more actions, and some aren't effective but some are. Prompt them to apply the effective actions only.
- A special case of this is where the only effective action is a comment. We provide tailored text ("Post Comment") in this case.
- User is submitting one action, which isn't effective. Tell them they're out of luck.
- A special case of this is an empty comment. We provide tailored text in this case.
By default, the transaction editor throws when transactions have no effect. The caller can then deal with this, or use `PhabricatorApplicationTransactionNoEffectResponse` to provide a standard dialog that gives the user information as above. For cases where we expect transactions to have no effect (notably, "edit" forms) we just continue on no-effect unconditionally.
Also fix an issue where new, combined or filtered transactions would not be represented properly in the Ajax response (i.e., return final transactions from `applyTransactions()`), and translate some strings.
Test Plan:
- Submitted empty and nonempy comments in Macro and Pholio.
- Submitted comments with new and existing "@mentions".
- Submitted edits in both applications.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T912, T2104
Differential Revision: https://secure.phabricator.com/D4160
2012-12-12 02:27:40 +01:00
|
|
|
->setContinueOnNoEffect(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
|
|
|
->setContentSource(
|
|
|
|
PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
Add ApplicationTransaction handling for transactions with no effect
Summary:
When a user submits an action with no effect (like an empty comment, an "abandon" on an already-accepted revision, or a "close, resolved" on a closed task) we want to alert them that their action isn't effective. These warnings fall into two general buckets:
- User is submitting two or more actions, and some aren't effective but some are. Prompt them to apply the effective actions only.
- A special case of this is where the only effective action is a comment. We provide tailored text ("Post Comment") in this case.
- User is submitting one action, which isn't effective. Tell them they're out of luck.
- A special case of this is an empty comment. We provide tailored text in this case.
By default, the transaction editor throws when transactions have no effect. The caller can then deal with this, or use `PhabricatorApplicationTransactionNoEffectResponse` to provide a standard dialog that gives the user information as above. For cases where we expect transactions to have no effect (notably, "edit" forms) we just continue on no-effect unconditionally.
Also fix an issue where new, combined or filtered transactions would not be represented properly in the Ajax response (i.e., return final transactions from `applyTransactions()`), and translate some strings.
Test Plan:
- Submitted empty and nonempy comments in Macro and Pholio.
- Submitted comments with new and existing "@mentions".
- Submitted edits in both applications.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T912, T2104
Differential Revision: https://secure.phabricator.com/D4160
2012-12-12 02:27:40 +01:00
|
|
|
)));
|
|
|
|
|
|
|
|
$xactions = $editor->applyTransactions($original, $xactions);
|
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
|
|
|
|
|
|
|
$view_uri = $this->getApplicationURI('/view/'.$original->getID().'/');
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
2011-05-03 19:45:45 +02:00
|
|
|
} catch (AphrontQueryDuplicateKeyException $ex) {
|
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
|
|
|
throw $ex;
|
2013-01-24 04:36:23 +01:00
|
|
|
$errors[] = pht('Macro name is not unique!');
|
|
|
|
$e_name = pht('Duplicate');
|
2011-05-03 19:45:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = new AphrontErrorView();
|
2013-01-24 04:36:23 +01:00
|
|
|
$error_view->setTitle(pht('Form Errors'));
|
2011-05-03 19:45:45 +02:00
|
|
|
$error_view->setErrors($errors);
|
|
|
|
} else {
|
|
|
|
$error_view = null;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
$current_file = null;
|
|
|
|
if ($macro->getFilePHID()) {
|
|
|
|
$current_file = id(new PhabricatorFile())->loadOneWhere(
|
|
|
|
'phid = %s',
|
|
|
|
$macro->getFilePHID());
|
|
|
|
}
|
|
|
|
|
2011-05-03 19:45:45 +02:00
|
|
|
$form = new AphrontFormView();
|
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
|
|
|
$form->setFlexible(true);
|
|
|
|
$form->addHiddenInput('name_form', 1);
|
2011-05-03 19:45:45 +02:00
|
|
|
$form->setUser($request->getUser());
|
|
|
|
|
|
|
|
$form
|
|
|
|
->setEncType('multipart/form-data')
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setLabel(pht('Name'))
|
2011-05-03 19:45:45 +02:00
|
|
|
->setName('name')
|
|
|
|
->setValue($macro->getName())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setCaption(
|
|
|
|
pht('This word or phrase will be replaced with the image.'))
|
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
|
|
|
->setError($e_name));
|
|
|
|
|
|
|
|
if (!$macro->getID()) {
|
|
|
|
if ($current_file) {
|
|
|
|
$current_file_view = id(new PhabricatorFileLinkView())
|
|
|
|
->setFilePHID($current_file->getPHID())
|
|
|
|
->setFileName($current_file->getName())
|
|
|
|
->setFileViewable(true)
|
|
|
|
->setFileViewURI($current_file->getBestURI())
|
|
|
|
->render();
|
|
|
|
$form->addHiddenInput('phid', $current_file->getPHID());
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setLabel(pht('Selected File'))
|
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
|
|
|
->setValue($current_file_view));
|
|
|
|
|
|
|
|
$other_label = pht('Change File');
|
|
|
|
} else {
|
|
|
|
$other_label = pht('File');
|
|
|
|
}
|
|
|
|
|
2013-02-21 21:43:39 +01:00
|
|
|
if ($can_fetch) {
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('URL'))
|
|
|
|
->setName('url')
|
|
|
|
->setValue($request->getStr('url'))
|
|
|
|
->setError($e_file));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
$form->appendChild(
|
2011-05-03 19:45:45 +02:00
|
|
|
id(new AphrontFormFileControl())
|
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
|
|
|
->setLabel($other_label)
|
2011-05-03 19:45:45 +02:00
|
|
|
->setName('file')
|
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
|
|
|
->setError($e_file));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/');
|
|
|
|
|
|
|
|
if ($macro->getID()) {
|
|
|
|
$cancel_uri = $view_uri;
|
|
|
|
} else {
|
|
|
|
$cancel_uri = $this->getApplicationURI();
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-05-03 19:45:45 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
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
|
|
|
->setValue(pht('Save Image Macro'))
|
|
|
|
->addCancelButton($cancel_uri));
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2011-05-03 19:45:45 +02:00
|
|
|
|
|
|
|
if ($macro->getID()) {
|
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 = pht('Edit Image Macro');
|
|
|
|
$crumb = pht('Edit');
|
|
|
|
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setHref($view_uri)
|
|
|
|
->setName(pht('Macro "%s"', $macro->getName())));
|
2011-05-03 19:45:45 +02:00
|
|
|
} else {
|
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 = pht('Create Image Macro');
|
|
|
|
$crumb = pht('Create');
|
2011-05-03 19:45:45 +02:00
|
|
|
}
|
2011-12-15 07:37:23 +01: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
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setHref($request->getRequestURI())
|
|
|
|
->setName($crumb));
|
|
|
|
|
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader($title);
|
|
|
|
|
|
|
|
|
|
|
|
$upload = null;
|
|
|
|
if ($macro->getID()) {
|
|
|
|
$upload_header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader(pht('Upload New File'));
|
|
|
|
|
|
|
|
$upload_form = id(new AphrontFormView())
|
|
|
|
->setFlexible(true)
|
|
|
|
->setEncType('multipart/form-data')
|
2013-02-21 21:43:39 +01:00
|
|
|
->setUser($request->getUser());
|
|
|
|
|
|
|
|
if ($can_fetch) {
|
|
|
|
$upload_form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('URL'))
|
|
|
|
->setName('url')
|
|
|
|
->setValue($request->getStr('url')));
|
|
|
|
}
|
|
|
|
|
|
|
|
$upload_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
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormFileControl())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setLabel(pht('File'))
|
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
|
|
|
->setName('file'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-01-24 04:36:23 +01:00
|
|
|
->setValue(pht('Upload File')));
|
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
|
|
|
|
|
|
|
$upload = array($upload_header, $upload_form);
|
|
|
|
}
|
2011-05-03 19:45:45 +02:00
|
|
|
|
2012-10-01 23:04:03 +02:00
|
|
|
return $this->buildApplicationPage(
|
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(
|
|
|
|
$crumbs,
|
|
|
|
$header,
|
|
|
|
$error_view,
|
|
|
|
$form,
|
|
|
|
$upload,
|
|
|
|
),
|
2011-05-03 19:45:45 +02:00
|
|
|
array(
|
2011-12-15 07:37:23 +01:00
|
|
|
'title' => $title,
|
2011-05-03 19:45:45 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|