FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
email-hist.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2010-2014 Hewlett-Packard Development Company, L.P.
4  * Copyright (C) 2014-2017 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_EMAILHISTOGRAM", _("Email/URL/Author Browser"));
23 
25  function __construct()
26  {
27  $this->Name = "email-hist";
28  $this->Title = TITLE_EMAILHISTOGRAM;
29  $this->viewName = "email-view";
30  $this->agentName = "copyright";
31  parent::__construct();
32  }
33 
42  protected function getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
43  {
44  $typeDescriptionPairs = array(
45  'email' => _("Email"),
46  'url' => _("URL"),
47  'author' => _("Author")
48  );
49  $tableVars = array();
50  $output = array();
51  foreach($typeDescriptionPairs as $type=>$description)
52  {
53  list($out, $vars) = $this->getTableForSingleType($type, $description, $upload_pk, $uploadtreeId, $filter, $agentId);
54  $tableVars[$type] = $vars;
55  $output[] = $out;
56  }
57 
58  $output[] = $tableVars;
59  return $output;
60  }
61 
62 
67  protected function fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
68  {
69  list($VEmail, $VUrl, $VAuthor, $tableVars) = $this->getTableContent($upload_pk, $Uploadtree_pk, $filter, $agentId);
70 
71  $out = $this->renderString('emailhist_tables.html.twig',
72  array('contEmail'=>$VEmail, 'contUrl'=>$VUrl, 'contAuthor'=>$VAuthor,
73  'fileList'=>$VF));
74  return array($out, $tableVars);
75  }
76 
81  function RegisterMenus()
82  {
83  // For all other menus, permit coming back here.
84  $URI = $this->Name . Traceback_parm_keep(array("show","format","page","upload","item"));
85  $Item = GetParm("item",PARM_INTEGER);
86  $Upload = GetParm("upload",PARM_INTEGER);
87  if (!empty($Item) && !empty($Upload))
88  {
89  if (GetParm("mod",PARM_STRING) == $this->Name)
90  {
91  menu_insert("Browse::Email/URL/Author",10);
92  menu_insert("Browse::[BREAK]",100);
93  }
94  else
95  {
96  $text = _("View email/URL/author histogram");
97  menu_insert("Browse::Email/URL/Author",10,$URI,$text);
98  }
99  }
100  }
101 
106  protected function createScriptBlock()
107  {
108  return "
109 
110  var emailTabCookie = 'stickyEmailTab';
111 
112  $(document).ready(function() {
113  tableEmail = createTableemail();
114  tableUrl = createTableurl();
115  tableAuthor = createTableauthor();
116  $(\"#EmailUrlAuthorTabs\").tabs({
117  active: ($.cookie(emailTabCookie) || 0),
118  activate: function(e, ui){
119  // Get active tab index and update cookie
120  var idString = $(e.currentTarget).attr('id');
121  idString = parseInt(idString.slice(-1)) - 1;
122  $.cookie(emailTabCookie, idString);
123  }
124  });
125  });
126  ";
127  }
128 
129 }
130 
131 $NewPlugin = new EmailHistogram;
getTableForSingleType($type, $description, $uploadId, $uploadTreeId, $filter, $agentId)
getTableContent($upload_pk, $uploadtreeId, $filter, $agentId)
Get contents for author table.
Definition: email-hist.php:42
fillTables($upload_pk, $Uploadtree_pk, $filter, $agentId, $VF)
Get copyright statements and fill the main content table.
Definition: email-hist.php:67
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
Definition: email-hist.php:81
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
const PARM_INTEGER
Definition: common-parm.php:25
createScriptBlock()
Create JavaScript block for histogram.
Definition: email-hist.php:106
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.
Base class for histogram plugins.