diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ce0e83299c..6c1ff60c61 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -944,6 +944,7 @@ phutil_register_library_map(array( 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', 'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php', 'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php', + 'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php', 'PhabricatorRemarkupRuleCountdown' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php', 'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleDifferential.php', 'PhabricatorRemarkupRuleDifferentialHandle' => 'infrastructure/markup/rule/handle/PhabricatorRemarkupRuleDifferentialHandle.php', @@ -2057,6 +2058,7 @@ phutil_register_library_map(array( 'PhabricatorPropertyListView' => 'AphrontView', 'PhabricatorRedirectController' => 'PhabricatorController', 'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController', + 'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl', 'PhabricatorRemarkupRuleCountdown' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleDifferential' => 'PhabricatorRemarkupRuleObjectName', 'PhabricatorRemarkupRuleDifferentialHandle' => 'PhabricatorRemarkupRuleObjectHandle', diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php index f86704f9da..5725717774 100644 --- a/src/applications/differential/view/DifferentialAddCommentView.php +++ b/src/applications/differential/view/DifferentialAddCommentView.php @@ -108,21 +108,12 @@ final class DifferentialAddCommentView extends AphrontView { ->setID('add-ccs-tokenizer') ->setDisableBehavior(true)) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setName('comment') ->setID('comment-content') ->setLabel('Comment') ->setEnableDragAndDropFileUploads(true) - ->setValue($this->draft) - ->setCaption(phutil_render_tag( - 'a', - array( - 'href' => PhabricatorEnv::getDoclink( - 'article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'))) + ->setValue($this->draft)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($is_serious ? 'Submit' : 'Clowncopterize')); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index a4d730057d..829889bbf7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -565,20 +565,11 @@ final class DiffusionCommitController extends DiffusionController { ->setID('add-ccs-tokenizer') ->setDisableBehavior(true)) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setLabel('Comments') ->setName('content') ->setValue($draft) - ->setID('audit-content') - ->setCaption(phutil_render_tag( - 'a', - array( - 'href' => PhabricatorEnv::getDoclink( - 'article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'))) + ->setID('audit-content')) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($is_serious ? 'Submit' : 'Cook the Books')); diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 12615caac5..7e95e04e77 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -374,9 +374,6 @@ final class ManiphestTaskDetailController extends ManiphestController { unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]); } - $remarkup_href = PhabricatorEnv::getDoclink( - 'article/Remarkup_Reference.html'); - $comment_form = new AphrontFormView(); $comment_form ->setUser($user) @@ -435,19 +432,10 @@ final class ManiphestTaskDetailController extends ManiphestController { ->setControlID('file') ->setControlStyle('display: none')) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setLabel('Comments') ->setName('comments') ->setValue($draft_text) - ->setCaption( - phutil_render_tag( - 'a', - array( - 'href' => $remarkup_href, - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference')) ->setID('transaction-comments')) ->appendChild( id(new AphrontFormDragAndDropUploadControl()) diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index 631c0fc877..ab48d6c89f 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -486,24 +486,28 @@ final class ManiphestTaskEditController extends ManiphestController { } } + + $description_control = new PhabricatorRemarkupControl(); + // "Upsell" creating tasks via email in create flows if the instance is + // configured for this awesomeness. $email_create = PhabricatorEnv::getEnvConfig( 'metamta.maniphest.public-create-email'); - $email_hint = null; if (!$task->getID() && $email_create) { $email_hint = 'You can also create tasks by sending an email to: '. ''.phutil_escape_html($email_create).''; + $description_control->setCaption($email_hint); } - $panel_id = celerity_generate_unique_node_id(); + $description_control + ->setLabel('Description') + ->setName('description') + ->setID('description-textarea') + ->setValue($task->getDescription()); $form - ->appendChild( - id(new AphrontFormTextAreaControl()) - ->setLabel('Description') - ->setName('description') - ->setID('description-textarea') - ->setCaption($email_hint) - ->setValue($task->getDescription())); + ->appendChild($description_control); + + $panel_id = celerity_generate_unique_node_id(); if (!$task->getID()) { $form diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php index 352c8e780f..e7a806049a 100644 --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -181,16 +181,6 @@ final class PhameBlogEditController $panel->addButton($delete_button); } - $remarkup_reference = phutil_render_tag( - 'a', - array( - 'href' => - PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'); - $form = id(new AphrontFormView()) ->setUser($user) ->appendChild( @@ -202,13 +192,12 @@ final class PhameBlogEditController ->setError($e_name) ) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setLabel('Description') ->setName('description') ->setValue($blog->getDescription()) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setID('blog-description') - ->setCaption($remarkup_reference) ) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php index 732d7c147b..a986e20e14 100644 --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -232,16 +232,6 @@ final class PhamePostEditController $panel->addButton($delete_button); } - $remarkup_reference = phutil_render_tag( - 'a', - array( - 'href' => - PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'); - $form = id(new AphrontFormView()) ->setUser($user) ->appendChild( @@ -264,14 +254,13 @@ final class PhamePostEditController ->setError($e_phame_title) ) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setLabel('Body') ->setName('body') ->setValue($post->getBody()) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setEnableDragAndDropFileUploads(true) ->setID('post-body') - ->setCaption($remarkup_reference) ) ->appendChild( id(new AphrontFormSelectControl()) diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php index 935fff78db..19b49365ce 100644 --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -177,15 +177,6 @@ final class PhrictionEditController $uri = PhrictionDocument::getSlugURI($uri); $uri = PhabricatorEnv::getProductionURI($uri); - $remarkup_reference = phutil_render_tag( - 'a', - array( - 'href' => PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'); - $cancel_uri = PhrictionDocument::getSlugURI($document->getSlug()); if ($draft && @@ -227,14 +218,13 @@ final class PhrictionEditController ->setLabel('URI') ->setValue($uri)) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setLabel('Content') ->setValue($content_text) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setName('content') ->setID('document-textarea') - ->setEnableDragAndDropFileUploads(true) - ->setCaption($remarkup_reference)) + ->setEnableDragAndDropFileUploads(true)) ->appendChild( id(new AphrontFormTextControl()) ->setLabel('Edit Notes') diff --git a/src/applications/ponder/controller/PonderQuestionAskController.php b/src/applications/ponder/controller/PonderQuestionAskController.php index 8b622fc4cd..e571016abd 100644 --- a/src/applications/ponder/controller/PonderQuestionAskController.php +++ b/src/applications/ponder/controller/PonderQuestionAskController.php @@ -100,20 +100,11 @@ final class PonderQuestionAskController extends PonderController { ->setName('title') ->setValue($title)) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setName('content') ->setID('content') ->setValue($content) - ->setLabel("Question") - ->setCaption(phutil_render_tag( - 'a', - array( - 'href' => PhabricatorEnv::getDoclink( - 'article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - "Formatting Reference"))) + ->setLabel("Question")) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Ask Away!')); diff --git a/src/applications/ponder/view/PonderAddAnswerView.php b/src/applications/ponder/view/PonderAddAnswerView.php index 3db0294683..c1604ea7b2 100644 --- a/src/applications/ponder/view/PonderAddAnswerView.php +++ b/src/applications/ponder/view/PonderAddAnswerView.php @@ -56,19 +56,10 @@ final class PonderAddAnswerView extends AphrontView { ->setWorkflow(true) ->addHiddenInput('question_id', $question->getID()) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setName('answer') ->setID('answer-content') - ->setEnableDragAndDropFileUploads(true) - ->setCaption(phutil_render_tag( - 'a', - array( - 'href' => PhabricatorEnv::getDoclink( - 'article/Remarkup_Reference.html'), - 'tabindex' => '-1', - 'target' => '_blank', - ), - 'Formatting Reference'))) + ->setEnableDragAndDropFileUploads(true)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($is_serious ? 'Submit' : 'Make it so.')); diff --git a/src/view/form/control/AphrontFormTextAreaControl.php b/src/view/form/control/AphrontFormTextAreaControl.php index da581b6191..c237eaaf0b 100644 --- a/src/view/form/control/AphrontFormTextAreaControl.php +++ b/src/view/form/control/AphrontFormTextAreaControl.php @@ -16,7 +16,10 @@ * limitations under the License. */ -final class AphrontFormTextAreaControl extends AphrontFormControl { +/** + * @concrete-extensible + */ +class AphrontFormTextAreaControl extends AphrontFormControl { const HEIGHT_VERY_SHORT = 'very-short'; const HEIGHT_SHORT = 'short'; diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php new file mode 100644 index 0000000000..b2335d302f --- /dev/null +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -0,0 +1,42 @@ +'.$caption; + } else { + $caption_suffix = ''; + } + + return phutil_render_tag( + 'a', + array( + 'href' => PhabricatorEnv::getDoclink( + 'article/Remarkup_Reference.html'), + 'tabindex' => '-1', + 'target' => '_blank', + ), + 'Formatting Reference') . + $caption_suffix; + } + +}