From b87a809b0bfe9a44243c7540841fdb185207cb0e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 27 Aug 2018 09:48:11 -0700 Subject: [PATCH] Make some remarkup handling in Config cleaner, fixing {{other.option} links Summary: Depends on D19609. Ref T13189. At some point, we switched from RemarkupEngine to RemarkupView and lost this piece of hack-magic. Restore the hack-magic. It's still hack-magic instead of a real rule, but things are at least cleaner than they were before. Test Plan: Viewed `auth.require-approval`, etc. Saw references to other config options linked properly. Reviewers: amckinley Maniphest Tasks: T13189 Differential Revision: https://secure.phabricator.com/D19610 --- src/__phutil_library_map__.php | 5 +-- .../PhabricatorConfigEditController.php | 26 +++-------- .../config/option/PhabricatorConfigOption.php | 43 ++++--------------- 3 files changed, 16 insertions(+), 58 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 05ef3c96fe..b6d71ea81b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -8290,10 +8290,7 @@ phutil_register_library_map(array( 'PhabricatorConfigManualActivity' => 'PhabricatorConfigEntryDAO', 'PhabricatorConfigModule' => 'Phobject', 'PhabricatorConfigModuleController' => 'PhabricatorConfigController', - 'PhabricatorConfigOption' => array( - 'Phobject', - 'PhabricatorMarkupInterface', - ), + 'PhabricatorConfigOption' => 'Phobject', 'PhabricatorConfigOptionType' => 'Phobject', 'PhabricatorConfigPHIDModule' => 'PhabricatorConfigModule', 'PhabricatorConfigProxySource' => 'PhabricatorConfigSource', diff --git a/src/applications/config/controller/PhabricatorConfigEditController.php b/src/applications/config/controller/PhabricatorConfigEditController.php index 37f7db6c7c..224705e181 100644 --- a/src/applications/config/controller/PhabricatorConfigEditController.php +++ b/src/applications/config/controller/PhabricatorConfigEditController.php @@ -153,30 +153,16 @@ final class PhabricatorConfigEditController $e_value); } - $engine = new PhabricatorMarkupEngine(); - $engine->setViewer($viewer); - $engine->addObject($option, 'description'); - $engine->process(); - $description = phutil_tag( - 'div', - array( - 'class' => 'phabricator-remarkup', - ), - $engine->getOutput($option, 'description')); - $form ->setUser($viewer) ->addHiddenInput('issue', $request->getStr('issue')); - $description = $option->getDescription(); - if (strlen($description)) { - $description_view = new PHUIRemarkupView($viewer, $description); - - $form - ->appendChild( - id(new AphrontFormMarkupControl()) - ->setLabel(pht('Description')) - ->setValue($description_view)); + $description = $option->newDescriptionRemarkupView($viewer); + if ($description) { + $form->appendChild( + id(new AphrontFormMarkupControl()) + ->setLabel(pht('Description')) + ->setValue($description)); } if ($group) { diff --git a/src/applications/config/option/PhabricatorConfigOption.php b/src/applications/config/option/PhabricatorConfigOption.php index 11b8de2617..385af002c7 100644 --- a/src/applications/config/option/PhabricatorConfigOption.php +++ b/src/applications/config/option/PhabricatorConfigOption.php @@ -1,8 +1,7 @@ getKey().':'.$field; - } - - public function newMarkupEngine($field) { - return PhabricatorMarkupEngine::newMarkupEngine(array()); - } - - public function getMarkupText($field) { - switch ($field) { - case 'description': - $text = $this->getDescription(); - break; - case 'summary': - $text = $this->getSummary(); - break; + public function newDescriptionRemarkupView(PhabricatorUser $viewer) { + $description = $this->getDescription(); + if (!strlen($description)) { + return null; } - // TODO: We should probably implement this as a real Markup rule, but - // markup rules are a bit of a mess right now and it doesn't hurt us to - // fake this. - $text = preg_replace( + // TODO: Some day, we should probably implement this as a real rule. + $description = preg_replace( '/{{([^}]+)}}/', '[[/config/edit/\\1/ | \\1]]', - $text); + $description); - return $text; - } - - public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { - return $output; - } - - public function shouldUseMarkupCache($field) { - return false; + return new PHUIRemarkupView($viewer, $description); } }