diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 61d3752a4..96c92629d 100755 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -173,6 +173,26 @@ protected function loadDocument($requestData) } } + /** + * Checks if doc is missing or is empty (no pages) + * + * @return boolean + */ + protected function isDocMissingOrEmpty() + { + return $this->isDocMissing() || $this->document->getDoc()->numPages < 1; + } + + /** + * Checks if doc is missing + * + * @return boolean + */ + protected function isDocMissing() + { + return $this->document === null || $this->document->getDoc() === null; + } + /** * Returns the LanguageService * diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 42b36e6ed..e05db0ac4 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -76,11 +76,7 @@ public function mainAction() { // Load current document. $this->loadDocument($this->requestData); - if ( - $this->document === null - || $this->document->getDoc() === null - || $this->document->getDoc()->numPages < 1 - ) { + if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. return ''; } else { diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index d95b59c05..e7edc19e1 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -390,10 +390,7 @@ protected function addToBasket($_piVars, $basket) } // get document instance to load further information $this->loadDocument(['id' => $documentItem['id']]); - if ( - $this->document === null - || $this->document->getDoc() === null - ) { + if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. return; } diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 657ff5c8d..79304c8d0 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -79,10 +79,7 @@ public function mainAction() // Load current document. $this->loadDocument($this->requestData); - if ( - $this->document === null - || $this->document->getDoc() === null - ) { + if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. return ''; } else { diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 5f488ef5f..0664fe303 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -57,10 +57,7 @@ public function mainAction() { // Load current document. $this->loadDocument($this->requestData); - if ( - $this->document === null - || $this->document->getDoc() === null - ) { + if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. return ''; } else { diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index 9a67c4938..4b58281ad 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -33,8 +33,7 @@ public function mainAction() { $this->loadDocument($this->requestData); if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->extConf['fileGrpThumbs']) ) { // Quit without doing anything if required variables are not set. diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index cb4ed047c..61a0aabda 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -69,10 +69,7 @@ public function mainAction() { // Load current document. $this->loadDocument($this->requestData); - if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 - ) { + if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. return ''; } else { diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 3bdff2e8c..4f3f371d6 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -43,10 +43,7 @@ public function mainAction() { // Load current document. $this->loadDocument($this->requestData); - if ( - $this->document === null - || $this->document->getDoc() === null - ) { + if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. return; } else { diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index ce19d5d78..2a7f2d826 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -54,10 +54,7 @@ public function mainAction() */ public function annotationtool() { - if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 - ) { + if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. return ''; } else { @@ -97,8 +94,7 @@ public function annotationtool() public function fulltextdownloadtool() { if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->extConf['fileGrpFulltext']) ) { // Quit without doing anything if required variables are not set. @@ -143,8 +139,7 @@ public function fulltextdownloadtool() public function fulltexttool() { if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->extConf['fileGrpFulltext']) ) { // Quit without doing anything if required variables are not set. @@ -189,8 +184,7 @@ public function fulltexttool() public function imagedownloadtool() { if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->settings['fileGrpsImageDownload']) ) { // Quit without doing anything if required variables are not set. @@ -281,9 +275,7 @@ public function imagemanipulationtool() public function pdfdownloadtool() { if ( - $this->document === null - || $this->document->getDoc() === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->extConf['fileGrpDownload']) ) { // Quit without doing anything if required variables are not set. @@ -396,8 +388,7 @@ protected function getWorkLink() public function searchindocumenttool() { if ( - $this->document === null - || $this->document->getDoc()->numPages < 1 + $this->isDocMissingOrEmpty() || empty($this->extConf['fileGrpFulltext']) || empty($this->settings['solrcore']) ) { diff --git a/Classes/Controller/View3DController.php b/Classes/Controller/View3DController.php index e1e101d4a..fd1a71076 100644 --- a/Classes/Controller/View3DController.php +++ b/Classes/Controller/View3DController.php @@ -33,8 +33,7 @@ public function mainAction() // Load current document. $this->loadDocument($this->requestData); if ( - $this->document === null - || $this->document->getDoc() === null + $this->isDocMissingOrEmpty() || $this->document->getDoc()->metadataArray['LOG_0001']['type'][0] != 'object' ) { // Quit without doing anything if required variables are not set.