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 ( bbfd73...ec350d )
by Sebastian
02:38
created

FormEngine::itemsProcFunc_collectionList()   B

Complexity

Conditions 7
Paths 10

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 24
rs 8.8333
c 0
b 0
f 0
cc 7
nc 10
nop 2
1
<?php
2
namespace Kitodo\Dlf\Hooks;
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
 * Hooks and helper for \TYPO3\CMS\Backend\Form\FormEngine
18
 *
19
 * @author Sebastian Meyer <[email protected]>
20
 * @package TYPO3
21
 * @subpackage dlf
22
 * @access public
23
 */
24
class FormEngine {
25
    /**
26
     * Helper to display document's thumbnail for table "tx_dlf_documents"
27
     *
28
     * @access public
29
     *
30
     * @param array &$params: An array with parameters
31
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Form\FormEngine 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...
32
     *
33
     * @return string HTML <img> tag for thumbnail
34
     */
35
    public function displayThumbnail(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

35
    public function displayThumbnail(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        // Simulate TCA field type "passthrough".
37
        $output = '<input type="hidden" name="'.$params['itemFormElName'].'" value="'.$params['itemFormElValue'].'" />';
38
        if (!empty($params['itemFormElValue'])) {
39
            $output .= '<img alt="" src="'.$params['itemFormElValue'].'" />';
40
        }
41
        return $output;
42
    }
43
44
    /**
45
     * Helper to get flexform's items array for plugin "tx_dlf_collection"
46
     *
47
     * @access public
48
     *
49
     * @param array &$params: An array with parameters
50
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
51
     *
52
     * @return void
53
     */
54
    public function itemsProcFunc_collectionList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

54
    public function itemsProcFunc_collectionList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
        $pages = $params['row']['pages'];
56
        if (!empty($pages)) {
57
            foreach ($pages as $page) {
58
                // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title.
59
                // i.e. instead of "18" it reads "pages_18|Title"
60
                if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($page)) {
61
                    $parts = explode('|', $page);
62
                    $page = array_pop(explode('_', $parts[0]));
0 ignored issues
show
Bug introduced by
explode('_', $parts[0]) cannot be passed to array_pop() as the parameter $array expects a reference. ( Ignorable by Annotation )

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

62
                    $page = array_pop(/** @scrutinizer ignore-type */ explode('_', $parts[0]));
Loading history...
63
                }
64
                if ($page > 0) {
65
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
66
                        'label,uid',
67
                        'tx_dlf_collections',
68
                        'pid='.intval($page)
69
                            .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
70
                            .Helper::whereClause('tx_dlf_collections'),
71
                        '',
72
                        'label',
73
                        ''
74
                    );
75
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
76
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
77
                            $params['items'][] = $resArray;
78
                        }
79
                    }
80
                }
81
            }
82
        }
83
    }
84
85
    /**
86
     * Helper to get flexform's items array for plugin "Search"
87
     *
88
     * @access public
89
     *
90
     * @param array &$params: An array with parameters
91
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
92
     *
93
     * @return void
94
     */
95
    public function itemsProcFunc_extendedSearchList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

95
    public function itemsProcFunc_extendedSearchList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
96
        $pages = $params['row']['pages'];
97
        if (!empty($pages)) {
98
            // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title.
99
            // i.e. instead of "18" it reads "pages_18|Title"
100
            if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($pages)) {
101
                $_parts = explode('|', $pages);
102
                $pages = array_pop(explode('_', $_parts[0]));
0 ignored issues
show
Bug introduced by
explode('_', $_parts[0]) cannot be passed to array_pop() as the parameter $array expects a reference. ( Ignorable by Annotation )

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

102
                $pages = array_pop(/** @scrutinizer ignore-type */ explode('_', $_parts[0]));
Loading history...
103
            }
104
            if ($pages > 0) {
105
                $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
106
                    'label,index_name',
107
                    'tx_dlf_metadata',
108
                    'index_indexed=1'
109
                        .' AND pid='.intval($pages)
110
                        .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
111
                        .Helper::whereClause('tx_dlf_metadata'),
112
                    '',
113
                    'sorting',
114
                    ''
115
                );
116
                if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
117
                    while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
118
                        $params['items'][] = $resArray;
119
                    }
120
                }
121
            }
122
        }
123
    }
124
125
    /**
126
     * Helper to get flexform's items array for plugin "Search"
127
     *
128
     * @access public
129
     *
130
     * @param array &$params: An array with parameters
131
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
132
     *
133
     * @return void
134
     */
135
    public function itemsProcFunc_facetsList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

135
    public function itemsProcFunc_facetsList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
136
        $pages = $params['row']['pages'];
