1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Update to use PHUIRemarkupView everywhere possible

Summary: Moves all the one off object calls to PHUIRemarkupView, adds a "Document" call as well (future plans).

Test Plan: Visited most pages I could get access to, but may want extra careful eyes on this diff.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15281
This commit is contained in:
Chad Little 2016-02-16 13:52:12 -08:00
parent 376c85a828
commit f35509e30e
34 changed files with 81 additions and 197 deletions

View file

@ -363,11 +363,7 @@ final class PhabricatorCalendarEventViewController
->getIconLabel($event->getIcon()));
if (strlen($event->getDescription())) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($event->getDescription()),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $event->getDescription());
$properties->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);

View file

@ -341,23 +341,14 @@ final class PhabricatorConfigWelcomeController
$header = id(new PHUIHeaderView())
->setHeader(pht('Welcome to Phabricator'));
$setup_header = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent(pht('=Setup and Configuration')),
'default',
$viewer);
$setup_header = new PHUIRemarkupView(
$viewer, pht('=Setup and Configuration'));
$explore_header = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent(pht('=Explore Phabricator')),
'default',
$viewer);
$explore_header = new PHUIRemarkupView(
$viewer, pht('=Explore Phabricator'));
$quick_header = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent(pht('=Quick Start Guides')),
'default',
$viewer);
$quick_header = new PHUIRemarkupView(
$viewer, pht('=Quick Start Guide'));
return id(new PHUIDocumentView())
->setHeader($header)
@ -376,10 +367,7 @@ final class PhabricatorConfigWelcomeController
$icon = id(new PHUIIconView())
->setIcon($icon.' fa-2x');
$content = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($content),
'default',
$viewer);
$content = new PHUIRemarkupView($viewer, $content);
$icon = phutil_tag(
'div',

View file

@ -132,11 +132,7 @@ final class PhabricatorCountdownViewController
$description = $countdown->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);

View file

@ -44,12 +44,7 @@ final class DifferentialRevertPlanField
return null;
}
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true)
->setContent($this->getValue()),
'default',
$this->getViewer());
return new PHUIRemarkupView($this->getViewer(), $this->getValue());
}
public function shouldAppearInGlobalSearch() {

View file

@ -122,12 +122,7 @@ final class DifferentialSummaryField
return null;
}
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true)
->setContent($this->getValue()),
'default',
$this->getViewer());
return new PHUIRemarkupView($this->getViewer(), $this->getValue());
}
public function getApplicationTransactionRemarkupBlocks(

View file

@ -136,12 +136,7 @@ final class DifferentialTestPlanField
return null;
}
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true)
->setContent($this->getValue()),
'default',
$this->getViewer());
return new PHUIRemarkupView($this->getViewer(), $this->getValue());
}
public function getApplicationTransactionRemarkupBlocks(

View file

@ -290,10 +290,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$description = $repository->getDetail('description');
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
$repository,
'description',
$user);
$description = new PHUIRemarkupView($user, $description);
$view->addSectionHeader(
pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);

View file

@ -309,10 +309,7 @@ final class DiffusionRepositoryEditMainController
if (!strlen($description)) {
$description = phutil_tag('em', array(), pht('No description provided.'));
} else {
$description = PhabricatorMarkupEngine::renderOneObject(
$repository,
'description',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
}
$view->addTextContent($description);

View file

@ -94,11 +94,7 @@ final class DivinerBookController extends DivinerController {
$preface = $book->getPreface();
$preface_view = null;
if (strlen($preface)) {
$preface_view =
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($preface),
'default',
$viewer);
$preface_view = new PHUIRemarkupView($viewer, $preface);
}
$document->appendChild($preface_view);

View file

@ -61,11 +61,7 @@ final class DivinerMainController extends DivinerController {
" %s\n\n",
'phabricator/ $ ./bin/diviner generate');
$text = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($text),
'default',
$viewer);
$text = new PHUIRemarkupView($viewer, $text);
$document->appendChild($text);
}

View file

