30 private $uploadtree_tablename;
41 parent::__construct();
44 $this->uploadDao = $container->get(
'dao.upload');
45 $this->renderer = $container->get(
'twig.environment');
64 $out = array(
"type" => $type,
"sorting" => $sorting,
"uploadId" => $uploadId,
65 "uploadTreeId" => $uploadTreeId,
"agentId" => $agentId,
"filter" => $filter,
"description" => $description);
67 if ($type !==
"statement" || $type !==
'scancode_statement') {
68 $typeDescriptor = $description;
70 $output =
"<h4>Activated $typeDescriptor statements:</h4>
72 <div class='btn btn-default' style='float:right; padding:5px; margin:5px;'>
73 <input type='checkbox' style='padding:2px;' id='inverseSearchActivated".$type.
"' name='inverseSearch'/>
74 <label class='control-label' for='inverseSearchActivated".$type.
"'>Inverse Search</label>
76 <table border=1 width='100%' id='copyright".$type.
"' class='wordbreaktable'></table></div>
79 <table border=0 width='100%' id='searchReplaceTable".$type.
"'>
81 <td style='width:80%'>
82 <div class='form-group'>
83 <label class='control-label col-sm-2'>Advance search:<img src='images/info_16.png' title='Use \"(*)\" to match any thing.\nExample: \"Copyright (*) All rights reserved(*)\" will match \"Copyright 2012-2020 Company ABC. All rights reserved {and some garbage here}\"' alt='' class='info-bullet'></label>
84 <div class='col-sm-10'>
85 <input id='advSearchText".$type.
"' type='text' class='form-control advSearch'>
90 <div class='form-group'>
91 <div class='col-sm-offset-2 col-sm-10'>
92 <button class='btn btn-default' style='margin-top:25px;padding:15%;' onClick='createReplacementText(\"".$type.
"\")' title='Create a replacement text with all placeholders.'>Create replacement text</button>
99 <div class='form-group'>
100 <label class='control-label col-sm-2'>Replace:<img src='images/info_16.png' title='Use \"$1 $2\" as placeholder for corresponding (*) values.\nExample: \"Copyright $1 All rights reserved\" will result in \"Copyright 2012-2020 Company ABC. All rights reserved\" from example above' alt='' class='info-bullet'></label>
101 <div class='col-sm-10'>
102 <input id='replaceText".$type.
"' type='text' class='form-control'>
107 <div class='form-group'>
108 <div class='col-sm-offset-2 col-sm-10'>
109 <button class='btn btn-default' id='testReplacement".$type.
"'>Test replacement</button>
110 <button class='btn btn-default' id='replaceSelected".$type.
"'>Replace selected rows</button>
111 <button class='btn btn-default' id='deleteSelected".$type.
"'>Deactivate selected rows</button>
115 <table border=1 id='testVal".$type.
"' style='display:none' class='dataTable wordbreaktable'>
116 <tr><th style='width:50%'>From</th><th style='width:50%'>To</th></tr>
117 <tr><td id='testVal".$type.
"From'></td><td id='testVal".$type.
"To'></td></tr>
120 <h4>Deactivated $typeDescriptor statements:</h4>
121 <div class='btn btn-default' style='float:right; padding:5px; margin:5px;'>
122 <input type='checkbox' id='inverseSearchDeactivated".$type.
"' name='inverseSearch'/>
123 <label class='control-label' for='inverseSearchDeactivated".$type.
"'>Inverse Search</label>
126 <div><table border=1 width='100%' id='copyright".$type.
"deactivated' class='wordbreaktable'></table>
128 <a id='undoSelected".$type.
"' class='buttonLink'>Undo selected rows</a>
132 return array($output, $out);
145 abstract protected function fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF);
159 protected function ShowUploadHist($upload_pk, $Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk)
161 $Agent_pks = implode(
"," , $Agent_pk);
162 list($ChildCount, $VF) = $this->
getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pks, $upload_pk);
163 $this->vars[
'childcount'] = $ChildCount;
164 $this->vars[
'fileListing'] = $VF;
176 if ($ChildCount == 0) {
182 return $ModLicView->execute();
184 return $this->
fillTables($upload_pk, $Uploadtree_pk, $filter, $Agent_pks, $VF);
193 if ($this->
State != PLUGIN_STATE_READY) {
196 return parent::OutputOpen();
211 if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
212 $text = _(
"Permission Denied");
213 return "<h2>$text</h2>";
224 $this->vars[
'dir2browse'] =
Dir2Browse($this->Name,$item,NULL,1,
"Browse",-1,
'',
'',$uploadtree_tablename);
225 if (empty($uploadId)) {
226 return 'no item selected';
230 $dataset = $this->agentName.
"_dataset";
231 $arsCopyrighttable = $this->agentName.
"_ars";
235 if ($this->agentName ==
"copyright") {
236 $arsResotable =
"reso_ars";
243 if (empty($agentId) || $agentId[0] == 0) {
246 $OutBuf .=
"<script language='javascript'>\n";
247 $OutBuf .=
"function Schedule_Reply()\n";
249 $OutBuf .=
" if ((Schedule.readyState==4) && (Schedule.status==200 || Schedule.status==400))\n";
250 $OutBuf .=
" document.getElementById('msgdiv').innerHTML = Schedule.responseText;\n";
252 $OutBuf .=
"</script>\n";
254 $OutBuf .=
"<form name='formy' method='post'>\n";
255 $OutBuf .=
"<div id='msgdiv'>\n";
256 $OutBuf .= _(
"No data available.");
257 $OutBuf .=
"<input type='button' class='btn btn-default btn-sm' name='scheduleAgent' value='Schedule Agent'";
258 $OutBuf .=
"onClick=\"Schedule_Get('" .
Traceback_uri() .
"?mod=schedule_agent&upload=$uploadId&agent=agent_{$this->agentName}')\">\n";
259 $OutBuf .=
"</input>";
260 $OutBuf .=
"</div> \n";
261 $OutBuf .=
"</form>\n";
263 $this->vars[
'pageContent'] = $OutBuf;
267 $AgentSelect =
AgentSelect($this->agentName, $uploadId, $dataset, $agentId,
"onchange=\"addArsGo('newds', $dataset);\"");
270 if (!empty($AgentSelect)) {
273 $OutBuf .=
"<script type='text/javascript'>
274 function addArsGo(formid, selectid)
276 var selectobj = document.getElementById(selectid);
277 var Agent_pk = selectobj.options[selectobj.selectedIndex].value;
278 document.getElementById(formid).action='$action'+'&agent='+Agent_pk;
279 document.getElementById(formid).submit();
284 $OutBuf .=
"<form action=\"$action\" id=\"newds\" method=\"POST\">$AgentSelect</form>";
287 $selectKey = $filter ==
'nolic' ?
'nolic' :
'all';
288 $OutBuf .=
"<select name='view_filter' class='form-control-sm' id='view_filter' onchange='ChangeFilter(this,$uploadId, $item);'>";
289 foreach (array(
'all'=>_(
"Show all"),
'nolic'=> _(
"Show files without licenses")) as $key=>$text) {
290 $selected = ($selectKey == $key) ?
"selected" :
"";
291 $OutBuf .=
"<option $selected value=\"$key\">$text</option>";
293 $OutBuf .=
"</select>";
295 $uri = preg_replace(
"/&item=([0-9]*)/",
"",
Traceback());
296 list($tables, $tableVars) = $this->
ShowUploadHist($uploadId, $item, $uri, $selectKey, $uploadtree_tablename, $agentId);
297 $this->vars[
'tables'] = $tableVars;
298 $this->vars[
'pageContent'] = $OutBuf . $tables;
312 protected function getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk)
317 $Children = GetNonArtifactChildren($Uploadtree_pk, $uploadtree_tablename);
321 foreach ($Children as $c) {
327 $VF .=
"<table border=0>";
328 foreach ($Children as $child) {
335 $ModLicView = &$Plugins[plugin_find_id($this->viewName)];
337 if (!empty($child[
'pfile_fk']) && !empty($ModLicView)) {
339 $LinkUri .=
"?mod=".$this->viewName.
"&agent=$Agent_pk&upload=$upload_pk&item=$child[uploadtree_pk]";
346 $uploadtree_pk =
DirGetNonArtifact($child[
'uploadtree_pk'], $uploadtree_tablename);
347 $LicUri =
"$Uri&item=" . $uploadtree_pk;
356 $cellContent =
Isdir($child[
'ufile_mode']) ? $child[
'ufile_name'].
'/' : $child[
'ufile_name'];
358 $cellContent =
"<a class='btn btn-outline-secondary btn-sm' href='$LicUri'><b>$cellContent</b></a>";
359 } elseif (!empty($LinkUri)) {
360 $cellContent =
"<a class='btn btn-outline-secondary btn-sm' href='$LinkUri'>$cellContent</a>";
362 $VF .=
"<tr><td id='$child[uploadtree_pk]' align='left'>$cellContent</td><td>";
365 $VF .=
"[" . number_format($LicCount, 0,
"",
",") .
" ";
366 $VF .=
"license" . ($LicCount == 1 ?
"" :
"s");
369 $ChildLicCount += $LicCount;
371 $VF .=
"</td></tr>\n";
374 return array($ChildCount, $VF);
385 $isADirectory =
IsDir($row[
'ufile_mode']);
386 return $isADirectory;
395 $defaultOrder = array (
399 return $defaultOrder;
408 return "copyrighthist.html.twig";
char * uploadtree_tablename
upload.uploadtree_tablename
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
Base class for histogram plugins.
ShowUploadHist($upload_pk, $Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk)
Given an $Uploadtree_pk, display: (1) The histogram for the directory BY LICENSE....
getTableForSingleType($type, $description, $uploadId, $uploadTreeId, $filter, $agentId)
getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk)
Output()
This function is called when user output is requested. This function is responsible for content....
static returnSortOrder()
Get sorting orders.
__construct()
base constructor. Most plugins will just use this
fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
Get copyright statements and fill the main content table.
createScriptBlock()
Create JavaScript block for histogram.
isADirectory($Uploadtree_pk)
Check if passed element is a directory.
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra="")
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).
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.
Traceback()
Get the URI + 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.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
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".
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
int IsDir(char *Fname)
Given a filename, is it a directory?