137
        if (!empty($pages)) {
138
            // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title.
139
            // i.e. instead of "18" it reads "pages_18|Title"
140
            if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($pages)) {
141
                $_parts = explode('|', $pages);
142
                $pages = array_pop(explode('_', $_parts[0]));
0 ignored issues
show
Bug introduced by
explode('_', $_parts[0]) cannot be passed to array_pop() as the parameter $array expects a reference. ( Ignorable by Annotation )

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

142
                $pages = array_pop(/** @scrutinizer ignore-type */ explode('_', $_parts[0]));
Loading history...
143
            }
144
            if ($pages > 0) {
145
                $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
146
                    'label,index_name',
147
                    'tx_dlf_metadata',
148
                    'is_facet=1'
149
                        .' AND pid='.intval($pages)
150
                        .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
151
                        .Helper::whereClause('tx_dlf_metadata'),
152
                    '',
153
                    'sorting',
154
                    ''
155
                );
156
                if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
157
                    while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
158
                        $params['items'][] = $resArray;
159
                    }
160
                }
161
            }
162
        }
163
    }
164
165
    /**
166
     * Helper to get flexform's items array for plugin "OaiPmh"
167
     *
168
     * @access public
169
     *
170
     * @param array &$params: An array with parameters
171
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
172
     *
173
     * @return void
174
     */
175
    public function itemsProcFunc_libraryList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

175
    public function itemsProcFunc_libraryList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
176
        $pages = $params['row']['pages'];
177
        if (!empty($pages)) {
178
            // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title.
179
            // i.e. instead of "18" it reads "pages_18|Title"
180
            if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($pages)) {
181
                $parts = explode('|', $pages);
182
                $pages = array_pop(explode('_', $parts[0]));
0 ignored issues
show
Bug introduced by
explode('_', $parts[0]) cannot be passed to array_pop() as the parameter $array expects a reference. ( Ignorable by Annotation )

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

182
                $pages = array_pop(/** @scrutinizer ignore-type */ explode('_', $parts[0]));
Loading history...
183
            }
184
            if ($pages > 0) {
185
                $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
186
                    'label,uid',
187
                    'tx_dlf_libraries',
188
                    'pid='.intval($pages)
189
                        .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
190
                        .Helper::whereClause('tx_dlf_libraries'),
191
                    '',
192
                    'label',
193
                    ''
194
                );
195
                if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
196
                    while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
197
                        $params['items'][] = $resArray;
198
                    }
199
                }
200
            }
201
        }
202
    }
203
204
    /**
205
     * Helper to get flexform's items array for plugin "Search"
206
     *
207
     * @access public
208
     *
209
     * @param array &$params: An array with parameters
210
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
211
     *
212
     * @return void
213
     */
214
    public function itemsProcFunc_solrList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

214
    public function itemsProcFunc_solrList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
215
        $pages = $params['row']['pages'];
216
        if (!empty($pages)) {
217
            foreach ($pages as $page) {
218
                // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title.
219
                // i.e. instead of "18" it reads "pages_18|Title"
220
                if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($page)) {
221
                    $parts = explode('|', $page);
222
                    $page = array_pop(explode('_', $parts[0]));
0 ignored issues
show
Bug introduced by
explode('_', $parts[0]) cannot be passed to array_pop() as the parameter $array expects a reference. ( Ignorable by Annotation )

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

222
                    $page = array_pop(/** @scrutinizer ignore-type */ explode('_', $parts[0]));
Loading history...
223
                }
224
                if ($page > 0) {
225
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
226
                        'label,uid',
227
                        'tx_dlf_solrcores',
228
                        'pid IN ('.intval($page).',0)'
229
                            .Helper::whereClause('tx_dlf_solrcores'),
230
                        '',
231
                        'label',
232
                        ''
233
                    );
234
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
235
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
236
                            $params['items'][] = $resArray;
237
                        }
238
                    }
239
                }
240
            }
241
        }
242
    }
243
244
    /**
245
     * Helper to get flexform's items array for plugin "Toolbox"
246
     *
247
     * @access public
248
     *
249
     * @param array &$params: An array with parameters
250
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
251
     *
252
     * @return void
253
     */
254
    public function itemsProcFunc_toolList(&$params, &$pObj) {
1 ignored issue
show
Unused Code introduced by
The parameter $pObj is not used and could be removed. ( Ignorable by Annotation )

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

254
    public function itemsProcFunc_toolList(&$params, /** @scrutinizer ignore-unused */ &$pObj) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
255
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) {
256
            $params['items'][] = [$GLOBALS['LANG']->sL($label), $class];
257
        }
258
    }
259
}
260