[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/view/ -> DifferentialResultsTableView.php (source)

   1  <?php
   2  
   3  final class DifferentialResultsTableView extends AphrontView {
   4  
   5    private $rows;
   6    private $showMoreString;
   7  
   8    public function setRows(array $rows) {
   9      $this->rows = $rows;
  10      return $this;
  11    }
  12  
  13    public function setShowMoreString($show_more_string) {
  14      $this->showMoreString = $show_more_string;
  15      return $this;
  16    }
  17  
  18    public function render() {
  19  
  20      $rows = array();
  21  
  22      $any_hidden = false;
  23      foreach ($this->rows as $row) {
  24  
  25        $style = idx($row, 'style');
  26        switch ($style) {
  27          case 'section':
  28            $cells = phutil_tag(
  29              'th',
  30              array(
  31                'colspan' => 2,
  32              ),
  33              idx($row, 'name'));
  34            break;
  35          default:
  36            $name = phutil_tag(
  37              'th',
  38              array(
  39              ),
  40              idx($row, 'name'));
  41            $value = phutil_tag(
  42              'td',
  43              array(
  44              ),
  45              idx($row, 'value'));
  46            $cells = array($name, $value);
  47            break;
  48        }
  49  
  50        $show = idx($row, 'show');
  51  
  52        $rows[] = javelin_tag(
  53          'tr',
  54          array(
  55            'style' => $show ? null : 'display: none',
  56            'sigil' => $show ? null : 'differential-results-row-toggle',
  57            'class' => 'differential-results-row-'.$style,
  58          ),
  59          $cells);
  60  
  61        if (!$show) {
  62          $any_hidden = true;
  63        }
  64      }
  65  
  66      if ($any_hidden) {
  67        $show_more = javelin_tag(
  68          'a',
  69          array(
  70            'href'        => '#',
  71            'mustcapture' => true,
  72          ),
  73          $this->showMoreString);
  74  
  75        $hide_more = javelin_tag(
  76          'a',
  77          array(
  78            'href'        => '#',
  79            'mustcapture' => true,
  80          ),
  81          'Hide');
  82  
  83        $rows[] = javelin_tag(
  84          'tr',
  85          array(
  86            'class' => 'differential-results-row-show',
  87            'sigil' => 'differential-results-row-show',
  88          ),
  89          phutil_tag('th', array('colspan' => 2), $show_more));
  90  
  91        $rows[] = javelin_tag(
  92          'tr',
  93          array(
  94            'class' => 'differential-results-row-show',
  95            'sigil' => 'differential-results-row-hide',
  96            'style' => 'display: none',
  97          ),
  98          phutil_tag('th', array('colspan' => 2), $hide_more));
  99  
 100        $this->initBehavior('differential-show-field-details');
 101      }
 102  
 103      $this->requireResource('differential-results-table-css');
 104  
 105      return javelin_tag(
 106        'table',
 107        array(
 108          'class' => 'differential-results-table',
 109          'sigil' => 'differential-results-table',
 110        ),
 111        $rows);
 112    }
 113  
 114  
 115  }


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