|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SSpkS\Handler; |
|
4
|
|
|
|
|
5
|
|
|
use \SSpkS\Output\HtmlOutput; |
|
6
|
|
|
use \SSpkS\Output\UrlFixer; |
|
7
|
|
|
use \SSpkS\Package\PackageFilter; |
|
8
|
|
|
use \SSpkS\Package\PackageFinder; |
|
9
|
|
|
|
|
10
|
|
|
class BrowserPackageListHandler implements HandlerInterface |
|
11
|
|
|
{ |
|
12
|
|
|
private $config; |
|
13
|
|
|
|
|
14
|
|
|
public function __construct(\SSpkS\Config $config) |
|
15
|
|
|
{ |
|
16
|
|
|
$this->config = $config; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function handle() |
|
20
|
|
|
{ |
|
21
|
|
|
// Architecture is set --> show packages for that arch |
|
22
|
|
|
$arch = trim($_GET['arch']); |
|
23
|
|
|
$channel = trim($_GET['channel']); |
|
24
|
|
|
if ($channel != 'beta') { |
|
25
|
|
|
$channel = 'stable'; |
|
26
|
|
|
} |
|
27
|
|
|
$packagesAvailable = array(); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$output = new HtmlOutput($this->config); |
|
30
|
|
|
$output->setVariable('arch', $arch); |
|
31
|
|
|
$output->setVariable('channel', ($channel == 'beta')); |
|
32
|
|
|
|
|
33
|
|
|
$pkgs = new PackageFinder($this->config->paths['packages']); |
|
34
|
|
|
$pkgf = new PackageFilter($pkgs->getAllPackages()); |
|
35
|
|
|
$pkgf->setArchitectureFilter($arch); |
|
36
|
|
|
$pkgf->setChannelFilter($channel); |
|
37
|
|
|
$pkgf->setFirmwareVersionFilter(false); |
|
38
|
|
|
$pkgf->setOldVersionFilter(true); |
|
39
|
|
|
$filteredPkgList = $pkgf->getFilteredPackageList(); |
|
40
|
|
|
|
|
41
|
|
|
$uf = new UrlFixer($this->config->baseUrl); |
|
42
|
|
|
$uf->fixPackageList($filteredPkgList); |
|
43
|
|
|
|
|
44
|
|
|
$packages = array(); |
|
45
|
|
|
foreach ($filteredPkgList as $pkg) { |
|
46
|
|
|
$packages[] = $pkg->getMetadata(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$output->setVariable('packagelist', array_values($packages)); |
|
50
|
|
|
$output->setTemplate('html_packagelist'); |
|
51
|
|
|
$output->output(); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.