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 (#663)
by
unknown
03:00
created

FeedsController::pi_getLL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
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\Extbase\Configuration\ConfigurationManager;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Config...on\ConfigurationManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Core\Database\ConnectionPool;
17
use Kitodo\Dlf\Common\Helper;
18
19
class FeedsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Mvc\Controller\ActionController was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
{
21
    public $prefixId = 'tx_dlf';
22
23
    /**
24
     * @var ConfigurationManager
25
     */
26
    protected $configurationManager;
27
28
    /**
29
     * @var \TYPO3\CMS\Core\Log\LogManager
30
     */
31
    protected $logger;
32
33
    /**
34
     * SearchController constructor.
35
     * @param $configurationManager
36
     */
37
    public function __construct(ConfigurationManager $configurationManager)
38
    {
39
        $this->configurationManager = $configurationManager;
40
        $this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
41
    }
42
43
    /**
44
     *
45
     */
46
    public function mainAction()
47
    {
48
        $requestData = $this->request->getArguments();
49
50
        // Create XML document.
51
        $rss = new \DOMDocument('1.0', 'utf-8');
52
        // Add mandatory root element.
53
        $root = $rss->createElement('rss');
54
        $root->setAttribute('version', '2.0');
55
        // Add channel element.
56
        $channel = $rss->createElement('channel');
57
        $channel->appendChild($rss->createElement('title', htmlspecialchars($this->settings['title'], ENT_NOQUOTES, 'UTF-8')));
58
59
        $currentUri = $this->controllerContext
60
            ->getUriBuilder()
61
            ->reset()
62
            ->setTargetPageUid($GLOBALS["TSFE"]->id)
63
            ->setAddQueryString(TRUE)
64
            ->buildFrontendUri();
65
        $channel->appendChild($rss->createElement('link', htmlspecialchars(GeneralUtility::locationHeaderUrl($currentUri), ENT_NOQUOTES, 'UTF-8')));
66
67
        if (!empty($this->settings['description'])) {
68
            $channel->appendChild($rss->createElement('description', htmlspecialchars($this->settings['description'], ENT_QUOTES, 'UTF-8')));
69
        }
70
71
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
72
            ->getQueryBuilderForTable('tx_dlf_structures');
73
74
        $result = $queryBuilder
75
            ->select('tx_dlf_libraries.label AS label')
76
            ->from('tx_dlf_libraries')
77
            ->where(
78
                $queryBuilder->expr()->eq('tx_dlf_libraries.pid', (int)$this->settings['pages']),
79
                $queryBuilder->expr()->eq('tx_dlf_libraries.uid', (int)$this->settings['library']),
80
                Helper::whereExpression('tx_dlf_libraries')
81
            )
82
            ->setMaxResults(1)
83
            ->execute();
84
85
        $allResults = $result->fetchAll();
86
87
        if (count($allResults) === 1) {
88
            $resArray = $allResults[0];
89
            $channel->appendChild($rss->createElement('copyright', htmlspecialchars($resArray['label'], ENT_NOQUOTES, 'UTF-8')));
90
        }
91
        $channel->appendChild($rss->createElement('pubDate', date('r', $GLOBALS['EXEC_TIME'])));
92
        $channel->appendChild($rss->createElement('generator', htmlspecialchars($this->settings['useragent'], ENT_NOQUOTES, 'UTF-8')));
93
        // Add item elements.
94
        if (
95
            !$this->settings['excludeOther']
96
            || empty($requestData['collection'])
97
            || GeneralUtility::inList($this->settings['collections'], $requestData['collection'])
98
        ) {
99
            $additionalWhere = '';
100
            // Check for pre-selected collections.
101
            if (!empty($requestData['collection'])) {
102
                $additionalWhere = 'tx_dlf_collections.uid=' . (int)$requestData['collection'];
103
            } elseif (!empty($this->settings['collections'])) {
104
                $additionalWhere = 'tx_dlf_collections.uid IN (' . implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])) . ')';
105
            }
106
107
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
108
                ->getQueryBuilderForTable('tx_dlf_documents');
109
110
            $result = $queryBuilder
111
                ->select(
112
                    'tx_dlf_documents.uid AS uid',
113
                    'tx_dlf_documents.partof AS partof',
114
                    'tx_dlf_documents.title AS title',
115
                    'tx_dlf_documents.volume AS volume',
116
                    'tx_dlf_documents.author AS author',
117
                    'tx_dlf_documents.record_id AS guid',
118
                    'tx_dlf_documents.tstamp AS tstamp',
119
                    'tx_dlf_documents.crdate AS crdate'
120
                )
121
                ->from('tx_dlf_documents')
122
                ->join(
123
                    'tx_dlf_documents',
124
                    'tx_dlf_relations',
125
                    'tx_dlf_documents_collections_mm',
126
                    $queryBuilder->expr()->eq('tx_dlf_documents.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_local'))
127
                )
128
                ->join(
129
                    'tx_dlf_documents_collections_mm',
130
                    'tx_dlf_collections',
131
                    'tx_dlf_collections',
132
                    $queryBuilder->expr()->eq('tx_dlf_collections.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_foreign'))
133
                )
134
                ->where(
135
                    $queryBuilder->expr()->eq('tx_dlf_documents.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])),
136
                    $queryBuilder->expr()->eq('tx_dlf_documents_collections_mm.ident', $queryBuilder->createNamedParameter('docs_colls')),
137
                    $queryBuilder->expr()->eq('tx_dlf_collections.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])),
138
                    $additionalWhere,
139
                    Helper::whereExpression('tx_dlf_documents'),
140
                    Helper::whereExpression('tx_dlf_collections')
141
                )
142
                ->groupBy('tx_dlf_documents.uid')
143
                ->orderBy('tx_dlf_documents.tstamp', 'DESC')
144
                ->setMaxResults((int) $this->settings['limit'])
145
                ->execute();
146
            $rows = $result->fetchAll();
147
148
            if (count($rows) > 0) {
149
                // Add each record as item element.
150
                foreach ($rows as $resArray) {
151
                    $item = $rss->createElement('item');
152
                    $title = '';
153
                    // Get title of superior document.
154
                    if ((empty($resArray['title']) || !empty($this->settings['prependSuperiorTitle']))
155
                        && !empty($resArray['partof'])
156
                    ) {
157
                        $superiorTitle = Document::getTitle($resArray['partof'], true);
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Controller\Document was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
158
                        if (!empty($superiorTitle)) {
159
                            $title .= '[' . $superiorTitle . ']';
160
                        }
161
                    }
162
                    // Get title of document.
163
                    if (!empty($resArray['title'])) {
164
                        $title .= ' ' . $resArray['title'];
165
                    }
166
                    // Set default title if empty.
167
                    if (empty($title)) {
168
                        $title = $this->pi_getLL('noTitle');
169
                    }
170
                    // Append volume information.
171
                    if (!empty($resArray['volume'])) {
172
                        $title .= ', ' . $this->pi_getLL('volume') . ' ' . $resArray['volume'];
173
                    }
174
                    // Is this document new or updated?
175
                    if ($resArray['crdate'] == $resArray['tstamp']) {
176
                        $title = $this->pi_getLL('new') . ' ' . trim($title);
177
                    } else {
178
                        $title = $this->pi_getLL('update') . ' ' . trim($title);
179
                    }
180
                    $item->appendChild($rss->createElement('title', htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8')));
181
                    // Add link.
182
                    $linkConf = [
183
                        'parameter' => $this->settings['targetPid'],
184
                        'forceAbsoluteUrl' => 1,
185
                        'forceAbsoluteUrl.' => ['scheme' => !empty($this->settings['forceAbsoluteUrlHttps']) ? 'https' : 'http'],
186
                        'additionalParams' => GeneralUtility::implodeArrayForUrl($this->prefixId, ['id' => $resArray['uid']], '', true, false)
187
                    ];
188
                    /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
189
                    $cObj = $this->configurationManager->getContentObject();
190
191
                    $item->appendChild($rss->createElement('link', htmlspecialchars($cObj->typoLink_URL($linkConf), ENT_NOQUOTES, 'UTF-8')));
192
                    // Add author if applicable.
193
                    if (!empty($resArray['author'])) {
194
                        $item->appendChild($rss->createElement('author', htmlspecialchars($resArray['author'], ENT_NOQUOTES, 'UTF-8')));
195
                    }
196
                    // Add online publication date.
197
                    $item->appendChild($rss->createElement('pubDate', date('r', $resArray['crdate'])));
198
                    // Add internal record identifier.
199
                    $item->appendChild($rss->createElement('guid', htmlspecialchars($resArray['guid'], ENT_NOQUOTES, 'UTF-8')));
200
                    $channel->appendChild($item);
201
                }
202
            }
203
        }
204
        $root->appendChild($channel);
205
        // Build XML output.
206
        $rss->appendChild($root);
207
        $content = $rss->saveXML();
208
        // Clean output buffer.
209
        ob_end_clean();
210
        // Send headers.
211
        header('HTTP/1.1 200 OK');
212
        header('Cache-Control: no-cache');
213
        header('Content-Length: ' . strlen($content));
214
        header('Content-Type: application/rss+xml; charset=utf-8');
215
        header('Date: ' . date('r', $GLOBALS['EXEC_TIME']));
216
        header('Expires: ' . date('r', $GLOBALS['EXEC_TIME']));
217
        echo $content;
218
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
219
    }
220
221
    protected function pi_getLL($label)
222
    {
223
        return $GLOBALS['TSFE']->sL('LLL:EXT:dlf/Resources/Private/Language/Feeds.xml:' . $label);
224
    }
225
226
}