FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AboutPage.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2017 Siemens AG
4  Author: Andreas Würl
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\UI\Page;
10 
16 use Symfony\Component\HttpFoundation\Request;
17 use Symfony\Component\HttpFoundation\Response;
18 
22 class AboutPage extends DefaultPlugin
23 {
24  const NAME = "about";
25 
27  private $licenseDao;
28 
29  public function __construct()
30  {
31  parent::__construct(self::NAME, array(
32  self::TITLE => "About Fossology",
33  self::MENU_LIST => "Help::About",
34  self::REQUIRES_LOGIN => false,
35  ));
36 
37  $this->licenseDao = $this->getObject('dao.license');
38  }
39 
44  protected function handle(Request $request)
45  {
46  $vars = array(
47  'licenseCount' => $this->licenseDao->getLicenseCount(),
48  'project' => _("FOSSology"),
49  );
50 
51  if (Auth::isAdmin()) {
52  $repositoryApi = new RepositoryApi(new CurlRequestService());
53  $latestRelease = $repositoryApi->getLatestRelease();
54  $commits = $repositoryApi->getCommitsOfLastDays(30);
55  $commit = empty($commits) ? '' : substr($commits[0]['sha'],0,6);
56 
57  $vars = array_merge($vars, array(
58  'latestVersion' => $latestRelease,
59  'lastestCommit' => $commit));
60  }
61 
62  return $this->render('about.html.twig', $this->mergeWithDefault($vars));
63  }
64 }
65 
66 register_plugin(new AboutPage());
Helper class to get the latest release and commits from GitHub API.
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
static isAdmin()
Check if user is admin.
Definition: Auth.php:92
render($templateName, $vars=null, $headers=null)
handle(Request $request)
Definition: AboutPage.php:44