Completed
Push — master ( 8849ee...a1b70f )
by Andreas
24:35
created

midcom_helper_imagepopup_viewer::get_navigation()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 39
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 27
nc 4
nop 1
dl 0
loc 39
ccs 19
cts 19
cp 1
crap 4
rs 9.488
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author tarjei huse
4
 * @package midcom.helper.imagepopup
5
 * @copyright The Midgard Project, http://www.midgard-project.org
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
/**
10
 * This is the class that defines which URLs should be handled by this module.
11
 *
12
 * @package midcom.helper.imagepopup
13
 */
14
class midcom_helper_imagepopup_viewer extends midcom_baseclasses_components_plugin
15
{
16 6
    public static function get_navigation(array $data)
17
    {
18 6
        $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__ais/imagepopup/";
0 ignored issues
show
Bug introduced by
Are you sure midcom_core_context::get...M_CONTEXT_ANCHORPREFIX) of type false|mixed can be used in concatenation? ( Ignorable by Annotation )

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

18
        $prefix = /** @scrutinizer ignore-type */ midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__ais/imagepopup/";
Loading history...
19
20
        $navlinks = [
21
            'links' => [
22 6
                'url' => $prefix . 'links/' . $data['filetype'] . '/',
23 6
                'label' => $data['l10n']->get('links'),
24
                'selected' => false
25 6
            ],
26
            'page' => [
27 6
                'url' => $prefix . $data['filetype'] . '/',
28 6
                'label' => $data['l10n_midcom']->get('page'),
29
                'selected' => false
30
            ],
31
            'folder' => [
32 6
                'url' => $prefix . 'folder/' . $data['filetype'] . '/',
33 6
                'label' => $data['l10n_midcom']->get('folder'),
34
                'selected' => false
35
            ],
36
            'unified' => [
37 6
                'url' => $prefix . 'unified/' . $data['filetype'] . '/',
38 6
                'label' => $data['l10n']->get('unified search'),
39
                'selected' => false
40
            ]
41
        ];
42 6
        $navlinks[$data['list_type']]['selected'] = true;
43
44 6
        if (!empty($data['object'])) {
45 2
            foreach ($navlinks as &$link) {
46 2
                $link['url'] .= $data['object']->guid . '/';
47
            }
48
        } else {
49 4
            unset($navlinks['page']);
50
        }
51 6
        if ($data['filetype'] !== 'file') {
52 1
            unset($navlinks['links']);
53
        }
54 6
        return $navlinks;
55
    }
56
}
57