@ -111,10 +111,7 @@ final class PhabricatorAsanaConfigOptions
"The Asana Workspaces your linked account has access to are:\n\n%s",
$out);
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($out),
'default',
$viewer);
return new PHUIRemarkupView($viewer, $out);
}
private function renderContextualProjectDescription(
@ -155,10 +152,7 @@ final class PhabricatorAsanaConfigOptions
$out = implode("\n", $out);
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($out),
'default',
$viewer);
return new PHUIRemarkupView($viewer, $out);
}
}

View file

@ -98,11 +98,7 @@ final class FundInitiativeViewController
$description = $initiative->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(
pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);
@ -110,11 +106,7 @@ final class FundInitiativeViewController
$risks = $initiative->getRisks();
if (strlen($risks)) {
$risks = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($risks),
'default',
$viewer);
$risks = new PHUIRemarkupView($viewer, $risks);
$view->addSectionHeader(
pht('Risks/Challenges'), 'fa-ambulance');
$view->addTextContent($risks);

View file

@ -181,16 +181,10 @@ final class HarbormasterBuildViewController
if ($step) {
$description = $step->getDescription();
if ($description) {
$rendered = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent($description)
->setPreserveLinebreaks(true),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(
pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($rendered);
$properties->addTextContent($description);
}
} else {
$target_box->setFormErrors(

View file

@ -258,11 +258,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
$preamble_box = null;
if (strlen($document->getPreamble())) {
$preamble_text = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent(
$document->getPreamble()),
'default',
$viewer);
$preamble_text = new PHUIRemarkupView($viewer, $document->getPreamble());
// NOTE: We're avoiding `setObject()` here so we don't pick up extra UI
// elements like "Subscribers". This information is available on the

View file

@ -104,14 +104,11 @@ final class PhabricatorApplicationDetailViewController
}
$overview = $application->getOverview();
if ($overview) {
if (strlen($overview)) {
$overview = new PHUIRemarkupView($viewer, $overview);
$properties->addSectionHeader(
pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent(
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($overview),
'default',
$viewer));
$properties->addTextContent($overview);
}
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(

View file

@ -117,10 +117,7 @@ final class PhabricatorApplicationEmailCommandsController
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
$content_box = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($content),
'default',
$viewer);
$content_box = new PHUIRemarkupView($viewer, $content);
$info_view = null;
if (!PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain')) {

View file

@ -120,11 +120,7 @@ final class NuancePhabricatorFormSourceDefinition
PHUIPropertyListView $view) {
$complaint = $item->getNuanceProperty('complaint');
$complaint = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($complaint),
'default',
$viewer);
$complaint = new PHUIRemarkupView($viewer, $complaint);
$view->addSectionHeader(
pht('Complaint'), 'fa-exclamation-circle');
$view->addTextContent($complaint);

View file

@ -189,13 +189,10 @@ final class PhabricatorOwnersDetailController
$description = $package->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(
pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent(
$output = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer));
$view->addTextContent($description);
}
$view->invokeWillRenderEvent();

View file

@ -118,10 +118,7 @@ final class PhameBlogManageController extends PhameBlogController {
$properties->invokeWillRenderEvent();
if (strlen($blog->getDescription())) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);

View file

@ -86,16 +86,13 @@ final class PholioInlineController extends PholioController {
),
$author_handle->renderLink());
$inline_content = new PHUIRemarkupView($viewer, $inline->getContent());
$comment_body = phutil_tag(
'div',
array(
'class' => 'pholio-inline-comment-body',
),
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent($inline->getContent()),
'default',
$viewer));
$inline_content);
return $this->newDialog()
->setTitle(pht('Inline Comment'))

View file

@ -48,12 +48,7 @@ abstract class PhortuneCartController
return null;
}
$output = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true)
->setContent($description),
'default',
$this->getViewer());
$output = new PHUIRemarkupView($this->getUser(), $description);
$box = id(new PHUIBoxView())
->addMargin(PHUI::MARGIN_LARGE)

View file

@ -136,11 +136,7 @@ final class PhortuneMerchantViewController
$description = $merchant->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(
pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);

View file

@ -134,16 +134,12 @@ final class PhabricatorPhurlURLViewController
$properties->invokeWillRenderEvent();
if (strlen($url->getDescription())) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($url->getDescription()),
'default',
$viewer);
$description = $url->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($description);
}

