Issues (2407)

administration/controller/extension/extension.php (5 issues)

1
<?php
2
/* 	Divine CMS - Open source CMS for widespread use.
3
    Copyright (c) 2019 Mykola Burakov ([email protected])
4
    See SOURCE.txt for other and additional information.
5
    This file is part of Divine CMS.
6
    This program is free software: you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation, either version 3 of the License, or
9
    (at your option) any later version.
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
    You should have received a copy of the GNU General Public License
15
    along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
class ControllerExtensionExtension extends \Divine\Engine\Core\Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    private $error = array();
0 ignored issues
show
The private property $error is not used, and could be removed.
Loading history...
19
20
    public function index()
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
21
    {
22
        $this->load->language('extension/extension');
23
        $this->document->setTitle($this->language->get('heading_title'));
24
25
        $data['breadcrumbs'] = array();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.
Loading history...
26
27
        $data['breadcrumbs'][] = array(
28
            'text' => $this->language->get('text_home'),
29
            'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true)
30
        );
31
32
        $data['breadcrumbs'][] = array(
33
            'text' => $this->language->get('heading_title'),
34
            'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'], true)
35
        );
36
37
        $data['heading_title'] = $this->language->get('heading_title');
38
        $data['text_list'] = $this->language->get('text_list');
39
        $data['text_type'] = $this->language->get('text_type');
40
        $data['text_filter'] = $this->language->get('text_filter');
41
        $data['text_loading'] = $this->language->get('text_loading');
42
        $data['text_confirm'] = $this->language->get('text_confirm');
43
44
        $data['token'] = $this->session->data['token'];
45
46
        if (isset($this->request->get['type'])) {
47
            $data['type'] = $this->request->get['type'];
48
        } else {
49
            $data['type'] = 'module';
50
        }
51
52
        $data['categories'] = array();
53
54
        $files = glob(SR_APPLICATION . 'controller/extension/extension/*.php', GLOB_BRACE);
55
56
        foreach ($files as $file) {
57
            $extension = basename($file, '.php');
58
59
            $this->load->language('extension/extension/' . $extension);
60
61
            if ($this->user->hasPermission('access', 'extension/extension/' . $extension)) {
62
                $files = glob(SR_APPLICATION . 'controller/{extension/' . $extension . ',' . $extension . '}/*.php', GLOB_BRACE);
63
64
                $data['categories'][] = array(
65
                    'code' => $extension,
66
                    'text' => $this->language->get('heading_title') . ' (' . count($files) . ')',
0 ignored issues
show
It seems like $files can also be of type false; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

66
                    'text' => $this->language->get('heading_title') . ' (' . count(/** @scrutinizer ignore-type */ $files) . ')',
Loading history...
67
                    'href' => $this->url->link('extension/extension/' . $extension, 'token=' . $this->session->data['token'], true)
68
                );
69
            }
70
        }
71
72
        $data['header'] = $this->load->controller('common/header');
73
        $data['column'] = $this->load->controller('common/column_left');
74
        $data['footer'] = $this->load->controller('common/footer');
75
76
        $this->response->setOutput($this->load->view('extension/extension', $data));
77
    }
78
}
79