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 (#664)
by
unknown
02:49
created

MetadataController::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 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Controller;
14
15
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
16
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...
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Core\Utility\MathUtility;
19
use TYPO3\CMS\Core\Utility\PathUtility;
20
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
21
use Kitodo\Dlf\Common\Document;
22
use Kitodo\Dlf\Common\DocumentList;
23
use Kitodo\Dlf\Common\Helper;
24
use Kitodo\Dlf\Common\Indexer;
25
use Kitodo\Dlf\Common\Solr;
26
use TYPO3\CMS\Core\Database\Connection;
27
use TYPO3\CMS\Core\Database\ConnectionPool;
28
use \Kitodo\Dlf\Domain\Model\SearchForm;
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Domain\Model\SearchForm 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...
29
use Ubl\Iiif\Context\IRI;
30
31
class MetadataController 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...
32
{
33
    public $prefixId = 'tx_dlf';
34
    public $extKey = 'dlf';
35
36
    /**
37
     * @var ConfigurationManager
38
     */
39
    protected $configurationManager;
40
41
    /**
42
     * @var \TYPO3\CMS\Core\Log\LogManager
43
     */
44
    protected $logger;
45
46
    /**
47
     * SearchController constructor.
48
     * @param $configurationManager
49
     */
50
    public function __construct(ConfigurationManager $configurationManager)
51
    {
52
        $this->configurationManager = $configurationManager;
53
        $this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
54
    }
55
56
    // TODO: Needs to be placed in an abstract class
57
    /**
58
     * Loads the current document into $this->doc
59
     *
60
     * @access protected
61
     *
62
     * @return void
63
     */
64
    protected function loadDocument($requestData)
65
    {
66
        // Check for required variable.
67
        if (
68
            !empty($requestData['id'])
69
            && !empty($this->settings['pages'])
70
        ) {
71
            // Should we exclude documents from other pages than $this->settings['pages']?
72
            $pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0);
73
            // Get instance of \Kitodo\Dlf\Common\Document.
74
            $this->doc = Document::getInstance($requestData['id'], $pid);
0 ignored issues
show
Bug Best Practice introduced by
The property doc does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
75
            if (!$this->doc->ready) {
76
                // Destroy the incomplete object.
77
                $this->doc = null;
78
                $this->logger->error('Failed to load document with UID ' . $requestData['id']);
1 ignored issue
show
Bug introduced by
The method error() does not exist on TYPO3\CMS\Core\Log\LogManager. ( Ignorable by Annotation )

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

78
                $this->logger->/** @scrutinizer ignore-call */ 
79
                               error('Failed to load document with UID ' . $requestData['id']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
            } else {
80
                // Set configuration PID.
81
                $this->doc->cPid = $this->settings['pages'];
82
            }
83
        } elseif (!empty($requestData['recordId'])) {
84
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
85
                ->getQueryBuilderForTable('tx_dlf_documents');
86
87
            // Get UID of document with given record identifier.
88
            $result = $queryBuilder
89
                ->select('tx_dlf_documents.uid AS uid')
90
                ->from('tx_dlf_documents')
91
                ->where(
92
                    $queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])),
93
                    Helper::whereExpression('tx_dlf_documents')
94
                )
95
                ->setMaxResults(1)
96
                ->execute();
97
98
            if ($resArray = $result->fetch()) {
99
                $requestData['id'] = $resArray['uid'];
100
                // Set superglobal $_GET array and unset variables to avoid infinite looping.
101
                $_GET[$this->prefixId]['id'] = $requestData['id'];
102
                unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']);
103
                // Try to load document.
104
                $this->loadDocument();
0 ignored issues
show
Bug introduced by
The call to Kitodo\Dlf\Controller\Me...troller::loadDocument() has too few arguments starting with requestData. ( Ignorable by Annotation )

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

104
                $this->/** @scrutinizer ignore-call */ 
105
                       loadDocument();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
105
            } else {
106
                $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"');
107
            }
108
        } else {
109
            $this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading');
110
        }
111
    }
112
113
    /**
114
     * @return string|void
115
     */
116
    public function mainAction()
