Differential D19414 Diff 46449 src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (strlen($encode_setting)) { | ||||
| $engine->setEncodingConfiguration($encode_setting); | $engine->setEncodingConfiguration($encode_setting); | ||||
| } | } | ||||
| $highlight_setting = $request->getStr('highlight'); | $highlight_setting = $request->getStr('highlight'); | ||||
| if (strlen($highlight_setting)) { | if (strlen($highlight_setting)) { | ||||
| $engine->setHighlightingConfiguration($highlight_setting); | $engine->setHighlightingConfiguration($highlight_setting); | ||||
| } | } | ||||
| $blame_setting = ($request->getStr('blame') !== 'off'); | |||||
| $engine->setBlameConfiguration($blame_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 = $this->newRefViewURI($ref, $candidate_engine); | $view_uri = $this->newRefViewURI($ref, $candidate_engine); | ||||
| Show All 19 Lines | final public function newDocumentView(PhabricatorDocumentRef $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); | ||||
| $config = array( | $config = array( | ||||
| 'controlID' => $control_id, | 'controlID' => $control_id, | ||||
| ); | ); | ||||
| $this->willStageRef($ref); | |||||
| if ($engine->shouldRenderAsync($ref)) { | if ($engine->shouldRenderAsync($ref)) { | ||||
| $content = $engine->newLoadingContent($ref); | $content = $engine->newLoadingContent($ref); | ||||
| $config['next'] = 'render'; | $config['next'] = 'render'; | ||||
| } else { | } else { | ||||
| $this->willRenderRef($ref); | $this->willRenderRef($ref); | ||||
| $content = $engine->newDocument($ref); | $content = $engine->newDocument($ref); | ||||
| if ($engine->canBlame($ref)) { | if ($engine->canBlame($ref)) { | ||||
| Show All 22 Lines | $meta = array( | ||||
| ), | ), | ||||
| 'highlight' => array( | 'highlight' => array( | ||||
| 'icon' => 'fa-lightbulb-o', | 'icon' => 'fa-lightbulb-o', | ||||
| 'name' => pht('Highlight As...'), | 'name' => pht('Highlight As...'), | ||||
| 'uri' => '/services/highlight/', | 'uri' => '/services/highlight/', | ||||
| 'value' => $highlight_setting, | 'value' => $highlight_setting, | ||||
| ), | ), | ||||
| 'blame' => array( | 'blame' => array( | ||||
| 'icon' => 'fa-backward', | |||||
| 'hide' => pht('Hide Blame'), | |||||
| 'show' => pht('Show Blame'), | |||||
| 'uri' => $ref->getBlameURI(), | 'uri' => $ref->getBlameURI(), | ||||
| 'enabled' => $blame_setting, | |||||
| 'value' => null, | 'value' => null, | ||||
| ), | ), | ||||
| 'coverage' => array( | 'coverage' => array( | ||||
| 'labels' => array( | 'labels' => array( | ||||
| // TODO: Modularize this properly, see T13125. | // TODO: Modularize this properly, see T13125. | ||||
| array( | array( | ||||
| 'C' => pht('Covered'), | 'C' => pht('Covered'), | ||||
| 'U' => pht('Not Covered'), | 'U' => pht('Not Covered'), | ||||
| Show All 21 Lines | final public function newDocumentView(PhabricatorDocumentRef $ref) { | ||||
| return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->appendChild($viewport); | ->appendChild($viewport); | ||||
| } | } | ||||
| final public function newRenderResponse(PhabricatorDocumentRef $ref) { | final public function newRenderResponse(PhabricatorDocumentRef $ref) { | ||||
| $this->willStageRef($ref); | |||||
| $this->willRenderRef($ref); | $this->willRenderRef($ref); | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $engines = PhabricatorDocumentEngine::getEnginesForRef($viewer, $ref); | $engines = PhabricatorDocumentEngine::getEnginesForRef($viewer, $ref); | ||||
| $engine_key = $this->getSelectedDocumentEngineKey(); | $engine_key = $this->getSelectedDocumentEngineKey(); | ||||
| if (!isset($engines[$engine_key])) { | if (!isset($engines[$engine_key])) { | ||||
| Show All 11 Lines | if (strlen($encode_setting)) { | ||||
| $engine->setEncodingConfiguration($encode_setting); | $engine->setEncodingConfiguration($encode_setting); | ||||
| } | } | ||||
| $highlight_setting = $request->getStr('highlight'); | $highlight_setting = $request->getStr('highlight'); | ||||
| if (strlen($highlight_setting)) { | if (strlen($highlight_setting)) { | ||||
| $engine->setHighlightingConfiguration($highlight_setting); | $engine->setHighlightingConfiguration($highlight_setting); | ||||
| } | } | ||||
| $blame_setting = ($request->getStr('blame') !== 'off'); | |||||
| $engine->setBlameConfiguration($blame_setting); | |||||
| try { | try { | ||||
| $content = $engine->newDocument($ref); | $content = $engine->newDocument($ref); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| return $this->newErrorResponse($ex->getMessage()); | return $this->newErrorResponse($ex->getMessage()); | ||||
| } | } | ||||
| return $this->newContentResponse($content); | return $this->newContentResponse($content); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | abstract class PhabricatorDocumentRenderingEngine | ||||
| } | } | ||||
| protected function addApplicationCrumbs( | protected function addApplicationCrumbs( | ||||
| PHUICrumbsView $crumbs, | PHUICrumbsView $crumbs, | ||||
| PhabricatorDocumentRef $ref = null) { | PhabricatorDocumentRef $ref = null) { | ||||
| return; | return; | ||||
| } | } | ||||
| protected function willStageRef(PhabricatorDocumentRef $ref) { | |||||
| return; | |||||
| } | |||||
| protected function willRenderRef(PhabricatorDocumentRef $ref) { | protected function willRenderRef(PhabricatorDocumentRef $ref) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||