Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/storage/PhrictionContent.php
<?php | <?php | ||||
/** | |||||
* @task markup Markup Interface | |||||
*/ | |||||
final class PhrictionContent | final class PhrictionContent | ||||
extends PhrictionDAO | extends PhrictionDAO { | ||||
implements PhabricatorMarkupInterface { | |||||
const MARKUP_FIELD_BODY = 'markup:body'; | |||||
protected $id; | protected $id; | ||||
protected $documentID; | protected $documentID; | ||||
protected $version; | protected $version; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $title; | protected $title; | ||||
protected $slug; | protected $slug; | ||||
protected $content; | protected $content; | ||||
protected $description; | protected $description; | ||||
protected $changeType; | protected $changeType; | ||||
protected $changeRef; | protected $changeRef; | ||||
private $renderedTableOfContents; | |||||
public function renderContent(PhabricatorUser $viewer) { | |||||
return PhabricatorMarkupEngine::renderOneObject( | |||||
$this, | |||||
self::MARKUP_FIELD_BODY, | |||||
$viewer, | |||||
$this); | |||||
} | |||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'version' => 'uint32', | 'version' => 'uint32', | ||||
'title' => 'sort', | 'title' => 'sort', | ||||
'slug' => 'text128', | 'slug' => 'text128', | ||||
'content' => 'text', | 'content' => 'text', | ||||
Show All 18 Lines | return array( | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getPHIDType() { | public function getPHIDType() { | ||||
return PhrictionContentPHIDType::TYPECONST; | return PhrictionContentPHIDType::TYPECONST; | ||||
} | } | ||||
public function newRemarkupView(PhabricatorUser $viewer) { | |||||
/* -( Markup Interface )--------------------------------------------------- */ | return id(new PHUIRemarkupView($viewer, $this->getContent())) | ||||
->setRemarkupOption(PHUIRemarkupView::OPTION_GENERATE_TOC, true) | |||||
->setGenerateTableOfContents(true); | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function getMarkupFieldKey($field) { | |||||
$content = $this->getMarkupText($field); | |||||
return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function getMarkupText($field) { | |||||
return $this->getContent(); | |||||
} | } | ||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function newMarkupEngine($field) { | |||||
return PhabricatorMarkupEngine::newPhrictionMarkupEngine(); | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function didMarkupText( | |||||
$field, | |||||
$output, | |||||
PhutilMarkupEngine $engine) { | |||||
$this->renderedTableOfContents = | |||||
PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine); | |||||
return phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => 'phabricator-remarkup', | |||||
), | |||||
$output); | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function getRenderedTableOfContents() { | |||||
return $this->renderedTableOfContents; | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function shouldUseMarkupCache($field) { | |||||
return (bool)$this->getID(); | |||||
} | |||||
} | } |