1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20: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())); ->getIconLabel($event->getIcon()));
if (strlen($event->getDescription())) { if (strlen($event->getDescription())) {
$description = PhabricatorMarkupEngine::renderOneObject( $description = new PHUIRemarkupView($viewer, $event->getDescription());
id(new PhabricatorMarkupOneOff())->setContent($event->getDescription()),
'default',
$viewer);
$properties->addSectionHeader( $properties->addSectionHeader(
pht('Description'), pht('Description'),
PHUIPropertyListView::ICON_SUMMARY); PHUIPropertyListView::ICON_SUMMARY);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -61,11 +61,7 @@ final class DivinerMainController extends DivinerController {
" %s\n\n", " %s\n\n",
'phabricator/ $ ./bin/diviner generate'); 'phabricator/ $ ./bin/diviner generate');
$text = PhabricatorMarkupEngine::renderOneObject( $text = new PHUIRemarkupView($viewer, $text);
id(new PhabricatorMarkupOneOff())->setContent($text),
'default',
$viewer);
$document->appendChild($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", "The Asana Workspaces your linked account has access to are:\n\n%s",
$out); $out);
return PhabricatorMarkupEngine::renderOneObject( return new PHUIRemarkupView($viewer, $out);
id(new PhabricatorMarkupOneOff())->setContent($out),
'default',
$viewer);
} }
private function renderContextualProjectDescription( private function renderContextualProjectDescription(
@ -155,10 +152,7 @@ final class PhabricatorAsanaConfigOptions
$out = implode("\n", $out); $out = implode("\n", $out);
return PhabricatorMarkupEngine::renderOneObject( return new PHUIRemarkupView($viewer, $out);
id(new PhabricatorMarkupOneOff())->setContent($out),
'default',
$viewer);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,22 +12,41 @@
final class PHUIRemarkupView extends AphrontView { final class PHUIRemarkupView extends AphrontView {
private $corpus; private $corpus;
private $markupType;
const DOCUMENT = 'document';
public function __construct(PhabricatorUser $viewer, $corpus) { public function __construct(PhabricatorUser $viewer, $corpus) {
$this->setUser($viewer); $this->setUser($viewer);
$this->corpus = $corpus; $this->corpus = $corpus;
} }
private function setMarkupType($type) {
$this->markupType($type);
return $this;
}
public function render() { public function render() {
$viewer = $this->getUser(); $viewer = $this->getUser();
$corpus = $this->corpus; $corpus = $this->corpus;
return PhabricatorMarkupEngine::renderOneObject( $content = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff()) id(new PhabricatorMarkupOneOff())
->setPreserveLinebreaks(true) ->setPreserveLinebreaks(true)
->setContent($corpus), ->setContent($corpus),
'default', 'default',
$viewer); $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) { public function appendRemarkupInstructions($remarkup) {
return $this->appendInstructions( return $this->appendInstructions(
PhabricatorMarkupEngine::renderOneObject( new PHUIRemarkupView($this->getUser(), $remarkup));
id(new PhabricatorMarkupOneOff())->setContent($remarkup),
'default',
$this->getUser()));
} }
public function buildLayoutView() { public function buildLayoutView() {

View file

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

View file

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