mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-25 14:08:19 +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',
|
'PhabricatorConfigManualActivity' => 'PhabricatorConfigEntryDAO',
|
||||||
'PhabricatorConfigModule' => 'Phobject',
|
'PhabricatorConfigModule' => 'Phobject',
|
||||||
'PhabricatorConfigModuleController' => 'PhabricatorConfigController',
|
'PhabricatorConfigModuleController' => 'PhabricatorConfigController',
|
||||||
'PhabricatorConfigOption' => array(
|
'PhabricatorConfigOption' => 'Phobject',
|
||||||
'Phobject',
|
|
||||||
'PhabricatorMarkupInterface',
|
|
||||||
),
|
|
||||||
'PhabricatorConfigOptionType' => 'Phobject',
|
'PhabricatorConfigOptionType' => 'Phobject',
|
||||||
'PhabricatorConfigPHIDModule' => 'PhabricatorConfigModule',
|
'PhabricatorConfigPHIDModule' => 'PhabricatorConfigModule',
|
||||||
'PhabricatorConfigProxySource' => 'PhabricatorConfigSource',
|
'PhabricatorConfigProxySource' => 'PhabricatorConfigSource',
|
||||||
|
|
|
@ -153,30 +153,16 @@ final class PhabricatorConfigEditController
|
||||||
$e_value);
|
$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
|
$form
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->addHiddenInput('issue', $request->getStr('issue'));
|
->addHiddenInput('issue', $request->getStr('issue'));
|
||||||
|
|
||||||
$description = $option->getDescription();
|
$description = $option->newDescriptionRemarkupView($viewer);
|
||||||
if (strlen($description)) {
|
if ($description) {
|
||||||
$description_view = new PHUIRemarkupView($viewer, $description);
|
$form->appendChild(
|
||||||
|
id(new AphrontFormMarkupControl())
|
||||||
$form
|
->setLabel(pht('Description'))
|
||||||
->appendChild(
|
->setValue($description));
|
||||||
id(new AphrontFormMarkupControl())
|
|
||||||
->setLabel(pht('Description'))
|
|
||||||
->setValue($description_view));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($group) {
|
if ($group) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorConfigOption
|
final class PhabricatorConfigOption
|
||||||
extends Phobject
|
extends Phobject {
|
||||||
implements PhabricatorMarkupInterface {
|
|
||||||
|
|
||||||
private $key;
|
private $key;
|
||||||
private $default;
|
private $default;
|
||||||
|
@ -204,43 +203,19 @@ final class PhabricatorConfigOption
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
public function newDescriptionRemarkupView(PhabricatorUser $viewer) {
|
||||||
|
$description = $this->getDescription();
|
||||||
public function getMarkupFieldKey($field) {
|
if (!strlen($description)) {
|
||||||
return $this->getKey().':'.$field;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We should probably implement this as a real Markup rule, but
|
// TODO: Some day, we should probably implement this as a real rule.
|
||||||
// markup rules are a bit of a mess right now and it doesn't hurt us to
|
$description = preg_replace(
|
||||||
// fake this.
|
|
||||||
$text = preg_replace(
|
|
||||||
'/{{([^}]+)}}/',
|
'/{{([^}]+)}}/',
|
||||||
'[[/config/edit/\\1/ | \\1]]',
|
'[[/config/edit/\\1/ | \\1]]',
|
||||||
$text);
|
$description);
|
||||||
|
|
||||||
return $text;
|
return new PHUIRemarkupView($viewer, $description);
|
||||||
}
|
|
||||||
|
|
||||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldUseMarkupCache($field) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue