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
20 changes: 20 additions & 0 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
6 changes: 1 addition & 5 deletions Classes/Controller/AudioPlayerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions Classes/Controller/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions Classes/Controller/MetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions Classes/Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions Classes/Controller/PageGridController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions Classes/Controller/TableOfContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 6 additions & 15 deletions Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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'])
) {
Expand Down
3 changes: 1 addition & 2 deletions Classes/Controller/View3DController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down