[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/view/ -> DiffusionCommitChangeTableView.php (source)

   1  <?php
   2  
   3  final class DiffusionCommitChangeTableView extends DiffusionView {
   4  
   5    private $pathChanges;
   6    private $ownersPaths = array();
   7    private $renderingReferences;
   8  
   9    public function setPathChanges(array $path_changes) {
  10      assert_instances_of($path_changes, 'DiffusionPathChange');
  11      $this->pathChanges = $path_changes;
  12      return $this;
  13    }
  14  
  15    public function setOwnersPaths(array $owners_paths) {
  16      assert_instances_of($owners_paths, 'PhabricatorOwnersPath');
  17      $this->ownersPaths = $owners_paths;
  18      return $this;
  19    }
  20  
  21    public function setRenderingReferences(array $value) {
  22      $this->renderingReferences = $value;
  23      return $this;
  24    }
  25  
  26    public function render() {
  27      $rows = array();
  28      $rowc = array();
  29  
  30      // TODO: Experiment with path stack rendering.
  31  
  32      // TODO: Copy Away and Move Away are rendered junkily still.
  33  
  34      foreach ($this->pathChanges as $id => $change) {
  35        $path = $change->getPath();
  36        $hash = substr(md5($path), 0, 8);
  37        if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
  38          $path .= '/';
  39        }
  40  
  41        if (isset($this->renderingReferences[$id])) {
  42          $path_column = javelin_tag(
  43            'a',
  44            array(
  45              'href' => '#'.$hash,
  46              'meta' => array(
  47                'id' => 'diff-'.$hash,
  48                'ref' => $this->renderingReferences[$id],
  49              ),
  50              'sigil' => 'differential-load',
  51            ),
  52            $path);
  53        } else {
  54          $path_column = $path;
  55        }
  56  
  57        $rows[] = array(
  58          $this->linkHistory($change->getPath()),
  59          $this->linkBrowse($change->getPath()),
  60          $this->linkChange(
  61            $change->getChangeType(),
  62            $change->getFileType(),
  63            $change->getPath()),
  64          $path_column,
  65        );
  66  
  67        $row_class = null;
  68        foreach ($this->ownersPaths as $owners_path) {
  69          $excluded = $owners_path->getExcluded();
  70          $owners_path = $owners_path->getPath();
  71          if (strncmp('/'.$path, $owners_path, strlen($owners_path)) == 0) {
  72            if ($excluded) {
  73              $row_class = null;
  74              break;
  75            }
  76            $row_class = 'highlighted';
  77          }
  78        }
  79        $rowc[] = $row_class;
  80      }
  81  
  82      $view = new AphrontTableView($rows);
  83      $view->setHeaders(
  84        array(
  85          pht('History'),
  86          pht('Browse'),
  87          pht('Change'),
  88          pht('Path'),
  89        ));
  90      $view->setColumnClasses(
  91        array(
  92          '',
  93          '',
  94          '',
  95          'wide',
  96        ));
  97      $view->setRowClasses($rowc);
  98      $view->setNoDataString(pht('This change has not been fully parsed yet.'));
  99  
 100      return $view->render();
 101    }
 102  
 103  }


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