117
    {
118
        $requestData = GeneralUtility::_GPmerged('tx_dlf');
119
        unset($requestData['__referrer'], $requestData['__trustedProperties']);
120
121
        $this->cObj = $this->configurationManager->getContentObject();
0 ignored issues
show
Bug Best Practice introduced by
The property cObj does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
122
123
        // Load current document.
124
        $this->loadDocument($requestData);
125
        if ($this->doc === null) {
126
            // Quit without doing anything if required variables are not set.
127
            return '';
128
        } else {
129
            // Set default values if not set.
130
            if (!isset($this->settings['rootline'])) {
131
                $this->settings['rootline'] = 0;
0 ignored issues
show
Bug Best Practice introduced by
The property settings does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
132
            }
133
            if (!isset($this->settings['originalIiifMetadata'])) {
134
                $this->settings['originalIiifMetadata'] = 0;
135
            }
136
            if (!isset($this->settings['displayIiifDescription'])) {
137
                $this->settings['displayIiifDescription'] = 1;
138
            }
139
            if (!isset($this->settings['displayIiifRights'])) {
140
                $this->settings['displayIiifRights'] = 1;
141
            }
142
            if (!isset($this->settings['displayIiifLinks'])) {
143
                $this->settings['displayIiifLinks'] = 1;
144
            }
145
        }
146
        $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->doc instanceof IiifManifest;
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Controller\IiifManifest 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...
147
        $metadata = [];
148
        if ($this->settings['rootline'] < 2) {
149
            // Get current structure's @ID.
150
            $ids = [];
151
            if (!empty($this->doc->physicalStructure[$requestData['page']]) && !empty($this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page']]])) {
152
                foreach ($this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page']]] as $logId) {
153
                    $count = $this->doc->getStructureDepth($logId);
154
                    $ids[$count][] = $logId;
155
                }
156
            }
157
            ksort($ids);
158
            reset($ids);
159
            // Check if we should display all metadata up to the root.
160
            if ($this->settings['rootline'] == 1) {
161
                foreach ($ids as $id) {
162
                    foreach ($id as $sid) {
163
                        if ($useOriginalIiifManifestMetadata) {
164
                            $data = $this->doc->getManifestMetadata($sid, $this->settings['pages']);
165
                        } else {
166
                            $data = $this->doc->getMetadata($sid, $this->settings['pages']);
167
                        }
168
                        if (!empty($data)) {
169
                            $data['_id'] = $sid;
170
                            $metadata[] = $data;
171
                        }
172
                    }
173
                }
174
            } else {
175
                $id = array_pop($ids);
176
                if (is_array($id)) {
177
                    foreach ($id as $sid) {
178
                        if ($useOriginalIiifManifestMetadata) {
179
                            $data = $this->doc->getManifestMetadata($sid, $this->settings['pages']);
180
                        } else {
181
                            $data = $this->doc->getMetadata($sid, $this->settings['pages']);
182
                        }
183
                        if (!empty($data)) {
184
                            $data['_id'] = $sid;
185
                            $metadata[] = $data;
186
                        }
187
                    }
188
                }
189
            }
190
        }
191
        // Get titledata?
192
        if (empty($metadata) || ($this->settings['rootline'] == 1 && $metadata[0]['_id'] != $this->doc->toplevelId)) {
193
            $data = $useOriginalIiifManifestMetadata ? $this->doc->getManifestMetadata($this->doc->toplevelId, $this->settings['pages']) : $this->doc->getTitleData($this->settings['pages']);
194
            $data['_id'] = $this->doc->toplevelId;
195
            array_unshift($metadata, $data);
196
        }
197
        if (empty($metadata)) {
198
            $this->logger->warning('No metadata found for document with UID ' . $this->doc->uid);
1 ignored issue
show
Bug introduced by
The method warning() does not exist on TYPO3\CMS\Core\Log\LogManager. ( Ignorable by Annotation )

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

198
            $this->logger->/** @scrutinizer ignore-call */ 
199
                           warning('No metadata found for document with UID ' . $this->doc->uid);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
199
            return '';
200
        }
201
        ksort($metadata);
202
        // Get hook objects.
203
        $this->hookObjects = Helper::getHookObjects($this->scriptRelPath);
0 ignored issues
show
Bug Best Practice introduced by
The property hookObjects does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
204
        // Hook for getting a customized title bar (requested by SBB).
205
        foreach ($this->hookObjects as $hookObj) {
206
            if (method_exists($hookObj, 'main_customizeTitleBarGetCustomTemplate')) {
207
                $hookObj->main_customizeTitleBarGetCustomTemplate($this, $metadata);
208
            }
209
        }
210
        $this->printMetadata($metadata, $useOriginalIiifManifestMetadata);
211
    }
212
213
    /**
214
     * Prepares the metadata array for output
215
     *
216
     * @access protected
217
     *
218
     * @param array $metadataArray: The metadata array
219
     * @param bool $useOriginalIiifManifestMetadata: Output IIIF metadata as simple key/value pairs?
220
     *
221
     * @return string The metadata array ready for output
222
     */
223
    protected function printMetadata(array $metadataArray, $useOriginalIiifManifestMetadata = false)
224
    {
225
        // Save original data array.
226
        $cObjData = $this->cObj->data;
227
        // Get list of metadata to show.
228
        $metaList = [];
229
        if ($useOriginalIiifManifestMetadata) {
230
            if ($this->settings['iiifMetadataWrap']) {
231
                $iiifwrap = $this->parseTS($this->settings['iiifMetadataWrap']);
232
            } else {
233
                $iiifwrap['key.']['wrap'] = '<dt>|</dt>';
234
                $iiifwrap['value.']['required'] = 1;
235
                $iiifwrap['value.']['wrap'] = '<dd>|</dd>';
236
            }
237
            $iiifLink = [];
238
            $iiifLink['key.']['wrap'] = '<dt>|</dt>';
239
            $iiifLink['value.']['required'] = 1;
240
            $iiifLink['value.']['setContentToCurrent'] = 1;
241
            $iiifLink['value.']['typolink.']['parameter.']['current'] = 1;
242
            $iiifLink['value.']['typolink.']['forceAbsoluteUrl'] = !empty($this->settings['forceAbsoluteUrl']) ? 1 : 0;
243
            $iiifLink['value.']['typolink.']['forceAbsoluteUrl.']['scheme'] = !empty($this->settings['forceAbsoluteUrl']) && !empty($this->settings['forceAbsoluteUrlHttps']) ? 'https' : 'http';
244
            $iiifLink['value.']['wrap'] = '<dd>|</dd>';
245
            foreach ($metadataArray as $metadata) {
246
                foreach ($metadata as $key => $group) {
247
                    $markerArray['METADATA'] = '<span class="tx-dlf-metadata-group">' . $this->pi_getLL($key) . '</span>';
248
                    // Reset content object's data array.
249
                    $this->cObj->data = $cObjData;
250
                    if (!is_array($group)) {
251
                        if ($key == '_id') {
252
                            continue;
253
                        }
254
                        $this->cObj->data[$key] = $group;
255
                        if (
256
                            IRI::isAbsoluteIri($this->cObj->data[$key])
257
                            && (($scheme = (new IRI($this->cObj->data[$key]))->getScheme()) == 'http' || $scheme == 'https')
258
                        ) {
259
                            $field = $this->cObj->stdWrap('', $iiifLink['key.']);
260
                            $field .= $this->cObj->stdWrap($this->cObj->data[$key], $iiifLink['value.']);
261
                        } else {
262
                            $field = $this->cObj->stdWrap('', $iiifwrap['key.']);
263
                            $field .= $this->cObj->stdWrap($this->cObj->data[$key], $iiifwrap['value.']);
264
                        }
265
                        $markerArray['METADATA'] .= $this->cObj->stdWrap($field, $iiifwrap['all.']);
266
                    } else {
267
                        // Load all the metadata values into the content object's data array.
268
                        foreach ($group as $label => $value) {
269
                            if ($label == '_id') {
270
                                continue;
271
                            }
272
                            if (is_array($value)) {
273
                                $this->cObj->data[$label] = implode($this->settings['separator'], $value);
274
                            } else {
275
                                $this->cObj->data[$label] = $value;
276
                            }
277
                            if (IRI::isAbsoluteIri($this->cObj->data[$label]) && (($scheme = (new IRI($this->cObj->data[$label]))->getScheme()) == 'http' || $scheme == 'https')) {
278
                                $nolabel = $this->cObj->data[$label] == $label;
279
                                $field = $this->cObj->stdWrap($nolabel ? '' : htmlspecialchars($label), $iiifLink['key.']);
280
                                $field .= $this->cObj->stdWrap($this->cObj->data[$label], $iiifLink['value.']);
281
                            } else {
282
                                $field = $this->cObj->stdWrap(htmlspecialchars($label), $iiifwrap['key.']);
283
                                $field .= $this->cObj->stdWrap($this->cObj->data[$label], $iiifwrap['value.']);
284
                            }
285
                            $markerArray['METADATA'] .= $this->cObj->stdWrap($field, $iiifwrap['all.']);
286
                        }
287
                    }
288
                }
289
            }
290
        } else {
291
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
292
                ->getQueryBuilderForTable('tx_dlf_metadata');
293
            $result = $queryBuilder
294
                ->select(
295
                    'tx_dlf_metadata.index_name AS index_name',
296
                    'tx_dlf_metadata.is_listed AS is_listed',
297
                    'tx_dlf_metadata.wrap AS wrap',
298
                    'tx_dlf_metadata.sys_language_uid AS sys_language_uid'
299
                )
300
                ->from('tx_dlf_metadata')
301
                ->where(
302
                    $queryBuilder->expr()->andX(
303
                        $queryBuilder->expr()->orX(
304
                            $queryBuilder->expr()->in('tx_dlf_metadata.sys_language_uid', [-1, 0]),
305
                            $queryBuilder->expr()->eq('tx_dlf_metadata.sys_language_uid', $GLOBALS['TSFE']->sys_language_uid)
306
                        ),
307
                        $queryBuilder->expr()->eq('tx_dlf_metadata.l18n_parent', 0)
308
                    ),
309
                    $queryBuilder->expr()->eq('tx_dlf_metadata.pid', intval($this->settings['pages']))
310
                )
311
                ->orderBy('tx_dlf_metadata.sorting')
312
                ->execute();
313
            while ($resArray = $result->fetch()) {
314
                if (is_array($resArray) && $resArray['sys_language_uid'] != $GLOBALS['TSFE']->sys_language_content && $GLOBALS['TSFE']->sys_language_contentOL) {
315
                    $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_dlf_metadata', $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
316
                }
317
                if ($resArray) {
318
                    if ($this->settings['showFull'] || $resArray['is_listed']) {
319
                        $metaList[$resArray['index_name']] = [
320
                            'wrap' => $resArray['wrap'],
321
                            'label' => Helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->settings['pages'])
322
                        ];
323
                    }
324
                }
325
            }
326
            // Get list of collections to show.
327
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
328
                ->getQueryBuilderForTable('tx_dlf_collections');
329
            $collList = [];
330
            $result = $queryBuilder
331
                ->select('tx_dlf_collections.index_name AS index_name')
332
                ->from('tx_dlf_collections')
333
                ->where(
334
                    $queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages']))
335
                )
336
                ->execute();
337
            while ($resArray = $result->fetch()) {
338
                $collList[] = $resArray['index_name'];
339
            }
340
            // Parse the metadata arrays.
341
            foreach ($metadataArray as $metadata) {
342
                $markerArray['METADATA'] = '';
343
                // Reset content object's data array.
344
                $this->cObj->data = $cObjData;
345
                // Load all the metadata values into the content object's data array.
346
                foreach ($metadata as $index_name => $value) {
347
                    if (is_array($value)) {
348
                        $this->cObj->data[$index_name] = implode($this->settings['separator'], $value);
349
                    } else {
350
                        $this->cObj->data[$index_name] = $value;
351
                    }
352
                }
353
                // Process each metadate.
354
                foreach ($metaList as $index_name => $metaConf) {
355
                    $parsedValue = '';
356
                    $fieldwrap = $this->parseTS($metaConf['wrap']);
357
                    do {
358
                        $value = @array_shift($metadata[$index_name]);
359
                        if ($index_name == 'title') {
360
                            // Get title of parent document if needed.
361
                            if (empty($value) && $this->settings['getTitle'] && $this->doc->parentId) {
362
                                $superiorTitle = Document::getTitle($this->doc->parentId, true);
363
                                if (!empty($superiorTitle)) {
364
                                    $value = '[' . $superiorTitle . ']';
365
                                }
366
                            }
367
                            if (!empty($value)) {
368
                                $value = htmlspecialchars($value);
369
                                // Link title to pageview.
370
                                if ($this->settings['linkTitle'] && $metadata['_id']) {
371
                                    $details = $this->doc->getLogicalStructure($metadata['_id']);
372
                                    $uri = $this->uriBuilder->reset()
373
                                        ->setArguments([
374
                                            $this->prefixId => [
375
                                                'id' => $this->doc->uid,
376
                                                'page' => (!empty($details['points']) ? intval($details['points']) : 1)
377
                                            ]
378
                                        ])
379
                                        ->setTargetPageUid($this->settings['targetPid'])
380
                                        ->build();
381
                                    $value = '<a href="' . $uri . '">' . $value . '</a>';
382
                                }
383
                            }
384
                        } elseif ($index_name == 'owner' && !empty($value)) {
385
                            // Translate name of holding library.
386
                            $value = htmlspecialchars(Helper::translate($value, 'tx_dlf_libraries', $this->settings['pages']));
387
                        } elseif ($index_name == 'type' && !empty($value)) {
388
                            // Translate document type.
389
                            $value = htmlspecialchars(Helper::translate($value, 'tx_dlf_structures', $this->settings['pages']));
390
                        } elseif ($index_name == 'collection' && !empty($value)) {
391
                            // Check if collections isn't hidden.
392
                            if (in_array($value, $collList)) {
393
                                // Translate collection.
394
                                $value = htmlspecialchars(Helper::translate($value, 'tx_dlf_collections', $this->settings['pages']));
395
                            } else {
396
                                $value = '';
397
                            }
398
                        } elseif ($index_name == 'language' && !empty($value)) {
399
                            // Translate ISO 639 language code.
400
                            $value = htmlspecialchars(Helper::getLanguageName($value));
401
                        } elseif (!empty($value)) {
402
                            // Sanitize value for output.
403
                            $value = htmlspecialchars($value);
404
                        }
405
                        // Hook for getting a customized value (requested by SBB).
406
                        foreach ($this->hookObjects as $hookObj) {
407
                            if (method_exists($hookObj, 'printMetadata_customizeMetadata')) {
408
                                $hookObj->printMetadata_customizeMetadata($value);
409
                            }
410
                        }
411
                        // $value might be empty for aggregation metadata fields including other "hidden" fields.
412
                        $value = $this->cObj->stdWrap($value, $fieldwrap['value.']);
413
                        if (!empty($value)) {
414
                            $parsedValue .= $value;
415
                        }
416
                    } while (is_array($metadata[$index_name]) && count($metadata[$index_name]) > 0);
417
418
                    if (!empty($parsedValue)) {
419
                        $field = $this->cObj->stdWrap(htmlspecialchars($metaConf['label']), $fieldwrap['key.']);
420
                        $field .= $parsedValue;
421
                        $markerArray['METADATA'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']);
422
                    }
423
                }
424
            }
425
        }
426
        $this->view->assign('metadata', $markerArray['METADATA']);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $markerArray does not seem to be defined for all execution paths leading up to this point.
Loading history...
427
    }
428
429
    // TODO: Needs to be placed in an abstract class (like before in AbstractPlugin)
430
    /**
431
     * Parses a string into a Typoscript array
432
     *
433
     * @access protected
434
     *
435
     * @param string $string: The string to parse
436
     *
437
     * @return array The resulting typoscript array
438
     */
439
    protected function parseTS($string = '')
440
    {
441
        $parser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
442
        $parser->parse($string);
443
        return $parser->setup;
444
    }
445
446
    protected function pi_getLL($label)
447
    {
448
        return $GLOBALS['TSFE']->sL('LLL:EXT:dlf/Resources/Private/Language/Metadata.xml:' . $label);
449
    }
450
451
}