From ccb206e984d1650fcad8b9c2376f4da409d58b9e Mon Sep 17 00:00:00 2001 From: Debarghya Das Date: Mon, 4 Feb 2013 09:54:01 -0800 Subject: [PATCH] Added a Disable Macros function that can be called in some contexts where Macros are unsuitable Summary: Semi Fixed T2397 Test Plan: Can disable the meme button on manually toggling the class variable. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2397 Differential Revision: https://secure.phabricator.com/D4781 --- .../blog/PhameBlogEditController.php | 3 ++- .../post/PhamePostEditController.php | 1 + .../control/PhabricatorRemarkupControl.php | 25 +++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php index d043b147a2..6a9f952726 100644 --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -122,7 +122,8 @@ final class PhameBlogEditController ->setName('description') ->setValue($blog->getDescription()) ->setID('blog-description') - ->setUser($user)) + ->setUser($user) + ->setDisableMacros(true)) ->appendChild( id(new AphrontFormPolicyControl()) ->setUser($user) diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php index 2f16595716..20217edc51 100644 --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -133,6 +133,7 @@ final class PhamePostEditController ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setID('post-body') ->setUser($user) + ->setDisableMacros(true) ) ->appendChild( id(new AphrontFormSelectControl()) diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php index 5198c0cf8d..5520a7f5fe 100644 --- a/src/view/form/control/PhabricatorRemarkupControl.php +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -1,7 +1,11 @@ disableMacro = $disable; + return $this; + } protected function renderInput() { $id = $this->getID(); if (!$id) { @@ -48,20 +52,22 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { ), 'table' => array( 'tip' => pht('Table'), - ), - array( + ) + ); + if (!$this->disableMacro and function_exists('imagettftext')) { + $actions[] = array( 'spacer' => true, - ), - 'meme' => array( + ); + $actions['meme'] = array( 'tip' => pht('Meme'), - ), - 'help' => array( + ); + } + $actions['help'] = array( 'tip' => pht('Help'), 'align' => 'right', 'href' => PhabricatorEnv::getDoclink( 'article/Remarkup_Reference.html'), - ), - ); + ); $buttons = array(); foreach ($actions as $action => $spec) { @@ -74,7 +80,6 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { ''); continue; } - $classes = array(); $classes[] = 'remarkup-assist-button'; if (idx($spec, 'align') == 'right') {