Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
chrizzor and sebastian-meyer authored Jul 15, 2024
1 parent 4c324ee commit ee8c48c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
9 changes: 5 additions & 4 deletions Classes/Common/DocumentAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* LICENSE.txt file that was distributed with this source code.
*/

use DateTime;
use Kitodo\Dlf\Domain\Model\Annotation;
use Kitodo\Dlf\Domain\Model\Document;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
Expand Down Expand Up @@ -279,10 +280,10 @@ protected function getAudioPagesByFileId($fileId, $range = null) {
}

foreach ($tracks as $index => $track) {
$begin = new \DateTime("1970-01-01 " . $track['begin']);
$extent = new \DateTime("1970-01-01 " . $track['extent']);
$diff = (new \DateTime("1970-01-01 00:00:00"))->diff($extent);
$end = (new \DateTime("1970-01-01 " . $track['begin']))->add($diff);
$begin = new DateTime("1970-01-01 " . $track['begin']);
$extent = new DateTime("1970-01-01 " . $track['extent']);
$diff = (new DateTime("1970-01-01 00:00:00"))->diff($extent);
$end = (new DateTime("1970-01-01 " . $track['begin']))->add($diff);

if (
!(
Expand Down
52 changes: 33 additions & 19 deletions Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,37 @@ protected function multipageNavigation() {
MathUtility::forceIntegerInRange((int) $this->requestData['docPage'][$i] - 1, 1, $document->numPages, 1)
];

$navigateAllPageNext = array_merge($navigateAllPageNext, [
'tx_dlf[docPage]['.$i.']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docPage'][$i] + 1, 1, $document->numPages, 1)
]);
$navigateAllPageNext = array_merge(
$navigateAllPageNext,
[
'tx_dlf[docPage][' . $i . ']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docPage'][$i] + 1, 1, $document->numPages, 1)
]
);

$navigateAllPagePrev = array_merge($navigateAllPagePrev, [
'tx_dlf[docPage]['.$i.']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docPage'][$i] - 1, 1, $document->numPages, 1)
]);
$navigateAllPagePrev = array_merge(
$navigateAllPagePrev,
[
'tx_dlf[docPage][' . $i . ']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docPage'][$i] - 1, 1, $document->numPages, 1)
]
);

$navigateAllMeasureNext = array_merge($navigateAllMeasureNext, [
'tx_dlf[docMeasure]['.$i.']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docMeasure'][$i] + 1, 1, $document->numMeasures, 1)
]);
$navigateAllMeasureNext = array_merge(
$navigateAllMeasureNext,
[
'tx_dlf[docMeasure][' . $i . ']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docMeasure'][$i] + 1, 1, $document->numMeasures, 1)
]
);

$navigateAllMeasurePrev = array_merge($navigateAllMeasurePrev, [
'tx_dlf[docMeasure]['.$i.']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docMeasure'][$i] - 1, 1, $document->numMeasures, 1)
]);
$navigateAllMeasurePrev = array_merge(
$navigateAllMeasurePrev,
[
'tx_dlf[docMeasure][' . $i . ']' =>
MathUtility::forceIntegerInRange((int) $this->requestData['docMeasure'][$i] - 1, 1, $document->numMeasures, 1)
]
);

if ($document->numMeasures > 0) {
$navigationMeasureArray[$i]['next'] = [
Expand Down Expand Up @@ -241,7 +253,8 @@ protected function multipageNavigation() {
* @param $page
* @return false|int|mixed|string|null
*/
public function convertMeasureOrPage($document, $measure = null, $page = null) {
public function convertMeasureOrPage($document, $measure = null, $page = null)
{
$return = null;
$measure2Page = array_column($document->musicalStructure, 'page');
if ($measure) {
Expand All @@ -266,7 +279,7 @@ public function addDocumentAction(FormAddDocument $formAddDocument)
}
$params = array_merge(
['tx_dlf' => $this->requestData],
['tx_dlf[multipleSource]['.$nextMultipleSourceKey.']' => $formAddDocument->getLocation()],
['tx_dlf[multipleSource][' . $nextMultipleSourceKey . ']' => $formAddDocument->getLocation()],
['tx_dlf[multiview]' => 1]
);
$uriBuilder = $this->uriBuilder;
Expand Down Expand Up @@ -297,7 +310,8 @@ protected function getMeasures(int $page, $specificDoc = null, $docNumber = null
$measureCoordsFromCurrentSite = [];
$measureCounterToMeasureId = [];
$measureLinks = [];
if ($defaultFileId = $doc->physicalStructureInfo[$currentPhysId]['files']['DEFAULT']) {
$defaultFileId = $doc->physicalStructureInfo[$currentPhysId]['files']['DEFAULT'];
if (isset($defaultFileId)) {
$musicalStruct = $doc->musicalStructureInfo;

$i = 0;
Expand Down
7 changes: 3 additions & 4 deletions Resources/Public/JavaScript/PageView/PageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ var dlfViewer = function(settings){
* @type {Object}
* @public
*/
this.tk = null
this.tk = null;

/**
* @type {Boolean|false}
Expand Down Expand Up @@ -344,7 +344,6 @@ dlfViewer.prototype.countPages = function () {
dlfViewer.prototype.addCustomControls = function() {
var fulltextControl = undefined,
fulltextDownloadControl = undefined,
scoreControl = undefined,
annotationControl = undefined,
imageManipulationControl = undefined,
images = this.images;
Expand Down Expand Up @@ -423,7 +422,7 @@ dlfViewer.prototype.addCustomControls = function() {
});
});

let selected = null
let selected = null;
map.on('pointermove', function (e) {
if (selected !== null) {
$('[data-annotation-id="'+selected.getId()+'"]').removeClass('hover')
Expand Down Expand Up @@ -919,7 +918,7 @@ dlfViewer.prototype.init = function(controlNames) {

dlfViewer.prototype.updateLayerSize = function() {
this.map.updateSize();
}
};

/**
* Generate the OpenLayers layer objects for given image sources. Returns a promise / jQuery deferred object.
Expand Down
3 changes: 2 additions & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@
'Dlf',
'PageView',
[
\Kitodo\Dlf\Controller\PageViewController::class => 'main, addDocument',
\Kitodo\Dlf\Controller\PageViewController::class => 'main',
\Kitodo\Dlf\Controller\PageViewController::class => 'addDocument',
],
// non-cacheable actions
[
Expand Down

0 comments on commit ee8c48c

Please sign in to comment.