Browse Source

Use lower case for all reserved types and keywords

pull/433/head
Sebastian Meyer 2 years ago
parent
commit
e832d94e20
  1. 6
      Classes/Command/IndexCommand.php
  2. 10
      Classes/Command/ReindexCommand.php
  3. 2
      Classes/Common/AbstractModule.php
  4. 16
      Classes/Common/AbstractPlugin.php
  5. 136
      Classes/Common/Document.php
  6. 16
      Classes/Common/DocumentList.php
  7. 6
      Classes/Common/DocumentTypeCheck.php
  8. 68
      Classes/Common/Helper.php
  9. 124
      Classes/Common/IiifManifest.php
  10. 2
      Classes/Common/IiifUrlReader.php
  11. 92
      Classes/Common/Indexer.php
  12. 64
      Classes/Common/MetsDocument.php
  13. 12
      Classes/Common/Solr.php
  14. 16
      Classes/Hooks/ConfigurationForm.php
  15. 2
      Classes/Hooks/DataHandler.php
  16. 2
      Classes/Hooks/ExtensionManagementUtility.php
  17. 4
      Classes/Hooks/FormEngine.php
  18. 32
      Classes/Module/NewTenant.php
  19. 2
      Classes/Plugin/AudioPlayer.php
  20. 42
      Classes/Plugin/Basket.php
  21. 12
      Classes/Plugin/Calendar.php
  22. 18
      Classes/Plugin/Collection.php
  23. 2
      Classes/Plugin/Eid/PageViewProxy.php
  24. 6
      Classes/Plugin/Feeds.php
  25. 62
      Classes/Plugin/ListView.php
  26. 12
      Classes/Plugin/Metadata.php
  27. 60
      Classes/Plugin/Navigation.php
  28. 16
      Classes/Plugin/OaiPmh.php
  29. 28
      Classes/Plugin/PageGrid.php
  30. 20
      Classes/Plugin/PageView.php
  31. 20
      Classes/Plugin/Search.php
  32. 6
      Classes/Plugin/Statistics.php
  33. 26
      Classes/Plugin/TableOfContents.php
  34. 2
      Classes/Plugin/Toolbox.php
  35. 10
      Classes/Plugin/Tools/AnnotationTool.php
  36. 6
      Classes/Plugin/Tools/FulltextTool.php
  37. 2
      Classes/Plugin/Tools/ImageDownloadTool.php
  38. 2
      Classes/Plugin/Tools/ImageManipulationTool.php
  39. 2
      Classes/Plugin/Tools/PdfDownloadTool.php
  40. 2
      Classes/Plugin/Tools/SearchInDocumentTool.php
  41. 4
      Classes/Plugin/Validator.php
  42. 4
      Configuration/TCA/tx_dlf_collections.php
  43. 4
      Configuration/TCA/tx_dlf_documents.php
  44. 6
      Configuration/TCA/tx_dlf_metadata.php
  45. 72
      class.ext_update.php
  46. 4
      ext_emconf.php
  47. 46
      ext_localconf.php

6
Classes/Command/IndexCommand.php

@ -38,7 +38,7 @@ class IndexCommand extends Command
->setHelp('')
->addOption(
'dry-run',
NULL,
null,
InputOption::VALUE_NONE,
'If this option is set, the files will not actually be processed but the location URI is shown.'
)
@ -73,7 +73,7 @@ class IndexCommand extends Command
// Make sure the _cli_ user is loaded
Bootstrap::getInstance()->initializeBackendAuthentication();
$dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE;
$dryRun = $input->getOption('dry-run') != false ? true : false;
$io = new SymfonyStyle($input, $output);
$io->title($this->getDescription());
@ -129,7 +129,7 @@ class IndexCommand extends Command
}
// Get the document...
$doc = Document::getInstance($input->getOption('doc'), $startingPoint, TRUE);
$doc = Document::getInstance($input->getOption('doc'), $startingPoint, true);
if ($doc->ready) {
if ($dryRun) {
$io->section('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.');

10
Classes/Command/ReindexCommand.php

@ -39,7 +39,7 @@ class ReindexCommand extends Command
->setHelp('')
->addOption(
'dry-run',
NULL,
null,
InputOption::VALUE_NONE,
'If this option is set, the files will not actually be processed but the location URI is shown.'
)
@ -80,7 +80,7 @@ class ReindexCommand extends Command
// Make sure the _cli_ user is loaded
Bootstrap::getInstance()->initializeBackendAuthentication();
$dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE;
$dryRun = $input->getOption('dry-run') != false ? true : false;
$io = new SymfonyStyle($input, $output);
$io->title($this->getDescription());
@ -131,7 +131,7 @@ class ReindexCommand extends Command
&& !is_array($input->getOption('coll'))
) {
// "coll" may be a single integer or a comma-separated list of integers.
if (empty(array_filter(GeneralUtility::intExplode(',', $input->getOption('coll'), TRUE)))) {
if (empty(array_filter(GeneralUtility::intExplode(',', $input->getOption('coll'), true)))) {
$io->error('ERROR: Parameter --coll|-c is not a valid comma-separated list of collection UIDs.');
exit(1);
}
@ -142,7 +142,7 @@ class ReindexCommand extends Command
}
foreach ($documents as $id => $document) {
$doc = Document::getInstance($document, $startingPoint, TRUE);
$doc = Document::getInstance($document, $startingPoint, true);
if ($doc->ready) {
if ($dryRun) {
$io->writeln('DRY RUN: Would index ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.');
@ -239,7 +239,7 @@ class ReindexCommand extends Command
$queryBuilder->expr()->in(
'tx_dlf_collections_join.uid',
$queryBuilder->createNamedParameter(
GeneralUtility::intExplode(',', $collIds, TRUE),
GeneralUtility::intExplode(',', $collIds, true),
Connection::PARAM_INT_ARRAY
)
),

2
Classes/Common/AbstractModule.php

@ -27,7 +27,7 @@ abstract class AbstractModule extends \TYPO3\CMS\Backend\Module\BaseScriptClass
public $prefixId = 'tx_dlf';
/**
* Holds the page record if access granted or FALSE if access denied
* Holds the page record if access granted or false if access denied
*
* @var mixed
* @access protected

16
Classes/Common/AbstractPlugin.php

@ -32,8 +32,8 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
public $prefixId = 'tx_dlf';
public $scriptRelPath = 'Classes/Common/AbstractPlugin.php';
// Plugins are cached by default (@see setCache()).
public $pi_USER_INT_obj = FALSE;
public $pi_checkCHash = TRUE;
public $pi_USER_INT_obj = false;
public $pi_checkCHash = true;
/**
* This holds the current document
@ -148,7 +148,7 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
$this->doc = Document::getInstance($this->piVars['id'], $pid);
if (!$this->doc->ready) {
// Destroy the incomplete object.
$this->doc = NULL;
$this->doc = null;
Helper::devLog('Failed to load document with UID ' . $this->piVars['id'], DEVLOG_SEVERITY_ERROR);
} else {
// Set configuration PID.
@ -244,20 +244,20 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
*
* @return void
*/
protected function setCache($cache = TRUE)
protected function setCache($cache = true)
{
if ($cache) {
// Set cObject type to "USER" (default).
$this->pi_USER_INT_obj = FALSE;
$this->pi_checkCHash = TRUE;
$this->pi_USER_INT_obj = false;
$this->pi_checkCHash = true;
if (count($this->piVars)) {
// Check cHash or disable caching.
$GLOBALS['TSFE']->reqCHash();
}
} else {
// Set cObject type to "USER_INT".
$this->pi_USER_INT_obj = TRUE;
$this->pi_checkCHash = FALSE;
$this->pi_USER_INT_obj = true;
$this->pi_checkCHash = false;
// Plugins are of type "USER" by default, so convert it to "USER_INT".
$this->cObj->convertToUserIntObject();
}

136
Classes/Common/Document.php

@ -93,7 +93,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $formatsLoaded = FALSE;
protected $formatsLoaded = false;
/**
* Are there any fulltext files available? This also includes IIIF text annotations
@ -103,7 +103,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $hasFulltext = FALSE;
protected $hasFulltext = false;
/**
* Last searched logical and physical page
@ -111,7 +111,7 @@ abstract class Document
* @var array
* @access protected
*/
protected $lastSearchedPhysicalPage = ['logicalPage' => NULL, 'physicalPage' => NULL];
protected $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null];
/**
* This holds the documents location
@ -145,7 +145,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $metadataArrayLoaded = FALSE;
protected $metadataArrayLoaded = false;
/**
* The holds the total number of pages
@ -186,7 +186,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $physicalStructureLoaded = FALSE;
protected $physicalStructureLoaded = false;
/**
* This holds the PID of the document or zero if not in database
@ -211,7 +211,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $ready = FALSE;
protected $ready = false;
/**
* The METS file's / IIIF manifest's record identifier
@ -245,7 +245,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $rootIdLoaded = FALSE;
protected $rootIdLoaded = false;
/**
* This holds the smLinks between logical and physical structMap
@ -262,7 +262,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $smLinksLoaded = FALSE;
protected $smLinksLoaded = false;
/**
* This holds the logical structure
@ -279,7 +279,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $tableOfContentsLoaded = FALSE;
protected $tableOfContentsLoaded = false;
/**
* This holds the document's thumbnail location
@ -296,7 +296,7 @@ abstract class Document
* @var bool
* @access protected
*/
protected $thumbnailLoaded = FALSE;
protected $thumbnailLoaded = false;
/**
* This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF)
@ -413,7 +413,7 @@ abstract class Document
*
* @return \Kitodo\Dlf\Common\Document Instance of this class, either MetsDocument or IiifManifest
*/
public static function &getInstance($uid, $pid = 0, $forceReload = FALSE)
public static function &getInstance($uid, $pid = 0, $forceReload = false)
{
// Sanitize input.
$pid = max(intval($pid), 0);
@ -453,10 +453,10 @@ abstract class Document
}
}
// Create new instance depending on format (METS or IIIF) ...
$instance = NULL;
$documentFormat = NULL;
$xml = NULL;
$iiif = NULL;
$instance = null;
$documentFormat = null;
$xml = null;
$iiif = null;
// Try to get document format from database
if (MathUtility::canBeInterpretedAsInteger($uid)) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
@ -505,27 +505,27 @@ abstract class Document
@ini_set('user_agent', $extConf['useragent']);
}
$content = GeneralUtility::getUrl($location);
if ($content !== FALSE) {
if ($content !== false) {
// TODO use single place to load xml
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(TRUE);
$libxmlErrors = libxml_use_internal_errors(true);
// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
$previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
// Try to load XML from file.
$xml = simplexml_load_string($content);
// reset entity loader setting
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
if ($xml !== FALSE) {
if ($xml !== false) {
/* @var $xml \SimpleXMLElement */
$xml->registerXPathNamespace('mets', 'http://www.loc.gov/METS/');
$xpathResult = $xml->xpath('//mets:mets');
$documentFormat = !empty($xpathResult) ? 'METS' : NULL;
$documentFormat = !empty($xpathResult) ? 'METS' : null;
} else {
// Try to load file as IIIF resource instead.
$contentAsJsonArray = json_decode($content, TRUE);
if ($contentAsJsonArray !== NULL) {
$contentAsJsonArray = json_decode($content, true);
if ($contentAsJsonArray !== null) {
// Load plugin configuration.
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
IiifHelper::setUrlReader(IiifUrlReader::getInstance());
@ -579,7 +579,7 @@ abstract class Document
*
* @return array Array of the element's id, label, type and physical page indexes/mptr link
*/
public abstract function getLogicalStructure($id, $recursive = FALSE);
public abstract function getLogicalStructure($id, $recursive = false);
/**
* This extracts all the metadata for a logical structure node
@ -616,7 +616,7 @@ abstract class Document
} else {
$physicalPage = 0;
foreach ($this->physicalStructureInfo as $page) {
if (strpos($page['orderlabel'], $logicalPage) !== FALSE) {
if (strpos($page['orderlabel'], $logicalPage) !== false) {
$this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage;
$this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage;
return $physicalPage;
@ -666,11 +666,11 @@ abstract class Document
if (!empty($this->physicalStructureInfo[$id])) {
// Get fulltext file.
$file = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$extConf['fileGrpFulltext']]));
if ($file !== FALSE) {
if ($file !== false) {
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(TRUE);
$libxmlErrors = libxml_use_internal_errors(true);
// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept.
$previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
// Load XML from file.
$rawTextXml = simplexml_load_string($file);
// Reset entity loader setting.
@ -723,7 +723,7 @@ abstract class Document
*
* @return string The title of the document itself or a parent document
*/
public static function getTitle($uid, $recursive = FALSE)
public static function getTitle($uid, $recursive = false)
{
$title = '';
// Sanitize input.
@ -756,7 +756,7 @@ abstract class Document
&& intval($partof)
&& $partof != $uid
) {
$title = self::getTitle($partof, TRUE);
$title = self::getTitle($partof, true);
}
} else {
Helper::devLog('No document with UID ' . $uid . ' found or document not accessible', DEVLOG_SEVERITY_WARNING);
@ -807,7 +807,7 @@ abstract class Document
* @param int $depth: current tree depth
* @param string $logId: ID of the logical structure whose depth is requested
*
* @return int|bool: FALSE if structure with $logId is not a child of this substructure,
* @return int|bool: false if structure with $logId is not a child of this substructure,
* or the actual depth.
*/
protected function getTreeDepth($structure, $depth, $logId)
@ -817,12 +817,12 @@ abstract class Document
return $depth;
} elseif (array_key_exists('children', $element)) {
$foundInChildren = $this->getTreeDepth($element['children'], $depth + 1, $logId);
if ($foundInChildren !== FALSE) {
if ($foundInChildren !== false) {
return $foundInChildren;
}
}
}
return FALSE;
return false;
}
/**
@ -831,7 +831,7 @@ abstract class Document
* @access public
*
* @param string $logId: The id of the logical structure element whose depth is requested
* @return int|bool tree depth as integer or FALSE if no element with $logId exists within the TOC.
* @return int|bool tree depth as integer or false if no element with $logId exists within the TOC.
*/
public function getStructureDepth($logId)
{
@ -858,7 +858,7 @@ abstract class Document
*
* @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument: any instance that has already been loaded
*
* @return bool TRUE if $preloadedDocument can actually be reused, FALSE if it has to be loaded again
* @return bool true if $preloadedDocument can actually be reused, false if it has to be loaded again
*/
protected abstract function setPreloadedDocument($preloadedDocument);
@ -871,7 +871,7 @@ abstract class Document
*
* @param string $location: The URL of the file to load
*
* @return bool TRUE on success or FALSE on failure
* @return bool true on success or false on failure
*/
protected abstract function loadLocation($location);
@ -882,7 +882,7 @@ abstract class Document
*
* @param string $location: The URL of the file to load
*
* @return bool TRUE on success or FALSE on failure
* @return bool true on success or false on failure
*/
protected function load($location)
{
@ -899,7 +899,7 @@ abstract class Document
} else {
Helper::devLog('Invalid file location "' . $location . '" for document loading', DEVLOG_SEVERITY_ERROR);
}
return FALSE;
return false;
}
/**
@ -947,7 +947,7 @@ abstract class Document
'class' => $resArray['class']
];
}
$this->formatsLoaded = TRUE;
$this->formatsLoaded = true;
}
}
@ -987,13 +987,13 @@ abstract class Document
* @param int $pid: The PID of the saved record
* @param int $core: The UID of the Solr core for indexing
*
* @return bool TRUE on success or FALSE on failure
* @return bool true on success or false on failure
*/
public function save($pid = 0, $core = 0)
{
if (\TYPO3_MODE !== 'BE') {
Helper::devLog('Saving a document is only allowed in the backend', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
// Make sure $pid is a non-negative integer.
$pid = max(intval($pid), 0);
@ -1008,7 +1008,7 @@ abstract class Document
$pid = $this->pid;
} elseif (!$pid) {
Helper::devLog('Invalid PID ' . $pid . ' for document saving', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
// Set PID for metadata definitions.
$this->cPid = $pid;
@ -1021,7 +1021,7 @@ abstract class Document
// Check for record identifier.
if (empty($metadata['record_id'][0])) {
Helper::devLog('No record identifier found to avoid duplication', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
// Load plugin configuration.
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
@ -1045,7 +1045,7 @@ abstract class Document
$structure = $resArray['uid'];
} else {
Helper::devLog('Could not identify document/structure type "' . $queryBuilder->expr()->literal($metadata['type'][0]) . '"', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
$metadata['type'][0] = $structure;
@ -1099,12 +1099,12 @@ abstract class Document
unset($collData);
// Add new collection's UID.
$collections[] = $substUid[$collNewUid];
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == FALSE) {
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == false) {
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.newCollection'), $collection, $substUid[$collNewUid])),
Helper::getMessage('flash.attention', TRUE),
Helper::getMessage('flash.attention', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
TRUE
true
);
}
}
@ -1150,12 +1150,12 @@ abstract class Document
$substUid = Helper::processDBasAdmin($libData);
// Add new library's UID.
$ownerUid = $substUid[$libNewUid];
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == FALSE) {
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == false) {
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.newLibrary'), $owner, $ownerUid)),
Helper::getMessage('flash.attention', TRUE),
Helper::getMessage('flash.attention', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
TRUE
true
);
}
}
@ -1236,7 +1236,7 @@ abstract class Document
'author' => implode('; ', $metadata['author']),
'year' => implode('; ', $metadata['year']),
'place' => implode('; ', $metadata['place']),
'thumbnail' => $this->_getThumbnail(TRUE),
'thumbnail' => $this->_getThumbnail(true),
'metadata' => serialize($listed),
'metadata_sorting' => serialize($sortable),
'structure' => $metadata['type'][0],
@ -1268,12 +1268,12 @@ abstract class Document
$this->pid = $pid;
$this->parentId = $partof;
}
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == FALSE) {
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == false) {
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.documentSaved'), $metadata['title'][0], $this->uid)),
Helper::getMessage('flash.done', TRUE),
Helper::getMessage('flash.done', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
TRUE
true
);
}
// Add document to index.
@ -1282,7 +1282,7 @@ abstract class Document
} else {
Helper::devLog('Invalid UID "' . $core . '" for Solr core', DEVLOG_SEVERITY_NOTICE);
}
return TRUE;
return true;
}
/**
@ -1355,7 +1355,7 @@ abstract class Document
) {
$this->prepareMetadataArray($cPid);
$this->metadataArray[0] = $cPid;
$this->metadataArrayLoaded = TRUE;
$this->metadataArrayLoaded = true;
}
return $this->metadataArray;
}
@ -1464,7 +1464,7 @@ abstract class Document
$parent = self::getInstance($this->parentId, $this->pid);
$this->rootId = $parent->rootId;
}
$this->rootIdLoaded = TRUE;
$this->rootIdLoaded = true;
}
return $this->rootId;
}
@ -1493,8 +1493,8 @@ abstract class Document
// Is there no logical structure array yet?
if (!$this->tableOfContentsLoaded) {
// Get all logical structures.
$this->getLogicalStructure('', TRUE);
$this->tableOfContentsLoaded = TRUE;
$this->getLogicalStructure('', true);
$this->tableOfContentsLoaded = true;
}
return $this->tableOfContents;
}
@ -1510,7 +1510,7 @@ abstract class Document
*
* @return string The document's thumbnail location
*/
protected abstract function _getThumbnail($forceReload = FALSE);
protected abstract function _getThumbnail($forceReload = false);
/**
* This returns the ID of the toplevel logical structure node
@ -1569,7 +1569,7 @@ abstract class Document
*
* @param int $uid: The UID of the document to parse or URL to XML file
* @param int $pid: If > 0, then only document with this PID gets loaded
* @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument: Either NULL or the \SimpleXMLElement
* @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument: Either null or the \SimpleXMLElement
* or IiifResourceInterface that has been loaded to determine the basic document format.
*
* @return void
@ -1591,7 +1591,7 @@ abstract class Document
&& $this->load($uid))) {
// Initialize core METS object.
$this->init();
if ($this->getDocument() !== NULL) {
if ($this->getDocument() !== null) {
// Cast to string for safety reasons.
$location = (string) $uid;
$this->establishRecordId($pid);
@ -1649,30 +1649,30 @@ abstract class Document
$this->parentId = $resArray['partof'];
$this->thumbnail = $resArray['thumbnail'];
$this->location = $resArray['location'];
$this->thumbnailLoaded = TRUE;
$this->thumbnailLoaded = true;
// Load XML file if necessary...
if (
$this->getDocument() === NULL
$this->getDocument() === null
&& $this->load($this->location)
) {
// ...and set some basic properties.
$this->init();
}
// Do we have a METS / IIIF object now?
if ($this->getDocument() !== NULL) {
if ($this->getDocument() !== null) {
// Set new location if necessary.
if (!empty($location)) {
$this->location = $location;
}
// Document ready!
$this->ready = TRUE;
$this->ready = true;
}
} elseif ($this->getDocument() !== NULL) {
} elseif ($this->getDocument() !== null) {
// Set location as UID for documents not in database.
$this->uid = $location;
$this->location = $location;
// Document ready!
$this->ready = TRUE;
$this->ready = true;
} else {
Helper::devLog('No document with UID ' . $uid . ' found or document not accessible', DEVLOG_SEVERITY_ERROR);
}
@ -1708,7 +1708,7 @@ abstract class Document
*
* @param string $var: Name of variable to check
*
* @return bool TRUE if variable is set and not empty, FALSE otherwise
* @return bool true if variable is set and not empty, false otherwise
*/
public function __isset($var) {
return !empty($this->__get($var));

16
Classes/Common/DocumentList.php

@ -218,7 +218,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
if ($resArray['uid'] == $record['uid']) {
$record['thumbnail'] = $resArray['thumbnail'];
$record['metadata'] = $metadata;
} elseif (($key = array_search(['u' => $resArray['uid']], $record['subparts'], TRUE)) !== FALSE) {
} elseif (($key = array_search(['u' => $resArray['uid']], $record['subparts'], true)) !== false) {
$record['subparts'][$key] = [
'uid' => $resArray['uid'],
'page' => 1,
@ -245,7 +245,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
'highlighting' => [
'query' => Solr::escapeQuery($this->metadata['searchString']),
'field' => 'fulltext',
'usefastvectorhighlighter' => TRUE
'usefastvectorhighlighter' => true
]
];
}
@ -289,7 +289,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
$record['thumbnail'] = $resArray->thumbnail;
$record['metadata'] = $metadata;
} else {
$highlightedDoc = !empty($highlighting) ? $highlighting->getResult($resArray->id) : NULL;
$highlightedDoc = !empty($highlighting) ? $highlighting->getResult($resArray->id) : null;
$highlight = !empty($highlightedDoc) ? $highlightedDoc->getField('fulltext')[0] : '';
$record['subparts'][$resArray->id] = [
'uid' => $resArray->uid,
@ -559,7 +559,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*
* @access protected
*
* @return bool TRUE on success or FALSE on failure
* @return bool true on success or false on failure
*/
protected function solrConnect()
{
@ -592,10 +592,10 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
// Add static fields.
$this->solrConfig['type'] = 'type';
} else {
return FALSE;
return false;
}
}
return TRUE;
return true;
}
/**
@ -608,7 +608,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*
* @return void
*/
public function sort($by, $asc = TRUE)
public function sort($by, $asc = true)
{
$newOrder = [];
$nonSortable = [];
@ -771,7 +771,7 @@ class DocumentList implements \ArrayAccess, \Countable, \Iterator, \TYPO3\CMS\Co
*
* @param string $var: Name of variable to check
*
* @return bool TRUE if variable is set and not empty, FALSE otherwise
* @return bool true if variable is set and not empty, false otherwise
*/
public function __isset($var) {
return !empty($this->__get($var));

6
Classes/Common/DocumentTypeCheck.php

@ -71,12 +71,12 @@ class DocumentTypeCheck
{
// Load current document.
$this->loadDocument();
if ($this->doc === NULL) {
if ($this->doc === null) {
// Quit without doing anything if document not available.
return '';
}
$toc = $this->doc->tableOfContents;
if ($this->doc instanceof IiifManifest && (!isset($toc[0]['type']) || array_search($toc[0]['type'], ['newspaper', 'year', 'issue']) !== FALSE)) {
if ($this->doc instanceof IiifManifest && (!isset($toc[0]['type']) || array_search($toc[0]['type'], ['newspaper', 'year', 'issue']) !== false)) {
// Calendar plugin does not support IIIF (yet). Abort for all newspaper related types or if type is missing.
return '';
}
@ -159,7 +159,7 @@ class DocumentTypeCheck
$this->doc = Document::getInstance($this->piVars['id']);
if (!$this->doc->ready) {
// Destroy the incomplete object.
$this->doc = NULL;
$this->doc = null;
Helper::devLog('Failed to load document with UID ' . $this->piVars['id'], DEVLOG_SEVERITY_WARNING);
}
} elseif (!empty($this->piVars['recordId'])) {

68
Classes/Common/Helper.php

@ -56,7 +56,7 @@ class Helper
*
* @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to
*/
public static function addMessage($message, $title, $severity, $session = FALSE, $queue = 'kitodo.default.flashMessages')
public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages')
{
$flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue);
@ -98,9 +98,9 @@ class Helper
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) {
return FALSE;
return false;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
return false;
}
break;
case 'ZDB':
@ -108,19 +108,19 @@ class Helper
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) {
return FALSE;
return false;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
return false;
}
break;
case 'SWD':
$checksum = 11 - $checksum;
if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) {
return FALSE;
return false;
} elseif ($checksum == 10) {
return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD');
} elseif (substr($id, -1, 1) != $checksum) {
return FALSE;
return false;
}
break;
case 'GKD':
@ -129,13 +129,13 @@ class Helper
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) {
return FALSE;
return false;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
return false;
}
break;
}
return TRUE;
return true;
}
/**
@ -146,7 +146,7 @@ class Helper
* @param string $encrypted: The encrypted value to decrypt
* @param string $hash: The control hash for decrypting
*
* @return mixed The decrypted value or NULL on error
* @return mixed The decrypted value or null on error
*/
public static function decrypt($encrypted, $hash)
{
@ -195,11 +195,11 @@ class Helper
$caller = $stacktrace[1]['class'] . $stacktrace[1]['type'] . $stacktrace[1]['function'];
foreach ($stacktrace[1]['args'] as $arg) {
if (is_bool($arg)) {
$args[] = ($arg ? 'TRUE' : 'FALSE');
$args[] = ($arg ? 'true' : 'false');
} elseif (is_scalar($arg)) {
$args[] = (string) $arg;
} elseif (is_null($arg)) {
$args[] = 'NULL';
$args[] = 'null';
} elseif (is_array($arg)) {
$args[] = '[data]';
$data[] = $arg;
@ -210,7 +210,7 @@ class Helper
}
}
$arguments = '(' . implode(', ', $args) . ')';
$additionalData = (empty($data) ? FALSE : $data);
$additionalData = (empty($data) ? false : $data);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[' . $caller . $arguments . '] ' . $message, self::$extKey, $severity, $additionalData);
}
}
@ -232,7 +232,7 @@ class Helper
}
$iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, openssl_cipher_iv_length('BF-CFB'));
$encrypted = openssl_encrypt($string, 'BF-CFB', substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), 0, $iv);
$salt = substr(md5(uniqid(rand(), TRUE)), 0, 10);
$salt = substr(md5(uniqid(rand(), true)), 0, 10);
$hash = $salt . substr(sha1($salt . $string), -10);
return ['encrypted' => $encrypted, 'hash' => $hash];
}
@ -375,9 +375,9 @@ class Helper
$lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639);
}
} elseif (\TYPO3_MODE === 'BE') {
$iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE);
$iso639 = $GLOBALS['LANG']->includeLLFile($file, false, true);
if (!empty($iso639['default'][$isoCode])) {
$lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, FALSE);
$lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, false);
}
} else {
self::devLog('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', DEVLOG_SEVERITY_ERROR);
@ -402,7 +402,7 @@ class Helper
*
* @return string The translated string or the given key on failure
*/
public static function getMessage($key, $hsc = FALSE, $default = '')
public static function getMessage($key, $hsc = false, $default = '')
{
// Set initial output to default value.
$translated = (string) $default;
@ -412,7 +412,7 @@ class Helper
if (\TYPO3_MODE === 'FE') {
self::$messages = $GLOBALS['TSFE']->readLLfile($file);
} elseif (\TYPO3_MODE === 'BE') {
self::$messages = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE);
self::$messages = $GLOBALS['LANG']->includeLLFile($file, false, true);
} else {
self::devLog('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', DEVLOG_SEVERITY_ERROR);
}
@ -422,7 +422,7 @@ class Helper
if (\TYPO3_MODE === 'FE') {
$translated = $GLOBALS['TSFE']->getLLL($key, self::$messages);
} elseif (\TYPO3_MODE === 'BE') {
$translated = $GLOBALS['LANG']->getLLL($key, self::$messages, FALSE);
$translated = $GLOBALS['LANG']->getLLL($key, self::$messages, false);
} else {
self::devLog('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', DEVLOG_SEVERITY_ERROR);
}
@ -577,7 +577,7 @@ class Helper
*
* @param string $key: Session data key for retrieval
*
* @return mixed Session value for given key or NULL on failure
* @return mixed Session value for given key or null on failure
*/
public static function loadFromSession($key)
{
@ -606,13 +606,13 @@ class Helper
*
* @param array $original: Original array
* @param array $overrule: Overrule array, overruling the original array
* @param bool $addKeys: If set to FALSE, keys that are not found in $original will not be set
* @param bool $addKeys: If set to false, keys that are not found in $original will not be set
* @param bool $includeEmptyValues: If set, values from $overrule will overrule if they are empty
* @param bool $enableUnsetFeature: If set, special value "__UNSET" can be used in the overrule array to unset keys in the original array
*
* @return array Merged array
*/
public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = TRUE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE)
public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true)
{
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature);
return $original;
@ -630,7 +630,7 @@ class Helper
*
* @return array Array of substituted "NEW..." identifiers and their actual UIDs.
*/
public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = FALSE, $cmdFirst = FALSE)
public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false)
{
if (
\TYPO3_MODE === 'BE'
@ -720,7 +720,7 @@ class Helper
* @param mixed $value: Value to save
* @param string $key: Session data key for saving
*
* @return bool TRUE on success, FALSE on failure
* @return bool true on success, false on failure
*/
public static function saveToSession($value, $key)
{
@ -728,19 +728,19 @@ class Helper
$key = (string) $key;
if (!$key) {
self::devLog('Invalid key "' . $key . '" for session data saving', DEVLOG_SEVERITY_WARNING);
return FALSE;
return false;
}
// Save value in session data.
if (\TYPO3_MODE === 'FE') {
$GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value);
$GLOBALS['TSFE']->fe_user->storeSessionData();
return TRUE;
return true;
} elseif (\TYPO3_MODE === 'BE') {
$GLOBALS['BE_USER']->setAndSaveSessionData($key, $value);
return TRUE;
return true;
} else {
self::devLog('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
}
@ -786,7 +786,7 @@ class Helper
->where(
$queryBuilder->expr()->eq($table . '.pid', $pid),
$queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)),
self::whereExpression($table, TRUE)
self::whereExpression($table, true)
)
->setMaxResults(1)
->execute();
@ -804,7 +804,7 @@ class Helper
$queryBuilder->expr()->eq($table . '.pid', $pid),
$queryBuilder->expr()->eq($table . '.uid', $resArray['l18n_parent']),
$queryBuilder->expr()->eq($table . '.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)),
self::whereExpression($table, TRUE)
self::whereExpression($table, true)
)
->setMaxResults(1)
->execute();
@ -839,7 +839,7 @@ class Helper
->where(
$queryBuilder->expr()->eq($table . '.pid', $pid),
$additionalWhere,
self::whereExpression($table, TRUE)
self::whereExpression($table, true)
)
->setMaxResults(10000)
->execute();
@ -879,7 +879,7 @@ class Helper
*
* @return string Additional WHERE clause
*/
public static function whereClause($table, $showHidden = FALSE)
public static function whereClause($table, $showHidden = false)
{
if (\TYPO3_MODE === 'FE') {
// Table "tx_dlf_formats" always has PID 0.
@ -917,7 +917,7 @@ class Helper
*
* @return string Additional WHERE expression
*/
public static function whereExpression($table, $showHidden = FALSE)
public static function whereExpression($table, $showHidden = false)
{
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table)

124
Classes/Common/IiifManifest.php

@ -86,7 +86,7 @@ final class IiifManifest extends Document
* @var bool
* @access protected
*/
protected $hasFulltextSet = FALSE;
protected $hasFulltextSet = false;
/**
* This holds the original manifest's parsed metadata array with their corresponding
@ -119,7 +119,7 @@ final class IiifManifest extends Document
*/
protected function establishRecordId($pid)
{
if ($this->iiif !== NULL) {
if ($this->iiif !== null) {
/*
* FIXME This will not consistently work because we can not be sure to have the pid at hand. It may miss
* if the plugin that actually loads the manifest allows content from other pages.
@ -134,7 +134,7 @@ final class IiifManifest extends Document
. ' AND tx_dlf_metadataformat.pid=' . intval($pid)
. ' AND ((tx_dlf_metadata.uid=tx_dlf_metadataformat.parent_id AND tx_dlf_metadataformat.encoded=tx_dlf_formats.uid'
. ' AND tx_dlf_metadata.index_name="record_id" AND tx_dlf_formats.type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->getIiifVersion(), 'tx_dlf_formats') . ') OR tx_dlf_metadata.format=0)'
. Helper::whereClause('tx_dlf_metadata', TRUE)
. Helper::whereClause('tx_dlf_metadata', true)
. Helper::whereClause('tx_dlf_metadataformat')
. Helper::whereClause('tx_dlf_formats')
);
@ -246,8 +246,8 @@ final class IiifManifest extends Document
{
// Is there no physical structure array yet?
if (!$this->physicalStructureLoaded) {
if ($this->iiif == NULL || !($this->iiif instanceof ManifestInterface)) {
return NULL;
if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) {
return null;
}
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
$iiifId = $this->iiif->getId();
@ -257,7 +257,7 @@ final class IiifManifest extends Document
$this->physicalStructureInfo[$physSeq[0]]['label'] = $this->iiif->getLabelForDisplay();
$this->physicalStructureInfo[$physSeq[0]]['orderlabel'] = $this->iiif->getLabelForDisplay();
$this->physicalStructureInfo[$physSeq[0]]['type'] = 'physSequence';
$this->physicalStructureInfo[$physSeq[0]]['contentIds'] = NULL;
$this->physicalStructureInfo[$physSeq[0]]['contentIds'] = null;
$fileUseDownload = $this->getUseGroups('fileGrpDownload');
$fileUseFulltext = $this->getUseGroups('fileGrpFulltext');
$fileUseThumbs = $this->getUseGroups('fileGrpThumbs');
@ -271,14 +271,14 @@ final class IiifManifest extends Document
if (isset($fileUseFulltext)) {
$iiifAlto = $this->iiif->getSeeAlsoUrlsForFormat("application/alto+xml");
if (empty($iiifAlto)) {
$iiifAlto = $this->iiif->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", TRUE);
$iiifAlto = $this->iiif->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", true);
}
if (!empty($iiifAlto)) {
// TODO use multiple possible alto files?
$this->mimeTypes[$iiifAlto[0]] = "application/alto+xml";
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseFulltext] = $iiifAlto[0];
$this->hasFulltext = TRUE;
$this->hasFulltextSet = TRUE;
$this->hasFulltext = true;
$this->hasFulltextSet = true;
}
}
if (!empty($this->iiif->getDefaultCanvases())) {
@ -295,7 +295,7 @@ final class IiifManifest extends Document
// put images in all non specific filegroups
if (isset($fileUses)) {
foreach ($fileUses as $fileUse) {
if ($image->getBody() != NULL && $image->getBody() instanceof ContentResourceInterface) {
if ($image->getBody() != null && $image->getBody() instanceof ContentResourceInterface) {
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse] = $image->getBody()->getId();
}
}
@ -303,40 +303,40 @@ final class IiifManifest extends Document
// populate structural metadata info
$elements[$canvasOrder] = $canvas->getId();
$this->physicalStructureInfo[$elements[$canvasOrder]]['id'] = $canvas->getId();
$this->physicalStructureInfo[$elements[$canvasOrder]]['dmdId'] = NULL;
$this->physicalStructureInfo[$elements[$canvasOrder]]['dmdId'] = null;
$this->physicalStructureInfo[$elements[$canvasOrder]]['label'] = $canvas->getLabelForDisplay();
$this->physicalStructureInfo[$elements[$canvasOrder]]['orderlabel'] = $canvas->getLabelForDisplay();
// assume that a canvas always represents a page
$this->physicalStructureInfo[$elements[$canvasOrder]]['type'] = 'page';
$this->physicalStructureInfo[$elements[$canvasOrder]]['contentIds'] = NULL;
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = NULL;
$this->physicalStructureInfo[$elements[$canvasOrder]]['contentIds'] = null;
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = null;
if (!empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = [];
$this->physicalStructureInfo[$physSeq[0]]['annotationContainers'] = [];
foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'][] = $annotationContainer->getId();
if ($extConf['indexAnnotations']) {
$this->hasFulltext = TRUE;
$this->hasFulltextSet = TRUE;
$this->hasFulltext = true;
$this->hasFulltextSet = true;
}
}
}
if (isset($fileUseFulltext)) {
$alto = $canvas->getSeeAlsoUrlsForFormat("application/alto+xml");
if (empty($alto)) {
$alto = $canvas->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", TRUE);
$alto = $canvas->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", true);
}
if (!empty($alto)) {
// TODO use all possible alto files?
$this->mimeTypes[$alto[0]] = "application/alto+xml";
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseFulltext] = $alto[0];
$this->hasFulltext = TRUE;
$this->hasFulltextSet = TRUE;
$this->hasFulltext = true;
$this->hasFulltextSet = true;
}
}
if (isset($fileUses)) {
foreach ($fileUses as $fileUse) {
if ($image->getBody() != NULL && $image->getBody() instanceof ContentResourceInterface) {
if ($image->getBody() != null && $image->getBody() instanceof ContentResourceInterface) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUse] = $image->getBody()->getId();
}
}
@ -355,7 +355,7 @@ final class IiifManifest extends Document
// Merge and re-index the array to get nice numeric indexes.
$this->physicalStructure = array_merge($physSeq, $elements);
}
$this->physicalStructureLoaded = TRUE;
$this->physicalStructureLoaded = true;
}
return $this->physicalStructure;
}
@ -380,15 +380,15 @@ final class IiifManifest extends Document
*/
public function getFileLocation($id)
{
if ($id == NULL) {
return NULL;
if ($id == null) {
return null;
}
$resource = $this->iiif->getContainedResourceById($id);
if (isset($resource)) {
if ($resource instanceof CanvasInterface) {
return (!empty($resource->getImageAnnotations()) && $resource->getImageAnnotations()->getSingleService() != NULL) ? $resource->getImageAnnotations()[0]->getSingleService()->getId() : $id;
return (!empty($resource->getImageAnnotations()) && $resource->getImageAnnotations()->getSingleService() != null) ? $resource->getImageAnnotations()[0]->getSingleService()->getId() : $id;
} elseif ($resource instanceof ContentResourceInterface) {
return $resource->getSingleService() != NULL && $resource->getSingleService() instanceof Service ? $resource->getSingleService()->getId() : $id;
return $resource->getSingleService() != null && $resource->getSingleService() instanceof Service ? $resource->getSingleService()->getId() : $id;
} elseif ($resource instanceof AbstractImageService) {
return $resource->getId();
} elseif ($resource instanceof AnnotationContainerInterface) {
@ -411,7 +411,7 @@ final class IiifManifest extends Document
} elseif ($fileResource instanceof AnnotationInterface) {
$format = "application/vnd.kitodo.iiif";
} elseif ($fileResource instanceof ContentResourceInterface) {
if ($fileResource->isText() || $fileResource->isImage() && ($fileResource->getSingleService() == NULL || !($fileResource->getSingleService() instanceof AbstractImageService))) {
if ($fileResource->isText() || $fileResource->isImage() && ($fileResource->getSingleService() == null || !($fileResource->getSingleService() instanceof AbstractImageService))) {
// Support static images without an image service
return $fileResource->getFormat();
}
@ -429,7 +429,7 @@ final class IiifManifest extends Document
* {@inheritDoc}
* @see Document::getLogicalStructure()
*/
public function getLogicalStructure($id, $recursive = FALSE)
public function getLogicalStructure($id, $recursive = false)
{
$details = [];
if (!$recursive && !empty($this->logicalUnits[$id])) {
@ -446,8 +446,8 @@ final class IiifManifest extends Document
// cache the ranges - they might occure multiple times in the structures "tree" - with full data as well as referenced as id
$processedStructures = [];
foreach ($logUnits as $logUnit) {
if (array_search($logUnit->getId(), $processedStructures) == FALSE) {
$this->tableOfContents[] = $this->getLogicalStructureInfo($logUnit, TRUE, $processedStructures);
if (array_search($logUnit->getId(), $processedStructures) == false) {
$this->tableOfContents[] = $this->getLogicalStructureInfo($logUnit, true, $processedStructures);
}
}
}
@ -465,13 +465,13 @@ final class IiifManifest extends Document
* @param array $processedStructures: IIIF resources that already have been processed
* @return array Logical structure array
*/
protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = FALSE, &$processedStructures = [])
protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = [])
{
$details = [];
$details['id'] = $resource->getId();
$details['dmdId'] = '';
$details['label'] = $resource->getLabelForDisplay() !== NULL ? $resource->getLabelForDisplay() : '';
$details['orderlabel'] = $resource->getLabelForDisplay() !== NULL ? $resource->getLabelForDisplay() : '';
$details['label'] = $resource->getLabelForDisplay() !== null ? $resource->getLabelForDisplay() : '';
$details['orderlabel'] = $resource->getLabelForDisplay() !== null ? $resource->getLabelForDisplay() : '';
$details['contentIds'] = '';
$details['volume'] = '';
$details['pagination'] = '';
@ -496,10 +496,10 @@ final class IiifManifest extends Document
$startCanvas = $resource->getStartCanvasOrFirstCanvas();
$canvases = $resource->getAllCanvases();
}
if ($startCanvas != NULL) {
if ($startCanvas != null) {
$details['pagination'] = $startCanvas->getLabel();
$startCanvasIndex = array_search($startCanvas, $this->iiif->getDefaultCanvases());
if ($startCanvasIndex !== FALSE) {
if ($startCanvasIndex !== false) {
$details['points'] = $startCanvasIndex + 1;
}
}
@ -513,7 +513,7 @@ final class IiifManifest extends Document
if ($recursive) {
$processedStructures[] = $resource->getId();
$details['children'] = [];
if ($resource instanceof ManifestInterface && $resource->getRootRanges() != NULL) {
if ($resource instanceof ManifestInterface && $resource->getRootRanges() != null) {
$rangesToAdd = [];
$rootRanges = [];
if (sizeof($this->iiif->getRootRanges()) == 1 && $this->iiif->getRootRanges()[0]->isTopRange()) {
@ -525,15 +525,15 @@ final class IiifManifest extends Document
$rootRanges[] = $range;
}
foreach ($rootRanges as $range) {
if ((array_search($range->getId(), $processedStructures) == FALSE)) {
$details['children'][] = $this->getLogicalStructureInfo($range, TRUE, $processedStructures);
if ((array_search($range->getId(), $processedStructures) == false)) {
$details['children'][] = $this->getLogicalStructureInfo($range, true, $processedStructures);
}
}
} elseif ($resource instanceof RangeInterface) {
if (!empty($resource->getAllRanges())) {
foreach ($resource->getAllRanges() as $range) {
if ((array_search($range->getId(), $processedStructures) == FALSE)) {
$details['children'][] = $this->getLogicalStructureInfo($range, TRUE, $processedStructures);
if ((array_search($range->getId(), $processedStructures) == false)) {
$details['children'][] = $this->getLogicalStructureInfo($range, true, $processedStructures);
}
}
}
@ -558,15 +558,15 @@ final class IiifManifest extends Document
*
* @todo This method is still in experimental; the method signature may change.
*/
public function getManifestMetadata($id, $cPid = 0, $withDescription = TRUE, $withRights = TRUE, $withRelated = TRUE)
public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true)
{
if (!empty($this->originalMetadataArray[$id])) {
return $this->originalMetadataArray[$id];
}
$iiifResource = $this->iiif->getContainedResourceById($id);
$result = [];
if ($iiifResource != NULL) {
if ($iiifResource->getLabel() != NULL && $iiifResource->getLabel() != "") {
if ($iiifResource != null) {
if ($iiifResource->getLabel() != null && $iiifResource->getLabel() != "") {
$result['label'] = $iiifResource->getLabel();
}
if (!empty($iiifResource->getMetadata())) {
@ -640,12 +640,12 @@ final class IiifManifest extends Document
'tx_dlf_metadata.pid=' . intval($cPid)
. ' AND tx_dlf_metadataformat.pid=' . intval($cPid)
. ' AND ((tx_dlf_metadata.uid=tx_dlf_metadataformat.parent_id AND tx_dlf_metadataformat.encoded=tx_dlf_formats.uid AND tx_dlf_formats.type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->getIiifVersion(), 'tx_dlf_formats') . ') OR tx_dlf_metadata.format=0)'
. Helper::whereClause('tx_dlf_metadata', TRUE) . Helper::whereClause('tx_dlf_metadataformat') . Helper::whereClause('tx_dlf_formats')
. Helper::whereClause('tx_dlf_metadata', true) . Helper::whereClause('tx_dlf_metadataformat') . Helper::whereClause('tx_dlf_formats')
);
$iiifResource = $this->iiif->getContainedResourceById($id);
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
// Set metadata field's value(s).
if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $iiifResource->jsonPath($resArray['xpath'])) != NULL) {
if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $iiifResource->jsonPath($resArray['xpath'])) != null) {
if (is_string($values)) {
$metadata[$resArray['index_name']] = [trim((string) $values)];
} elseif ($values instanceof JSONPath && is_array($values->data()) && count($values->data()) > 1) {
@ -663,7 +663,7 @@ final class IiifManifest extends Document
if (!empty($metadata[$resArray['index_name']]) && $resArray['is_sortable']) {
if (
$resArray['format'] > 0 && !empty($resArray['xpath_sorting'])
&& ($values = $iiifResource->jsonPath($resArray['xpath_sorting']) != NULL)
&& ($values = $iiifResource->jsonPath($resArray['xpath_sorting']) != null)
) {
if (is_string($values)) {
$metadata[$resArray['index_name'] . '_sorting'][0] = [trim((string) $values)];
@ -699,7 +699,7 @@ final class IiifManifest extends Document
$this->smLinkRangeCanvasesRecursively($range);
}
}
$this->smLinksLoaded = TRUE;
$this->smLinksLoaded = true;
}
return $this->smLinks;
}
@ -789,7 +789,7 @@ final class IiifManifest extends Document
foreach ($annotationContainer->getTextAnnotations(Motivation::PAINTING) as $annotation) {
if (
$annotation->getTargetResourceId() == $iiifResource->getId() &&
$annotation->getBody() != NULL && $annotation->getBody()->getChars() != NULL
$annotation->getBody() != null && $annotation->getBody()->getChars() != null
) {
$annotationTexts[] = $annotation->getBody()->getChars();
}
@ -835,21 +835,21 @@ final class IiifManifest extends Document
protected function loadLocation($location)
{
$fileResource = GeneralUtility::getUrl($location);
if ($fileResource !== FALSE) {
if ($fileResource !== false) {
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
IiifHelper::setUrlReader(IiifUrlReader::getInstance());
IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']);
IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']);
$resource = IiifHelper::loadIiifResource($fileResource);
if ($resource != NULL) {
if ($resource != null) {
if ($resource instanceof ManifestInterface) {
$this->iiif = $resource;
return TRUE;
return true;
}
}
}
Helper::devLog('Could not load IIIF manifest from "' . $location . '"', DEVLOG_SEVERITY_ERROR);
return FALSE;
return false;
}
/**
@ -870,9 +870,9 @@ final class IiifManifest extends Document
{
if ($preloadedDocument instanceof ManifestInterface) {
$this->iiif = $preloadedDocument;
return TRUE;
return true;
}
return FALSE;
return false;
}
/**
@ -895,22 +895,22 @@ final class IiifManifest extends Document
!empty($canvas->getSeeAlsoUrlsForFormat("application/alto+xml")) ||
!empty($canvas->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/"))
) {
$this->hasFulltextSet = TRUE;
$this->hasFulltext = TRUE;
$this->hasFulltextSet = true;
$this->hasFulltext = true;
return;
}
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
if ($extConf['indexAnnotations'] == 1 && !empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) {
foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) {
if (($textAnnotations = $annotationContainer->getTextAnnotations(Motivation::PAINTING)) != NULL) {
if (($textAnnotations = $annotationContainer->getTextAnnotations(Motivation::PAINTING)) != null) {
foreach ($textAnnotations as $annotation) {
if (
$annotation->getBody() != NULL &&
$annotation->getBody() != null &&
$annotation->getBody()->getFormat() == "text/plain" &&
$annotation->getBody()->getChars() != NULL
$annotation->getBody()->getChars() != null
) {
$this->hasFulltextSet = TRUE;
$this->hasFulltext = TRUE;
$this->hasFulltextSet = true;
$this->hasFulltext = true;
return;
}
}
@ -918,7 +918,7 @@ final class IiifManifest extends Document
}
}
}
$this->hasFulltextSet = TRUE;
$this->hasFulltextSet = true;
}
}
@ -926,7 +926,7 @@ final class IiifManifest extends Document
* {@inheritDoc}
* @see \Kitodo\Dlf\Common\Document::_getThumbnail()
*/
protected function _getThumbnail($forceReload = FALSE)
protected function _getThumbnail($forceReload = false)
{
return $this->iiif->getThumbnailUrl();
}
@ -960,7 +960,7 @@ final class IiifManifest extends Document
IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']);
IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']);
$resource = IiifHelper::loadIiifResource($this->asJson);
if ($resource != NULL && $resource instanceof ManifestInterface) {
if ($resource != null && $resource instanceof ManifestInterface) {
$this->asJson = '';
$this->iiif = $resource;
$this->init();

2
Classes/Common/IiifUrlReader.php

@ -41,7 +41,7 @@ class IiifUrlReader implements UrlReaderInterface
public function getContent($url)
{
$fileContents = GeneralUtility::getUrl($url);
if ($fileContents !== FALSE) {
if ($fileContents !== false) {
return $fileContents;
} else {
return '';

92
Classes/Common/Indexer.php

@ -60,7 +60,7 @@ class Indexer
* @var bool
* @access protected
*/
protected static $fieldsLoaded = FALSE;
protected static $fieldsLoaded = false;
/**
* List of already processed documents
@ -96,7 +96,7 @@ class Indexer
$errors = 0;
// Handle multi-volume documents.
if ($doc->parentId) {
$parent = Document::getInstance($doc->parentId, 0, TRUE);
$parent = Document::getInstance($doc->parentId, 0, true);
if ($parent->ready) {
$errors = self::add($parent, $core);
} else {
@ -150,43 +150,43 @@ class Indexer
$allResults = $result->fetchAll();
$resArray = $allResults[0];
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == FALSE) {
if ((\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI) == false) {
if (!$errors) {
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.documentIndexed'), $resArray['title'], $doc->uid)),
Helper::getMessage('flash.done', TRUE),
Helper::getMessage('flash.done', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
TRUE
true
);
} else {
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.documentNotIndexed'), $resArray['title'], $doc->uid)),
Helper::getMessage('flash.error', TRUE),
Helper::getMessage('flash.error', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
TRUE
true