Path: blob/master/src/applications/diffusion/view/DiffusionBrowseTableView.php
12242 views
<?php12final class DiffusionBrowseTableView extends DiffusionView {34private $paths;56public function setPaths(array $paths) {7assert_instances_of($paths, 'DiffusionRepositoryPath');8$this->paths = $paths;9return $this;10}1112public function render() {13$request = $this->getDiffusionRequest();14$repository = $request->getRepository();15require_celerity_resource('diffusion-css');1617if ($request->getPath() !== null) {18$base_path = trim($request->getPath(), '/');19if ($base_path) {20$base_path = $base_path.'/';21}22} else {23$base_path = '';24}2526$need_pull = array();27$rows = array();28foreach ($this->paths as $path) {29$full_path = $base_path.$path->getPath();3031$dir_slash = null;32$file_type = $path->getFileType();33if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {34$browse_text = $path->getPath().'/';35$dir_slash = '/';3637$browse_link = phutil_tag('strong', array(), $this->linkBrowse(38$full_path.$dir_slash,39array(40'type' => $file_type,41'name' => $browse_text,42)));4344$history_path = $full_path.'/';45} else if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {46$browse_text = $path->getPath().'/';47$browse_link = phutil_tag('strong', array(), $this->linkBrowse(48null,49array(50'type' => $file_type,51'name' => $browse_text,52'hash' => $path->getHash(),53'external' => $path->getExternalURI(),54)));5556$history_path = $full_path.'/';57} else {58$browse_text = $path->getPath();59$browse_link = $this->linkBrowse(60$full_path,61array(62'type' => $file_type,63'name' => $browse_text,64));6566$history_path = $full_path;67}6869$history_link = $this->linkHistory($history_path);7071$dict = array(72'lint' => celerity_generate_unique_node_id(),73'date' => celerity_generate_unique_node_id(),74'details' => celerity_generate_unique_node_id(),75);7677$need_pull[$full_path.$dir_slash] = $dict;78foreach ($dict as $k => $uniq) {79$dict[$k] = phutil_tag('span', array('id' => $uniq), '');80}8182$rows[] = array(83$browse_link,84idx($dict, 'lint'),85$dict['details'],86$dict['date'],87$history_link,88);8990}9192if ($need_pull) {93Javelin::initBehavior(94'diffusion-pull-lastmodified',95array(96'uri' => (string)$request->generateURI(97array(98'action' => 'lastmodified',99'stable' => true,100)),101'map' => $need_pull,102));103}104105$branch = $this->getDiffusionRequest()->loadBranch();106$show_lint = ($branch && $branch->getLintCommit());107$lint = $request->getLint();108109$view = new AphrontTableView($rows);110$view->setColumnClasses(111array(112'',113'',114'wide commit-detail',115'right',116'right narrow',117));118$view->setColumnVisibility(119array(120true,121$show_lint,122true,123true,124true,125));126127$view->setDeviceVisibility(128array(129true,130false,131false,132false,133false,134));135136137return phutil_tag_div('diffusion-browse-table', $view->render());138}139140}141142143