[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/legalpad/storage/ -> LegalpadDocumentBody.php (source)

   1  <?php
   2  
   3  final class LegalpadDocumentBody extends LegalpadDAO
   4    implements
   5      PhabricatorMarkupInterface {
   6  
   7    const MARKUP_FIELD_TEXT = 'markup:text ';
   8  
   9    protected $phid;
  10    protected $creatorPHID;
  11    protected $documentPHID;
  12    protected $version;
  13    protected $title;
  14    protected $text;
  15  
  16    public function getConfiguration() {
  17      return array(
  18        self::CONFIG_AUX_PHID => true,
  19        self::CONFIG_COLUMN_SCHEMA => array(
  20          'version' => 'uint32',
  21          'title' => 'text255',
  22          'text' => 'text?',
  23        ),
  24        self::CONFIG_KEY_SCHEMA => array(
  25          'key_document' => array(
  26            'columns' => array('documentPHID', 'version'),
  27            'unique' => true,
  28          ),
  29        ),
  30      ) + parent::getConfiguration();
  31    }
  32  
  33    public function generatePHID() {
  34      return PhabricatorPHID::generateNewPHID(
  35        PhabricatorPHIDConstants::PHID_TYPE_LEGB);
  36    }
  37  
  38  /* -(  PhabricatorMarkupInterface  )----------------------------------------- */
  39  
  40  
  41    public function getMarkupFieldKey($field) {
  42      $hash = PhabricatorHash::digest($this->getMarkupText($field));
  43      return 'LEGB:'.$hash;
  44    }
  45  
  46    public function newMarkupEngine($field) {
  47      return PhabricatorMarkupEngine::newMarkupEngine(array());
  48    }
  49  
  50    public function getMarkupText($field) {
  51      switch ($field) {
  52        case self::MARKUP_FIELD_TEXT:
  53          $text = $this->getText();
  54          break;
  55        case self::MARKUP_FIELD_TITLE:
  56          $text = $this->getTitle();
  57          break;
  58        default:
  59          throw new Exception('Unknown field: '.$field);
  60          break;
  61      }
  62  
  63      return $text;
  64    }
  65  
  66    public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
  67      require_celerity_resource('phabricator-remarkup-css');
  68      return phutil_tag(
  69        'div',
  70        array(
  71          'class' => 'phabricator-remarkup',
  72        ),
  73        $output);
  74    }
  75  
  76    public function shouldUseMarkupCache($field) {
  77      return (bool)$this->getID();
  78    }
  79  
  80  }


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