Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/PhabricatorMarkupOneOff.php
<?php | <?php | ||||
/** | /** | ||||
* DEPRECATED. Use @{class:PHUIRemarkupView}. | * DEPRECATED. Use @{class:PHUIRemarkupView}. | ||||
*/ | */ | ||||
final class PhabricatorMarkupOneOff | final class PhabricatorMarkupOneOff | ||||
extends Phobject | extends Phobject | ||||
implements PhabricatorMarkupInterface { | implements PhabricatorMarkupInterface { | ||||
private $content; | private $content; | ||||
private $preserveLinebreaks; | private $preserveLinebreaks; | ||||
private $engineRuleset; | private $engineRuleset; | ||||
private $engine; | private $engine; | ||||
private $disableCache; | private $disableCache; | ||||
private $contentCacheFragment; | |||||
private $generateTableOfContents; | |||||
private $tableOfContents; | |||||
public function setEngineRuleset($engine_ruleset) { | public function setEngineRuleset($engine_ruleset) { | ||||
$this->engineRuleset = $engine_ruleset; | $this->engineRuleset = $engine_ruleset; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getEngineRuleset() { | public function getEngineRuleset() { | ||||
return $this->engineRuleset; | return $this->engineRuleset; | ||||
Show All 26 Lines | public function setDisableCache($disable_cache) { | ||||
$this->disableCache = $disable_cache; | $this->disableCache = $disable_cache; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getDisableCache() { | public function getDisableCache() { | ||||
return $this->disableCache; | return $this->disableCache; | ||||
} | } | ||||
public function setGenerateTableOfContents($generate) { | |||||
$this->generateTableOfContents = $generate; | |||||
return $this; | |||||
} | |||||
public function getGenerateTableOfContents() { | |||||
return $this->generateTableOfContents; | |||||
} | |||||
public function getTableOfContents() { | |||||
return $this->tableOfContents; | |||||
} | |||||
public function setContentCacheFragment($fragment) { | |||||
$this->contentCacheFragment = $fragment; | |||||
return $this; | |||||
} | |||||
public function getContentCacheFragment() { | |||||
return $this->contentCacheFragment; | |||||
} | |||||
public function getMarkupFieldKey($field) { | public function getMarkupFieldKey($field) { | ||||
$fragment = $this->getContentCacheFragment(); | |||||
if ($fragment !== null) { | |||||
return $fragment; | |||||
} | |||||
return PhabricatorHash::digestForIndex($this->getContent()).':oneoff'; | return PhabricatorHash::digestForIndex($this->getContent()).':oneoff'; | ||||
} | } | ||||
public function newMarkupEngine($field) { | public function newMarkupEngine($field) { | ||||
if ($this->engine) { | if ($this->engine) { | ||||
return $this->engine; | return $this->engine; | ||||
} | } | ||||
Show All 10 Lines | public function getMarkupText($field) { | ||||
return $this->getContent(); | return $this->getContent(); | ||||
} | } | ||||
public function didMarkupText( | public function didMarkupText( | ||||
$field, | $field, | ||||
$output, | $output, | ||||
PhutilMarkupEngine $engine) { | PhutilMarkupEngine $engine) { | ||||
if ($this->getGenerateTableOfContents()) { | |||||
$toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine); | |||||
$this->tableOfContents = $toc; | |||||
} | |||||
require_celerity_resource('phabricator-remarkup-css'); | require_celerity_resource('phabricator-remarkup-css'); | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phabricator-remarkup', | 'class' => 'phabricator-remarkup', | ||||
), | ), | ||||
$output); | $output); | ||||
} | } | ||||
Show All 9 Lines |