|
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 FM\ElFinderPHP\Connector\ElFinderConnector; |
|
10
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
|
11
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
12
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class FrontController. |
|
17
|
|
|
* @Route("/front") |
|
18
|
|
|
* @deprecated not used for now |
|
19
|
|
|
* @package Chamilo\CoreBundle\Controller |
|
20
|
|
|
*/ |
|
21
|
|
|
class FrontController extends Controller |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Get templates (left column when creating a document). |
|
25
|
|
|
* |
|
26
|
|
|
* @Route("/editor/templates", name="editor_templates") |
|
27
|
|
|
* @Method({"GET"}) |
|
28
|
|
|
*/ |
|
29
|
|
|
public function editorTemplates() |
|
30
|
|
|
{ |
|
31
|
|
|
$editor = new CkEditor( |
|
32
|
|
|
$this->get('translator.default'), |
|
33
|
|
|
$this->get('router') |
|
34
|
|
|
); |
|
35
|
|
|
$templates = $editor->simpleFormatTemplates(); |
|
36
|
|
|
|
|
37
|
|
|
return $this->render( |
|
38
|
|
|
'@ChamiloCore/default/javascript/editor/ckeditor/templates.html.twig', |
|
39
|
|
|
['templates' => $templates] |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @Route("/editor/filemanager", name="editor_filemanager") |
|
45
|
|
|
* @Method({"GET"}) |
|
46
|
|
|
*/ |
|
47
|
|
|
public function editorFileManager(Request $request) |
|
48
|
|
|
{ |
|
49
|
|
|
\Chat::setDisableChat(); |
|
50
|
|
|
|
|
51
|
|
|
$courseId = $request->get('course_id'); |
|
52
|
|
|
$sessionId = $request->get('session_id'); |
|
53
|
|
|
|
|
54
|
|
|
return $this->render( |
|
55
|
|
|
'@ChamiloCore/default/javascript/editor/ckeditor/elfinder.html.twig', |
|
56
|
|
|
[ |
|
57
|
|
|
'course_id' => $courseId, |
|
58
|
|
|
'session_id' => $sessionId, |
|
59
|
|
|
] |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @Route("/editor/connector", name="editor_connector") |
|
65
|
|
|
* @Method({"GET|POST"}) |
|
66
|
|
|
*/ |
|
67
|
|
|
public function editorConnector(Request $request) |
|
68
|
|
|
{ |
|
69
|
|
|
error_reporting(-1); |
|
70
|
|
|
$courseId = $request->get('course_id'); |
|
71
|
|
|
$sessionId = $request->get('session_id'); |
|
72
|
|
|
|
|
73
|
|
|
$courseInfo = []; |
|
74
|
|
|
if (!empty($courseId)) { |
|
75
|
|
|
$courseInfo = api_get_course_info_by_id($courseId); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** @var Connector $connector */ |
|
79
|
|
|
$connector = new Connector( |
|
80
|
|
|
$this->container->get('doctrine')->getManager(), |
|
81
|
|
|
[], |
|
82
|
|
|
$this->get('router'), |
|
83
|
|
|
$this->container->get('translator.default'), |
|
84
|
|
|
$this->container->get('security.authorization_checker'), |
|
85
|
|
|
$this->getUser(), |
|
86
|
|
|
$courseInfo, |
|
87
|
|
|
$sessionId |
|
88
|
|
|
); |
|
89
|
|
|
|
|
90
|
|
|
$driverList = [ |
|
91
|
|
|
'PersonalDriver', |
|
92
|
|
|
'CourseDriver', |
|
93
|
|
|
//'CourseUserDriver', |
|
94
|
|
|
//'HomeDriver' |
|
95
|
|
|
]; |
|
96
|
|
|
$connector->setDriverList($driverList); |
|
97
|
|
|
|
|
98
|
|
|
$operations = $connector->getOperations(); |
|
99
|
|
|
|
|
100
|
|
|
// Run elFinder |
|
101
|
|
|
ob_start(); |
|
102
|
|
|
$finder = new Finder($operations); |
|
103
|
|
|
$elFinderConnector = new ElFinderConnector($finder); |
|
104
|
|
|
$elFinderConnector->run(); |
|
105
|
|
|
$content = ob_get_contents(); |
|
106
|
|
|
|
|
107
|
|
|
return $this->render( |
|
108
|
|
|
'@ChamiloCore/layout_empty.html.twig', |
|
109
|
|
|
['content' => $content] |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @Route("/login") |
|
115
|
|
|
* @Method({"GET"}) |
|
116
|
|
|
*/ |
|
117
|
|
|
public function showLoginAction() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->render( |
|
120
|
|
|
'ChamiloCoreBundle:Security:only_login.html.twig', |
|
121
|
|
|
['error' => null] |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @Route("/config_editor", name="config_editor") |
|
127
|
|
|
* @Method({"GET"}) |
|
128
|
|
|
* |
|
129
|
|
|
* @return Response |
|
130
|
|
|
*/ |
|
131
|
|
|
public function configEditorAction() |
|
132
|
|
|
{ |
|
133
|
|
|
$moreButtonsInMaximizedMode = false; |
|
134
|
|
|
$settingsManager = $this->get('chamilo.settings.manager'); |
|
135
|
|
|
|
|
136
|
|
|
if ($settingsManager->getSetting('editor.more_buttons_maximized_mode') == 'true') { |
|
137
|
|
|
$moreButtonsInMaximizedMode = true; |
|
138
|
|
|
} |
|
139
|
|
|
$request = $this->get('request_stack')->getCurrentRequest(); |
|
140
|
|
|
$courseId = $request->get('course_id'); |
|
141
|
|
|
$sessionId = $request->get('session_id'); |
|
142
|
|
|
|
|
143
|
|
|
return $this->render( |
|
144
|
|
|
'ChamiloCoreBundle:default/javascript/editor/ckeditor:config_js.html.twig', |
|
145
|
|
|
[ |
|
146
|
|
|
'more_buttons_in_max_mode' => $moreButtonsInMaximizedMode, |
|
147
|
|
|
'course_id' => $courseId, |
|
148
|
|
|
'session_id' => $sessionId, |
|
149
|
|
|
] |
|
150
|
|
|
); |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|