Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
_build
venv
*.map
.php-cs-fixer.cache
26 changes: 26 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace PhpCsFixer;

$finder = Finder::create()
->in([
__DIR__ . '/Classes',
__DIR__ . '/Configuration',
__DIR__ . '/Tests',
]);

return (new Config())
->setRules([
'@PSR12' => true,
])
->setFinder($finder);
4 changes: 2 additions & 2 deletions Classes/Api/Orcid/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class Client
/**
* @var string constant for API hostname
**/
const HOSTNAME = 'orcid.org';
public const HOSTNAME = 'orcid.org';

/**
* @var string constant for API version
**/
const VERSION = '3.0';
public const VERSION = '3.0';

/**
* @access protected
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private function setNewOwner(string $owner): void
{
if (empty($this->owner)) {
// owner is not set but found by metadata --> take it or take default library
$owner = $owner ? : 'default';
$owner = $owner ?: 'default';
$this->owner = $this->libraryRepository->findOneBy(['indexName' => $owner]);
if (empty($this->owner)) {
// create library
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/DbDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
class DbDocsCommand extends Command
{

protected Generator $generator;

public function __construct(Generator $generator)
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
class DeleteCommand extends BaseCommand
{

/**
* Configure the command by defining the name, options and arguments
*
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
class IndexCommand extends BaseCommand
{

/**
* Configure the command by defining the name, options and arguments
*
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
class OptimizeCommand extends Command
{

/**
* Configure the command by defining the name, options and arguments
*
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/SuggestBuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
class SuggestBuildCommand extends Command
{

/**
* Configure the command by defining the name, options and arguments
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/AnnotationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(string $apiUrl)
*
* @return mixed[] Array of annotation data
*/
protected function requestAnnotations(string $url) : array
protected function requestAnnotations(string $url): array
{
$jsonld = Helper::getUrl($url);

Expand Down
12 changes: 7 additions & 5 deletions Classes/Common/DocumentAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function getAnnotations(): array
if ($this->document->getCurrentDocument() instanceof MetsDocument) {
if (
$meiTargetPages = $this->getMeasurePagesByFileId(
$annotationTarget->getId(), $annotationTarget->getRangeValue()
$annotationTarget->getId(),
$annotationTarget->getRangeValue()
)
) {
$targetPages[] = [
Expand All @@ -96,7 +97,8 @@ public function getAnnotations(): array
];
} elseif (
$audioTargetPages = $this->getAudioPagesByFileId(
$annotationTarget->getId(), $annotationTarget->getRangeValue()
$annotationTarget->getId(),
$annotationTarget->getRangeValue()
)
) {
$targetPages[] = [
Expand Down Expand Up @@ -132,11 +134,11 @@ public function getAnnotations(): array
);
}
} elseif ($annotationTarget->getObjectId()) {
$objectTargetPages = [];
$objectTargetPages = [];
foreach ($this->document->getCurrentDocument()->physicalStructureInfo as $physInfo) {
$order = $physInfo['order'];
$order = $physInfo['order'];
if ($order) {
$objectTargetPages[] = $order;
$objectTargetPages[] = $order;
}
}
if ($objectTargetPages) {
Expand Down
1 change: 0 additions & 1 deletion Classes/Common/FulltextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
interface FulltextInterface
{

/**
* Set the page identifier.
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Indexer
/**
* Prefix for translation keys.
*/
const LANG_PREFIX = 'LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:';
public const LANG_PREFIX = 'LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:';

/**
* @access protected
Expand Down
14 changes: 7 additions & 7 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

namespace Kitodo\Dlf\Common;

use \DOMDocument;
use \DOMElement;
use \DOMNode;
use \DOMNodeList;
use \DOMXPath;
use DOMDocument;
use DOMElement;
use DOMNode;
use DOMNodeList;
use DOMXPath;
use Kitodo\Dlf\Hooks\KitodoProductionHacks;
use \SimpleXMLElement;
use SimpleXMLElement;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
Expand Down Expand Up @@ -1290,7 +1290,7 @@ protected function magicGetMdSec(): array
}
}

$amdSecXml = $this->mets->xpath('./mets:amdSec');;
$amdSecXml = $this->mets->xpath('./mets:amdSec');
if (!empty($amdSecXml)) {
foreach ($amdSecXml as $amdSecTag) {
$childIds = [];
Expand Down
1 change: 0 additions & 1 deletion Classes/Common/Solr/SearchResult/Highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class Highlight
{

/**
* @access private
* @var string The identifier in form 'w_h_x_y'
Expand Down
1 change: 0 additions & 1 deletion Classes/Common/Solr/SearchResult/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class Page
{

/**
* @access private
* @var int The identifier of the page
Expand Down
1 change: 0 additions & 1 deletion Classes/Common/Solr/SearchResult/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class Region
{

/**
* @access private
* @var int The identifier of the region
Expand Down
1 change: 0 additions & 1 deletion Classes/Common/Solr/SearchResult/ResultDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class ResultDocument
{

/**
* @access private
* @var string|null The identifier
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/Solr/Solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ protected function loadSolrConnectionInfo(): void
}

// Set connection timeout lower than PHP's max_execution_time.
$maxExecutionTime = (int) ini_get('max_execution_time') ? : 30;
$maxExecutionTime = (int) ini_get('max_execution_time') ?: 30;
$config['timeout'] = MathUtility::forceIntegerInRange($conf['timeout'] ?? null, 1, $maxExecutionTime, 10);
$this->config = $config;
}
Expand Down
18 changes: 11 additions & 7 deletions Classes/Common/Solr/SolrSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,15 @@ public function submit(int $start, int $rows, bool $processResults = true): void
$searchResult['snippet'] = $doc['snippet'];
$searchResult['highlight'] = $doc['highlight'];
$searchResult['highlight_word'] = preg_replace(
'/^;|;$/', '', // remove ; at beginning or end
'/^;|;$/',
'', // remove ; at beginning or end
preg_replace(
'/;+/', ';', // replace any multiple of ; with a single ;
'/;+/',
';', // replace any multiple of ; with a single ;
preg_replace(
'/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']
'/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/',
';',
$this->searchParams['query']
)
)
); // replace search operators and special characters with ;
Expand Down Expand Up @@ -845,7 +849,7 @@ protected function searchSolr(array $parameters = [], bool $enableCache = true):
*
* @return string
*/
private function getCollectionFilterQuery(string $query) : string
private function getCollectionFilterQuery(string $query): string
{
$collectionsQueryString = '';
$virtualCollectionsQueryString = '';
Expand Down Expand Up @@ -889,7 +893,7 @@ private function getCollectionFilterQuery(string $query) : string
private function filterCollections(): void
{
if (is_array($this->collections)) {
array_filter($this->collections, fn($value) => $value !== null);
array_filter($this->collections, fn ($value) => $value !== null);
}
}

Expand All @@ -900,7 +904,7 @@ private function filterCollections(): void
*
* @return array<string, string>
*/
private function getSort() : array
private function getSort(): array
{
if (!empty($this->searchParams['orderBy'])) {
return [
Expand Down Expand Up @@ -947,7 +951,7 @@ private function getDocument(Document $record, array $highlighting, array $field

foreach ($parameters['listMetadataRecords'] as $indexName => $solrField) {
if (!empty($record->$solrField)) {
$document['metadata'][$indexName] = $record->$solrField;
$document['metadata'][$indexName] = $record->$solrField;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/StdOutStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(protected readonly StreamInterface $stream)

/**
* @access public
*
*
* @return void
*/
public function emit()
Expand Down
1 change: 0 additions & 1 deletion Classes/Configuration/UseGroupsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class UseGroupsConfiguration
{

/**
* @access private
* @var ?UseGroupsConfiguration The instance of singleton.
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/AudioPlayerController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/Backend/NewTenantController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected function getDocumentData(string $id, array $data): array|false

$title = $this->document->getTitle();
if (empty($title)) {
$title = LocalizationUtility::translate('basket.noTitle', 'dlf') ? : '';
$title = LocalizationUtility::translate('basket.noTitle', 'dlf') ?: '';
}

// Set page and cutout information
Expand Down
8 changes: 6 additions & 2 deletions Classes/Controller/CollectionController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down Expand Up @@ -138,11 +139,14 @@ public function showAction(Collection $collection): ResponseInterface
// If a targetPid is given, the results will be shown by ListView on the target page.
if (!empty($this->settings['targetPid'])) {
return $this->redirect(
'main', 'ListView', null,
'main',
'ListView',
null,
[
'search' => $search,
'page' => $currentPage
], $this->settings['targetPid']
],
$this->settings['targetPid']
);
}

Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/Embedded3dViewerController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down Expand Up @@ -26,8 +27,7 @@
*/
class Embedded3dViewerController extends AbstractController
{

const MIDDLEWARE_DLF_EMBEDDED_3D_VIEWER_PREFIX = '/?middleware=dlf/embedded3dviewer';
public const MIDDLEWARE_DLF_EMBEDDED_3D_VIEWER_PREFIX = '/?middleware=dlf/embedded3dviewer';

/**
* @access public
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/FeedsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
Expand Down Expand Up @@ -27,7 +28,6 @@
*/
class FeedsController extends AbstractController
{

/**
* @access protected
* @var LibraryRepository
Expand Down Expand Up @@ -105,7 +105,7 @@ public function mainAction(): ResponseInterface
}
// Set default title if empty.
if (empty($title)) {
$title = LocalizationUtility::translate('noTitle', 'dlf') ? : '';
$title = LocalizationUtility::translate('noTitle', 'dlf') ?: '';
}
// Append volume information.
if (!empty($document->getVolume())) {
Expand Down
Loading
Loading