[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/config/controller/ -> PhabricatorConfigAllController.php (source)

   1  <?php
   2  
   3  final class PhabricatorConfigAllController
   4    extends PhabricatorConfigController {
   5  
   6    public function processRequest() {
   7      $request = $this->getRequest();
   8      $user = $request->getUser();
   9  
  10      $db_values = id(new PhabricatorConfigEntry())
  11        ->loadAllWhere('namespace = %s', 'default');
  12      $db_values = mpull($db_values, null, 'getConfigKey');
  13  
  14      $rows = array();
  15      $options = PhabricatorApplicationConfigOptions::loadAllOptions();
  16      ksort($options);
  17      foreach ($options as $option) {
  18        $key = $option->getKey();
  19  
  20        if ($option->getMasked()) {
  21          $value = phutil_tag('em', array(), pht('Masked'));
  22        } else if ($option->getHidden()) {
  23          $value = phutil_tag('em', array(), pht('Hidden'));
  24        } else {
  25          $value = PhabricatorEnv::getEnvConfig($key);
  26          $value = PhabricatorConfigJSON::prettyPrintJSON($value);
  27        }
  28  
  29        $db_value = idx($db_values, $key);
  30        $rows[] = array(
  31          phutil_tag(
  32            'a',
  33            array(
  34              'href' => $this->getApplicationURI('edit/'.$key.'/'),
  35            ),
  36            $key),
  37          $value,
  38          $db_value && !$db_value->getIsDeleted() ? pht('Customized') : '',
  39        );
  40      }
  41      $table = id(new AphrontTableView($rows))
  42        ->setColumnClasses(
  43          array(
  44            '',
  45            'wide',
  46          ))
  47        ->setHeaders(
  48          array(
  49            pht('Key'),
  50            pht('Value'),
  51            pht('Customized'),
  52          ));
  53  
  54      $title = pht('Current Settings');
  55  
  56      $crumbs = $this
  57        ->buildApplicationCrumbs()
  58        ->addTextCrumb($title);
  59  
  60      $panel = new PHUIObjectBoxView();
  61      $panel->setHeaderText(pht('Current Settings'));
  62      $panel->appendChild($table);
  63  
  64      $versions = $this->loadVersions();
  65  
  66      $version_property_list = id(new PHUIPropertyListView());
  67      foreach ($versions as $version) {
  68        list($name, $hash) = $version;
  69        $version_property_list->addProperty($name, $hash);
  70      }
  71  
  72      $object_box = id(new PHUIObjectBoxView())
  73        ->setHeaderText(pht('Current Version'))
  74        ->addPropertyList($version_property_list);
  75  
  76      $phabricator_root = dirname(phutil_get_library_root('phabricator'));
  77      $version_path = $phabricator_root.'/conf/local/VERSION';
  78      if (Filesystem::pathExists($version_path)) {
  79        $version_from_file = Filesystem::readFile($version_path);
  80        $version_property_list->addProperty(
  81          pht('Local Version'),
  82          $version_from_file);
  83      }
  84  
  85      $nav = $this->buildSideNavView();
  86      $nav->selectFilter('all/');
  87      $nav->setCrumbs($crumbs);
  88      $nav->appendChild($object_box);
  89      $nav->appendChild($panel);
  90  
  91  
  92      return $this->buildApplicationPage(
  93        $nav,
  94        array(
  95          'title' => $title,
  96        ));
  97    }
  98  
  99    private function loadVersions() {
 100      $specs = array(
 101        array(
 102          'name' => pht('Phabricator Version'),
 103          'root' => 'phabricator',
 104        ),
 105        array(
 106          'name' => pht('Arcanist Version'),
 107          'root' => 'arcanist',
 108        ),
 109        array(
 110          'name' => pht('libphutil Version'),
 111          'root' => 'phutil',
 112        ),
 113      );
 114  
 115      $futures = array();
 116      foreach ($specs as $key => $spec) {
 117        $root = dirname(phutil_get_library_root($spec['root']));
 118        $futures[$key] = id(new ExecFuture('git log --format=%%H -n 1 --'))
 119          ->setCWD($root);
 120      }
 121  
 122      $results = array();
 123      foreach ($futures as $key => $future) {
 124        list($err, $stdout) = $future->resolve();
 125        if (!$err) {
 126          $name = trim($stdout);
 127        } else {
 128          $name = pht('Unknown');
 129        }
 130        $results[$key] = array($specs[$key]['name'], $name);
 131      }
 132  
 133      return array_select_keys($results, array_keys($specs));
 134    }
 135  
 136  
 137  }


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