Completed
Push — master ( 82664b...176635 )
by Julito
88:10 queued 58:03
created

FrontController::editorFileManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
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 FM\ElFinderPHP\Connector\ElFinderConnector;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\HttpFoundation\Response;
13
14
use Chamilo\CoreBundle\Component\Editor\Connector;
15
use Chamilo\CoreBundle\Component\Editor\Finder;
16
17
18
/**
19
 * Class FrontController
20
 * @package Chamilo\CoreBundle\Controller
21
 */
22
class FrontController extends Controller
23
{
24
    /**
25
     * Get templates (left column when creating a document)
26
     * @Route("/editor/templates", name="editor_templates")
27
     * @Method({"GET"})
28
     */
29
    public function editorTemplates()
30
    {
31
        $editor = new CkEditor(
32
            $this->container->get('translator.default'),
33
            $this->container->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
                'course_id' => $courseId,
57
                'session_id' => $sessionId
58
            ]
59
        );
60
    }
61
62
    /**
63
     * @Route("/editor/connector", name="editor_connector")
64
     * @Method({"GET|POST"})
65
     */
66
    public function editorConnector(Request $request)
67
    {
68
        error_reporting(-1);
69
        $courseId = $request->get('course_id');
70
        $sessionId = $request->get('session_id');
71
72
        $courseInfo = [];
73
        if (!empty($courseId)) {
74
            $courseInfo = api_get_course_info_by_id($courseId);
75
        }
76
77
        /** @var Connector $connector */
78
        $connector = new Connector(
79
            $this->container->get('doctrine')->getManager(),
80
            [],
81
            $this->container->get('router'),
82
            $this->container->get('translator.default'),
83
            $this->container->get('security.context'),
84
            $this->getUser(),
85
            $courseInfo
86
        );
87
88
        $driverList = array(
89
            'PersonalDriver',
90
            'CourseDriver',
91
            //'CourseUserDriver',
92
            //'HomeDriver'
93
        );
94
        $connector->setDriverList($driverList);
95
96
        $operations = $connector->getOperations();
97
98
        // Run elFinder
99
        ob_start();
100
        $finder = new Finder($operations);
101
        $elFinderConnector = new ElFinderConnector($finder);
102
        $elFinderConnector->run();
103
        $content = ob_get_contents();
104
105
        return $this->render(
106
            '@ChamiloCore/layout_empty.html.twig',
107
            ['content' => $content]
108
        );
109
    }
110
111
112
    /**
113
     * @Route("/login")
114
     * @Method({"GET"})
115
     */
116
    public function showLoginAction()
117
    {
118
        return $this->render(
119
            'ChamiloCoreBundle:Security:only_login.html.twig',
120
            array('error' => null)
121
        );
122
    }
123
124
}
125