diff --git a/src/applications/conpherence/controller/ConpherenceNewController.php b/src/applications/conpherence/controller/ConpherenceNewController.php --- a/src/applications/conpherence/controller/ConpherenceNewController.php +++ b/src/applications/conpherence/controller/ConpherenceNewController.php @@ -87,10 +87,11 @@ ->setError($e_participants)) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setName('message') - ->setValue($message) - ->setLabel(pht('Message')) - ->setError($e_message)); + ->setUser($user) + ->setName('message') + ->setValue($message) + ->setLabel(pht('Message')) + ->setError($e_message)); $dialog->appendChild($form); diff --git a/src/applications/differential/customfield/DifferentialRevertPlanField.php b/src/applications/differential/customfield/DifferentialRevertPlanField.php --- a/src/applications/differential/customfield/DifferentialRevertPlanField.php +++ b/src/applications/differential/customfield/DifferentialRevertPlanField.php @@ -85,6 +85,7 @@ public function renderEditControl(array $handles) { return id(new PhabricatorRemarkupControl()) + ->setUser($this->getViewer()) ->setName($this->getFieldKey()) ->setValue($this->getValue()) ->setLabel($this->getFieldName()); diff --git a/src/applications/differential/customfield/DifferentialSummaryField.php b/src/applications/differential/customfield/DifferentialSummaryField.php --- a/src/applications/differential/customfield/DifferentialSummaryField.php +++ b/src/applications/differential/customfield/DifferentialSummaryField.php @@ -39,6 +39,7 @@ public function renderEditControl(array $handles) { return id(new PhabricatorRemarkupControl()) + ->setUser($this->getViewer()) ->setName($this->getFieldKey()) ->setValue($this->getValue()) ->setError($this->getFieldError()) diff --git a/src/applications/differential/customfield/DifferentialTestPlanField.php b/src/applications/differential/customfield/DifferentialTestPlanField.php --- a/src/applications/differential/customfield/DifferentialTestPlanField.php +++ b/src/applications/differential/customfield/DifferentialTestPlanField.php @@ -53,6 +53,7 @@ public function renderEditControl(array $handles) { return id(new PhabricatorRemarkupControl()) + ->setUser($this->getViewer()) ->setName($this->getFieldKey()) ->setValue($this->getValue()) ->setError($this->getFieldError()) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php --- a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php @@ -120,6 +120,7 @@ $form ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($user) ->setName('description') ->setLabel(pht('Description')) ->setValue($v_desc)) diff --git a/src/applications/fund/controller/FundInitiativeEditController.php b/src/applications/fund/controller/FundInitiativeEditController.php --- a/src/applications/fund/controller/FundInitiativeEditController.php +++ b/src/applications/fund/controller/FundInitiativeEditController.php @@ -200,11 +200,13 @@ ->setOptions($merchant_options)) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setName('description') ->setLabel(pht('Description')) ->setValue($v_desc)) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setName('risks') ->setLabel(pht('Risks/Challenges')) ->setValue($v_risk)) diff --git a/src/applications/harbormaster/controller/HarbormasterStepEditController.php b/src/applications/harbormaster/controller/HarbormasterStepEditController.php --- a/src/applications/harbormaster/controller/HarbormasterStepEditController.php +++ b/src/applications/harbormaster/controller/HarbormasterStepEditController.php @@ -155,6 +155,7 @@ $form ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setName('description') ->setLabel(pht('Description')) ->setError($e_description) diff --git a/src/applications/legalpad/controller/LegalpadDocumentEditController.php b/src/applications/legalpad/controller/LegalpadDocumentEditController.php --- a/src/applications/legalpad/controller/LegalpadDocumentEditController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentEditController.php @@ -143,20 +143,22 @@ $form ->appendChild( id(new PhabricatorRemarkupControl()) - ->setID('preamble') - ->setLabel(pht('Preamble')) - ->setValue($v_preamble) - ->setName('preamble') - ->setCaption( - pht('Optional help text for users signing this document.'))) + ->setUser($user) + ->setID('preamble') + ->setLabel(pht('Preamble')) + ->setValue($v_preamble) + ->setName('preamble') + ->setCaption( + pht('Optional help text for users signing this document.'))) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setID('document-text') - ->setLabel(pht('Document Body')) - ->setError($e_text) - ->setValue($text) - ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) - ->setName('text')); + ->setUser($user) + ->setID('document-text') + ->setLabel(pht('Document Body')) + ->setError($e_text) + ->setValue($text) + ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) + ->setName('text')); $policies = id(new PhabricatorPolicyQuery()) ->setViewer($user) diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -254,6 +254,7 @@ ->setControlStyle('display: none')) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($user) ->setLabel(pht('Comments')) ->setName('comments') ->setValue($draft_text) diff --git a/src/applications/people/customfield/PhabricatorUserBlurbField.php b/src/applications/people/customfield/PhabricatorUserBlurbField.php --- a/src/applications/people/customfield/PhabricatorUserBlurbField.php +++ b/src/applications/people/customfield/PhabricatorUserBlurbField.php @@ -52,6 +52,7 @@ public function renderEditControl(array $handles) { return id(new PhabricatorRemarkupControl()) + ->setUser($this->getViewer()) ->setName($this->getFieldKey()) ->setValue($this->value) ->setLabel($this->getFieldName()); diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -122,12 +122,13 @@ ->setError($e_name)) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setLabel(pht('Description')) - ->setName('description') - ->setValue($blog->getDescription()) - ->setID('blog-description') - ->setUser($user) - ->setDisableMacros(true)) + ->setUser($user) + ->setLabel(pht('Description')) + ->setName('description') + ->setValue($blog->getDescription()) + ->setID('blog-description') + ->setUser($user) + ->setDisableMacros(true)) ->appendChild( id(new AphrontFormPolicyControl()) ->setUser($user) diff --git a/src/applications/pholio/controller/PholioInlineController.php b/src/applications/pholio/controller/PholioInlineController.php --- a/src/applications/pholio/controller/PholioInlineController.php +++ b/src/applications/pholio/controller/PholioInlineController.php @@ -157,6 +157,7 @@ $form ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setName('content') ->setLabel(pht('Comment')) ->setValue($v_content)); diff --git a/src/applications/pholio/view/PholioUploadedImageView.php b/src/applications/pholio/view/PholioUploadedImageView.php --- a/src/applications/pholio/view/PholioUploadedImageView.php +++ b/src/applications/pholio/view/PholioUploadedImageView.php @@ -32,6 +32,7 @@ ->setLabel(pht('Title')); $description = id(new PhabricatorRemarkupControl()) + ->setUser($this->getUser()) ->setName('description_'.$phid) ->setValue($image->getDescription()) ->setSigil('image-description') diff --git a/src/applications/phortune/controller/PhortuneMerchantEditController.php b/src/applications/phortune/controller/PhortuneMerchantEditController.php --- a/src/applications/phortune/controller/PhortuneMerchantEditController.php +++ b/src/applications/phortune/controller/PhortuneMerchantEditController.php @@ -131,6 +131,7 @@ ->setError($e_name)) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setName('desc') ->setLabel(pht('Description')) ->setValue($v_desc)) diff --git a/src/applications/ponder/controller/PonderAnswerEditController.php b/src/applications/ponder/controller/PonderAnswerEditController.php --- a/src/applications/ponder/controller/PonderAnswerEditController.php +++ b/src/applications/ponder/controller/PonderAnswerEditController.php @@ -71,6 +71,7 @@ ->setValue($question->getTitle())) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($viewer) ->setLabel(pht('Answer')) ->setName('content') ->setID($answer_content_id) diff --git a/src/applications/ponder/controller/PonderQuestionEditController.php b/src/applications/ponder/controller/PonderQuestionEditController.php --- a/src/applications/ponder/controller/PonderQuestionEditController.php +++ b/src/applications/ponder/controller/PonderQuestionEditController.php @@ -98,6 +98,7 @@ ->setError($e_title)) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($user) ->setName('content') ->setID('content') ->setValue($v_content) diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -163,6 +163,7 @@ ->setError($e_question)) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($user) ->setLabel(pht('Description')) ->setName('description') ->setValue($v_description)) diff --git a/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php b/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php --- a/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php +++ b/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php @@ -73,6 +73,7 @@ ->setFullWidth(true) ->appendChild( id(new PhabricatorRemarkupControl()) + ->setUser($user) ->setName('text') ->setValue($xaction->getComment()->getContent()))); diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php @@ -9,6 +9,7 @@ public function renderEditControl(array $handles) { return id(new PhabricatorRemarkupControl()) + ->setUser($this->getViewer()) ->setLabel($this->getFieldName()) ->setName($this->getFieldKey()) ->setCaption($this->getCaption()) diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php --- a/src/view/form/control/PhabricatorRemarkupControl.php +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -22,6 +22,12 @@ $this->setID($id); } + $viewer = $this->getUser(); + if (!$viewer) { + throw new Exception( + pht('Call setUser() before rendering a PhabricatorRemarkupControl!')); + } + // We need to have this if previews render images, since Ajax can not // currently ship JS or CSS. require_celerity_resource('lightbox-attachment-css'); @@ -82,7 +88,17 @@ ), ); - if (!$this->disableMacro and function_exists('imagettftext')) { + $can_use_macros = + (!$this->disableMacro) && + (function_exists('imagettftext')); + + if ($can_use_macros) { + $can_use_macros = PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorMacroApplication', + $viewer); + } + + if ($can_use_macros) { $actions[] = array( 'spacer' => true, ); @@ -184,16 +200,13 @@ $monospaced_textareas = null; $monospaced_textareas_class = null; - $user = $this->getUser(); - - if ($user) { - $monospaced_textareas = $user - ->loadPreferences() - ->getPreference( - PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS); - if ($monospaced_textareas == 'enabled') { - $monospaced_textareas_class = 'PhabricatorMonospaced'; - } + + $monospaced_textareas = $viewer + ->loadPreferences() + ->getPreference( + PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS); + if ($monospaced_textareas == 'enabled') { + $monospaced_textareas_class = 'PhabricatorMonospaced'; } $this->setCustomClass(