|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
namespace Chamilo\CoreBundle\Controller; |
|
5
|
|
|
|
|
6
|
|
|
use Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor; |
|
7
|
|
|
use Chamilo\CoreBundle\Component\Editor\Connector; |
|
8
|
|
|
use Chamilo\CoreBundle\Component\Editor\Finder; |
|
9
|
|
|
use Chamilo\CoreBundle\Component\Utils\ChamiloApi; |
|
10
|
|
|
use Chamilo\SettingsBundle\Manager\SettingsManager; |
|
11
|
|
|
use DocumentManager; |
|
12
|
|
|
use FM\ElfinderBundle\Connector\ElFinderConnector; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
14
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
15
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
16
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class EditorController. |
|
20
|
|
|
* |
|
21
|
|
|
* @Route("/editor") |
|
22
|
|
|
* |
|
23
|
|
|
* @deprecated not used for now |
|
24
|
|
|
* |
|
25
|
|
|
* @package Chamilo\CoreBundle\Controller |
|
26
|
|
|
*/ |
|
27
|
|
|
class EditorController extends BaseController |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Get templates (left column when creating a document). |
|
31
|
|
|
* |
|
32
|
|
|
* @Route("/templates", methods={"GET"}, name="editor_templates") |
|
33
|
|
|
* |
|
34
|
|
|
* @param TranslatorInterface $translator |
|
35
|
|
|
* @param RouterInterface $router |
|
36
|
|
|
* |
|
37
|
|
|
* @return Response |
|
38
|
|
|
*/ |
|
39
|
|
|
public function editorTemplatesAction(TranslatorInterface $translator, RouterInterface $router) |
|
40
|
|
|
{ |
|
41
|
|
|
$editor = new CkEditor( |
|
42
|
|
|
$translator, |
|
43
|
|
|
$router |
|
44
|
|
|
); |
|
45
|
|
|
$templates = $editor->simpleFormatTemplates(); |
|
46
|
|
|
|
|
47
|
|
|
return $this->render( |
|
48
|
|
|
'@ChamiloTheme/Editor/templates.html.twig', |
|
49
|
|
|
['templates' => $templates] |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @Route("/myfilemanager", methods={"GET"}, name="editor_myfiles") |
|
55
|
|
|
* |
|
56
|
|
|
* @return Response |
|
57
|
|
|
*/ |
|
58
|
|
|
public function editorFileManager(): Response |
|
59
|
|
|
{ |
|
60
|
|
|
\Chat::setDisableChat(); |
|
61
|
|
|
$params = [ |
|
62
|
|
|
'course_condition' => '?'.$this->getCourseUrlQuery(), |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
return $this->render('@ChamiloTheme/Editor/elfinder.html.twig', $params); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @Route("/filemanager/{parentId}", methods={"GET"}, name="editor_filemanager") |
|
70
|
|
|
* |
|
71
|
|
|
* @param int $parentId |
|
72
|
|
|
* |
|
73
|
|
|
* @return Response |
|
74
|
|
|
*/ |
|
75
|
|
|
public function customEditorFileManager($parentId = 0): Response |
|
76
|
|
|
{ |
|
77
|
|
|
$courseInfo = api_get_course_info(); |
|
78
|
|
|
|
|
79
|
|
|
$params = [ |
|
80
|
|
|
'table' => '', |
|
81
|
|
|
'parent_id' => 0, |
|
82
|
|
|
'allow_course' => false, |
|
83
|
|
|
]; |
|
84
|
|
|
|
|
85
|
|
|
if (!empty($courseInfo)) { |
|
86
|
|
|
$groupIid = api_get_group_id(); |
|
87
|
|
|
$isAllowedToEdit = api_is_allowed_to_edit(); |
|
88
|
|
|
$groupMemberWithUploadRights = false; |
|
89
|
|
|
|
|
90
|
|
|
$path = '/'; |
|
91
|
|
|
if (!empty($parentId)) { |
|
92
|
|
|
$doc = $this->getDoctrine()->getRepository('ChamiloCourseBundle:CDocument')->find($parentId); |
|
93
|
|
|
$path = $doc->getPath(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$documentAndFolders = DocumentManager::getAllDocumentData( |
|
97
|
|
|
$courseInfo, |
|
98
|
|
|
$path, |
|
99
|
|
|
$groupIid, |
|
100
|
|
|
null, |
|
101
|
|
|
$isAllowedToEdit || $groupMemberWithUploadRights, |
|
102
|
|
|
false, |
|
103
|
|
|
0, |
|
104
|
|
|
null, |
|
105
|
|
|
$parentId |
|
106
|
|
|
); |
|
107
|
|
|
|
|
108
|
|
|
$url = $this->generateUrl('editor_filemanager', ['parentId' => $parentId]); |
|
109
|
|
|
$data = DocumentManager::processDocumentAndFolders( |
|
110
|
|
|
$documentAndFolders, |
|
111
|
|
|
$courseInfo, |
|
112
|
|
|
false, |
|
113
|
|
|
$groupMemberWithUploadRights, |
|
114
|
|
|
$path, |
|
115
|
|
|
true, |
|
116
|
|
|
$url |
|
117
|
|
|
); |
|
118
|
|
|
|
|
119
|
|
|
$show = [1, 1, 1, 1]; |
|
120
|
|
|
if ($isAllowedToEdit) { |
|
121
|
|
|
$show = [0, 1, 1, 1, 1]; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
$table = new \SortableTableFromArrayConfig( |
|
125
|
|
|
$data, |
|
126
|
|
|
2, |
|
127
|
|
|
20, |
|
128
|
|
|
'documents', |
|
129
|
|
|
$show, |
|
130
|
|
|
[], |
|
131
|
|
|
'ASC', |
|
132
|
|
|
true |
|
133
|
|
|
); |
|
134
|
|
|
$column = 1; |
|
135
|
|
|
if ($isAllowedToEdit) { |
|
136
|
|
|
$table->set_header($column++, '', false, ['style' => 'width:12px;']); |
|
137
|
|
|
} |
|
138
|
|
|
$table->set_header($column++, get_lang('Type'), false, ['style' => 'width:30px;']); |
|
139
|
|
|
$table->set_header($column++, get_lang('Name')); |
|
140
|
|
|
$table->set_header($column++, get_lang('Size'), false, ['style' => 'width:50px;']); |
|
141
|
|
|
$table->set_header($column, get_lang('Date'), false, ['style' => 'width:150px;']); |
|
142
|
|
|
|
|
143
|
|
|
$params = [ |
|
144
|
|
|
'table' => $table->return_table(), |
|
145
|
|
|
'parent_id' => (int) $parentId, |
|
146
|
|
|
'allow_course' => true, |
|
147
|
|
|
]; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
return $this->render('@ChamiloTheme/Editor/custom.html.twig', $params); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @Route("/connector", methods={"GET", "POST"}, name="editor_connector") |
|
155
|
|
|
* |
|
156
|
|
|
* @param TranslatorInterface $translator |
|
157
|
|
|
* @param RouterInterface $router |
|
158
|
|
|
* |
|
159
|
|
|
* @return Response |
|
160
|
|
|
*/ |
|
161
|
|
|
public function editorConnector(TranslatorInterface $translator, RouterInterface $router) |
|
162
|
|
|
{ |
|
163
|
|
|
$course = $this->getCourse(); |
|
164
|
|
|
$session = $this->getCourseSession(); |
|
165
|
|
|
|
|
166
|
|
|
/** @var Connector $connector */ |
|
167
|
|
|
$connector = new Connector( |
|
168
|
|
|
$this->getDoctrine()->getManager(), |
|
169
|
|
|
[], |
|
170
|
|
|
$router, |
|
171
|
|
|
$translator, |
|
172
|
|
|
$this->container->get('security.authorization_checker'), |
|
173
|
|
|
$this->getUser(), |
|
174
|
|
|
$course, |
|
175
|
|
|
$session |
|
176
|
|
|
); |
|
177
|
|
|
|
|
178
|
|
|
$driverList = [ |
|
179
|
|
|
'PersonalDriver', |
|
180
|
|
|
'CourseDriver', |
|
181
|
|
|
//'CourseUserDriver', |
|
182
|
|
|
//'HomeDriver' |
|
183
|
|
|
]; |
|
184
|
|
|
$connector->setDriverList($driverList); |
|
185
|
|
|
|
|
186
|
|
|
$operations = $connector->getOperations(); |
|
187
|
|
|
|
|
188
|
|
|
// Run elFinder |
|
189
|
|
|
ob_start(); |
|
190
|
|
|
$finder = new Finder($operations); |
|
191
|
|
|
$elFinderConnector = new ElFinderConnector($finder); |
|
192
|
|
|
$elFinderConnector->run(); |
|
193
|
|
|
$content = ob_get_contents(); |
|
194
|
|
|
|
|
195
|
|
|
return $this->render( |
|
196
|
|
|
'@ChamiloTheme/layout_empty.html.twig', |
|
197
|
|
|
['content' => $content] |
|
198
|
|
|
); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @Route("/config", methods={"GET"}, name="config_editor") |
|
203
|
|
|
* |
|
204
|
|
|
* @param SettingsManager $settingsManager |
|
205
|
|
|
* |
|
206
|
|
|
* @return Response |
|
207
|
|
|
*/ |
|
208
|
|
|
public function configEditorAction(SettingsManager $settingsManager) |
|
209
|
|
|
{ |
|
210
|
|
|
$moreButtonsInMaximizedMode = false; |
|
211
|
|
|
//$settingsManager = $this->get('chamilo.settings.manager'); |
|
212
|
|
|
|
|
213
|
|
|
if ($settingsManager->getSetting('editor.more_buttons_maximized_mode') === 'true') { |
|
214
|
|
|
$moreButtonsInMaximizedMode = true; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
return $this->render( |
|
218
|
|
|
'@ChamiloTheme/Editor/config_js.html.twig', |
|
219
|
|
|
[ |
|
220
|
|
|
// @todo replace api_get_bootstrap_and_font_awesome |
|
221
|
|
|
'bootstrap_css' => api_get_bootstrap_and_font_awesome(true), |
|
222
|
|
|
'css_editor' => ChamiloApi::getEditorBlockStylePath(), |
|
223
|
|
|
'more_buttons_in_max_mode' => $moreButtonsInMaximizedMode, |
|
224
|
|
|
] |
|
225
|
|
|
); |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|