|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Kitodo\Dlf\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\Document; |
|
15
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
16
|
|
|
use Psr\Log\LoggerAwareInterface; |
|
17
|
|
|
use Psr\Log\LoggerAwareTrait; |
|
18
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface |
|
26
|
|
|
{ |
|
27
|
|
|
use LoggerAwareTrait; |
|
28
|
|
|
|
|
29
|
|
|
public $prefixId = 'tx_dlf'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $extConf; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* This holds the current document |
|
38
|
|
|
* |
|
39
|
|
|
* @var \Kitodo\Dlf\Common\Document |
|
40
|
|
|
* @access protected |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $doc; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Loads the current document into $this->doc |
|
46
|
|
|
* |
|
47
|
|
|
* @access protected |
|
48
|
|
|
* |
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function loadDocument($requestData) |
|
52
|
|
|
{ |
|
53
|
|
|
// Check for required variable. |
|
54
|
|
|
if ( |
|
55
|
|
|
!empty($requestData['id']) |
|
56
|
|
|
&& !empty($this->settings['pages']) |
|
57
|
|
|
) { |
|
58
|
|
|
// Should we exclude documents from other pages than $this->settings['pages']? |
|
59
|
|
|
$pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0); |
|
60
|
|
|
// Get instance of \Kitodo\Dlf\Common\Document. |
|
61
|
|
|
$this->doc = Document::getInstance($requestData['id'], $pid); |
|
62
|
|
|
if (!$this->doc->ready) { |
|
63
|
|
|
// Destroy the incomplete object. |
|
64
|
|
|
$this->doc = null; |
|
65
|
|
|
$this->logger->error('Failed to load document with UID ' . $requestData['id']); |
|
|
|
|
|
|
66
|
|
|
} else { |
|
67
|
|
|
// Set configuration PID. |
|
68
|
|
|
$this->doc->cPid = $this->settings['pages']; |
|
69
|
|
|
} |
|
70
|
|
|
} elseif (!empty($requestData['recordId'])) { |
|
71
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
72
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
73
|
|
|
|
|
74
|
|
|
// Get UID of document with given record identifier. |
|
75
|
|
|
$result = $queryBuilder |
|
76
|
|
|
->select('tx_dlf_documents.uid AS uid') |
|
77
|
|
|
->from('tx_dlf_documents') |
|
78
|
|
|
->where( |
|
79
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])), |
|
80
|
|
|
Helper::whereExpression('tx_dlf_documents') |
|
81
|
|
|
) |
|
82
|
|
|
->setMaxResults(1) |
|
83
|
|
|
->execute(); |
|
84
|
|
|
|
|
85
|
|
|
if ($resArray = $result->fetch()) { |
|
86
|
|
|
$requestData['id'] = $resArray['uid']; |
|
87
|
|
|
// Set superglobal $_GET array and unset variables to avoid infinite looping. |
|
88
|
|
|
$_GET[$this->prefixId]['id'] = $requestData['id']; |
|
89
|
|
|
unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']); |
|
90
|
|
|
// Try to load document. |
|
91
|
|
|
$this->loadDocument($requestData); |
|
92
|
|
|
} else { |
|
93
|
|
|
$this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"'); |
|
94
|
|
|
} |
|
95
|
|
|
} else { |
|
96
|
|
|
$this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading'); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.