[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/dashboard/storage/ -> PhabricatorDashboardPanelTransaction.php (source)

   1  <?php
   2  
   3  final class PhabricatorDashboardPanelTransaction
   4    extends PhabricatorApplicationTransaction {
   5  
   6    const TYPE_NAME = 'dashpanel:name';
   7    const TYPE_ARCHIVE = 'dashboard:archive';
   8  
   9    public function getApplicationName() {
  10      return 'dashboard';
  11    }
  12  
  13    public function getApplicationTransactionType() {
  14      return PhabricatorDashboardPanelPHIDType::TYPECONST;
  15    }
  16  
  17    public function getTitle() {
  18      $author_phid = $this->getAuthorPHID();
  19      $object_phid = $this->getObjectPHID();
  20  
  21      $old = $this->getOldValue();
  22      $new = $this->getNewValue();
  23  
  24      $author_link = $this->renderHandleLink($author_phid);
  25  
  26      $type = $this->getTransactionType();
  27      switch ($type) {
  28        case self::TYPE_NAME:
  29          if (!strlen($old)) {
  30            return pht(
  31              '%s created this panel.',
  32              $author_link);
  33          } else {
  34            return pht(
  35              '%s renamed this panel from "%s" to "%s".',
  36              $author_link,
  37              $old,
  38              $new);
  39          }
  40        case self::TYPE_ARCHIVE:
  41          if ($new) {
  42            return pht(
  43              '%s archived this panel.',
  44              $author_link);
  45          } else {
  46            return pht(
  47              '%s activated this panel.',
  48              $author_link);
  49          }
  50      }
  51  
  52      return parent::getTitle();
  53    }
  54  
  55    public function getTitleForFeed(PhabricatorFeedStory $story) {
  56      $author_phid = $this->getAuthorPHID();
  57      $object_phid = $this->getObjectPHID();
  58  
  59      $old = $this->getOldValue();
  60      $new = $this->getNewValue();
  61  
  62      $author_link = $this->renderHandleLink($author_phid);
  63      $object_link = $this->renderHandleLink($object_phid);
  64  
  65      $type = $this->getTransactionType();
  66      switch ($type) {
  67        case self::TYPE_NAME:
  68          if (!strlen($old)) {
  69            return pht(
  70              '%s created dashboard panel %s.',
  71              $author_link,
  72              $object_link);
  73          } else {
  74            return pht(
  75              '%s renamed dashboard panel %s from "%s" to "%s".',
  76              $author_link,
  77              $object_link,
  78              $old,
  79              $new);
  80          }
  81        case self::TYPE_ARCHIVE:
  82          if ($new) {
  83            return pht(
  84              '%s archived dashboard panel %s.',
  85              $author_link,
  86              $object_link);
  87          } else {
  88            return pht(
  89              '%s activated dashboard panel %s.',
  90              $author_link,
  91              $object_link);
  92          }
  93      }
  94  
  95      return parent::getTitleForFeed($story);
  96    }
  97  
  98    public function getColor() {
  99      $old = $this->getOldValue();
 100      $new = $this->getNewValue();
 101  
 102      switch ($this->getTransactionType()) {
 103        case self::TYPE_NAME:
 104          if (!strlen($old)) {
 105            return PhabricatorTransactions::COLOR_GREEN;
 106          }
 107          break;
 108      }
 109  
 110      return parent::getColor();
 111    }
 112  }


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