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

AudioPlayer::addPlayerJS()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 22
rs 9.9332
c 0
b 0
f 0
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
/**
15
 * Plugin AudioPlayer for the 'dlf' extension
16
 *
17
 * @author Sebastian Meyer <[email protected]>
18
 * @package TYPO3
19
 * @subpackage dlf
20
 * @access public
21
 */
22
class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin {
23
    public $scriptRelPath = 'Classes/Plugin/AudioPlayer.php';
24
25
    /**
26
     * Holds the current audio file's URL, MIME type and optional label
27
     *
28
     * @var array
29
     * @access protected
30
     */
31
    protected $audio = [];
32
33
    /**
34
     * Adds Player javascript
35
     *
36
     * @access protected
37
     *
38
     * @return string Player script tags ready for output
39
     */
40
    protected function addPlayerJS() {
41
        $output = [];
42
        $output[] = '<link type="text/css" rel="stylesheet" href="'.\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey).'Resources/Public/Javascript/jPlayer/blue.monday/css/jplayer.blue.monday.min.css">';
43
        $output[] = '<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey).'Resources/Public/Javascript/jPlayer/jquery.jplayer.min.js"></script>';
44
        $output[] = '<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey).'Resources/Public/Javascript/AudioPlayer/AudioPlayer.js"></script>';
45
        // Add player configuration.
46
        $output[] = '
47
            <style>#tx-dlf-audio { width: 100px; height: 100px; }</style>
48
            <script id="tx-dlf-audioplayer-initViewer" type="text/javascript">
49
                $(document).ready(function() {
50
                    AudioPlayer = new dlfAudioPlayer({
51
                        audio: {
52
                            mimeType: "'.$this->audio['mimetype'].'",
53
                            title: "'.$this->audio['label'].'",
54
                            url:  "'.$this->audio['url'].'"
55
                        },
56
                        parentElId: "tx-dlf-audio",
57
                        swfPath: "'.\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey).'Resources/Public/Javascript/jPlayer/jquery.jplayer.swf"
58
                    });
59
                });
60
            </script>';
61
        return implode("\n", $output);
62
    }
63
64
    /**
65
     * The main method of the PlugIn
66
     *
67
     * @access public
68
     *
69
     * @param string $content: The PlugIn content
70
     * @param array $conf: The PlugIn configuration
71
     *
72
     * @return string The content that is displayed on the website
73
     */
74
    public function main($content, $conf) {
75
        $this->init($conf);
76
        // Load current document.
77
        $this->loadDocument();
78
        if ($this->doc === NULL
79
            || $this->doc->numPages < 1) {
0 ignored issues
show
Bug Best Practice introduced by
The property $numPages is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
80
            // Quit without doing anything if required variables are not set.
81
            return $content;
82
        } else {
83
            // Set default values if not set.
84
            // $this->piVars['page'] may be integer or string (physical structure @ID)
85
            if ((int) $this->piVars['page'] > 0
86
                || empty($this->piVars['page'])) {
87
                $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
88
            } else {
89
                $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
0 ignored issues
show
Bug Best Practice introduced by
The property $physicalStructure is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
90
            }
91
            $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
92
        }
93
        // Check if there are any audio files available.
94
        if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']])) {
0 ignored issues
show
Bug Best Practice introduced by
The property $physicalStructureInfo is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
95
            // Get audio data.
96
            $this->audio['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']]);
97
            $this->audio['label'] = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['label'];
98
            $this->audio['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']]);
99
        } else {
100
            // Quit without doing anything if required variables are not set.
101
            return $content;
102
        }
103
        // Load template file.
104
        $this->getTemplate();
105
        // Fill in the template markers.
106
        $markerArray = [
107
            '###PLAYER_JS###' => $this->addPlayerJS()
108
        ];
109
        $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Frontend\Conte...substituteMarkerArray() has been deprecated: since TYPO3 v8, will be removed in TYPO3 v9, please use the MarkerBasedTemplateService instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

109
        $content .= /** @scrutinizer ignore-deprecated */ $this->cObj->substituteMarkerArray($this->template, $markerArray);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
110
        return $this->pi_wrapInBaseClass($content);
111
    }
112
}
113