Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#870)
by
unknown
07:25 queued 04:28
created

NavigationController::pageSelectAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 15
rs 9.9332
1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Helper;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Core\Utility\MathUtility;
17
18
/**
19
 * Controller class for the plugin 'Navigation'.
20
 *
21
 * @author Sebastian Meyer <[email protected]>
22
 * @package TYPO3
23
 * @subpackage dlf
24
 * @access public
25
 */
26
class NavigationController extends AbstractController
27
{
28
    /**
29
     * Method to get the page select values and use them with chash
30
     * @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm
31
     * @return void
32
     */
33
    public function pageSelectAction(\Kitodo\Dlf\Domain\Model\PageSelectForm $pageSelectForm = NULL) {
34
        if ($pageSelectForm) {
35
            $uriBuilder = $this->getControllerContext()->getUriBuilder();
36
            $uri = $uriBuilder->reset()
37
                ->setArguments(
38
                    [
39
                        'tx_dlf' => [
40
                            'id' => $pageSelectForm->getId(),
41
                            'page' => $pageSelectForm->getPage(),
42
                            'double' => $pageSelectForm->getDouble()
43
                        ]
44
                    ]
45
                )
46
                ->uriFor('main');
47
            $this->redirectToUri($uri);
48
        }
49
    }
50
51
    /**
52
     * The main method of the plugin
53
     *
54
     * @return void
55
     */
56
    public function mainAction()
57
    {
58
        // Load current document.
59
        $this->loadDocument($this->requestData);
60
        if (
61
            $this->document === null
62
            || $this->document->getDoc() === null
63
        ) {
64
            // Quit without doing anything if required variables are not set.
65
            return '';
0 ignored issues
show
Bug Best Practice introduced by
The expression return '' returns the type string which is incompatible with the documented return type void.
Loading history...
66
        } else {
67
            // Set default values if not set.
68
            if ($this->document->getDoc()->numPages > 0) {
69
                if (!empty($this->requestData['logicalPage'])) {
70
                    $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']);
71
                    // The logical page parameter should not appear
72
                    unset($this->requestData['logicalPage']);
73
                }
74
                // Set default values if not set.
75
                // $this->requestData['page'] may be integer or string (physical structure @ID)
76
                if (
77
                    (int) $this->requestData['page'] > 0
78
                    || empty($this->requestData['page'])
79
                ) {
80
                    $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1);
81
                } else {
82
                    $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure);
83
                }
84
                $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0);
85
            } else {
86
                $this->requestData['page'] = 0;
87
                $this->requestData['double'] = 0;
88
            }
89
        }
90
91
        // Steps for X pages backward / forward. Double page view uses double steps.
92
        $pageSteps = $this->settings['pageStep'] * ($this->requestData['double'] + 1);
93
94
        $this->view->assign('pageSteps', $pageSteps);
95
        $this->view->assign('numPages', $this->document->getDoc()->numPages);
96
        $this->view->assign('viewData', $this->viewData);
97
98
        $pageOptions = [];
99
        for ($i = 1; $i <= $this->document->getDoc()->numPages; $i++) {
100
            $pageOptions[$i] = '[' . $i . ']' . ($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel']) : '');
101
        }
102
        $this->view->assign('pageOptions', $pageOptions);
103
104
        // prepare feature array for fluid
105
        $features = [];
106
        foreach (explode(',', $this->settings['features']) as $feature) {
107
            $features[$feature] = true;
108
        }
109
        $this->view->assign('features', $features);
110
    }
111
}
112