40 const NAME =
"fileBrowse";
42 private $uploadtree_tablename =
"";
50 private $licenseProjector;
52 protected $agentNames = AgentRef::AGENT_LIST;
54 public function __construct()
56 parent::__construct(self::NAME, array(
57 self::TITLE => _(
"File Browser"),
58 self::DEPENDENCIES => array(
"browse",
"view"),
60 self::REQUIRES_LOGIN =>
false 64 $this->uploadDao = $container->get(
'dao.upload');
65 $this->licenseDao = $container->get(
'dao.license');
66 $this->agentDao = $container->get(
'dao.agent');
74 $text = _(
"File Browser");
75 menu_insert(
"Browse-Pfile::File Browser", 20,
'fileBrowse', $text);
82 if (empty($Item) || empty($Upload)) {
85 $viewLicenseURI =
"view-license" .
Traceback_parm_keep(array(
"show",
"format",
"page",
"upload",
"item"));
86 $menuName = $this->Title;
92 $text = _(
"File Browser");
94 menu_insert(
"View::$menuName", 98, $viewLicenseURI, $text);
95 menu_insert(
"View-Meta::$menuName", 98, $viewLicenseURI, $text);
103 protected function handle(Request $request)
105 $upload = intval($request->get(
"upload"));
106 $groupId = Auth::getGroupId();
107 if (!$this->uploadDao->isAccessible($upload, $groupId)) {
108 return $this->flushContent(_(
"Permission Denied"));
111 $item = intval($request->get(
"item"));
114 $vars[
'uploadId'] = $upload;
116 if ($request->get(
'show')==
'quick') {
119 $vars[
'itemId'] = $item;
122 $left = $itemTreeBounds->getLeft();
124 return $this->flushContent(_(
"Job unpack/adj2nest hasn't completed."));
127 if (is_a($histVars,
'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
130 $vars = array_merge($vars, $histVars);
134 $allLicensesPre = $this->licenseDao->getLicenseArray();
135 $allLicenses = array();
136 foreach ($allLicensesPre as $value) {
137 $allLicenses[$value[
'shortname']] = array(
'rf_pk' => $value[
'id']);
139 $vars[
'scannerLicenses'] = $allLicenses;
141 $vars[
'content'] =
js_url();
143 return $this->
render(
"file-browse.html.twig",$this->mergeWithDefault($vars));
154 $groupId = Auth::getGroupId();
159 $scannerAgents = array_keys($this->agentNames);
160 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
161 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
162 $agentMap = $scanJobProxy->getAgentMap();
164 $vars = array(
'agentId' => $selectedAgentId,
165 'agentMap' => $agentMap,
166 'scanners'=>$scannerVars);
168 $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $selectedAgentId;
170 $this->licenseProjector =
new LicenseMap($this->
getObject(
'db.manager'),$groupId,LicenseMap::CONCLUSION,
true);
172 $childCount = $dirVars[
'iTotalRecords'];
182 if ($childCount == 0) {
183 return new RedirectResponse(
"?mod=view-license" .
Traceback_parm_keep(array(
"upload",
"item")));
186 $vars[
'licenseUri'] =
Traceback_uri() .
"?mod=popup-license&rf=";
189 return array_merge($vars, $dirVars);
198 $isFlat = isset($_GET[
'flatten']);
199 $vars[
'isFlat'] = $isFlat;
200 $vars[
'iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
201 $uri =
Traceback_uri().
'?mod='.$this->Name.Traceback_parm_keep(array(
'upload',
'folder',
'show',
'item'));
202 $vars[
'fileSwitch'] = $isFlat ? $uri : $uri.
"&flatten=yes";
214 return $this->renderer->loadTemplate($templateName)->render($vars);
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
RegisterMenus()
Customize submenus.
render($templateName, $vars=null, $headers=null)
Wrapper class for license map.
renderString($templateName, $vars)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
countFileListing(ItemTreeBounds $itemTreeBounds)
char * uploadtree_tablename
upload.uploadtree_tablename
#define PERM_READ
Read-only permission.
showUploadHist(ItemTreeBounds $itemTreeBounds)
Given an $Uploadtree_pk, display:
Traceback_parm_keep($List)
Create a new URI, keeping only these items.