|
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\AbstractDocument; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Plugin 'Embedded3dViewer' for the 'dlf' extension |
|
18
|
|
|
* |
|
19
|
|
|
* @package TYPO3 |
|
20
|
|
|
* @subpackage dlf |
|
21
|
|
|
* |
|
22
|
|
|
* @access public |
|
23
|
|
|
*/ |
|
24
|
|
|
class Embedded3dViewerController extends AbstractController |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
const MIDDLEWARE_DLF_EMBEDDED_3D_VIEWER_PREFIX = '/?middleware=dlf/embedded3dviewer'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @access public |
|
31
|
|
|
* |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function mainAction(): void |
|
35
|
|
|
{ |
|
36
|
|
|
if (!empty($this->requestData['model']) || !empty($this->settings['model'])) { |
|
37
|
|
|
$this->view->assign('embedded3dViewerUrl', $this->buildEmbedded3dViewerUrl()); |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
if (!empty($this->settings['document'])) { |
|
42
|
|
|
$this->assignModelFromDocument($this->getDocumentByUrl($this->settings['document'])); |
|
43
|
|
|
} else { |
|
44
|
|
|
$this->loadDocument(); |
|
45
|
|
|
if (!$this->isDocMissingOrEmpty()) { |
|
46
|
|
|
$this->assignModelFromDocument($this->document->getCurrentDocument()); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Builds the embedded 3D viewer url. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $model The model url |
|
56
|
|
|
* @return string The embedded 3D viewer url |
|
57
|
|
|
*/ |
|
58
|
|
|
public function buildEmbedded3dViewerUrl(string $model = ''): string |
|
59
|
|
|
{ |
|
60
|
|
|
$viewer = ""; |
|
61
|
|
|
$embedded3dViewerUrl = self::MIDDLEWARE_DLF_EMBEDDED_3D_VIEWER_PREFIX; |
|
62
|
|
|
|
|
63
|
|
|
if (!empty($this->requestData['model'])) { |
|
64
|
|
|
$model = $this->requestData['model']; |
|
65
|
|
|
} elseif (!empty($this->settings['model'])) { |
|
66
|
|
|
$model = $this->settings['model']; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (!empty($model)) { |
|
70
|
|
|
$embedded3dViewerUrl .= '&model=' . $model; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (!empty($this->requestData['viewer'])) { |
|
74
|
|
|
$viewer = $this->requestData['viewer']; |
|
75
|
|
|
} elseif (!empty($this->settings['viewer'])) { |
|
76
|
|
|
$viewer = $this->settings['viewer']; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
if (!empty($viewer)) { |
|
80
|
|
|
$embedded3dViewerUrl .= '&viewer=' . $viewer; |
|
81
|
|
|
} |
|
82
|
|
|
return $embedded3dViewerUrl; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Assign the model from document to view. |
|
87
|
|
|
* |
|
88
|
|
|
* @param AbstractDocument $document The document containing the model |
|
89
|
|
|
*/ |
|
90
|
|
|
public function assignModelFromDocument(AbstractDocument $document): void |
|
91
|
|
|
{ |
|
92
|
|
|
if ($document->getToplevelMetadata()['type'][0] === 'object') { |
|
93
|
|
|
$model = trim($document->getFileLocation($document->physicalStructureInfo[$document->physicalStructure[1]]['files']['DEFAULT'])); |
|
94
|
|
|
$this->view->assign('embedded3dViewerUrl', $this->buildEmbedded3dViewerUrl($model)); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|