18 use Symfony\Component\HttpFoundation\RedirectResponse;
19 use Symfony\Component\HttpFoundation\Request;
20 use Symfony\Component\HttpFoundation\Response;
30 const NAME =
"fileBrowse";
32 private $uploadtree_tablename =
"";
40 private $licenseProjector;
42 protected $agentNames = AgentRef::AGENT_LIST;
44 public function __construct()
46 parent::__construct(self::NAME, array(
47 self::TITLE => _(
"File Browser"),
48 self::DEPENDENCIES => array(
"browse",
"view"),
50 self::REQUIRES_LOGIN =>
false
54 $this->uploadDao = $container->get(
'dao.upload');
55 $this->licenseDao = $container->get(
'dao.license');
56 $this->agentDao = $container->get(
'dao.agent');
64 $text = _(
"File Browser");
65 menu_insert(
"Browse-Pfile::File Browser", 20,
'fileBrowse', $text);
72 if (empty($Item) || empty($Upload)) {
75 $viewLicenseURI = $this->Name .
Traceback_parm_keep(array(
"show",
"format",
"page",
"upload",
"item"));
76 $menuName = $this->Title;
78 $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($Upload);
79 $itemBounds = $this->uploadDao->getItemTreeBounds($Item, $uploadTreeTable);
80 if (! $itemBounds->containsFiles()) {
85 $treeDao = $container->get(
'dao.tree');
86 $parent = $treeDao->getParentOfItem($itemBounds);
88 "format",
"page",
"upload")) .
"&item=$parent";
95 $text = _(
"File Browser");
97 menu_insert(
"View::$menuName", 98, $viewLicenseURI, $text);
98 menu_insert(
"View-Meta::$menuName", 98, $viewLicenseURI, $text);
106 protected function handle(Request $request)
108 $upload = intval($request->get(
"upload"));
109 $groupId = Auth::getGroupId();
110 if (!$this->uploadDao->isAccessible($upload, $groupId)) {
111 return $this->flushContent(_(
"Permission Denied"));
114 $item = intval($request->get(
"item"));
117 $vars[
'uploadId'] = $upload;
119 if ($request->get(
'show')==
'quick') {
122 $vars[
'itemId'] = $item;
125 $left = $itemTreeBounds->getLeft();
127 return $this->flushContent(_(
"Job unpack/adj2nest hasn't completed."));
130 if (is_a($histVars,
'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
133 $vars = array_merge($vars, $histVars);
137 $allLicensesPre = $this->licenseDao->getLicenseArray();
138 $allLicenses = array();
139 foreach ($allLicensesPre as $value) {
140 $allLicenses[$value[
'shortname']] = array(
'rf_pk' => $value[
'id']);
142 $vars[
'scannerLicenses'] = $allLicenses;
144 $vars[
'content'] =
js_url();
146 return $this->
render(
"file-browse.html.twig",$this->mergeWithDefault($vars));
157 $groupId = Auth::getGroupId();
162 $scannerAgents = array_keys($this->agentNames);
163 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
164 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
165 $agentMap = $scanJobProxy->getAgentMap();
167 $vars = array(
'agentId' => $selectedAgentId,
168 'agentMap' => $agentMap,
169 'scanners'=>$scannerVars);
171 $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $selectedAgentId;
173 $this->licenseProjector =
new LicenseMap($this->
getObject(
'db.manager'),$groupId,LicenseMap::CONCLUSION,
true);
175 $childCount = $dirVars[
'iTotalRecords'];
185 if ($childCount == 0) {
186 return new RedirectResponse(
"?mod=view-license" .
Traceback_parm_keep(array(
"upload",
"item")));
189 $vars[
'licenseUri'] =
Traceback_uri() .
"?mod=popup-license&rf=";
192 return array_merge($vars, $dirVars);
201 $isFlat = isset($_GET[
'flatten']);
202 $vars[
'isFlat'] = $isFlat;
203 $vars[
'iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
204 $uri =
Traceback_uri().
'?mod='.$this->Name.Traceback_parm_keep(array(
'upload',
'folder',
'show',
'item'));
205 $vars[
'fileSwitch'] = $isFlat ? $uri : $uri.
"&flatten=yes";
217 return $this->renderer->load($templateName)->render($vars);
char * uploadtree_tablename
upload.uploadtree_tablename
Contains the constants and helpers for authentication of user.
Wrapper class for license map.
RegisterMenus()
Customize submenus.
render($templateName, $vars=null, $headers=null)
renderString($templateName, $vars)
countFileListing(ItemTreeBounds $itemTreeBounds)
showUploadHist(ItemTreeBounds $itemTreeBounds)
Given an $Uploadtree_pk, display:
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.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
#define PERM_READ
Read-only permission.