FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
copyright-hist.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2010-2014 Hewlett-Packard Development Company, L.P.
4  * Copyright (C) 2014-2017,2019 Siemens AG
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
19 
20 require_once('HistogramBase.php');
21 
22 define("TITLE_COPYRIGHTHISTOGRAM", _("Copyright Browser"));
23 
29  function __construct()
30  {
31  $this->Name = "copyright-hist";
32  $this->Title = TITLE_COPYRIGHTHISTOGRAM;
33  $this->viewName = "copyright-view";
34  $this->agentName = "copyright";
35  parent::__construct();
36  }
37 
46  protected function getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
47  {
48  $typeDescriptionPairs = array(
49  'statement' => _("Agent Findings"),
50  'copyFindings' => _("User Findings")
51  );
52  $tableVars = array();
53  $output = array();
54  foreach($typeDescriptionPairs as $type=>$description)
55  {
56  list ($out, $vars) = $this->getTableForSingleType($type, $description,
57  $upload_pk, $uploadtreeId, $filter, $agentId);
58  $tableVars[$type] = $vars;
59  $output[] = $out;
60  }
61 
62  $output[] = $tableVars;
63  return $output;
64  }
65 
66 
71  protected function fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
72  {
73  list ($vCopyright, $vTextFindings, $tableVars) = $this->getTableContent(
74  $upload_pk, $Uploadtree_pk, $filter, $agentId);
75 
76  $out = $this->renderString('copyrighthist_tables.html.twig',
77  array(
78  'contCopyright' => $vCopyright,
79  'contTextFindings' => $vTextFindings,
80  'fileList' => $VF
81  ));
82  return array($out, $tableVars);
83  }
84 
89  function RegisterMenus()
90  {
91  // For all other menus, permit coming back here.
92  $URI = $this->Name . Traceback_parm_keep(array("show","format","page","upload","item"));
93  $Item = GetParm("item",PARM_INTEGER);
94  $Upload = GetParm("upload",PARM_INTEGER);
95  if (!empty($Item) && !empty($Upload))
96  {
97  if (GetParm("mod",PARM_STRING) == $this->Name)
98  {
99  menu_insert("Browse::Copyright agent/user findings",10);
100  menu_insert("Browse::[BREAK]",100);
101  }
102  else
103  {
104  $text = _("View copyright agent/user findings histogram");
105  menu_insert("Browse::Copyright",10,$URI,$text);
106  }
107  }
108  }
109 
114  protected function createScriptBlock()
115  {
116  return "
117 
118  var copyrightTabCookie = 'stickyCopyrightTab';
119 
120  $(document).ready(function() {
121  tableCopyright = createTablestatement();
122  tableFindings = createPlainTablecopyFindings();
123  $('#copyrightFindingsTabs').tabs({
124  active: ($.cookie(copyrightTabCookie) || 0),
125  activate: function(e, ui){
126  // Get active tab index and update cookie
127  var idString = $(e.currentTarget).attr('id');
128  idString = parseInt(idString.slice(-1)) - 1;
129  $.cookie(copyrightTabCookie, idString);
130  }
131  });
132  });
133  ";
134  }
135 
136 }
137 
138 $NewPlugin = new CopyrightHistogram;
getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
Get contents for copyright table.
getTableForSingleType($type, $description, $uploadId, $uploadTreeId, $filter, $agentId)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:57
renderString($templateName, $vars=null)
Definition: FO_Plugin.php:422
const PARM_STRING
Definition: common-parm.php:29
createScriptBlock()
Create JavaScript block for histogram.
const PARM_INTEGER
Definition: common-parm.php:25
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...
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:321
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
Get copyright statements and fill the main content table.
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
Base class for histogram plugins.