@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 140 lines 3.5 kB view raw
1<?php 2 3final class DiffusionBrowseTableView extends DiffusionView { 4 5 private $paths; 6 7 /** 8 * @param array<DiffusionRepositoryPath> $paths 9 */ 10 public function setPaths(array $paths) { 11 assert_instances_of($paths, DiffusionRepositoryPath::class); 12 $this->paths = $paths; 13 return $this; 14 } 15 16 public function render() { 17 $request = $this->getDiffusionRequest(); 18 $repository = $request->getRepository(); 19 require_celerity_resource('diffusion-css'); 20 21 $base_path = trim($request->getPath(), '/'); 22 if ($base_path) { 23 $base_path = $base_path.'/'; 24 } 25 26 $need_pull = array(); 27 $rows = array(); 28 foreach ($this->paths as $path) { 29 $full_path = $base_path.$path->getPath(); 30 31 $dir_slash = null; 32 $file_type = $path->getFileType(); 33 if ($file_type == DifferentialChangeType::FILE_DIRECTORY) { 34 $browse_text = $path->getPath().'/'; 35 $dir_slash = '/'; 36 37 $browse_link = phutil_tag('strong', array(), $this->linkBrowse( 38 $full_path.$dir_slash, 39 array( 40 'type' => $file_type, 41 'name' => $browse_text, 42 ))); 43 44 $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( 48 null, 49 array( 50 'type' => $file_type, 51 'name' => $browse_text, 52 'hash' => $path->getHash(), 53 'external' => $path->getExternalURI(), 54 ))); 55 56 $history_path = $full_path.'/'; 57 } else { 58 $browse_text = $path->getPath(); 59 $browse_link = $this->linkBrowse( 60 $full_path, 61 array( 62 'type' => $file_type, 63 'name' => $browse_text, 64 )); 65 66 $history_path = $full_path; 67 } 68 69 $history_link = $this->linkHistory($history_path); 70 71 $dict = array( 72 'lint' => celerity_generate_unique_node_id(), 73 'date' => celerity_generate_unique_node_id(), 74 'details' => celerity_generate_unique_node_id(), 75 ); 76 77 $need_pull[$full_path.$dir_slash] = $dict; 78 foreach ($dict as $k => $uniq) { 79 $dict[$k] = phutil_tag('span', array('id' => $uniq), ''); 80 } 81 82 $rows[] = array( 83 $browse_link, 84 idx($dict, 'lint'), 85 $dict['details'], 86 $dict['date'], 87 $history_link, 88 ); 89 90 } 91 92 if ($need_pull) { 93 Javelin::initBehavior( 94 'diffusion-pull-lastmodified', 95 array( 96 'uri' => (string)$request->generateURI( 97 array( 98 'action' => 'lastmodified', 99 'stable' => true, 100 )), 101 'map' => $need_pull, 102 )); 103 } 104 105 $branch = $this->getDiffusionRequest()->loadBranch(); 106 $show_lint = ($branch && $branch->getLintCommit()); 107 $lint = $request->getLint(); 108 109 $view = new AphrontTableView($rows); 110 $view->setColumnClasses( 111 array( 112 '', 113 '', 114 'wide commit-detail', 115 'right', 116 'right narrow', 117 )); 118 $view->setColumnVisibility( 119 array( 120 true, 121 $show_lint, 122 true, 123 true, 124 true, 125 )); 126 127 $view->setDeviceVisibility( 128 array( 129 true, 130 false, 131 false, 132 false, 133 false, 134 )); 135 136 137 return phutil_tag_div('diffusion-browse-table', $view->render()); 138 } 139 140}