|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* AjaxBackofficeController |
|
21
|
|
|
*/ |
|
22
|
|
|
class AjaxBackofficeController extends \EWW\Dpf\Controller\AbstractController |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* bookmarkRepository |
|
26
|
|
|
* |
|
27
|
|
|
* @var \EWW\Dpf\Domain\Repository\BookmarkRepository |
|
28
|
|
|
* @inject |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $bookmarkRepository = null; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Adds a the given document identifier to the bookmark list of the current fe user. |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $identifier |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
|
|
public function addBookmarkAction($identifier) |
|
40
|
|
|
{ |
|
41
|
|
|
/** @var \EWW\Dpf\Domain\Model\Bookmark $bookmark */ |
|
42
|
|
|
$bookmark = $this->bookmarkRepository->findBookmark($this->security->getUser()->getUid(), $identifier); |
|
43
|
|
|
if (!$bookmark) { |
|
|
|
|
|
|
44
|
|
|
$bookmark = $this->objectManager->get(\EWW\Dpf\Domain\Model\Bookmark::class); |
|
45
|
|
|
$bookmark->setDocumentIdentifier($identifier); |
|
46
|
|
|
$bookmark->setFeUserUid($this->security->getUser()->getUid()); |
|
47
|
|
|
$this->bookmarkRepository->add($bookmark); |
|
48
|
|
|
return true; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return false; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Removes the given document from the bookmark list of the current fe user. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $identifier |
|
58
|
|
|
* @return bool |
|
59
|
|
|
*/ |
|
60
|
|
|
public function removeBookmarkAction($identifier) |
|
61
|
|
|
{ |
|
62
|
|
|
/** @var \EWW\Dpf\Domain\Model\Bookmark $bookmark */ |
|
63
|
|
|
$bookmark = $this->bookmarkRepository->findBookmark($this->security->getUser()->getUid(), $identifier); |
|
64
|
|
|
if ($bookmark) { |
|
|
|
|
|
|
65
|
|
|
$this->bookmarkRepository->remove($bookmark); |
|
66
|
|
|
return true; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return false; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Adds a workspace filter to the session. |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $name |
|
76
|
|
|
* @param array $values |
|
77
|
|
|
*/ |
|
78
|
|
|
public function addWorkspaceFilterAction($name, $values = []) |
|
79
|
|
|
{ |
|
80
|
|
|
if ($name && $values && is_array($values)) { |
|
|
|
|
|
|
81
|
|
|
$workspaceFilters = $this->getSessionData('workspaceFilters'); |
|
82
|
|
|
if ($workspaceFilters && is_array($workspaceFilters)) { |
|
83
|
|
|
$workspaceFilters[$name] = $values; |
|
84
|
|
|
$this->setSessionData('workspaceFilters', $workspaceFilters); |
|
|
|
|
|
|
85
|
|
|
} else { |
|
86
|
|
|
$this->setSessionData('workspaceFilters', [$name => $values]); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
} else { |
|
89
|
|
|
$workspaceFilters = $this->getSessionData('workspaceFilters'); |
|
90
|
|
|
if ($name && is_array($workspaceFilters) && array_key_exists($name, $workspaceFilters)) { |
|
91
|
|
|
unset($workspaceFilters[$name]); |
|
92
|
|
|
$this->setSessionData('workspaceFilters', $workspaceFilters); |
|
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return; |
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Adds a workspace sort to the session. |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $field |
|
104
|
|
|
* @param string $order |
|
105
|
|
|
*/ |
|
106
|
|
|
public function addWorkspaceSortAction($field, $order) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->session->setWorkspaceSort($field, $order); |
|
109
|
|
|
return; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Toggles the filter to exclude discarded documents. |
|
114
|
|
|
* |
|
115
|
|
|
*/ |
|
116
|
|
|
public function toggleWorkspaceExcludeDiscardedAction() |
|
117
|
|
|
{ |
|
118
|
|
|
$this->session->toggleWorkspaceExcludeDiscardedFilter(); |
|
119
|
|
|
return; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Toggles the filter to hide bookmarked documents. |
|
124
|
|
|
* |
|
125
|
|
|
*/ |
|
126
|
|
|
public function toggleWorkspaceBookmarksOnlyAction() |
|
127
|
|
|
{ |
|
128
|
|
|
$this->session->toggleWorkspaceBookmarksOnlyFilter(); |
|
129
|
|
|
return; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Sets the items per page for the workspace list. |
|
134
|
|
|
* |
|
135
|
|
|
* @param int $itemsPerPage |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setWorkspaceItemsPerPageAction($itemsPerPage) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->session->setWorkspaceItemsPerPage($itemsPerPage); |
|
140
|
|
|
return; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
|
|
144
|
|
|
} |
|
145
|
|
|
|