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 (#715)
by Alexander
03:39
created

PageGridController   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 11
eloc 29
c 5
b 0
f 0
dl 0
loc 68
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mainAction() 0 29 6
A getEntry() 0 20 5
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 TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
17
class PageGridController extends AbstractController
18
{
19
    /**
20
     * The main method of the plugin
21
     *
22
     * @return void
23
     */
24
    public function mainAction()
25
    {
26
        $requestData = GeneralUtility::_GPmerged('tx_dlf');
27
        unset($requestData['__referrer'], $requestData['__trustedProperties']);
28
29
        $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf');
30
31
        $this->loadDocument($requestData);
32
        if (
33
            $this->doc === null
34
            || $this->doc->numPages < 1
35
            || empty($extConf['fileGrpThumbs'])
36
        ) {
37
            // Quit without doing anything if required variables are not set.
38
            return;
39
        }
40
41
        $entryArray = [];
42
43
        $numPages = $this->doc->numPages;
44
        // Iterate through visible page set and display thumbnails.
45
        for ($i = 1; $i < $numPages; $i++) {
46
            $foundEntry = $this->getEntry($i, $extConf['fileGrpThumbs']);
47
            $foundEntry['state'] = ($i == $requestData['page']) ? 'cur' : 'no';
48
            $entryArray[] = $foundEntry;
49
        }
50
51
        $this->view->assign('pageGridEntries', $entryArray);
52
        $this->view->assign('docUid', $requestData['id']);
53
    }
54
55
    /**
56
     * Renders entry for one page of the current document.
57
     *
58
     * @access protected
59
     *
60
     * @param int $number: The page to render
61
     * @param string $fileGrpThumbs: the file group(s) of thumbs
62
     *
63
     * @return array The rendered entry ready for fluid
64
     */
65
    protected function getEntry($number, $fileGrpThumbs)
66
    {
67
        // Set pagination.
68
        $entry['pagination'] = htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['orderlabel']);
69
        $entry['page'] = $number;
70
        $entry['thumbnail'] = '';
71
72
        // Get thumbnail or placeholder.
73
        $fileGrpsThumb = GeneralUtility::trimExplode(',', $fileGrpThumbs);
74
        if (is_array($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'])) {
75
            if (array_intersect($fileGrpsThumb, array_keys($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'])) !== []) {
76
                while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
77
                    if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb])) {
78
                        $entry['thumbnail'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb]);
79
                        break;
80
                    }
81
                }
82
            }
83
        }
84
        return $entry;
85
    }
86
}
87