本文整理汇总了PHP中PhabricatorMarkupEngine::newDiffusionMarkupEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorMarkupEngine::newDiffusionMarkupEngine方法的具体用法?PHP PhabricatorMarkupEngine::newDiffusionMarkupEngine怎么用?PHP PhabricatorMarkupEngine::newDiffusionMarkupEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorMarkupEngine
的用法示例。
在下文中一共展示了PhabricatorMarkupEngine::newDiffusionMarkupEngine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: markupText
private function markupText($text)
{
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$text = $engine->markupText($text);
$text = phutil_render_tag('div', array('class' => 'phabricator-remarkup'), $text);
return $text;
}
示例2: markupText
protected function markupText($text)
{
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$engine->setConfig('viewer', $this->getRequest()->getUser());
$text = $engine->markupText($text);
$text = phutil_tag('div', array('class' => 'phabricator-remarkup'), $text);
return $text;
}
示例3: processRequest
public function processRequest()
{
$drequest = $this->getDiffusionRequest();
$request = $this->getRequest();
$user = $request->getUser();
if (!$request->isAjax()) {
// This request came out of the dropdown menu, either "View Standalone"
// or "View Raw File".
$view = $request->getStr('view');
if ($view == 'r') {
$uri = $drequest->generateURI(array('action' => 'browse', 'params' => array('view' => 'raw')));
} else {
$uri = $drequest->generateURI(array('action' => 'change'));
}
return id(new AphrontRedirectResponse())->setURI($uri);
}
$diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest);
$changeset = $diff_query->loadChangeset();
if (!$changeset) {
return new Aphront404Response();
}
$parser = new DifferentialChangesetParser();
$parser->setUser($user);
$parser->setChangeset($changeset);
$parser->setRenderingReference($diff_query->getRenderingReference());
$parser->setMarkupEngine(PhabricatorMarkupEngine::newDiffusionMarkupEngine());
$pquery = new DiffusionPathIDQuery(array($changeset->getFilename()));
$ids = $pquery->loadPathIDs();
$path_id = $ids[$changeset->getFilename()];
$parser->setLeftSideCommentMapping($path_id, false);
$parser->setRightSideCommentMapping($path_id, true);
$parser->setWhitespaceMode(DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere('commitPHID = %s AND pathID = %d AND
(authorPHID = %s OR auditCommentID IS NOT NULL)', $drequest->loadCommit()->getPHID(), $path_id, $user->getPHID());
if ($inlines) {
foreach ($inlines as $inline) {
$parser->parseInlineComment($inline);
}
$phids = mpull($inlines, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$parser->setHandles($handles);
}
$spec = $request->getStr('range');
list($range_s, $range_e, $mask) = DifferentialChangesetParser::parseRangeSpecification($spec);
$output = $parser->render($range_s, $range_e, $mask);
return id(new PhabricatorChangesetResponse())->setRenderedChangeset($output);
}
示例4: getEngine
private function getEngine()
{
if (!$this->engine) {
$this->engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
}
return $this->engine;
}
示例5: processRequest
public function processRequest()
{
$drequest = $this->diffusionRequest;
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
$results = $browse_query->loadPaths();
$content = array();
$content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
if (!$results) {
if ($browse_query->getReasonForEmptyResultSet() == DiffusionBrowseQuery::REASON_IS_FILE) {
$controller = new DiffusionBrowseFileController($this->getRequest());
$controller->setDiffusionRequest($drequest);
return $this->delegateToController($controller);
}
$empty_result = new DiffusionEmptyResultView();
$empty_result->setDiffusionRequest($drequest);
$empty_result->setBrowseQuery($browse_query);
$empty_result->setView($this->getRequest()->getStr('view'));
$content[] = $empty_result;
} else {
$readme = null;
$phids = array();
foreach ($results as $result) {
$data = $result->getLastCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
}
$path = $result->getPath();
if (preg_match('/^readme(|\\.txt|\\.remarkup)$/i', $path)) {
$readme = $result;
}
}
$phids = array_keys($phids);
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
if ($readme) {
$readme_request = DiffusionRequest::newFromDictionary(array('repository' => $drequest->getRepository(), 'commit' => $drequest->getStableCommitName(), 'path' => $readme->getFullPath()));
$content_query = DiffusionFileContentQuery::newFromDiffusionRequest($readme_request);
$content_query->loadFileContent();
$readme_content = $content_query->getRawData();
if (preg_match('/.txt$/', $readme->getPath())) {
$readme_content = phutil_escape_html($readme_content);
$readme_content = nl2br($readme_content);
} else {
// Markup extensionless files as remarkup so we get links and such.
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$readme_content = $engine->markupText($readme_content);
$readme_content = phutil_render_tag('div', array('class' => 'phabricator-remarkup'), $readme_content);
}
$readme_panel = new AphrontPanelView();
$readme_panel->setHeader('README');
$readme_panel->appendChild($readme_content);
$content[] = $readme_panel;
}
$browse_table = new DiffusionBrowseTableView();
$browse_table->setDiffusionRequest($drequest);
$browse_table->setHandles($handles);
$browse_table->setPaths($results);
$browse_panel = new AphrontPanelView();
$browse_panel->appendChild($browse_table);
$content[] = $browse_panel;
}
$content[] = $this->buildOpenRevisions();
$nav = $this->buildSideNav('browse', false);
$nav->appendChild($content);
return $this->buildStandardPageResponse($nav, array('title' => basename($drequest->getPath())));
}
示例6: renderReadme
public final function renderReadme(array $results)
{
$drequest = $this->getRequest();
$readme = null;
foreach ($results as $result) {
$file_type = $result->getFileType();
if ($file_type != ArcanistDiffChangeType::FILE_NORMAL && $file_type != ArcanistDiffChangeType::FILE_TEXT) {
// Skip directories, etc.
continue;
}
$path = $result->getPath();
if (preg_match('/^readme(|\\.txt|\\.remarkup|\\.rainbow)$/i', $path)) {
$readme = $result;
break;
}
}
if (!$readme) {
return null;
}
$readme_request = DiffusionRequest::newFromDictionary(array('repository' => $drequest->getRepository(), 'commit' => $drequest->getStableCommitName(), 'path' => $readme->getFullPath()));
$content_query = DiffusionFileContentQuery::newFromDiffusionRequest($readme_request);
$content_query->loadFileContent();
$readme_content = $content_query->getRawData();
if (preg_match('/\\.txt$/', $readme->getPath())) {
$readme_content = phutil_escape_html($readme_content);
$readme_content = nl2br($readme_content);
$class = null;
} else {
if (preg_match('/\\.rainbow$/', $readme->getPath())) {
$highlighter = new PhutilRainbowSyntaxHighlighter();
$readme_content = $highlighter->getHighlightFuture($readme_content)->resolve();
$readme_content = nl2br($readme_content);
require_celerity_resource('syntax-highlighting-css');
$class = 'remarkup-code';
} else {
// Markup extensionless files as remarkup so we get links and such.
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$readme_content = $engine->markupText($readme_content);
$class = 'phabricator-remarkup';
}
}
$readme_content = phutil_render_tag('div', array('class' => $class), $readme_content);
return $readme_content;
}