Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileViewController.php
Show First 20 Lines • Show All 416 Lines • ▼ Show 20 Lines | private function newFileContent(PhabricatorFile $file) { | ||||
} | } | ||||
$engine = $engines[$engine_key]; | $engine = $engines[$engine_key]; | ||||
$lines = $request->getURILineRange('lines', 1000); | $lines = $request->getURILineRange('lines', 1000); | ||||
if ($lines) { | if ($lines) { | ||||
$engine->setHighlightedLines(range($lines[0], $lines[1])); | $engine->setHighlightedLines(range($lines[0], $lines[1])); | ||||
} | } | ||||
$encode_setting = $request->getStr('encode'); | |||||
if (strlen($encode_setting)) { | |||||
$engine->setEncodingConfiguration($encode_setting); | |||||
} | |||||
$highlight_setting = $request->getStr('highlight'); | |||||
if (strlen($highlight_setting)) { | |||||
$engine->setHighlightingConfiguration($highlight_setting); | |||||
} | |||||
$views = array(); | $views = array(); | ||||
foreach ($engines as $candidate_key => $candidate_engine) { | foreach ($engines as $candidate_key => $candidate_engine) { | ||||
$label = $candidate_engine->getViewAsLabel($ref); | $label = $candidate_engine->getViewAsLabel($ref); | ||||
if ($label === null) { | if ($label === null) { | ||||
continue; | continue; | ||||
} | } | ||||
$view_uri = '/file/view/'.$file->getID().'/'.$candidate_key.'/'; | $view_uri = '/file/view/'.$file->getID().'/'.$candidate_key.'/'; | ||||
$view_icon = $candidate_engine->getViewAsIconIcon($ref); | $view_icon = $candidate_engine->getViewAsIconIcon($ref); | ||||
$view_color = $candidate_engine->getViewAsIconColor($ref); | $view_color = $candidate_engine->getViewAsIconColor($ref); | ||||
$loading = $candidate_engine->newLoadingContent($ref); | $loading = $candidate_engine->newLoadingContent($ref); | ||||
$views[] = array( | $views[] = array( | ||||
'viewKey' => $candidate_engine->getDocumentEngineKey(), | 'viewKey' => $candidate_engine->getDocumentEngineKey(), | ||||
'icon' => $view_icon, | 'icon' => $view_icon, | ||||
'color' => $view_color, | 'color' => $view_color, | ||||
'name' => $label, | 'name' => $label, | ||||
'engineURI' => $candidate_engine->getRenderURI($ref), | 'engineURI' => $candidate_engine->getRenderURI($ref), | ||||
'viewURI' => $view_uri, | 'viewURI' => $view_uri, | ||||
'loadingMarkup' => hsprintf('%s', $loading), | 'loadingMarkup' => hsprintf('%s', $loading), | ||||
'canEncode' => $candidate_engine->canConfigureEncoding($ref), | |||||
'canHighlight' => $candidate_engine->CanConfigureHighlighting($ref), | |||||
); | ); | ||||
} | } | ||||
$viewport_id = celerity_generate_unique_node_id(); | $viewport_id = celerity_generate_unique_node_id(); | ||||
$control_id = celerity_generate_unique_node_id(); | $control_id = celerity_generate_unique_node_id(); | ||||
$icon = $engine->newDocumentIcon($ref); | $icon = $engine->newDocumentIcon($ref); | ||||
if ($engine->shouldRenderAsync($ref)) { | if ($engine->shouldRenderAsync($ref)) { | ||||
Show All 15 Lines | $viewport = phutil_tag( | ||||
), | ), | ||||
$content); | $content); | ||||
$meta = array( | $meta = array( | ||||
'viewportID' => $viewport_id, | 'viewportID' => $viewport_id, | ||||
'viewKey' => $engine->getDocumentEngineKey(), | 'viewKey' => $engine->getDocumentEngineKey(), | ||||
'views' => $views, | 'views' => $views, | ||||
'standaloneURI' => $engine->getRenderURI($ref), | 'standaloneURI' => $engine->getRenderURI($ref), | ||||
'encode' => array( | |||||
'icon' => 'fa-font', | |||||
'name' => pht('Change Text Encoding...'), | |||||
'uri' => '/services/encoding/', | |||||
'value' => $encode_setting, | |||||
), | |||||
'highlight' => array( | |||||
'icon' => 'fa-lightbulb-o', | |||||
'name' => pht('Highlight As...'), | |||||
'uri' => '/services/highlight/', | |||||
'value' => $highlight_setting, | |||||
), | |||||
); | ); | ||||
$view_button = id(new PHUIButtonView()) | $view_button = id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setText(pht('View Options')) | ->setText(pht('View Options')) | ||||
->setIcon('fa-file-image-o') | ->setIcon('fa-file-image-o') | ||||
->setColor(PHUIButtonView::GREY) | ->setColor(PHUIButtonView::GREY) | ||||
->setID($control_id) | ->setID($control_id) | ||||
Show All 16 Lines |