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
Push — master ( 14584b...f60880 )
by Sebastian
02:42
created

Statistics   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 69
dl 0
loc 98
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B main() 0 85 5
1
<?php
2
namespace Kitodo\Dlf\Plugin;
3
4
/**
5
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
6
 *
7
 * This file is part of the Kitodo and TYPO3 projects.
8
 *
9
 * @license GNU General Public License version 3 or later.
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 */
13
14
use Kitodo\Dlf\Common\Helper;
15
16
/**
17
 * Plugin 'Statistics' for the 'dlf' extension
18
 *
19
 * @author Sebastian Meyer <[email protected]>
20
 * @package TYPO3
21
 * @subpackage dlf
22
 * @access public
23
 */
24
class Statistics extends \Kitodo\Dlf\Common\AbstractPlugin {
25
    public $scriptRelPath = 'Classes/Plugin/Statistics.php';
26
27
    /**
28
     * The main method of the PlugIn
29
     *
30
     * @access public
31
     *
32
     * @param string $content: The PlugIn content
33
     * @param array $conf: The PlugIn configuration
34
     *
35
     * @return string The content that is displayed on the website
36
     */
37
    public function main($content, $conf) {
38
        $this->init($conf);
39
        // Turn cache on.
40
        $this->setCache(TRUE);
41
        // Quit without doing anything if required configuration variables are not set.
42
        if (empty($this->conf['pages'])) {
43
            Helper::devLog('Incomplete plugin configuration', DEVLOG_SEVERITY_WARNING);
44
            return $content;
45
        }
46
        // Get description.
47
        $content .= $this->pi_RTEcssText($this->conf['description']);
48
        // Check for selected collections.
49
        if ($this->conf['collections']) {
50
            // Include only selected collections.
51
            $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
52
                'tx_dlf_documents.uid AS uid',
53
                'tx_dlf_documents',
54
                'tx_dlf_relations',
55
                'tx_dlf_collections',
56
                'AND tx_dlf_documents.pid='.intval($this->conf['pages'])
57
                    .' AND tx_dlf_collections.pid='.intval($this->conf['pages'])
58
                    .' AND tx_dlf_documents.partof=0'
59
                    .' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')'
60
                    .' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations')
61
                    .Helper::whereClause('tx_dlf_documents')
62
                    .Helper::whereClause('tx_dlf_collections'),
63
                'tx_dlf_documents.uid',
64
                '',
65
                ''
66
            );
67
            $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
68
                'tx_dlf_documents.uid AS uid',
69
                'tx_dlf_documents',
70
                'tx_dlf_relations',
71
                'tx_dlf_collections',
72
                'AND tx_dlf_documents.pid='.intval($this->conf['pages'])
73
                    .' AND tx_dlf_collections.pid='.intval($this->conf['pages'])
74
                    .' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.Helper::whereClause('tx_dlf_documents').')'
75
                    .' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')'
76
                    .' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations')
77
                    .Helper::whereClause('tx_dlf_documents')
78
                    .Helper::whereClause('tx_dlf_collections'),
79
                'tx_dlf_documents.uid',
80
                '',
81
                ''
82
            );
83
        } else {
84
            // Include all collections.
85
            $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
86
                'tx_dlf_documents.uid AS uid',
87
                'tx_dlf_documents',
88
                'tx_dlf_documents.pid='.intval($this->conf['pages'])
89
                    .' AND tx_dlf_documents.partof=0'
90
                    .Helper::whereClause('tx_dlf_documents'),
91
                '',
92
                '',
93
                ''
94
            );
95
            $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
96
                'tx_dlf_documents.uid AS uid',
97
                'tx_dlf_documents',
98
                'tx_dlf_documents.pid='.intval($this->conf['pages'])
99
                    .' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.Helper::whereClause('tx_dlf_documents').')'
100
                    .Helper::whereClause('tx_dlf_documents'),
101
                '',
102
                '',
103
                ''
104
            );
105
        }
106
        $countTitles = $GLOBALS['TYPO3_DB']->sql_num_rows($resultTitles);
107
        $countVolumes = $GLOBALS['TYPO3_DB']->sql_num_rows($resultVolumes);
108
        // Set replacements.
109
        $replace = [
110
            'key' => [
111
                '###TITLES###',
112
                '###VOLUMES###'
113
            ],
114
            'value' => [
115
                $countTitles.($countTitles > 1 ? $this->pi_getLL('titles', '', TRUE) : $this->pi_getLL('title', '', TRUE)),
116
                $countVolumes.($countVolumes > 1 ? $this->pi_getLL('volumes', '', TRUE) : $this->pi_getLL('volume', '', TRUE))
117
            ]
118
        ];
119
        // Apply replacements.
120
        $content = str_replace($replace['key'], $replace['value'], $content);
121
        return $this->pi_wrapInBaseClass($content);
122
    }
123
}
124