[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class LegalpadTransaction extends PhabricatorApplicationTransaction {
   4  
   5    public function getApplicationName() {
   6      return 'legalpad';
   7    }
   8  
   9    public function getApplicationTransactionType() {
  10      return PhabricatorLegalpadDocumentPHIDType::TYPECONST;
  11    }
  12  
  13    public function getApplicationTransactionCommentObject() {
  14      return new LegalpadTransactionComment();
  15    }
  16  
  17    public function getApplicationTransactionViewObject() {
  18      return new LegalpadTransactionView();
  19    }
  20  
  21    public function shouldHide() {
  22      $old = $this->getOldValue();
  23  
  24      switch ($this->getTransactionType()) {
  25        case LegalpadTransactionType::TYPE_TITLE:
  26        case LegalpadTransactionType::TYPE_TEXT:
  27          return ($old === null);
  28        case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
  29          return true;
  30      }
  31  
  32      return parent::shouldHide();
  33    }
  34  
  35    public function getTitle() {
  36      $author_phid = $this->getAuthorPHID();
  37  
  38      $old = $this->getOldValue();
  39      $new = $this->getNewValue();
  40  
  41      $type = $this->getTransactionType();
  42      switch ($type) {
  43        case LegalpadTransactionType::TYPE_TITLE:
  44          return pht(
  45            '%s renamed this document from "%s" to "%s".',
  46            $this->renderHandleLink($author_phid),
  47            $old,
  48            $new);
  49        case LegalpadTransactionType::TYPE_TEXT:
  50          return pht(
  51            "%s updated the document's text.",
  52            $this->renderHandleLink($author_phid));
  53        case LegalpadTransactionType::TYPE_PREAMBLE:
  54          return pht(
  55            '%s updated the preamble.',
  56            $this->renderHandleLink($author_phid));
  57      }
  58  
  59      return parent::getTitle();
  60    }
  61  
  62    public function hasChangeDetails() {
  63      switch ($this->getTransactionType()) {
  64        case LegalpadTransactionType::TYPE_TITLE:
  65        case LegalpadTransactionType::TYPE_TEXT:
  66        case LegalpadTransactionType::TYPE_PREAMBLE:
  67          return true;
  68      }
  69      return parent::hasChangeDetails();
  70    }
  71  
  72    public function renderChangeDetails(PhabricatorUser $viewer) {
  73      return $this->renderTextCorpusChangeDetails(
  74        $viewer,
  75        $this->getOldValue(),
  76        $this->getNewValue());
  77    }
  78  
  79  }


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