Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/document/PhabricatorDocumentEngine.php
<?php | <?php | ||||
abstract class PhabricatorDocumentEngine | abstract class PhabricatorDocumentEngine | ||||
extends Phobject { | extends Phobject { | ||||
private $viewer; | private $viewer; | ||||
private $highlightedLines = array(); | |||||
final public function setViewer(PhabricatorUser $viewer) { | final public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getViewer() { | final public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
} | } | ||||
final public function setHighlightedLines(array $highlighted_lines) { | |||||
$this->highlightedLines = $highlighted_lines; | |||||
return $this; | |||||
} | |||||
final public function getHighlightedLines() { | |||||
return $this->highlightedLines; | |||||
} | |||||
final public function canRenderDocument(PhabricatorDocumentRef $ref) { | final public function canRenderDocument(PhabricatorDocumentRef $ref) { | ||||
return $this->canRenderDocumentType($ref); | return $this->canRenderDocumentType($ref); | ||||
} | } | ||||
public function shouldRenderAsync(PhabricatorDocumentRef $ref) { | |||||
return false; | |||||
} | |||||
abstract protected function canRenderDocumentType( | abstract protected function canRenderDocumentType( | ||||
PhabricatorDocumentRef $ref); | PhabricatorDocumentRef $ref); | ||||
final public function newDocument(PhabricatorDocumentRef $ref) { | final public function newDocument(PhabricatorDocumentRef $ref) { | ||||
$can_complete = $this->canRenderCompleteDocument($ref); | $can_complete = $this->canRenderCompleteDocument($ref); | ||||
$can_partial = $this->canRenderPartialDocument($ref); | $can_partial = $this->canRenderPartialDocument($ref); | ||||
if (!$can_complete && !$can_partial) { | if (!$can_complete && !$can_partial) { | ||||
Show All 15 Lines | abstract class PhabricatorDocumentEngine | ||||
abstract protected function newDocumentContent( | abstract protected function newDocumentContent( | ||||
PhabricatorDocumentRef $ref); | PhabricatorDocumentRef $ref); | ||||
protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { | protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { | ||||
return 'fa-file-o'; | return 'fa-file-o'; | ||||
} | } | ||||
protected function getDocumentRenderingText(PhabricatorDocumentRef $ref) { | |||||
return pht('Loading...'); | |||||
} | |||||
final public function getDocumentEngineKey() { | final public function getDocumentEngineKey() { | ||||
return $this->getPhobjectClassConstant('ENGINEKEY'); | return $this->getPhobjectClassConstant('ENGINEKEY'); | ||||
} | } | ||||
final public static function getAllEngines() { | final public static function getAllEngines() { | ||||
return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
->setUniqueMethod('getDocumentEngineKey') | ->setUniqueMethod('getDocumentEngineKey') | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | protected function newMessage($message) { | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'document-engine-error', | 'class' => 'document-engine-error', | ||||
), | ), | ||||
$message); | $message); | ||||
} | } | ||||
final public function newLoadingContent(PhabricatorDocumentRef $ref) { | |||||
$spinner = id(new PHUIIconView()) | |||||
->setIcon('fa-gear') | |||||
->addClass('ph-spin'); | |||||
return phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => 'document-engine-loading', | |||||
), | |||||
array( | |||||
$spinner, | |||||
$this->getDocumentRenderingText($ref), | |||||
)); | |||||
} | |||||
} | } |