<commit_before><?php

final class PhabricatorProjectTransaction
  extends PhabricatorApplicationTransaction {

  const TYPE_NAME       = 'project:name';
  const TYPE_SLUGS      = 'project:slugs';
  const TYPE_STATUS     = 'project:status';
  const TYPE_IMAGE      = 'project:image';
  const TYPE_ICON       = 'project:icon';
  const TYPE_COLOR      = 'project:color';
  const TYPE_LOCKED     = 'project:locked';
  const TYPE_PARENT = 'project:parent';
  const TYPE_MILESTONE = 'project:milestone';
  const TYPE_HASWORKBOARD = 'project:hasworkboard';
  const TYPE_DEFAULT_SORT = 'project:sort';
  const TYPE_DEFAULT_FILTER = 'project:filter';
  const TYPE_BACKGROUND = 'project:background';

  // NOTE: This is deprecated, members are just a normal edge now.
  const TYPE_MEMBERS    = 'project:members';

  const MAILTAG_METADATA    = 'project-metadata';
  const MAILTAG_MEMBERS     = 'project-members';
  const MAILTAG_WATCHERS    = 'project-watchers';
  const MAILTAG_OTHER       = 'project-other';

  public function getApplicationName() {
    return 'project';
  }

  public function getApplicationTransactionType() {
    return PhabricatorProjectProjectPHIDType::TYPECONST;
  }

  public function getRequiredHandlePHIDs() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();

    $req_phids = array();
    switch ($this->getTransactionType()) {
      case self::TYPE_MEMBERS:
        $add = array_diff($new, $old);
        $rem = array_diff($old, $new);
        $req_phids = array_merge($add, $rem);
        break;
      case self::TYPE_IMAGE:
        $req_phids[] = $old;
        $req_phids[] = $new;
        break;
    }

    return array_merge($req_phids, parent::getRequiredHandlePHIDs());
  }

  public function getColor() {

    $old = $this->getOldValue();
    $new = $this->getNewValue();

    switch ($this->getTransactionType()) {
      case self::TYPE_STATUS:
        if ($old == 0) {
          return 'red';
        } else {
          return 'green';
        }
      }
    return parent::getColor();
  }

  public function shouldHide() {
    switch ($this->getTransactionType()) {
      case PhabricatorTransactions::TYPE_EDGE:
        $edge_type = $this->getMetadataValue('edge:type');
        switch ($edge_type) {
          case PhabricatorProjectSilencedEdgeType::EDGECONST:
            return true;
          default:
            break;
        }
    }

    return parent::shouldHide();
  }

  public function shouldHideForFeed() {
    switch ($this->getTransactionType()) {
      case self::TYPE_HASWORKBOARD:
      case self::TYPE_DEFAULT_SORT:
      case self::TYPE_DEFAULT_FILTER:
      case self::TYPE_BACKGROUND:
        return true;
    }

    return parent::shouldHideForFeed();
  }

  public function shouldHideForMail(array $xactions) {
    switch ($this->getTransactionType()) {
      case self::TYPE_HASWORKBOARD:
      case self::TYPE_DEFAULT_SORT:
      case self::TYPE_DEFAULT_FILTER:
      case self::TYPE_BACKGROUND:
        return true;
    }

    return parent::shouldHideForMail($xactions);
  }

  public function getIcon() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();

    switch ($this->getTransactionType()) {
      case self::TYPE_STATUS:
        if ($old == 0) {
          return 'fa-ban';
        } else {
          return 'fa-check';
        }
      case self::TYPE_LOCKED:
        if ($new) {
          return 'fa-lock';
        } else {
          return 'fa-unlock';
        }
      case self::TYPE_ICON:
        return 'fa-'.$new;
      case self::TYPE_IMAGE:
        return 'fa-photo';
      case self::TYPE_MEMBERS:
        return 'fa-user';
      case self::TYPE_SLUGS:
        return 'fa-tag';
    }
    return parent::getIcon();
  }

  public function getTitle() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();
    $author_phid = $this->getAuthorPHID();
    $author_handle = $this->renderHandleLink($author_phid);

    switch ($this->getTransactionType()) {
      case PhabricatorTransactions::TYPE_CREATE:
        return pht(
          '%s created this project.',<commit_msg>Super Pro Dexule fix for project icon timeline<commit_after><?php

final class PhabricatorProjectTransaction
  extends PhabricatorApplicationTransaction {

  const TYPE_NAME       = 'project:name';
  const TYPE_SLUGS      = 'project:slugs';
  const TYPE_STATUS     = 'project:status';
  const TYPE_IMAGE      = 'project:image';
  const TYPE_ICON       = 'project:icon';
  const TYPE_COLOR      = 'project:color';
  const TYPE_LOCKED     = 'project:locked';
  const TYPE_PARENT = 'project:parent';
  const TYPE_MILESTONE = 'project:milestone';
  const TYPE_HASWORKBOARD = 'project:hasworkboard';
  const TYPE_DEFAULT_SORT = 'project:sort';
  const TYPE_DEFAULT_FILTER = 'project:filter';
  const TYPE_BACKGROUND = 'project:background';

  // NOTE: This is deprecated, members are just a normal edge now.
  const TYPE_MEMBERS    = 'project:members';

  const MAILTAG_METADATA    = 'project-metadata';
  const MAILTAG_MEMBERS     = 'project-members';
  const MAILTAG_WATCHERS    = 'project-watchers';
  const MAILTAG_OTHER       = 'project-other';

  public function getApplicationName() {
    return 'project';
  }

  public function getApplicationTransactionType() {
    return PhabricatorProjectProjectPHIDType::TYPECONST;
  }

  public function getRequiredHandlePHIDs() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();

    $req_phids = array();
    switch ($this->getTransactionType()) {
      case self::TYPE_MEMBERS:
        $add = array_diff($new, $old);
        $rem = array_diff($old, $new);
        $req_phids = array_merge($add, $rem);
        break;
      case self::TYPE_IMAGE:
        $req_phids[] = $old;
        $req_phids[] = $new;
        break;
    }

    return array_merge($req_phids, parent::getRequiredHandlePHIDs());
  }

  public function getColor() {

    $old = $this->getOldValue();
    $new = $this->getNewValue();

    switch ($this->getTransactionType()) {
      case self::TYPE_STATUS:
        if ($old == 0) {
          return 'red';
        } else {
          return 'green';
        }
      }
    return parent::getColor();
  }

  public function shouldHide() {
    switch ($this->getTransactionType()) {
      case PhabricatorTransactions::TYPE_EDGE:
        $edge_type = $this->getMetadataValue('edge:type');
        switch ($edge_type) {
          case PhabricatorProjectSilencedEdgeType::EDGECONST:
            return true;
          default:
            break;
        }
    }

    return parent::shouldHide();
  }

  public function shouldHideForFeed() {
    switch ($this->getTransactionType()) {
      case self::TYPE_HASWORKBOARD:
      case self::TYPE_DEFAULT_SORT:
      case self::TYPE_DEFAULT_FILTER:
      case self::TYPE_BACKGROUND:
        return true;
    }

    return parent::shouldHideForFeed();
  }

  public function shouldHideForMail(array $xactions) {
    switch ($this->getTransactionType()) {
      case self::TYPE_HASWORKBOARD:
      case self::TYPE_DEFAULT_SORT:
      case self::TYPE_DEFAULT_FILTER:
      case self::TYPE_BACKGROUND:
        return true;
    }

    return parent::shouldHideForMail($xactions);
  }

  public function getIcon() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();

    switch ($this->getTransactionType()) {
      case self::TYPE_STATUS:
        if ($old == 0) {
          return 'fa-ban';
        } else {
          return 'fa-check';
        }
      case self::TYPE_LOCKED:
        if ($new) {
          return 'fa-lock';
        } else {
          return 'fa-unlock';
        }
      case self::TYPE_ICON:
        return PhabricatorProjectIconSet::getIconIcon($new);
      case self::TYPE_IMAGE:
        return 'fa-photo';
      case self::TYPE_MEMBERS:
        return 'fa-user';
      case self::TYPE_SLUGS:
        return 'fa-tag';
    }
    return parent::getIcon();
  }

  public function getTitle() {
    $old = $this->getOldValue();
    $new = $this->getNewValue();
    $author_phid = $this->getAuthorPHID();
    $author_handle = $this->renderHandleLink($author_phid);

    switch ($this->getTransactionType()) {
      case PhabricatorTransactions::TYPE_CREATE:
        return pht(
          '%s created this project.',
{'fraction_non_alphanumeric': 0.1251364132411786, 'fraction_numerical': 0.0004850248575239481, 'mean_word_length': 2.7765567765567765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373043', 'n_tokens_mistral': 2565, 'n_tokens_neox': 2513, 'n_words': 518}