mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
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
This commit is contained in:
parent
0295a00229
commit
b87a809b0b
3 changed files with 16 additions and 58 deletions
|
@ -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',
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorConfigOption
|
||||
extends Phobject
|
||||
implements PhabricatorMarkupInterface {
|
||||
extends Phobject {
|
||||
|
||||
private $key;
|
||||
private $default;
|
||||
|
@ -204,43 +203,19 @@ final class PhabricatorConfigOption
|
|||
return $this;
|
||||
}
|
||||
|
||||
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||||
|
||||
public function getMarkupFieldKey($field) {
|
||||
return $this->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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue