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

AudioplayerController::mainAction()   B

Complexity

Conditions 8
Paths 13

Size

Total Lines 43
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 26
c 3
b 0
f 0
dl 0
loc 43
rs 8.4444
cc 8
nc 13
nop 0
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\Page\PageRenderer;
15
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17
use TYPO3\CMS\Core\Utility\MathUtility;
18
use TYPO3\CMS\Core\Utility\PathUtility;
19
20
/**
21
 * Controller for the plugin AudioPlayer for the 'dlf' extension
22
 *
23
 * @author Sebastian Meyer <[email protected]>
24
 * @package TYPO3
25
 * @subpackage dlf
26
 * @access public
27
 */
28
class AudioplayerController extends AbstractController
29
{
30
    /**
31
     * @var string
32
     */
33
    protected $extKey = 'dlf';
34
35
    /**
36
     * Holds the current audio file's URL, MIME type and optional label
37
     *
38
     * @var array
39
     * @access protected
40
     */
41
    protected $audio = [];
42
43
    /**
44
     * Adds Player javascript
45
     *
46
     * @access protected
47
     *
48
     * @return void
49
     */
50
    protected function addPlayerJS()
51
    {
52
        // Inline CSS.
53
        $inlineCSS = '#tx-dlf-audio { width: 100px; height: 100px; }';
54
55
        // AudioPlayer configuration.
56
        $audioPlayerConfiguration = '
57
            $(document).ready(function() {
58
                AudioPlayer = new dlfAudioPlayer({
59
                    audio: {
60
                        mimeType: "' . $this->audio['mimetype'] . '",
61
                        title: "' . $this->audio['label'] . '",
62
                        url:  "' . $this->audio['url'] . '"
63
                    },
64
                    parentElId: "tx-dlf-audio",
65
                    swfPath: "' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/jPlayer/jquery.jplayer.swf"
66
                });
67
            });
68
        ';
69
70
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
71
        $pageRenderer->addCssInlineBlock('kitodo-audioplayer-configuration', $inlineCSS);
72
        $pageRenderer->addJsFooterInlineCode('kitodo-audioplayer-configuration', $audioPlayerConfiguration);
73
    }
74
75
    /**
76
     * The main method of the plugin
77
     *
78
     * @return void
79
     */
80
    public function mainAction()
81
    {
82
        $requestData = GeneralUtility::_GPmerged('tx_dlf');
83
        unset($requestData['__referrer'], $requestData['__trustedProperties']);
84
85
        // Load current document.
86
        $this->loadDocument($requestData);
87
        if (
88
            $this->doc === null
89
            || $this->doc->numPages < 1
90
        ) {
91
            // Quit without doing anything if required variables are not set.
92
            return;
93
        } else {
94
            // Set default values if not set.
95
            // $requestData['page'] may be integer or string (physical structure @ID)
96
            if (
97
                (int) $requestData['page'] > 0
98
                || empty($requestData['page'])
99
            ) {
100
                $requestData['page'] = MathUtility::forceIntegerInRange((int) $requestData['page'], 1, $this->doc->numPages, 1);
101
            } else {
102
                $requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure);
103
            }
104
            $requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], 0, 1, 0);
105
        }
106
        // Check if there are any audio files available.
107
        $fileGrpsAudio = GeneralUtility::trimExplode(',', $this->settings['fileGrpAudio']);
108
        while ($fileGrpAudio = array_shift($fileGrpsAudio)) {
109
            if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$requestData['page']]]['files'][$fileGrpAudio])) {
110
                // Get audio data.
111
                $this->audio['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$requestData['page']]]['files'][$fileGrpAudio]);
112
                $this->audio['label'] = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$requestData['page']]]['label'];
113
                $this->audio['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$requestData['page']]]['files'][$fileGrpAudio]);
114
                break;
115
            }
116
        }
117
        if (!empty($this->audio)) {
118
            // Add jPlayer javascript.
119
            $this->addPlayerJS();
120
        } else {
121
            // Quit without doing anything if required variables are not set.
122
            return;
123
        }
124
    }
125
}
126