You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
4.3 KiB
156 lines
4.3 KiB
|
9 years ago
|
<?php
|
||
|
|
/* For licensing terms, see /license.txt */
|
||
|
|
|
||
|
|
namespace Chamilo\CoreBundle\Controller;
|
||
|
|
|
||
|
|
use Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor;
|
||
|
8 years ago
|
use Chamilo\CoreBundle\Component\Editor\Connector;
|
||
|
|
use Chamilo\CoreBundle\Component\Editor\Finder;
|
||
|
9 years ago
|
use FM\ElFinderPHP\Connector\ElFinderConnector;
|
||
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||
|
8 years ago
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||
|
9 years ago
|
use Symfony\Component\HttpFoundation\Request;
|
||
|
|
|
||
|
|
/**
|
||
|
8 years ago
|
* Class EditorController.
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @Route("/front")
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @deprecated not used for now
|
||
|
8 years ago
|
*
|
||
|
9 years ago
|
* @package Chamilo\CoreBundle\Controller
|
||
|
|
*/
|
||
|
8 years ago
|
class EditorController extends Controller
|
||
|
9 years ago
|
{
|
||
|
|
/**
|
||
|
8 years ago
|
* Get templates (left column when creating a document).
|
||
|
|
*
|
||
|
9 years ago
|
* @Route("/editor/templates", name="editor_templates")
|
||
|
|
* @Method({"GET"})
|
||
|
|
*/
|
||
|
|
public function editorTemplates()
|
||
|
|
{
|
||
|
|
$editor = new CkEditor(
|
||
|
8 years ago
|
$this->get('translator.default'),
|
||
|
|
$this->get('router')
|
||
|
9 years ago
|
);
|
||
|
|
$templates = $editor->simpleFormatTemplates();
|
||
|
|
|
||
|
|
return $this->render(
|
||
|
|
'@ChamiloCore/default/javascript/editor/ckeditor/templates.html.twig',
|
||
|
|
['templates' => $templates]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Route("/editor/filemanager", name="editor_filemanager")
|
||
|
|
* @Method({"GET"})
|
||
|
|
*/
|
||
|
|
public function editorFileManager(Request $request)
|
||
|
|
{
|
||
|
|
\Chat::setDisableChat();
|
||
|
|
|
||
|
|
$courseId = $request->get('course_id');
|
||
|
|
$sessionId = $request->get('session_id');
|
||
|
|
|
||
|
|
return $this->render(
|
||
|
9 years ago
|
'@ChamiloCore/default/javascript/editor/ckeditor/elfinder.html.twig',
|
||
|
|
[
|
||
|
9 years ago
|
'course_id' => $courseId,
|
||
|
8 years ago
|
'session_id' => $sessionId,
|
||
|
9 years ago
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Route("/editor/connector", name="editor_connector")
|
||
|
|
* @Method({"GET|POST"})
|
||
|
|
*/
|
||
|
|
public function editorConnector(Request $request)
|
||
|
|
{
|
||
|
|
error_reporting(-1);
|
||
|
|
$courseId = $request->get('course_id');
|
||
|
|
$sessionId = $request->get('session_id');
|
||
|
|
|
||
|
|
$courseInfo = [];
|
||
|
|
if (!empty($courseId)) {
|
||
|
|
$courseInfo = api_get_course_info_by_id($courseId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @var Connector $connector */
|
||
|
|
$connector = new Connector(
|
||
|
|
$this->container->get('doctrine')->getManager(),
|
||
|
|
[],
|
||
|
8 years ago
|
$this->get('router'),
|
||
|
9 years ago
|
$this->container->get('translator.default'),
|
||
|
|
$this->container->get('security.authorization_checker'),
|
||
|
|
$this->getUser(),
|
||
|
|
$courseInfo,
|
||
|
|
$sessionId
|
||
|
|
);
|
||
|
|
|
||
|
9 years ago
|
$driverList = [
|
||
|
9 years ago
|
'PersonalDriver',
|
||
|
|
'CourseDriver',
|
||
|
|
//'CourseUserDriver',
|
||
|
|
//'HomeDriver'
|
||
|
9 years ago
|
];
|
||
|
9 years ago
|
$connector->setDriverList($driverList);
|
||
|
|
|
||
|
|
$operations = $connector->getOperations();
|
||
|
|
|
||
|
|
// Run elFinder
|
||
|
|
ob_start();
|
||
|
|
$finder = new Finder($operations);
|
||
|
|
$elFinderConnector = new ElFinderConnector($finder);
|
||
|
|
$elFinderConnector->run();
|
||
|
|
$content = ob_get_contents();
|
||
|
|
|
||
|
|
return $this->render(
|
||
|
|
'@ChamiloCore/layout_empty.html.twig',
|
||
|
|
['content' => $content]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Route("/login")
|
||
|
|
* @Method({"GET"})
|
||
|
|
*/
|
||
|
|
public function showLoginAction()
|
||
|
|
{
|
||
|
|
return $this->render(
|
||
|
|
'ChamiloCoreBundle:Security:only_login.html.twig',
|
||
|
9 years ago
|
['error' => null]
|
||
|
9 years ago
|
);
|
||
|
|
}
|
||
|
8 years ago
|
|
||
|
|
/**
|
||
|
|
* @Route("/config_editor", name="config_editor")
|
||
|
|
* @Method({"GET"})
|
||
|
|
*
|
||
|
|
* @return Response
|
||
|
|
*/
|
||
|
|
public function configEditorAction()
|
||
|
|
{
|
||
|
|
$moreButtonsInMaximizedMode = false;
|
||
|
|
$settingsManager = $this->get('chamilo.settings.manager');
|
||
|
|
|
||
|
|
if ($settingsManager->getSetting('editor.more_buttons_maximized_mode') == 'true') {
|
||
|
|
$moreButtonsInMaximizedMode = true;
|
||
|
|
}
|
||
|
|
$request = $this->get('request_stack')->getCurrentRequest();
|
||
|
|
$courseId = $request->get('course_id');
|
||
|
|
$sessionId = $request->get('session_id');
|
||
|
|
|
||
|
|
return $this->render(
|
||
|
|
'ChamiloCoreBundle:default/javascript/editor/ckeditor:config_js.html.twig',
|
||
|
|
[
|
||
|
|
'more_buttons_in_max_mode' => $moreButtonsInMaximizedMode,
|
||
|
|
'course_id' => $courseId,
|
||
|
|
'session_id' => $sessionId,
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
9 years ago
|
}
|