Skip to content

Commit

Permalink
Codacy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizzor committed Jul 3, 2024
1 parent 8b6b40f commit 40028a4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
10 changes: 5 additions & 5 deletions Classes/Common/DocumentAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected function getPagesByLogicalId($logicalId)
protected function getPagesByPhysicalId($physicalId)
{
$pages = [];
foreach ($this->document->getCurrentDocument()->physicalStructureInfo as $id => $physicalInfo) {
foreach ($this->document->getCurrentDocument()->physicalStructureInfo as $physicalInfo) {
$order = $physicalInfo['order'];
if (is_numeric($order)) {
$pages[] = $order;
Expand Down Expand Up @@ -228,7 +228,7 @@ protected function getPagesByPhysicalId($physicalId)
protected function getPagesByFileId($fileId)
{
$pages = [];
foreach ($this->document->getCurrentDocument()->physicalStructureInfo as $key => $physicalInfo) {
foreach ($this->document->getCurrentDocument()->physicalStructureInfo as $physicalInfo) {
if (
array_key_exists('files', $physicalInfo) &&
is_array($physicalInfo['files']) &&
Expand Down Expand Up @@ -287,7 +287,7 @@ protected function getAudioPagesByFileId($fileId, $range = null) {
if (
!(
$intervalFrom < $end && (
is_null($intervalTo) || $intervalTo > $begin
$intervalTo === null || $intervalTo > $begin
)
)
) {
Expand All @@ -299,7 +299,7 @@ protected function getAudioPagesByFileId($fileId, $range = null) {
// Get the related page numbers
$trackPages = [];
foreach ($tracks as $track) {
if (!is_null($track['order'])) {
if ($track['order'] !== null) {
$trackPages[] = $track['order'];
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ protected static function loadData($document)

if ($apiBaseUrl) {
$purl = $document->getCurrentDocument()->mets->xpath('//mods:mods/mods:identifier[@type="purl"]');
if (sizeof($purl) > 0) {
if (count($purl) > 0) {
$annotationRequest = new AnnotationRequest($apiBaseUrl);
$annotationData = $annotationRequest->getAll((string)$purl[0]);
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ protected function _getMusicalStructure(): array
// Does the document have a structMap node of type "MUSICAL"?
$elementNodes = $this->mets->xpath('./mets:structMap[@TYPE="MUSICAL"]/mets:div[@TYPE="measures"]/mets:div');
if (!empty($elementNodes)) {
$musicalSeq = [];
// Get file groups.
$fileUse = $this->magicGetFileGrps();

Expand Down Expand Up @@ -1578,6 +1579,8 @@ protected function _getMusicalStructure(): array
}
}

$elements = [];

// Build the physical elements' array from the physical structMap node.
foreach ($elementNodes as $elementNode) {
$elements[(int) $elementNode['ORDER']] = (string) $elementNode['ID'];
Expand Down Expand Up @@ -1615,9 +1618,6 @@ protected function _getMusicalStructure(): array
// Set total number of measures.
$this->numMeasures = count($elements);

// Merge and re-index the array to get nice numeric indexes.
$measures = array_merge($musicalSeq, $elements);

// Get the track/page info (begin and extent time).
$this->musicalStructure = [];
$measurePages = [];
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ protected function getMeasures(int $page, $specificDoc = null): array
$musicalStruct = $doc->musicalStructureInfo;

$i = 0;
foreach ($musicalStruct as $measureId => $measureData) {
foreach ($musicalStruct as $measureData) {
if ($defaultFileId == $measureData['files']['DEFAULT']['fileid']) {
$measureCoordsFromCurrentSite[$measureData['files']['SCORE']['begin']] = $measureData['files']['DEFAULT']['coords'];
$measureCounterToMeasureId[$i] = $measureData['files']['SCORE']['begin'];
Expand Down Expand Up @@ -345,7 +345,7 @@ protected function getScore(int $page, $specificDoc = null)
if ($this->settings['useInternalProxy']) {
// Configure @action URL for form.
$uri = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setTargetPageUid($this->pageUid)
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? true : false)
->setArguments([
'eID' => 'tx_dlf_pageview_proxy',
Expand Down Expand Up @@ -412,10 +412,10 @@ protected function addViewerJS(): void
$this->document->getCurrentDocument()->tableOfContents[0]['type'] == 'multivolume_work') { // @todo Change type
$jsViewer = 'tx_dlf_viewer = [];';
$i = 0;
$globalPage = $this->requestData['page'];
foreach ($this->documentArray as $document) {
if ($document !== null) {
$docPage = $this->requestData['docPage'][$i];
$docImage = [];

// check if page or measure is set
if ($this->requestData['docMeasure'][$i]) {
Expand Down
16 changes: 8 additions & 8 deletions Classes/Domain/Model/AnnotationTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public function isValidRange()
if (empty($this->rangeParameterName) && empty($this->rangeValue)) {
return true;
} elseif ($this->isFacsimileRange()) {
return 1 === preg_match("/^(\d+)(,\d+){3}?$/", $this->rangeValue);
return preg_match("/^(\d+)(,\d+){3}?$/", $this->rangeValue) === 1;
} elseif($this->isAudioRange()) {
return 1 === preg_match(
return preg_match(
"/^(?:\d+(?:\.\d*)?|\.\d+){0,1}(?:,(?:\d+(?:\.\d*)?|\.\d+))*$/",
$this->rangeValue
);
) === 1;
} elseif($this->isScoreRange()) {
return 1 === preg_match("/^((\d+|start|end|all|(\d+|start)(-(\d+|end)){0,1})+)(,(\d+|start|end|all|(\d+|start)(-(\d+|end)){0,1})+){0,}?$/",
$this->rangeValue);
return preg_match("/^((\d+|start|end|all|(\d+|start)(-(\d+|end)){0,1})+)(,(\d+|start|end|all|(\d+|start)(-(\d+|end)){0,1})+){0,}?$/",
$this->rangeValue) === 1;
}

return false;
Expand All @@ -137,23 +137,23 @@ public function isValidRange()
*/
public function isScoreRange()
{
return 'measureRanges' === $this->getRangeParameterName();
return $this->getRangeParameterName() === 'measureRanges' ;
}

/**
* @return bool
*/
public function isAudioRange()
{
return 't' === $this->getRangeParameterName();
return $this->getRangeParameterName() === 't';
}

/**
* @return bool
*/
public function isFacsimileRange()
{
return 'xywh' === $this->getRangeParameterName();
return $this->getRangeParameterName() === 'xywh';
}

}
4 changes: 2 additions & 2 deletions Resources/Public/JavaScript/PageView/ScoreControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

/*global ol */
const className = 'score-visible';
const scrollOffset = 100;
var zoom = 40;
Expand Down Expand Up @@ -96,7 +96,7 @@ dlfScoreUtil.fetchScoreDataFromServer = function (url, pagebeginning) {

/**
* Encapsulates especially the score behavior
* @constructor
* @class
* @param {ol.Map} map
*/
const dlfViewerScoreControl = function (dlfViewer, pagebeginning, pagecount) {
Expand Down
1 change: 1 addition & 0 deletions Resources/Public/JavaScript/PageView/gridstack.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global GridStack */
$( document ).ready(function() {
var options = { // put in gridstack options here
disableOneColumnMode: true, // for jfiddle small window size
Expand Down

0 comments on commit 40028a4

Please sign in to comment.