View file

@ -122,13 +122,13 @@ final class PhabricatorSlowvotePollController
$view->invokeWillRenderEvent();
if (strlen($poll->getDescription())) {
$view->addTextContent(
$output = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent(
$poll->getDescription()),
'default',
$viewer));
$description = $poll->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);
}
return $view;

View file

@ -74,13 +74,9 @@ final class SlowvoteEmbedView extends AphrontView {
$header = id(new PHUIHeaderView())
->setHeader($link_to_slowvote);
$description = null;
if ($poll->getDescription()) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent(
$poll->getDescription()),
'default',
$this->getUser());
$description = $poll->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($this->getUser(), $description);
$description = phutil_tag(
'div',
array(

View file

@ -83,15 +83,10 @@ final class PhabricatorSpacesViewController
$description = $space->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer);
$description = new PHUIRemarkupView($viewer, $description);
$list->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$list->addTextContent($description);
}

View file

@ -50,10 +50,7 @@ final class PhabricatorApplicationTransactionCommentRawController
$details_text = pht(
'For full details, run `/bin/mail show-outbound --id %d`',
$source_id);
$addendum = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($details_text),
'default',
$viewer);
$addendum = new PHUIRemarkupView($viewer, $details_text);
}
}
}

View file

@ -121,11 +121,7 @@ final class PhabricatorTypeaheadFunctionHelpController
}
$content = implode("\n\n", $content);
$content_box = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($content),
'default',
$viewer);
$content_box = new PHUIRemarkupView($viewer, $content);
$header = id(new PHUIHeaderView())
->setHeader($title);

View file

@ -40,10 +40,7 @@ IMPORTANT: This is not really important.
EOCONTENT
);
$remarkup = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($content),
'default',
$viewer);
$remarkup = new PHUIRemarkupView($viewer, $content);
$frame = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE)

View file

@ -39,12 +39,7 @@ final class PhabricatorStandardCustomFieldRemarkup
// end of the world.
$viewer = $this->getViewer();
return PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setContent($value)
->setPReserveLinebreaks(true),
'default',
$viewer);
return new PHUIRemarkupView($viewer, $value);
}
public function getApplicationTransactionTitle(

View file

@ -12,22 +12,41 @@
final class PHUIRemarkupView extends AphrontView {
private $corpus;
private $markupType;
const DOCUMENT = 'document';
public function __construct(PhabricatorUser $viewer, $corpus) {
$this->setUser($viewer);
$this->corpus = $corpus;
}
private function setMarkupType($type) {
$this->markupType($type);
return $this;
}
public function render() {
$viewer = $this->getUser();
$corpus = $this->corpus;
return PhabricatorMarkupEngine::renderOneObject(
$content = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true)
->setContent($corpus),
'default',
$viewer);
if ($this->markupType == self::DOCUMENT) {
return phutil_tag(
'div',
array(
'class' => 'phabricator-remarkup phui-document-view',
),
$content);
}
return $content;
}
}

View file

@ -85,10 +85,8 @@ final class AphrontFormView extends AphrontView {
public function appendRemarkupInstructions($remarkup) {
return $this->appendInstructions(
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($remarkup),
'default',
$this->getUser()));
new PHUIRemarkupView($this->getUser(), $remarkup));
}
public function buildLayoutView() {

View file

@ -35,11 +35,10 @@ final class PHUIFormLayoutView extends AphrontView {
throw new PhutilInvalidStateException('setUser');
}
return $this->appendInstructions(
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($remarkup),
'default',
$this->getUser()));
$viewer = $this->getUser();
$instructions = new PHUIRemarkupView($viewer, $remarkup);
return $this->appendInstructions($instructions);
}
public function render() {

View file

@ -74,11 +74,8 @@ class PHUIFormPageView extends AphrontView {
}
public function addRemarkupInstructions($remarkup, $before = null) {
return $this->addInstructions(
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($remarkup),
'default',
$this->getUser()), $before);
$remarkup = new PHUIRemarkupView($this->getUser(), $remarkup);
return $this->addInstructions($remarkup, $before);
}
public function addControl(AphrontFormControl $control) {