[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DiffusionBrowseTableView extends DiffusionView { 4 5 private $paths; 6 private $handles = array(); 7 8 public function setPaths(array $paths) { 9 assert_instances_of($paths, 'DiffusionRepositoryPath'); 10 $this->paths = $paths; 11 return $this; 12 } 13 14 public function setHandles(array $handles) { 15 assert_instances_of($handles, 'PhabricatorObjectHandle'); 16 $this->handles = $handles; 17 return $this; 18 } 19 20 public function render() { 21 $request = $this->getDiffusionRequest(); 22 $repository = $request->getRepository(); 23 24 $base_path = trim($request->getPath(), '/'); 25 if ($base_path) { 26 $base_path = $base_path.'/'; 27 } 28 29 $need_pull = array(); 30 $rows = array(); 31 $show_edit = false; 32 foreach ($this->paths as $path) { 33 34 $dir_slash = null; 35 $file_type = $path->getFileType(); 36 if ($file_type == DifferentialChangeType::FILE_DIRECTORY) { 37 $browse_text = $path->getPath().'/'; 38 $dir_slash = '/'; 39 40 $browse_link = phutil_tag('strong', array(), $this->linkBrowse( 41 $base_path.$path->getPath().$dir_slash, 42 array( 43 'text' => $this->renderPathIcon('dir', $browse_text), 44 ))); 45 } else if ($file_type == DifferentialChangeType::FILE_SUBMODULE) { 46 $browse_text = $path->getPath().'/'; 47 $browse_link = phutil_tag('strong', array(), $this->linkExternal( 48 $path->getHash(), 49 $path->getExternalURI(), 50 $this->renderPathIcon('ext', $browse_text))); 51 } else { 52 if ($file_type == DifferentialChangeType::FILE_SYMLINK) { 53 $type = 'link'; 54 } else { 55 $type = 'file'; 56 } 57 $browse_text = $path->getPath(); 58 $browse_link = $this->linkBrowse( 59 $base_path.$path->getPath(), 60 array( 61 'text' => $this->renderPathIcon($type, $browse_text), 62 )); 63 } 64 65 $dict = array( 66 'lint' => celerity_generate_unique_node_id(), 67 'commit' => celerity_generate_unique_node_id(), 68 'date' => celerity_generate_unique_node_id(), 69 'time' => celerity_generate_unique_node_id(), 70 'author' => celerity_generate_unique_node_id(), 71 'details' => celerity_generate_unique_node_id(), 72 ); 73 74 $need_pull[$base_path.$path->getPath().$dir_slash] = $dict; 75 foreach ($dict as $k => $uniq) { 76 $dict[$k] = phutil_tag('span', array('id' => $uniq), ''); 77 } 78 79 $rows[] = array( 80 $browse_link, 81 idx($dict, 'lint'), 82 $dict['commit'], 83 $dict['author'], 84 $dict['details'], 85 $dict['date'], 86 $dict['time'], 87 ); 88 } 89 90 if ($need_pull) { 91 Javelin::initBehavior( 92 'diffusion-pull-lastmodified', 93 array( 94 'uri' => (string)$request->generateURI( 95 array( 96 'action' => 'lastmodified', 97 'stable' => true, 98 )), 99 'map' => $need_pull, 100 )); 101 } 102 103 $branch = $this->getDiffusionRequest()->loadBranch(); 104 $show_lint = ($branch && $branch->getLintCommit()); 105 $lint = $request->getLint(); 106 107 $view = new AphrontTableView($rows); 108 $view->setHeaders( 109 array( 110 pht('Path'), 111 ($lint ? $lint : pht('Lint')), 112 pht('Modified'), 113 pht('Author/Committer'), 114 pht('Details'), 115 pht('Date'), 116 pht('Time'), 117 )); 118 $view->setColumnClasses( 119 array( 120 '', 121 'n', 122 'n', 123 '', 124 'wide', 125 '', 126 'right', 127 )); 128 $view->setColumnVisibility( 129 array( 130 true, 131 $show_lint, 132 true, 133 true, 134 true, 135 true, 136 true, 137 )); 138 139 $view->setDeviceVisibility( 140 array( 141 true, 142 false, 143 true, 144 false, 145 true, 146 false, 147 false, 148 )); 149 150 151 return $view->render(); 152 } 153 154 private function renderPathIcon($type, $text) { 155 156 require_celerity_resource('diffusion-icons-css'); 157 158 return phutil_tag( 159 'span', 160 array( 161 'class' => 'diffusion-path-icon diffusion-path-icon-'.$type, 162 ), 163 $text); 164 } 165 166 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |