40 private $uploadtree_tablename;
46 function __construct()
51 parent::__construct();
54 $this->uploadDao = $container->get(
'dao.upload');
55 $this->renderer = $container->get(
'twig.environment');
74 $out = array(
"type" => $type,
"sorting" => $sorting,
"uploadId" => $uploadId,
75 "uploadTreeId" => $uploadTreeId,
"agentId" => $agentId,
"filter" => $filter,
"description" => $description);
77 if($type !==
"statement")
79 $typeDescriptor = $description;
81 $output =
"<h4>Activated $typeDescriptor statements:</h4> 82 <div><table border=1 width='100%' id='copyright".$type.
"'></table></div> 86 Replace: <input type='text' id='replaceText".$type.
"' style='width:80%'> 89 <a style='cursor: pointer; margin-left:10px;' id='replaceSelected".$type.
"' class='buttonLink'>Mark selected rows for replace</a> 90 <a style='cursor: pointer; margin-left:10px;' id='deleteSelected".$type.
"' class='buttonLink'>Mark selected rows for deletion</a> 92 <h4>Deactivated $typeDescriptor statements:</h4> 94 <div><table border=1 width='100%' id='copyright".$type.
"deactivated'></table></div>";
96 return array($output, $out);
109 abstract protected function fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF);
123 protected function ShowUploadHist($upload_pk, $Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk)
125 list($ChildCount, $VF) = $this->
getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk);
126 $this->vars[
'childcount'] = $ChildCount;
127 $this->vars[
'fileListing'] = $VF;
139 if ($ChildCount == 0)
146 return $ModLicView->execute();
148 return $this->
fillTables($upload_pk, $Uploadtree_pk, $filter, $Agent_pk, $VF);
157 if ($this->
State != PLUGIN_STATE_READY) {
160 return parent::OutputOpen();
175 if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId()))
177 $text = _(
"Permission Denied");
178 return "<h2>$text</h2>";
189 $this->vars[
'dir2browse'] =
Dir2Browse($this->Name,$item,NULL,1,
"Browse",-1,
'',
'',$uploadtree_tablename);
190 if (empty($uploadId))
192 return 'no item selected';
196 $dataset = $this->agentName.
"_dataset";
197 $arstable = $this->agentName.
"_ars";
209 $OutBuf .=
"<script language='javascript'>\n";
210 $OutBuf .=
"function Schedule_Reply()\n";
212 $OutBuf .=
" if ((Schedule.readyState==4) && (Schedule.status==200 || Schedule.status==400))\n";
213 $OutBuf .=
" document.getElementById('msgdiv').innerHTML = Schedule.responseText;\n";
215 $OutBuf .=
"</script>\n";
217 $OutBuf .=
"<form name='formy' method='post'>\n";
218 $OutBuf .=
"<div id='msgdiv'>\n";
219 $OutBuf .= _(
"No data available.");
220 $OutBuf .=
"<input type='button' name='scheduleAgent' value='Schedule Agent'";
221 $OutBuf .=
"onClick=\"Schedule_Get('" .
Traceback_uri() .
"?mod=schedule_agent&upload=$uploadId&agent=agent_{$this->agentName}')\">\n";
222 $OutBuf .=
"</input>";
223 $OutBuf .=
"</div> \n";
224 $OutBuf .=
"</form>\n";
226 $this->vars[
'pageContent'] = $OutBuf;
230 $AgentSelect =
AgentSelect($this->agentName, $uploadId, $dataset, $agentId,
"onchange=\"addArsGo('newds', 'copyright_dataset');\"");
233 if (!empty($AgentSelect))
237 $OutBuf .=
"<script type='text/javascript'> 238 function addArsGo(formid, selectid) 240 var selectobj = document.getElementById(selectid); 241 var Agent_pk = selectobj.options[selectobj.selectedIndex].value; 242 document.getElementById(formid).action='$action'+'&agent='+Agent_pk; 243 document.getElementById(formid).submit(); 248 $OutBuf .=
"<form action=\"$action\" id=\"newds\" method=\"POST\">$AgentSelect</form>";
251 $selectKey = $filter ==
'nolic' ?
'nolic' :
'all';
252 $OutBuf .=
"<select name='view_filter' id='view_filter' onchange='ChangeFilter(this,$uploadId, $item);'>";
253 foreach(array(
'all'=>_(
"Show all"),
'nolic'=> _(
"Show files without licenses")) as $key=>$text)
255 $selected = ($selectKey == $key) ?
"selected" :
"";
256 $OutBuf .=
"<option $selected value=\"$key\">$text</option>";
258 $OutBuf .=
"</select>";
260 $uri = preg_replace(
"/&item=([0-9]*)/",
"",
Traceback());
261 list($tables, $tableVars) = $this->
ShowUploadHist($uploadId, $item, $uri, $selectKey, $uploadtree_tablename, $agentId);
262 $this->vars[
'tables'] = $tableVars;
263 $this->vars[
'pageContent'] = $OutBuf . $tables;
277 protected function getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk)
282 $Children = GetNonArtifactChildren($Uploadtree_pk, $uploadtree_tablename);
286 foreach ($Children as $c)
294 $VF .=
"<table border=0>";
295 foreach ($Children as $child)
304 $ModLicView = &$Plugins[plugin_find_id($this->viewName)];
306 if (!empty($child[
'pfile_fk']) && !empty($ModLicView))
309 $LinkUri .=
"?mod=".$this->viewName.
"&agent=$Agent_pk&upload=$upload_pk&item=$child[uploadtree_pk]";
318 $uploadtree_pk =
DirGetNonArtifact($child[
'uploadtree_pk'], $uploadtree_tablename);
319 $LicUri =
"$Uri&item=" . $uploadtree_pk;
329 $cellContent =
Isdir($child[
'ufile_mode']) ? $child[
'ufile_name'].
'/' : $child[
'ufile_name'];
332 $cellContent =
"<a href='$LicUri'><b>$cellContent</b></a>";
334 else if (!empty($LinkUri))
336 $cellContent =
"<a href='$LinkUri'>$cellContent</a>";
338 $VF .=
"<tr><td id='$child[uploadtree_pk]' align='left'>$cellContent</td><td>";
342 $VF .=
"[" . number_format($LicCount, 0,
"",
",") .
" ";
343 $VF .=
"license" . ($LicCount == 1 ?
"" :
"s");
346 $ChildLicCount += $LicCount;
348 $VF .=
"</td></tr>\n";
351 return array($ChildCount, $VF);
362 $isADirectory =
IsDir($row[
'ufile_mode']);
363 return $isADirectory;
371 $defaultOrder = array (
375 return $defaultOrder;
384 return "copyrighthist.html.twig";
fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
Get copyright statements and fill the main content table.
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree"...
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.
isADirectory($Uploadtree_pk)
Check if passed element is a directory.
createScriptBlock()
Create JavaScript block for histogram.
ShowUploadHist($upload_pk, $Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk)
Given an $Uploadtree_pk, display: (1) The histogram for the directory BY LICENSE. (2) The file listing for the directory.
int IsDir(char *Fname)
Given a filename, is it a directory?
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
getTableForSingleType($type, $description, $uploadId, $uploadTreeId, $filter, $agentId)
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk)...
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra="")
char * uploadtree_tablename
upload.uploadtree_tablename
This is the Plugin class. All plugins should:
getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk)
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
Output()
This function is called when user output is requested. This function is responsible for content...
Traceback()
Get the URI + query to this location.
returnSortOrder()
Get sorting orders.
Base class for histogram plugins.