Browse Source

Switch to short array notation

pull/329/head
Sebastian Meyer 4 years ago
parent
commit
f16b78e3ef
  1. 16
      Classes/Cli/CommandLineIndexer.php
  2. 2
      Classes/Common/AbstractPlugin.php
  3. 126
      Classes/Common/Document.php
  4. 62
      Classes/Common/DocumentList.php
  5. 2
      Classes/Common/DocumentTypeCheck.php
  6. 26
      Classes/Common/Helper.php
  7. 22
      Classes/Common/Indexer.php
  8. 46
      Classes/Common/Solr.php
  9. 2
      Classes/Formats/Mods.php
  10. 72
      Classes/Hooks/ConfigurationForm.php
  11. 14
      Classes/Hooks/DataHandler.php
  12. 2
      Classes/Hooks/FormEngine.php
  13. 8
      Classes/Plugins/AudioPlayer.php
  14. 32
      Classes/Plugins/Basket.php
  15. 54
      Classes/Plugins/Calendar.php
  16. 46
      Classes/Plugins/Collection.php
  17. 2
      Classes/Plugins/Eid/PageViewProxy.php
  18. 2
      Classes/Plugins/Eid/SearchSuggest.php
  19. 6
      Classes/Plugins/Feeds.php
  20. 52
      Classes/Plugins/ListView.php
  21. 16
      Classes/Plugins/Metadata.php
  22. 32
      Classes/Plugins/Navigation.php
  23. 60
      Classes/Plugins/OaiPmh.php
  24. 10
      Classes/Plugins/PageGrid.php
  25. 36
      Classes/Plugins/PageView.php
  26. 70
      Classes/Plugins/Search.php
  27. 12
      Classes/Plugins/Statistics.php
  28. 30
      Classes/Plugins/TableOfContents.php
  29. 6
      Classes/Plugins/Toolbox.php
  30. 6
      Classes/Plugins/Tools/ImageDownloadTool.php
  31. 8
      Classes/Plugins/Tools/PdfDownloadTool.php
  32. 32
      Configuration/TCA/Overrides/tt_content.php
  33. 72
      Configuration/TCA/tx_dlf_actionlog.php
  34. 64
      Configuration/TCA/tx_dlf_basket.php
  35. 236
      Configuration/TCA/tx_dlf_collections.php
  36. 276
      Configuration/TCA/tx_dlf_documents.php
  37. 64
      Configuration/TCA/tx_dlf_formats.php
  38. 164
      Configuration/TCA/tx_dlf_libraries.php
  39. 56
      Configuration/TCA/tx_dlf_mail.php
  40. 208
      Configuration/TCA/tx_dlf_metadata.php
  41. 72
      Configuration/TCA/tx_dlf_metadataformat.php
  42. 48
      Configuration/TCA/tx_dlf_printer.php
  43. 48
      Configuration/TCA/tx_dlf_solrcores.php
  44. 142
      Configuration/TCA/tx_dlf_structures.php
  45. 4
      ext_localconf.php

16
Classes/Cli/CommandLineIndexer.php

@ -47,11 +47,11 @@ class CommandLineIndexer extends \TYPO3\CMS\Core\Controller\CommandLineControlle
case 'index':
// Add command line arguments.
$this->cli_options[] = array ('-doc UID/URL', 'UID or (properly encoded) URL of the document.');
$this->cli_options[] = ['-doc UID/URL', 'UID or (properly encoded) URL of the document.'];
$this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.');
$this->cli_options[] = ['-pid UID', 'UID of the page the document should be added to.'];
$this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.');
$this->cli_options[] = ['-core UID', 'UID of the Solr core the document should be added to.'];
// Check the command line arguments.
$this->cli_validateArgs();
@ -115,11 +115,11 @@ class CommandLineIndexer extends \TYPO3\CMS\Core\Controller\CommandLineControlle
case 'reindex':
// Add command line arguments.
$this->cli_options[] = array ('-coll UID', 'UID of the collection.');
$this->cli_options[] = ['-coll UID', 'UID of the collection.'];
$this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.');
$this->cli_options[] = ['-pid UID', 'UID of the page the document should be added to.'];
$this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.');
$this->cli_options[] = ['-core UID', 'UID of the Solr core the document should be added to.'];
// Check the command line arguments.
$this->cli_validateArgs();
@ -215,14 +215,14 @@ class CommandLineIndexer extends \TYPO3\CMS\Core\Controller\CommandLineControlle
parent::__construct();
// Set basic information about the script.
$this->cli_help = array (
$this->cli_help = [
'name' => 'Command Line Interface for Kitodo.Presentation',
'synopsis' => '###OPTIONS###',
'description' => 'Currently the only tasks available are "index" and "reindex".'.LF.'Try "/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK" for more options.',
'examples' => '/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK -ARG1=VALUE1 -ARG2=VALUE2',
'options' => '',
'author' => 'Kitodo. Key to digital objects e.V. <contact@kitodo.org>',
);
];
}

2
Classes/Common/AbstractPlugin.php

@ -81,7 +81,7 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
protected function init(array $conf) {
// Read FlexForm configuration.
$flexFormConf = array ();
$flexFormConf = [];
$this->cObj->readFlexformIntoConf($this->cObj->data['pi_flexform'], $flexFormConf);

126
Classes/Common/Document.php

@ -45,7 +45,7 @@ final class Document {
* @var array
* @access protected
*/
protected $dmdSec = array ();
protected $dmdSec = [];
/**
* Are the METS file's dmdSecs loaded?
@ -71,7 +71,7 @@ final class Document {
* @var array
* @access protected
*/
protected $fileGrps = array ();
protected $fileGrps = [];
/**
* Are the file groups loaded?
@ -89,20 +89,20 @@ final class Document {
* @var array
* @access protected
*/
protected $formats = array (
'OAI' => array (
protected $formats = [
'OAI' => [
'rootElement' => 'OAI-PMH',
'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/',
),
'METS' => array (
],
'METS' => [
'rootElement' => 'mets',
'namespaceURI' => 'http://www.loc.gov/METS/',
),
'XLINK' => array (
],
'XLINK' => [
'rootElement' => 'xlink',
'namespaceURI' => 'http://www.w3.org/1999/xlink',
)
);
]
];
/**
* Are the available metadata formats loaded?
@ -127,7 +127,7 @@ final class Document {
* @var array
* @access protected
*/
protected $lastSearchedPhysicalPage = array ('logicalPage' => NULL, 'physicalPage' => NULL);
protected $lastSearchedPhysicalPage = ['logicalPage' => NULL, 'physicalPage' => NULL];
/**
* This holds the documents location
@ -143,7 +143,7 @@ final class Document {
* @var array
* @access protected
*/
protected $logicalUnits = array ();
protected $logicalUnits = [];
/**
* This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key
@ -151,7 +151,7 @@ final class Document {
* @var array
* @access protected
*/
protected $metadataArray = array ();
protected $metadataArray = [];
/**
* Is the metadata array loaded?
@ -192,7 +192,7 @@ final class Document {
* @var array
* @access protected
*/
protected $physicalStructure = array ();
protected $physicalStructure = [];
/**
* This holds the physical structure metadata
@ -200,7 +200,7 @@ final class Document {
* @var array
* @access protected
*/
protected $physicalStructureInfo = array ();
protected $physicalStructureInfo = [];
/**
* Is the physical structure loaded?
@ -225,7 +225,7 @@ final class Document {
* @var array
* @access protected
*/
protected $rawTextArray = array ();
protected $rawTextArray = [];
/**
* Is the document instantiated successfully?
@ -249,7 +249,7 @@ final class Document {
* @var array (\Kitodo\Dlf\Common\Document)
* @access protected
*/
protected static $registry = array ();
protected static $registry = [];
/**
* This holds the UID of the root document or zero if not multi-volumed
@ -274,7 +274,7 @@ final class Document {
* @var array
* @access protected
*/
protected $smLinks = array ('l2p' => array (), 'p2l' => array ());
protected $smLinks = ['l2p' => [], 'p2l' => []];
/**
* Are the smLinks loaded?
@ -291,7 +291,7 @@ final class Document {
* @var array
* @access protected
*/
protected $tableOfContents = array ();
protected $tableOfContents = [];
/**
* Is the table of contents loaded?
@ -353,7 +353,7 @@ final class Document {
public static function clearRegistry() {
// Reset registry array.
self::$registry = array ();
self::$registry = [];
}
@ -511,7 +511,7 @@ final class Document {
*/
public function getLogicalStructure($id, $recursive = FALSE) {
$details = array ();
$details = [];
// Is the requested logical unit already loaded?
if (!$recursive && !empty($this->logicalUnits[$id])) {
@ -578,7 +578,7 @@ final class Document {
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
// Extract identity information.
$details = array ();
$details = [];
$details['id'] = $attributes['ID'];
@ -655,7 +655,7 @@ final class Document {
}
// Get the files this structure element is pointing at.
$details['files'] = array ();
$details['files'] = [];
$fileUse = $this->_getFileGrps();
@ -677,7 +677,7 @@ final class Document {
// Walk the structure recursively? And are there any children of the current element?
if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) {
$details['children'] = array ();
$details['children'] = [];
foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) {
@ -725,7 +725,7 @@ final class Document {
}
return array ();
return [];
}
@ -737,24 +737,24 @@ final class Document {
}
// Initialize metadata array with empty values.
$metadata = array (
'title' => array (),
'title_sorting' => array (),
'author' => array (),
'place' => array (),
'year' => array (),
'prod_id' => array (),
'record_id' => array (),
'opac_id' => array (),
'union_id' => array (),
'urn' => array (),
'purl' => array (),
'type' => array (),
'volume' => array (),
'volume_sorting' => array (),
'collection' => array (),
'owner' => array (),
);
$metadata = [
'title' => [],
'title_sorting' => [],
'author' => [],
'place' => [],
'year' => [],
'prod_id' => [],
'record_id' => [],
'opac_id' => [],
'union_id' => [],
'urn' => [],
'purl' => [],
'type' => [],
'volume' => [],
'volume_sorting' => [],
'collection' => [],
'owner' => [],
];
// Get the logical structure node's DMDID.
if (!empty($this->logicalUnits[$id])) {
@ -808,20 +808,20 @@ final class Document {
}
return array ();
return [];
}
// Get the structure's type.
if (!empty($this->logicalUnits[$id])) {
$metadata['type'] = array ($this->logicalUnits[$id]['type']);
$metadata['type'] = [$this->logicalUnits[$id]['type']];
} else {
$struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE');
$metadata['type'] = array ((string) $struct[0]);
$metadata['type'] = [(string) $struct[0]];
}
@ -850,7 +850,7 @@ final class Document {
if ($values instanceof \DOMNodeList && $values->length > 0) {
$metadata[$resArray['index_name']] = array ();
$metadata[$resArray['index_name']] = [];
foreach ($values as $value) {
@ -860,7 +860,7 @@ final class Document {
} elseif (!($values instanceof \DOMNodeList)) {
$metadata[$resArray['index_name']] = array (trim((string) $values));
$metadata[$resArray['index_name']] = [trim((string) $values)];
}
@ -872,7 +872,7 @@ final class Document {
// These empty fields are then shown within the search facets as 'empty'.
if (empty($metadata[$resArray['index_name']][0]) && strlen($resArray['default_value']) > 0) {
$metadata[$resArray['index_name']] = array ($resArray['default_value']);
$metadata[$resArray['index_name']] = [$resArray['default_value']];
}
@ -941,7 +941,7 @@ final class Document {
} else {
// There is no dmdSec for this structure node.
return array ();
return [];
}
@ -1322,11 +1322,11 @@ final class Document {
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
// Update format registry.
$this->formats[$resArray['type']] = array (
$this->formats[$resArray['type']] = [
'rootElement' => $resArray['root'],
'namespaceURI' => $resArray['namespace'],
'class' => $resArray['class']
);
];
}
@ -1512,7 +1512,7 @@ final class Document {
$metadata['type'][0] = $structure;
// Get UIDs for collections.
$collections = array ();
$collections = [];
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid',
@ -1541,7 +1541,7 @@ final class Document {
// Insert new collection.
$collNewUid = uniqid('NEW');
$collData['tx_dlf_collections'][$collNewUid] = array (
$collData['tx_dlf_collections'][$collNewUid] = [
'pid' => $pid,
'label' => $collection,
'index_name' => $collection,
@ -1550,7 +1550,7 @@ final class Document {
'documents' => 0,
'owner' => 0,
'status' => 0,
);
];
$substUid = Helper::processDB($collData);
@ -1601,7 +1601,7 @@ final class Document {
// Insert new library.
$libNewUid = uniqid('NEW');
$libData['tx_dlf_libraries'][$libNewUid] = array (
$libData['tx_dlf_libraries'][$libNewUid] = [
'pid' => $pid,
'label' => $owner,
'index_name' => $owner,
@ -1614,7 +1614,7 @@ final class Document {
'opac_base' => '',
'union_label' => '',
'union_base' => '',
);
];
$substUid = Helper::processDB($libData);
@ -1705,9 +1705,9 @@ final class Document {
}
// Get metadata for lists and sorting.
$listed = array ();
$listed = [];
$sortable = array ();
$sortable = [];
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable',
@ -1739,7 +1739,7 @@ final class Document {
}
// Fill data array.
$data['tx_dlf_documents'][$this->uid] = array (
$data['tx_dlf_documents'][$this->uid] = [
'pid' => $pid,
$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0,
$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0,
@ -1766,7 +1766,7 @@ final class Document {
'owner' => $metadata['owner'][0],
'solrcore' => $core,
'status' => 0,
);
];
// Unhide hidden documents.
if (!empty($conf['unhideOnIndex'])) {
@ -2022,7 +2022,7 @@ final class Document {
}
return array ();
return [];
}
@ -2746,7 +2746,7 @@ final class Document {
// \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization
$this->asXML = $this->xml->asXML();
return array ('uid', 'pid', 'recordId', 'parentId', 'asXML');
return ['uid', 'pid', 'recordId', 'parentId', 'asXML'];
}

62
Classes/Common/DocumentList.php

@ -38,7 +38,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
* @var array
* @access protected
*/
protected $elements = array ();
protected $elements = [];
/**
* This holds the list's metadata
@ -46,7 +46,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
* @var array
* @access protected
*/
protected $metadata = array ();
protected $metadata = [];
/**
* This holds the current list position
@ -63,7 +63,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
* @var array
* @access protected
*/
protected $records = array ();
protected $records = [];
/**
* Instance of \Kitodo\Dlf\Common\Solr class
@ -79,7 +79,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
* @var array
* @access protected
*/
protected $solrConfig = array ();
protected $solrConfig = [];
/**
* This adds an array of elements at the given position to the list
@ -158,7 +158,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*/
protected function getRecord($element) {
if (is_array($element) && array_keys($element) == array ('u', 'h', 's', 'p')) {
if (is_array($element) && array_keys($element) == ['u', 'h', 's', 'p']) {
// Return already processed record if possible.
if (!empty($this->records[$element['u']])) {
@ -167,12 +167,12 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
}
$record = array (
$record = [
'uid' => $element['u'],
'page' => 1,
'preview' => '',
'subparts' => $element['p']
);
];
// Check if it's a list of database records or Solr documents.
if (!empty($this->metadata['options']['source']) && $this->metadata['options']['source'] == 'collection') {
@ -226,15 +226,15 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
$record['metadata'] = $metadata;
} elseif (($key = array_search(array ('u' => $resArray['uid']), $record['subparts'], TRUE)) !== FALSE) {
} elseif (($key = array_search(['u' => $resArray['uid']], $record['subparts'], TRUE)) !== FALSE) {
$record['subparts'][$key] = array (
$record['subparts'][$key] = [
'uid' => $resArray['uid'],
'page' => 1,
'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''),
'thumbnail' => $resArray['thumbnail'],
'metadata' => $metadata
);
];
}
@ -244,7 +244,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
if ($this->solrConnect()) {
$params = array ();
$params = [];
// Restrict the fields to the required ones
$params['fields'] = 'uid,id,toplevel,thumbnail,page';
@ -258,13 +258,13 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
// If it is a fulltext search, enable highlighting.
if ($this->metadata['fulltextSearch']) {
$params['component'] = array (
'highlighting' => array (
$params['component'] = [
'highlighting' => [
'query' => Solr::escapeQuery($this->metadata['searchString']),
'field' => 'fulltext',
'usefastvectorhighlighter' => TRUE
)
);
]
];
}
@ -276,7 +276,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
$params['rows'] = 10000;
// Take over existing filter queries.
$params['filterquery'] = isset($this->metadata['options']['params']['filterquery']) ? $this->metadata['options']['params']['filterquery'] : array ();
$params['filterquery'] = isset($this->metadata['options']['params']['filterquery']) ? $this->metadata['options']['params']['filterquery'] : [];
// Extend filter query to get all documents with the same uid.
foreach ($params['filterquery'] as $key => $value) {
@ -290,7 +290,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
}
// Add filter query to get all documents with the required uid.
$params['filterquery'][] = array ('query' => 'uid:'.Solr::escapeQuery($record['uid']));
$params['filterquery'][] = ['query' => 'uid:'.Solr::escapeQuery($record['uid'])];
// Add sorting
$params['sort'] = $this->metadata['options']['params']['sort'];
@ -313,13 +313,13 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
foreach ($result as $resArray) {
// Prepare document's metadata.
$metadata = array ();
$metadata = [];
foreach ($this->solrConfig as $index_name => $solr_name) {
if (!empty($resArray->$solr_name)) {
$metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : array ($resArray->$solr_name));
$metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : [$resArray->$solr_name]);
}
@ -337,13 +337,13 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
$highlightedDoc = !empty($highlighting) ? $highlighting->getResult($resArray->id) : NULL;
$highlight = !empty($highlightedDoc) ? $highlightedDoc->getField('fulltext')[0] : '';
$record['subparts'][$resArray->id] = array (
$record['subparts'][$resArray->id] = [
'uid' => $resArray->uid,
'page' => $resArray->page,
'preview' => $highlight,
'thumbnail' => $resArray->thumbnail,
'metadata' => $metadata
);
];
}
@ -437,7 +437,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
$element = $this->remove($position);
$this->add(array ($element), $position + $steps);
$this->add([$element], $position + $steps);
}
@ -641,11 +641,11 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*/
public function reset() {
$this->elements = array ();
$this->elements = [];
$this->records = array ();
$this->records = [];
$this->metadata = array ();
$this->metadata = [];
$this->count = 0;
@ -687,7 +687,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
} else {
Helper::saveToSession(array ($this->elements, $this->metadata), get_class($this));
Helper::saveToSession([$this->elements, $this->metadata], get_class($this));
}
@ -751,9 +751,9 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*/
public function sort($by, $asc = TRUE) {
$newOrder = array ();
$newOrder = [];
$nonSortable = array ();
$nonSortable = [];
foreach ($this->elements as $num => $element) {
@ -858,7 +858,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*
* @return void
*/
protected function _setMetadata(array $metadata = array ()) {
protected function _setMetadata(array $metadata = []) {
$this->metadata = $metadata;
@ -874,7 +874,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*
* @return void
*/
public function __construct(array $elements = array (), array $metadata = array ()) {
public function __construct(array $elements = [], array $metadata = []) {
if (empty($elements) && empty($metadata)) {
@ -993,7 +993,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*/
public function __sleep() {
return array ('elements', 'metadata');
return ['elements', 'metadata'];
}

2
Classes/Common/DocumentTypeCheck.php

@ -45,7 +45,7 @@ class DocumentTypeCheck {
* @var array
* @access protected
*/
protected $piVars = array ();
protected $piVars = [];
/**
* This holds the DLF parameter prefix

26
Classes/Common/Helper.php

@ -36,7 +36,7 @@ class Helper {
* @var array
* @access protected
*/
protected static $messages = array ();
protected static $messages = [];
/**
* Adds a message to the message queue.
@ -321,7 +321,7 @@ class Helper {
$hash = $salt.substr(sha1($salt.$string), -10);
return array ('encrypted' => $encrypted, 'hash' => $hash);
return ['encrypted' => $encrypted, 'hash' => $hash];
}
@ -437,7 +437,7 @@ class Helper {
*/
public static function getHookObjects($scriptRelPath) {
$hookObjects = array ();
$hookObjects = [];
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) {
@ -474,7 +474,7 @@ class Helper {
// Sanitize input.
$uid = max(intval($uid), 0);
if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) {
if (!$uid || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'])) {
if (TYPO3_DLOG) {
@ -545,7 +545,7 @@ class Helper {
$_pid = $pid;
if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) {
if (!$index_name || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'])) {
if (TYPO3_DLOG) {
@ -756,7 +756,7 @@ class Helper {
*/
public static function getURN($base, $id) {
$concordance = array (
$concordance = [
'0' => 1,
'1' => 2,
'2' => 3,
@ -795,7 +795,7 @@ class Helper {
'z' => 38,
'-' => 39,
':' => 17,
);
];
$urn = strtolower($base.$id);
@ -912,7 +912,7 @@ class Helper {
*
* @return array Array of substituted "NEW..." identifiers and their actual UIDs.
*/
public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) {
public static function processDB(array $data = [], array $cmd = [], $reverseOrder = FALSE, $be_user = FALSE) {
// Instantiate TYPO3 core engine.
$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
@ -970,7 +970,7 @@ class Helper {
*
* @return array Array of substituted "NEW..." identifiers and their actual UIDs.
*/
public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) {
public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = FALSE) {
if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) {
@ -980,11 +980,11 @@ class Helper {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd));
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, ['data' => $data, 'cmd' => $cmd]);
}
return array ();
return [];
}
@ -1123,7 +1123,7 @@ class Helper {
$_pid = $pid;
// Load labels into static variable for future use.
static $labels = array ();
static $labels = [];
// Sanitize input.
$pid = max(intval($pid), 0);
@ -1190,7 +1190,7 @@ class Helper {
if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) {
// Check if this table is allowed for translation.
if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) {
if (in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'])) {
$additionalWhere = ' AND sys_language_uid IN (-1,0)';

22
Classes/Common/Indexer.php

@ -36,15 +36,15 @@ class Indexer {
* @var array
* @access protected
*/
protected static $fields = array (
'autocomplete' => array (),
'facets' => array (),
'sortables' => array (),
'indexed' => array (),
'stored' => array (),
'tokenized' => array (),
'fieldboost' => array ()
);
protected static $fields = [
'autocomplete' => [],
'facets' => [],
'sortables' => [],
'indexed' => [],
'stored' => [],
'tokenized' => [],
'fieldboost' => []
];
/**
* Is the index configuration loaded?
@ -61,7 +61,7 @@ class Indexer {
* @var array
* @access protected
*/
protected static $processedDocs = array ();
protected static $processedDocs = [];
/**
* Instance of \Kitodo\Dlf\Common\Solr class
@ -579,7 +579,7 @@ class Indexer {
$solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']);
$autocomplete = array ();
$autocomplete = [];
foreach ($metadata as $index_name => $data) {

46
Classes/Common/Solr.php

@ -68,7 +68,7 @@ class Solr {
* @var array
* @access protected
*/
protected $params = array ();
protected $params = [];
/**
* Is the search instantiated successfully?
@ -84,7 +84,7 @@ class Solr {
* @var array (\Kitodo\Dlf\Common\Solr)
* @access protected
*/
protected static $registry = array ();
protected static $registry = [];
/**
* This holds the Solr service object
@ -136,7 +136,7 @@ class Solr {
if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(?.*\)?$/', $query)) {
// Get all indexed fields.
$fields = array ();
$fields = [];
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_metadata.index_name,tx_dlf_metadata.index_tokenized,tx_dlf_metadata.index_stored',
@ -257,7 +257,7 @@ class Solr {
*/
public static function getSolrConnectionInfo() {
$solrInfo = array ();
$solrInfo = [];
// Extract extension configuration.
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
@ -349,12 +349,12 @@ class Solr {
*/
public function search() {
$toplevel = array ();
$toplevel = [];
// Take over query parameters.
$params = $this->params;
$params['filterquery'] = isset($params['filterquery']) ? $params['filterquery'] : array ();
$params['filterquery'] = isset($params['filterquery']) ? $params['filterquery'] : [];
// Set some query parameters.
$params['start'] = 0;
@ -369,7 +369,7 @@ class Solr {
// Restore query parameters
$params = $this->params;
$params['filterquery'] = isset($params['filterquery']) ? $params['filterquery'] : array ();
$params['filterquery'] = isset($params['filterquery']) ? $params['filterquery'] : [];
// Restrict the fields to the required ones.
$params['fields'] = 'uid,id';
@ -386,7 +386,7 @@ class Solr {
}
// Set filter query to just get toplevel documents.
$params['filterquery'][] = array ('query' => 'toplevel:true');
$params['filterquery'][] = ['query' => 'toplevel:true'];
// Set join query to get all documents with the same uids.
$params['query'] = '{!join from=uid to=uid}'.$params['query'];
@ -400,12 +400,12 @@ class Solr {
// Process results.
foreach ($results as $doc) {
$toplevel[$doc->id] = array (
$toplevel[$doc->id] = [
'u' => $doc->uid,
'h' => '',
's' => '',
'p' => array ()
);
'p' => []
];
}
@ -417,10 +417,10 @@ class Solr {
$list->add(array_values($toplevel));
// Set metadata for search.
$list->metadata = array (
$list->metadata = [
'label' => '',
'description' => '',
'options' => array (
'options' => [
'source' => 'search',
'engine' => 'solr',
'select' => $this->params['query'],
@ -432,8 +432,8 @@ class Solr {
'order.asc' => TRUE,
'numberOfHits' => $this->numberOfHits,
'numberOfToplevelHits' => $numberOfToplevelHits
)
);
]
];
return $list;
@ -449,7 +449,7 @@ class Solr {
*
* @return array The Apache Solr Documents that were fetched
*/
public function search_raw($query = '', $parameters = array ()) {
public function search_raw($query = '', $parameters = []) {
// Set additional query parameters.
$parameters['start'] = 0;
@ -462,7 +462,7 @@ class Solr {
$selectQuery = $this->service->createSelect(array_merge($this->params, $parameters));
$result = $this->service->select($selectQuery);
$resultSet = array ();
$resultSet = [];
foreach ($result as $doc) {
@ -645,9 +645,9 @@ class Solr {
$solrInfo = self::getSolrConnectionInfo();
$config = array (
'endpoint' => array (
'dlf' => array (
$config = [
'endpoint' => [
'dlf' => [
'scheme' => $solrInfo['scheme'],
'host' => $solrInfo['host'],
'port' => $solrInfo['port'],
@ -656,9 +656,9 @@ class Solr {
'username' => $solrInfo['username'],
'password' => $solrInfo['password'],
'timeout' => $solrInfo['timeout']
)
)
);
]
]
];
// Instantiate Solarium\Client class.
$this->service = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Solarium\Client::class, $config);

2
Classes/Formats/Mods.php

@ -59,7 +59,7 @@ class Mods implements \Kitodo\Dlf\Common\MetadataInterface {
} elseif (($nameParts = $authors[$i]->xpath('./mods:namePart'))) {
$name = array ();
$name = [];
$k = 4;

72
Classes/Hooks/ConfigurationForm.php

@ -30,7 +30,7 @@ class ConfigurationForm {
* @var array
* @access protected
*/
protected $conf = array ();
protected $conf = [];
/**
* This holds the output ready to return
@ -68,12 +68,12 @@ class ConfigurationForm {
// Build request URI.
$url = $solrInfo['scheme'].'://'.$host.':'.$solrInfo['port'].'/'.$solrInfo['path'].'/admin/cores?wt=xml';
$context = stream_context_create(array (
'http' => array (
$context = stream_context_create([
'http' => [
'method' => 'GET',
'user_agent' => (!empty($this->conf['useragent']) ? $this->conf['useragent'] : ini_get('user_agent'))
)
));
]
]);
// Try to connect to Solr server.
$response = @simplexml_load_string(file_get_contents($url, FALSE, $context));
@ -152,7 +152,7 @@ class ConfigurationForm {
);
// Check if user is configured properly.
if (count(array_diff(array ($groupUid), $resArray['usergroup'])) == 0
if (count(array_diff([$groupUid], $resArray['usergroup'])) == 0
&& !$resArray['admin']
&& $GLOBALS['TYPO3_DB']->sql_num_rows($result2) > 0) {
@ -171,17 +171,17 @@ class ConfigurationForm {
if (!$checkOnly && $groupUid) {
// Keep exisiting values and add the new ones.
$usergroup = array_unique(array_merge(array ($groupUid), $resArray['usergroup']));
$usergroup = array_unique(array_merge([$groupUid], $resArray['usergroup']));
// Try to configure user.
$data = array ();
$data['be_users'][$resArray['uid']] = array (
$data = [];
$data['be_users'][$resArray['uid']] = [
'admin' => 0,
'usergroup' => implode(',', $usergroup),
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['disabled'] => 0,
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['starttime'] => 0,
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['endtime'] => 0
);
];
Helper::processDBasAdmin($data);
@ -231,14 +231,14 @@ class ConfigurationForm {
// Try to create user.
$tempUid = uniqid('NEW');
$data = array ();
$data['be_users'][$tempUid] = array (
$data = [];
$data['be_users'][$tempUid] = [
'pid' => 0,
'username' => '_cli_dlf',
'password' => md5($tempUid),
'realName' => $GLOBALS['LANG']->getLL('cliUserGroup.usrRealName'),
'usergroup' => intval($groupUid)
);
];
$substUid = Helper::processDBasAdmin($data);
@ -297,7 +297,7 @@ class ConfigurationForm {
*
* @return integer UID of usergroup or 0 if something is wrong
*/
protected function checkCliGroup($checkOnly, $settings = array ()) {
protected function checkCliGroup($checkOnly, $settings = []) {
// Set default return value.
$grpUid = 0;
@ -305,9 +305,9 @@ class ConfigurationForm {
// Set default configuration for usergroup.
if (empty($settings)) {
$settings = array (
'non_exclude_fields' => array (),
'tables_select' => array (
$settings = [
'non_exclude_fields' => [],
'tables_select' => [
'tx_dlf_documents',
'tx_dlf_collections',
'tx_dlf_libraries',
@ -316,13 +316,13 @@ class ConfigurationForm {
'tx_dlf_metadataformat',
'tx_dlf_formats',
'tx_dlf_solrcores'
),
'tables_modify' => array (
],
'tables_modify' => [
'tx_dlf_documents',
'tx_dlf_collections',
'tx_dlf_libraries'
)
);
]
];
// Set allowed exclude fields.
foreach ($settings['tables_modify'] as $table) {
@ -389,13 +389,13 @@ class ConfigurationForm {
$tables_modify = array_unique(array_merge($settings['tables_modify'], $resArray['tables_modify']));
// Try to configure usergroup.
$data = array ();
$data['be_groups'][$resArray['uid']] = array (
$data = [];
$data['be_groups'][$resArray['uid']] = [
'non_exclude_fields' => implode(',', $non_exclude_fields),
'tables_select' => implode(',', $tables_select),
'tables_modify' => implode(',', $tables_modify),
$GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled'] => 0
);
];
Helper::processDBasAdmin($data);
@ -445,15 +445,15 @@ class ConfigurationForm {
// Try to create usergroup.
$tempUid = uniqid('NEW');
$data = array ();
$data['be_groups'][$tempUid] = array (
$data = [];
$data['be_groups'][$tempUid] = [
'pid' => 0,
'title' => '_cli_dlf',
'description' => $GLOBALS['LANG']->getLL('cliUserGroup.grpDescription'),
'non_exclude_fields' => implode(',', $settings['non_exclude_fields']),
'tables_select' => implode(',', $settings['tables_select']),
'tables_modify' => implode(',', $settings['tables_modify'])
);
];
$substUid = Helper::processDBasAdmin($data);
@ -567,11 +567,11 @@ class ConfigurationForm {
*/
public function checkMetadataFormats(&$params, &$pObj) {
$nsDefined = array (
$nsDefined = [
'MODS' => FALSE,
'TEIHDR' => FALSE,
'ALTO' => FALSE
);
];
// Check existing format specifications.
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@ -587,44 +587,44 @@ class ConfigurationForm {
}
// Build data array.
$data = array ();
$data = [];
// Add MODS namespace.
if (!$nsDefined['MODS']) {
$data['tx_dlf_formats'][uniqid('NEW')] = array (
$data['tx_dlf_formats'][uniqid('NEW')] = [
'pid' => 0,
'type' => 'MODS',
'root' => 'mods',
'namespace' => 'http://www.loc.gov/mods/v3',
'class' => 'Kitodo\\Dlf\\Formats\\Mods'
);
];
}
// Add TEIHDR namespace.
if (!$nsDefined['TEIHDR']) {
$data['tx_dlf_formats'][uniqid('NEW')] = array (
$data['tx_dlf_formats'][uniqid('NEW')] = [
'pid' => 0,
'type' => 'TEIHDR',
'root' => 'teiHeader',
'namespace' => 'http://www.tei-c.org/ns/1.0',
'class' => 'Kitodo\\Dlf\\Formats\\TeiHeader'
);
];
}
// Add ALTO namespace.
if (!$nsDefined['ALTO']) {
$data['tx_dlf_formats'][uniqid('NEW')] = array (
$data['tx_dlf_formats'][uniqid('NEW')] = [
'pid' => 0,
'type' => 'ALTO',
'root' => 'alto',
'namespace' => 'http://www.loc.gov/standards/alto/ns-v2#',
'class' => 'Kitodo\\Dlf\\Formats\\Alto'
);
];
}

14
Classes/Hooks/DataHandler.php

@ -133,12 +133,12 @@ class DataHandler {
}
$context = stream_context_create(array (
'http' => array (
$context = stream_context_create([
'http' => [
'method' => 'GET',
'user_agent' => ($conf['useragent'] ? $conf['useragent'] : ini_get('user_agent'))
)
));
]
]);
// Build request for adding new Solr core.
// @see http://wiki.apache.org/solr/CoreAdmin
@ -168,7 +168,7 @@ class DataHandler {
}
// Solr core could not be created, thus unset field array.
$fieldArray = array ();
$fieldArray = [];
break;
@ -246,7 +246,7 @@ class DataHandler {
if (count($fieldArray) < 2) {
// Unset the whole field array.
$fieldArray = array ();
$fieldArray = [];
} else {
@ -385,7 +385,7 @@ class DataHandler {
*/
public function processCmdmap_postProcess($command, $table, $id, $value, $pObj) {
if (in_array($command, array ('move', 'delete', 'undelete')) && $table == 'tx_dlf_documents') {
if (in_array($command, ['move', 'delete', 'undelete']) && $table == 'tx_dlf_documents') {
// Get Solr core.
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(

2
Classes/Hooks/FormEngine.php

@ -331,7 +331,7 @@ class FormEngine {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'] as $class => $label) {
$params['items'][] = array ($GLOBALS['LANG']->sL($label), $class);
$params['items'][] = [$GLOBALS['LANG']->sL($label), $class];
}

8
Classes/Plugins/AudioPlayer.php

@ -29,7 +29,7 @@ class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin {
* @var array
* @access protected
*/
protected $audio = array ();
protected $audio = [];
/**
* Adds Player javascript
@ -40,7 +40,7 @@ class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin {