FOSSology  4.4.0
Open Source License Compliance by Open Source Software
copyright-hist.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010-2014 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2014-2017,2019 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 require_once('HistogramBase.php');
10 
11 define("TITLE_COPYRIGHTHISTOGRAM", _("Copyright Browser"));
12 
18 {
19  function __construct()
20  {
21  $this->Name = "copyright-hist";
22  $this->Title = TITLE_COPYRIGHTHISTOGRAM;
23  $this->viewName = "copyright-view";
24  $this->agentName = "copyright";
25  parent::__construct();
26  }
27 
36  protected function getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
37  {
38  $typeDescriptionPairs = array(
39  'statement' => _("FOSSology Findings"),
40  'scancode_statement' => _("ScanCode Findings"),
41  'copyFindings' => _("User Findings")
42  );
43  $tableVars = array();
44  $output = array();
45  foreach ($typeDescriptionPairs as $type=>$description) {
46  if ($type==="scancode_statement") {
47  $agentId=LatestAgentpk($upload_pk, 'scancode_ars');
48  $this->agentName = "scancode";
49  }
50  list ($out, $vars) = $this->getTableForSingleType($type, $description,
51  $upload_pk, $uploadtreeId, $filter, $agentId);
52  $tableVars[$type] = $vars;
53  $output[] = $out;
54  }
55 
56  $output[] = $tableVars;
57  return $output;
58  }
59 
60 
65  protected function fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
66  {
67  list ($vCopyright, $vScancode, $vTextFindings, $tableVars) = $this->getTableContent(
68  $upload_pk, $Uploadtree_pk, $filter, $agentId);
69 
70  $out = $this->renderString('copyrighthist_tables.html.twig',
71  array(
72  'contCopyright' => $vCopyright,
73  'contScancodeCopyright' => $vScancode,
74  'contTextFindings' => $vTextFindings,
75  'fileList' => $VF
76  ));
77  return array($out, $tableVars);
78  }
79 
84  function RegisterMenus()
85  {
86  // For all other menus, permit coming back here.
87  $URI = $this->Name . Traceback_parm_keep(array("show","format","page","upload","item"));
88  $Item = GetParm("item",PARM_INTEGER);
89  $Upload = GetParm("upload",PARM_INTEGER);
90  if (!empty($Item) && !empty($Upload)) {
91  if (GetParm("mod",PARM_STRING) == $this->Name) {
92  menu_insert("Browse::Copyright",10);
93  menu_insert("Browse::[BREAK]",100);
94  } else {
95  $text = _("View copyright histogram");
96  menu_insert("Browse::Copyright",10,$URI,$text);
97  }
98  }
99  }
100 
105  protected function createScriptBlock()
106  {
107  return "
108 
109  var copyrightTabCookie = 'stickyCopyrightTab';
110 
111  $(document).ready(function() {
112  tableCopyright = createTablestatement();
113  tableScancode = createTablescancode_statement();
114  tableFindings = createPlainTablecopyFindings();
115  $('#testReplacementstatement').click(function() {
116  testReplacement(tableCopyright, 'statement');
117  });
118  $('#copyrightFindingsTabs').tabs({
119  active: ($.cookie(copyrightTabCookie) || 0),
120  activate: function(e, ui){
121  // Get active tab index and update cookie
122  var idString = $(e.currentTarget).attr('id');
123  idString = parseInt(idString.slice(-1)) - 1;
124  $.cookie(copyrightTabCookie, idString);
125  }
126  });
127  });
128  ";
129  }
130 }
131 
132 $NewPlugin = new CopyrightHistogram;
Create histogram plugin for copyright.
__construct()
base constructor. Most plugins will just use this
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
createScriptBlock()
Create JavaScript block for histogram.
fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
Get copyright statements and fill the main content table.
getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
Get contents for copyright table.
renderString($templateName, $vars=null)
Definition: FO_Plugin.php:414
Base class for histogram plugins.
getTableForSingleType($type, $description, $uploadId, $uploadTreeId, $filter, $agentId)
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
menu_insert($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
Given a Path, order level for the last item, and optional plugin name, insert the menu item.
const PARM_INTEGER
Definition: common-parm.php:14
const PARM_STRING
Definition: common-parm.php:18
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:46
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:308