[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phriction/storage/ -> PhrictionContent.php (source)

   1  <?php
   2  
   3  /**
   4   * @task markup Markup Interface
   5   */
   6  final class PhrictionContent extends PhrictionDAO
   7    implements PhabricatorMarkupInterface {
   8  
   9    const MARKUP_FIELD_BODY = 'markup:body';
  10  
  11    protected $id;
  12    protected $documentID;
  13    protected $version;
  14    protected $authorPHID;
  15  
  16    protected $title;
  17    protected $slug;
  18    protected $content;
  19    protected $description;
  20  
  21    protected $changeType;
  22    protected $changeRef;
  23  
  24    public function renderContent(PhabricatorUser $viewer) {
  25      return PhabricatorMarkupEngine::renderOneObject(
  26        $this,
  27        self::MARKUP_FIELD_BODY,
  28        $viewer);
  29    }
  30  
  31    public function getConfiguration() {
  32      return array(
  33        self::CONFIG_COLUMN_SCHEMA => array(
  34          'version' => 'uint32',
  35          'title' => 'sort',
  36          'slug' => 'text128',
  37          'content' => 'text',
  38          'changeType' => 'uint32',
  39          'changeRef' => 'uint32?',
  40  
  41          // T6203/NULLABILITY
  42          // This should just be empty if not provided?
  43          'description' => 'text?',
  44        ),
  45        self::CONFIG_KEY_SCHEMA => array(
  46          'documentID' => array(
  47            'columns' => array('documentID', 'version'),
  48            'unique' => true,
  49          ),
  50          'authorPHID' => array(
  51            'columns' => array('authorPHID'),
  52          ),
  53          'slug' => array(
  54            'columns' => array('slug'),
  55          ),
  56        ),
  57      ) + parent::getConfiguration();
  58    }
  59  
  60  
  61  /* -(  Markup Interface  )--------------------------------------------------- */
  62  
  63  
  64    /**
  65     * @task markup
  66     */
  67    public function getMarkupFieldKey($field) {
  68      if ($this->shouldUseMarkupCache($field)) {
  69        $id = $this->getID();
  70      } else {
  71        $id = PhabricatorHash::digest($this->getMarkupText($field));
  72      }
  73      return "phriction:{$field}:{$id}";
  74    }
  75  
  76  
  77    /**
  78     * @task markup
  79     */
  80    public function getMarkupText($field) {
  81      return $this->getContent();
  82    }
  83  
  84  
  85    /**
  86     * @task markup
  87     */
  88    public function newMarkupEngine($field) {
  89      return PhabricatorMarkupEngine::newPhrictionMarkupEngine();
  90    }
  91  
  92  
  93    /**
  94     * @task markup
  95     */
  96    public function didMarkupText(
  97      $field,
  98      $output,
  99      PhutilMarkupEngine $engine) {
 100  
 101      $toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents(
 102        $engine);
 103  
 104      if ($toc) {
 105        $toc = phutil_tag_div('phabricator-remarkup-toc', array(
 106          phutil_tag_div(
 107            'phabricator-remarkup-toc-header',
 108            pht('Table of Contents')),
 109          $toc,
 110        ));
 111      }
 112  
 113      return phutil_tag_div('phabricator-remarkup', array($toc, $output));
 114    }
 115  
 116  
 117    /**
 118     * @task markup
 119     */
 120    public function shouldUseMarkupCache($field) {
 121      return (bool)$this->getID();
 122    }
 123  
 124  
 125  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1