FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
AboutPage.php
1 <?php
2 /*
3 Copyright (C) 2014-2017, Siemens AG
4 Author: Andreas Würl
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 namespace Fossology\UI\Page;
21 
29 
33 class AboutPage extends DefaultPlugin
34 {
35  const NAME = "about";
36 
38  private $licenseDao;
39 
40  public function __construct()
41  {
42  parent::__construct(self::NAME, array(
43  self::TITLE => "About Fossology",
44  self::MENU_LIST => "Help::About",
45  self::REQUIRES_LOGIN => false,
46  ));
47 
48  $this->licenseDao = $this->getObject('dao.license');
49  }
50 
55  protected function handle(Request $request)
56  {
57  $vars = array(
58  'licenseCount' => $this->licenseDao->getLicenseCount(),
59  'project' => _("FOSSology"),
60  'copyright' => _("Copyright (C) 2007-2014 Hewlett-Packard Development Company, L.P.<br>\nCopyright (C) 2014-2017 Siemens AG."),
61  );
62 
63  if (Auth::isAdmin()) {
64  $repositoryApi = new RepositoryApi(new CurlRequestService());
65  $latestRelease = $repositoryApi->getLatestRelease();
66  $commits = $repositoryApi->getCommitsOfLastDays(30);
67  $commit = empty($commits) ? '' : substr($commits[0]['sha'],0,6);
68 
69  $vars = array_merge($vars, array(
70  'latestVersion' => $latestRelease,
71  'lastestCommit' => $commit));
72  }
73 
74  return $this->render('about.html.twig', $this->mergeWithDefault($vars));
75  }
76 }
77 
78 register_plugin(new AboutPage());
static isAdmin()
Check if user is admin.
Definition: Auth.php:87
about page on UI
Definition: AboutPage.php:33
Helper class to get the latest release and commits from GitHub API.
render($templateName, $vars=null, $headers=null)
handle(Request $request)
Definition: AboutPage.php:55