[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/repository/controller/ -> PhabricatorRepositoryListController.php (source)

   1  <?php
   2  
   3  final class PhabricatorRepositoryListController
   4    extends PhabricatorRepositoryController {
   5  
   6    public function processRequest() {
   7  
   8      $request = $this->getRequest();
   9      $user = $request->getUser();
  10      $is_admin = $user->getIsAdmin();
  11  
  12      $repos = id(new PhabricatorRepositoryQuery())
  13        ->setViewer($user)
  14        ->execute();
  15      $repos = msort($repos, 'getName');
  16  
  17      $rows = array();
  18      foreach ($repos as $repo) {
  19  
  20        if ($repo->isTracked()) {
  21          $diffusion_link = phutil_tag(
  22            'a',
  23            array(
  24              'href' => '/diffusion/'.$repo->getCallsign().'/',
  25            ),
  26            'View in Diffusion');
  27        } else {
  28          $diffusion_link = phutil_tag('em', array(), 'Not Tracked');
  29        }
  30  
  31        $rows[] = array(
  32          $repo->getCallsign(),
  33          $repo->getName(),
  34          PhabricatorRepositoryType::getNameForRepositoryType(
  35            $repo->getVersionControlSystem()),
  36          $diffusion_link,
  37          phutil_tag(
  38            'a',
  39            array(
  40              'class' => 'button small grey',
  41              'href'  => '/diffusion/'.$repo->getCallsign().'/edit/',
  42            ),
  43            'Edit'),
  44        );
  45      }
  46  
  47      $table = new AphrontTableView($rows);
  48      $table->setHeaders(
  49        array(
  50          'Callsign',
  51          'Repository',
  52          'Type',
  53          'Diffusion',
  54          '',
  55        ));
  56      $table->setColumnClasses(
  57        array(
  58          null,
  59          'wide',
  60          null,
  61          null,
  62          'action',
  63        ));
  64  
  65      $table->setColumnVisibility(
  66        array(
  67          true,
  68          true,
  69          true,
  70          true,
  71          $is_admin,
  72        ));
  73  
  74      $panel = new AphrontPanelView();
  75      $panel->setHeader('Repositories');
  76      if ($is_admin) {
  77        $panel->setCreateButton('Create New Repository', '/diffusion/new/');
  78      }
  79      $panel->appendChild($table);
  80      $panel->setNoBackground();
  81  
  82      $projects = id(new PhabricatorRepositoryArcanistProject())->loadAll();
  83  
  84      $rows = array();
  85      foreach ($projects as $project) {
  86        $repo = idx($repos, $project->getRepositoryID());
  87        if ($repo) {
  88          $repo_name = $repo->getName();
  89        } else {
  90          $repo_name = '-';
  91        }
  92  
  93        $rows[] = array(
  94          $project->getName(),
  95          $repo_name,
  96          phutil_tag(
  97            'a',
  98            array(
  99              'href' => '/repository/project/edit/'.$project->getID().'/',
 100              'class' => 'button grey small',
 101            ),
 102            'Edit'),
 103          javelin_tag(
 104            'a',
 105            array(
 106              'href' => '/repository/project/delete/'.$project->getID().'/',
 107              'class' => 'button grey small',
 108              'sigil' => 'workflow',
 109            ),
 110            'Delete'),
 111        );
 112  
 113      }
 114  
 115      $project_table = new AphrontTableView($rows);
 116      $project_table->setHeaders(
 117        array(
 118          'Project ID',
 119          'Repository',
 120          '',
 121          '',
 122        ));
 123      $project_table->setColumnClasses(
 124        array(
 125          '',
 126          'wide',
 127          'action',
 128          'action',
 129        ));
 130  
 131      $project_table->setColumnVisibility(
 132        array(
 133          true,
 134          true,
 135          $is_admin,
 136          $is_admin,
 137        ));
 138  
 139      $project_panel = new AphrontPanelView();
 140      $project_panel->setHeader('Arcanist Projects');
 141      $project_panel->appendChild($project_table);
 142      $project_panel->setNoBackground();
 143  
 144      return $this->buildStandardPageResponse(
 145        array(
 146          $panel,
 147          $project_panel,
 148        ),
 149        array(
 150          'title' => 'Repository List',
 151        ));
 152    }
 153  
 154  }


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