Differential D13933 Diff 33634 src/applications/macro/controller/PhabricatorMacroOriginalSizeController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/controller/PhabricatorMacroOriginalSizeController.php
- This file was added.
| <?php | |||||
| final class PhabricatorMacroOriginalSizeController | |||||
| extends PhabricatorMacroController { | |||||
| public function handleRequest(AphrontRequest $request) { | |||||
| $viewer = $request->getViewer(); | |||||
| $id = $request->getURIData('id'); | |||||
| $this->requireApplicationCapability( | |||||
| PhabricatorMacroManageCapability::CAPABILITY); | |||||
| $macro = id(new PhabricatorMacroQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($id)) | |||||
| ->needFiles(true) | |||||
| ->executeOne(); | |||||
| if (!$macro) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $view_uri = $this->getApplicationURI('/view/'.$id.'/'); | |||||
| if ($macro->getFile()->getMimeType() === 'image/gif') { | |||||
| $dialog = new AphrontDialogView(); | |||||
| $dialog | |||||
| ->setUser($request->getUser()) | |||||
| ->setTitle(pht('Animated macros can not be resized')) | |||||
| ->appendChild( | |||||
| phutil_tag( | |||||
| 'p', | |||||
| array(), | |||||
| pht( | |||||
| 'Sorry, but animated macros can not be '. | |||||
| 'automatically resized by Phabricator.'))) | |||||
| ->addCancelButton($view_uri); | |||||
| return id(new AphrontDialogResponse())->setDialog($dialog); | |||||
| } | |||||
| $xaction = id(new PhabricatorMacroTransaction()) | |||||
| ->setTransactionType(PhabricatorMacroTransaction::TYPE_ORIGINAL_SIZE) | |||||
| ->setNewValue($macro->getUseOriginalSize() ? 0 : 1); | |||||
| $editor = id(new PhabricatorMacroEditor()) | |||||
| ->setActor($viewer) | |||||
| ->setContentSourceFromRequest($request); | |||||
| $xactions = $editor->applyTransactions($macro, array($xaction)); | |||||
| return id(new AphrontRedirectResponse())->setURI($view_uri); | |||||
| } | |||||
| } | |||||