2012-07-23 20:01:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorInlineCommentPreviewController
|
|
|
|
extends PhabricatorController {
|
|
|
|
|
|
|
|
abstract protected function loadInlineComments();
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$inlines = $this->loadInlineComments();
|
|
|
|
assert_instances_of($inlines, 'PhabricatorInlineCommentInterface');
|
2012-10-24 02:33:58 +02:00
|
|
|
|
|
|
|
$engine = new PhabricatorMarkupEngine();
|
|
|
|
$engine->setViewer($user);
|
|
|
|
foreach ($inlines as $inline) {
|
|
|
|
$engine->addObject(
|
|
|
|
$inline,
|
|
|
|
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
|
|
|
|
}
|
|
|
|
$engine->process();
|
2012-07-23 20:01:28 +02:00
|
|
|
|
|
|
|
$phids = array($user->getPHID());
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2012-07-23 20:01:28 +02:00
|
|
|
|
|
|
|
$views = array();
|
|
|
|
foreach ($inlines as $inline) {
|
|
|
|
$view = new DifferentialInlineCommentView();
|
|
|
|
$view->setInlineComment($inline);
|
|
|
|
$view->setMarkupEngine($engine);
|
|
|
|
$view->setHandles($handles);
|
|
|
|
$view->setEditable(false);
|
|
|
|
$view->setPreview(true);
|
|
|
|
$views[] = $view->render();
|
|
|
|
}
|
2013-02-13 23:08:57 +01:00
|
|
|
$views = implode("\n", $views);
|
2012-07-23 20:01:28 +02:00
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
|
|
->setContent($views);
|
|
|
|
}
|
|
|
|
}
|