diff --git a/main/document/create_document.php b/main/document/create_document.php
index f0708f39c9..fa7e61b42c 100644
--- a/main/document/create_document.php
+++ b/main/document/create_document.php
@@ -218,7 +218,7 @@ $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
// Create a new form
$form = new FormValidator('create_document', 'post', api_get_self().'?'.api_get_cidreq().'&dir='.Security::remove_XSS(
urlencode($dir)
-).'&selectcat='.$select_cat, null, array('class' => 'form-vertical'));
+).'&selectcat='.$select_cat, null, array('class' => 'form-horizontal'));
// form title
$form->addElement('header', $nameTools);
@@ -254,13 +254,13 @@ function document_exists($filename)
// Add group to the form
if ($is_certificate_mode) {
- $form->addElement('text', 'title', get_lang('CertificateName'), 'class="span4" id="document_title"');
+ $form->addElement('text', 'title', get_lang('CertificateName'), array('id' => 'document_title'));
} else {
- $form->addElement('text', 'title', get_lang('Title'), 'class="span4" id="document_title"');
+ $form->addElement('text', 'title', get_lang('Title'), array('id' => 'document_title'));
}
// Show read-only box only in groups
-if (!empty($_SESSION['_gid'])) {
+if (!empty(api_get_group_id())) {
$group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
@@ -642,15 +642,6 @@ if ($form->validate()) {
$create_certificate = get_lang('CreateCertificateWithTags');
Display::display_normal_message($create_certificate.':
'.$str_info, false);
}
- // HTML-editor
- echo '
-
-
-
- '.$form->return_form().'
-
-
';
+ echo $form->return_form();
Display :: display_footer();
}
diff --git a/main/document/edit_document.php b/main/document/edit_document.php
index b4e8afd668..4fb4159a05 100644
--- a/main/document/edit_document.php
+++ b/main/document/edit_document.php
@@ -416,7 +416,7 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin(
) || $is_allowed_to_edit || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id())
) {
$action = api_get_self().'?id='.$document_data['id'];
- $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
+ $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-horizontal'));
// Form title
$form->addElement('header', $nameTools);
@@ -453,20 +453,16 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin(
}
if (!$group_document && !is_my_shared_folder(api_get_user_id(), $my_cur_dir_path, $current_session_id)) {
- $metadata_link = ''.get_lang('AddMetadata').'';
+ $metadata_link = ''.get_lang('AddMetadata').'';
- //Updated on field
+ // Updated on field
$last_edit_date = api_get_local_time($last_edit_date);
- $display_date = date_to_str_ago($last_edit_date).' '.api_format_date(
- $last_edit_date
- ).'';
- $form->addElement('static', null, get_lang('Metadata'), $metadata_link);
- $form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
+ $display_date = date_to_str_ago($last_edit_date).' '.api_format_date($last_edit_date).'';
+ $form->addElement('label', get_lang('Metadata'), $metadata_link);
+ $form->addElement('label', get_lang('UpdatedOn'), $display_date);
}
- $form->addElement('textarea', 'comment', get_lang('Comment'), 'rows="3" style="width:300px;"');
+ $form->addElement('textarea', 'comment', get_lang('Comment'));
if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
@@ -476,9 +472,9 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin(
}
if ($is_certificate_mode) {
- $form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), 'class="save"');
+ $form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), array('class' => 'save'));
} else {
- $form->addElement('style_submit_button', 'submit', get_lang('SaveDocument'), 'class="save"');
+ $form->addElement('style_submit_button', 'submit', get_lang('SaveDocument'), array('class' => 'save'));
}
$defaults['filename'] = $filename;
@@ -510,15 +506,8 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin(
if ($extension == 'svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
}
- echo '
-
-
-
- '.$form->return_form().'
-
-
';
+
+ echo $form->return_form();
}
Display::display_footer();
diff --git a/main/inc/Entity/SystemTemplate.php b/main/inc/Entity/SystemTemplate.php
new file mode 100644
index 0000000000..b7e7afc8b7
--- /dev/null
+++ b/main/inc/Entity/SystemTemplate.php
@@ -0,0 +1,154 @@
+id;
+ }
+
+ /**
+ * Set title
+ *
+ * @param string $title
+ * @return SystemTemplate
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * Get title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Set comment
+ *
+ * @param string $comment
+ * @return SystemTemplate
+ */
+ public function setComment($comment)
+ {
+ $this->comment = $comment;
+
+ return $this;
+ }
+
+ /**
+ * Get comment
+ *
+ * @return string
+ */
+ public function getComment()
+ {
+ return $this->comment;
+ }
+
+ /**
+ * Set image
+ *
+ * @param string $image
+ * @return SystemTemplate
+ */
+ public function setImage($image)
+ {
+ $this->image = $image;
+
+ return $this;
+ }
+
+ /**
+ * Get image
+ *
+ * @return string
+ */
+ public function getImage()
+ {
+ return $this->image;
+ }
+
+ /**
+ * Set content
+ *
+ * @param string $content
+ * @return SystemTemplate
+ */
+ public function setContent($content)
+ {
+ $this->content = $content;
+
+ return $this;
+ }
+
+ /**
+ * Get content
+ *
+ * @return string
+ */
+ public function getContent()
+ {
+ return $this->content;
+ }
+}
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index 1e6d16d3e0..50f02ca301 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -274,6 +274,7 @@ define('WEB_DATA_PATH', 'WEB_DATA_PATH');
define('REL_DATA_PATH', 'REL_DATA_PATH');
define('SYS_DEFAULT_COURSE_DOCUMENT_PATH', 'SYS_DEFAULT_COURSE_DOCUMENT_PATH');
+define('REL_DEFAULT_COURSE_DOCUMENT_PATH', 'REL_DEFAULT_COURSE_DOCUMENT_PATH');
define('WEB_DEFAULT_COURSE_DOCUMENT_PATH', 'WEB_DEFAULT_COURSE_DOCUMENT_PATH');
// Constants for requesting path conversion.
@@ -635,13 +636,17 @@ function api_get_path($path_type, $path = null) {
$paths[WEB_COURSE_PATH] = $root_web.$course_folder;
$paths[WEB_DATA_COURSE_PATH] = $paths[WEB_DATA_PATH].$course_folder;
- $paths[WEB_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[WEB_DATA_PATH].'default_course_document/';
-
$paths[REL_COURSE_PATH] = $root_rel.$course_folder;
$paths[REL_CODE_PATH] = $root_rel.$code_folder;
$paths[WEB_CODE_PATH] = $root_web.$code_folder;
$paths[REL_DATA_PATH] = $root_rel.'data/';
+
+ $paths[WEB_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[WEB_DATA_PATH].'default_course_document/';
+
+ $paths[REL_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[REL_DATA_PATH].'default_course_document/';
+
+
$paths[SYS_CODE_PATH] = $root_sys.$code_folder;
// Now we can switch into api_get_path() "terminology".
diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php
index 16b74ffba6..38cb77d58d 100644
--- a/main/inc/lib/template.lib.php
+++ b/main/inc/lib/template.lib.php
@@ -528,7 +528,6 @@ class Template
$js_file_to_string .= $this->fetch($this->app['template_style'].'/mail_editor/email_link.js.tpl');
}
-
if (!$disable_js_and_css_files) {
$this->assign('js_file_to_string', $js_file_to_string);
@@ -901,7 +900,7 @@ class Template
*/
public function getNavigationLinks()
{
- // Deleting the myprofile link.
+ // Deleting the my profile link.
if (api_get_setting('allow_social_tool') == 'true') {
unset($this->menu_navigation['myprofile']);
}
@@ -912,7 +911,7 @@ class Template
* @param string $layout
* @return mixed
*/
- public function render_layout($layout = null)
+ public function renderLayout($layout = null)
{
if (empty($layout)) {
$layout = $this->app['default_layout'];
@@ -921,15 +920,26 @@ class Template
return $this->app['twig']->render($this->app['template_style'].'/layout/'.$layout);
}
+
+ /**
+ * @param string $layout
+ * @deprecated use renderLayout
+ * @return mixed
+ */
+ public function render_layout($layout = null)
+ {
+ return $this->renderLayout($layout);
+ }
+
/**
* @param string $template
* @param array $elements
+ * @deprecated use renderTemplate
* @return mixed
*/
public function render_template($template, $elements = array())
{
- $this->addJsFiles();
- return $this->app['twig']->render($this->app['template_style'].'/'.$template, $elements);
+ return $this->returnTemplate($template, $elements);
}
/**
@@ -939,7 +949,8 @@ class Template
*/
public function renderTemplate($template, $elements = array())
{
- return $this->render_template($template, $elements);
+ $this->addJsFiles();
+ return $this->app['twig']->render($this->app['template_style'].'/'.$template, $elements);
}
/**
diff --git a/main/inc/routes.php b/main/inc/routes.php
index 2c547f8b2e..552445c06d 100644
--- a/main/inc/routes.php
+++ b/main/inc/routes.php
@@ -575,15 +575,17 @@ $app->match('/learnpath/subscribe_users/{lpId}', 'learnpath.controller:indexActi
/** Data document_templates files */
$app->get('/data/document_templates/{file}', 'index.controller:getDocumentTemplateAction')
- ->bind('data');
+ ->bind('get_document_template_action');
/** Data default_platform_document files */
$app->get('/data/default_platform_document/{file}', 'index.controller:getDefaultPlatformDocumentAction')
+ ->bind('get_default_platform_document_action')
->assert('file', '.+')
->assert('type', '.+');
/** Data default_platform_document files */
$app->get('/data/default_course_document/{file}', 'index.controller:getDefaultCourseDocumentAction')
+ ->bind('get_default_course_document_action')
->assert('file', '.+')
->assert('type', '.+');
@@ -639,15 +641,6 @@ $app->match('/admin/questionmanager/categories/new', 'question_manager.controlle
$app->match('/admin/questionmanager/categories/{id}/delete', 'question_manager.controller:deleteCategoryAction', 'POST')
->bind('admin_category_delete');
-/** Editor */
-$app->match('/editor/filemanager', 'editor.controller:filemanagerAction', 'GET|POST')
- ->assert('type', '.+')
- ->bind('filemanager');
-
-$app->match('/editor/connector', 'editor.controller:connectorAction', 'GET|POST')
- ->assert('type', '.+')
- ->bind('editor_connector');
-
/** Exercises */
$app->match('courses/{cidReq}/{id_session}/exercise/question-pool', 'exercise_manager.controller:questionPoolAction', 'POST')
->before($settingCourseConditions)
@@ -721,6 +714,17 @@ $app->match('/ajax', 'model_ajax.controller:indexAction', 'GET')
->assert('type', '.+')
->bind('model_ajax');
+
+/** Editor */
+$app->match('/editor/filemanager', 'editor.controller:filemanagerAction', 'GET|POST')
+ ->assert('type', '.+')
+ ->bind('filemanager');
+
+$app->match('/editor/connector', 'editor.controller:connectorAction', 'GET|POST')
+ ->assert('type', '.+')
+ ->bind('editor_connector');
+
+
if ($alreadyInstalled) {
$app->mount('/admin/', new ChamiloLMS\Provider\ReflectionControllerProvider('admin.controller'));
$app->mount('/admin/administrator/upgrade', new ChamiloLMS\Provider\ReflectionControllerProvider('upgrade.controller'));
@@ -728,9 +732,10 @@ if ($alreadyInstalled) {
$app->mount('/admin/administrator/question_scores', new ChamiloLMS\Provider\ReflectionControllerProvider('question_score.controller'));
$app->mount('/admin/administrator/question_score_names', new ChamiloLMS\Provider\ReflectionControllerProvider('question_score_name.controller'));
+ $app->mount('/editor/', new ChamiloLMS\Provider\ReflectionControllerProvider('editor.controller'));
$app->mount('/user/', new ChamiloLMS\Provider\ReflectionControllerProvider('profile.controller'));
- $app->mount('/', new ChamiloLMS\Provider\ReflectionControllerProvider('user.controller'));
+ $app->mount('/user/', new ChamiloLMS\Provider\ReflectionControllerProvider('profile.controller'));
$app->mount('/courses/{course}/curriculum/category', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_category.controller'));
$app->mount('/courses/{course}/curriculum/item', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_item.controller'));
diff --git a/main/inc/services.php b/main/inc/services.php
index 571cdb7d2a..64cbadde09 100644
--- a/main/inc/services.php
+++ b/main/inc/services.php
@@ -742,7 +742,7 @@ $app['news.controller'] = $app->share(
$app['editor.controller'] = $app->share(
function () use ($app) {
- return new ChamiloLMS\Controller\EditorController();
+ return new ChamiloLMS\Controller\EditorController($app);
}
);
diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php
index 2e9f08a9c9..7f85452b8e 100644
--- a/main/newscorm/learnpath.class.php
+++ b/main/newscorm/learnpath.class.php
@@ -6651,8 +6651,8 @@ class learnpath
/**
* Displays a document by id
*
- * @param unknown_type $id
- * @return unknown
+ * @param int $id
+ * @return string
*/
public function display_document($id, $show_title = false, $iframe = true, $edit_link = false)
{
@@ -6667,10 +6667,8 @@ class learnpath
// TODO: Add a path filter.
if ($iframe) {
- $return .= '';
+ $url = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.str_replace('%2F', '/', urlencode($row_doc['path'])).'?'.api_get_cidreq();
+ $return .= '';
} else {
$return .= file_get_contents(api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$row_doc['path']);
}
diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php
index e154a2811d..9403a2c95d 100644
--- a/main/newscorm/lp_add_item.php
+++ b/main/newscorm/lp_add_item.php
@@ -23,78 +23,11 @@ include 'learnpath_functions.inc.php';
include 'resourcelinker.inc.php';
$language_file = 'learnpath';
+/** @var \learnpath $learnPath */
+$learnPath = $_SESSION['oLP'];
$htmlHeadXtra[] = '
-";
+ $htmlHeadXtra[] = "";
}
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_add_item.php');
@@ -162,15 +94,15 @@ if (!empty($gradebook) && $gradebook == 'view') {
}
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
-$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $_SESSION['oLP']->get_name());
+$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $learnPath->get_name());
switch ($type) {
case 'chapter':
- $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id(), 'name' => get_lang('NewStep'));
+ $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep'));
$interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewChapter'));
break;
case 'document':
- $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id(), 'name' => get_lang('NewStep'));
+ $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep'));
break;
default:
$interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewStep'));
@@ -183,7 +115,7 @@ if ($action == 'add_item' && $type == 'document' ) {
// Theme calls.
$show_learn_path = true;
-$lp_theme_css = $_SESSION['oLP']->get_theme();
+$lp_theme_css = $learnPath->get_theme();
Display::display_header(null, 'Path');
@@ -243,21 +175,15 @@ $(document).ready(function() {
/* DISPLAY SECTION */
-echo $_SESSION['oLP']->build_action_menu();
+echo $learnPath->build_action_menu();
echo '';
echo '';
//hide bar div
@@ -275,74 +201,74 @@ if (in_array($message, array('ItemUpdated'))) {
if (isset($new_item_id) && is_numeric($new_item_id)) {
switch ($type) {
case 'chapter':
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $_POST['type']);
+ echo $learnPath->display_manipulate($new_item_id, $_POST['type']);
Display::display_confirmation_message(get_lang('NewChapterCreated'));
break;
case TOOL_LINK:
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewLinksCreated'));
break;
case TOOL_STUDENTPUBLICATION:
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewStudentPublicationCreated'));
break;
case 'module':
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewModuleCreated'));
break;
case TOOL_QUIZ:
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewExerciseCreated'));
break;
case TOOL_DOCUMENT:
Display::display_confirmation_message(get_lang('NewDocumentCreated'));
- echo $_SESSION['oLP']->display_item($new_item_id);
+ echo $learnPath->display_item($new_item_id);
break;
case TOOL_FORUM:
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewForumCreated'));
break;
case 'thread':
- echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);
+ echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewThreadCreated'));
break;
}
} else {
switch ($type) {
case 'chapter':
- echo $_SESSION['oLP']->display_item_form($type, get_lang('EnterDataNewChapter'));
+ echo $learnPath->display_item_form($type, get_lang('EnterDataNewChapter'));
break;
case 'module':
- echo $_SESSION['oLP']->display_item_form($type, get_lang('EnterDataNewModule'));
+ echo $learnPath->display_item_form($type, get_lang('EnterDataNewModule'));
break;
case 'document':
if (isset($_GET['file']) && is_numeric($_GET['file'])) {
- echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
+ echo $learnPath->display_document_form('add', 0, $_GET['file']);
} else {
- echo $_SESSION['oLP']->display_document_form('add', 0);
+ echo $learnPath->display_document_form('add', 0);
}
break;
case 'hotpotatoes':
- echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']);
+ echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']);
break;
case 'quiz':
echo Display::display_warning_message(get_lang('ExerciseCantBeEditedAfterAddingToTheLP'));
- echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
+ echo $learnPath->display_quiz_form('add', 0, $_GET['file']);
break;
case 'forum':
- echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
+ echo $learnPath->display_forum_form('add', 0, $_GET['forum_id']);
break;
case 'thread':
- echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
+ echo $learnPath->display_thread_form('add', 0, $_GET['thread_id']);
break;
case 'link':
- echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
+ echo $learnPath->display_link_form('add', 0, $_GET['file']);
break;
case 'student_publication':
- echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
+ echo $learnPath->display_student_publication_form('add', 0, $_GET['file']);
break;
case 'step':
- $_SESSION['oLP']->display_resources();
+ $learnPath->display_resources();
break;
}
}
diff --git a/main/template/default/javascript/editor/ckeditor/elfinder.tpl b/main/template/default/javascript/editor/ckeditor/elfinder.tpl
index afda5edb79..6c6675441e 100644
--- a/main/template/default/javascript/editor/ckeditor/elfinder.tpl
+++ b/main/template/default/javascript/editor/ckeditor/elfinder.tpl
@@ -22,7 +22,7 @@
$().ready(function() {
var funcNum = getUrlParam('CKEditorFuncNum');
var elf = $('#elfinder').elfinder({
- url : '{{ url('editor_connector') }}', // connector URL (REQUIRED)
+ url : '{{ url('editor.controller:connectorAction') }}', // connector URL (REQUIRED)
getFileCallback : function(file) {
window.opener.CKEDITOR.tools.callFunction(funcNum, file);
window.close();
diff --git a/main/template/default/javascript/editor/ckeditor/templates.tpl b/main/template/default/javascript/editor/ckeditor/templates.tpl
new file mode 100644
index 0000000000..5bbf1df89d
--- /dev/null
+++ b/main/template/default/javascript/editor/ckeditor/templates.tpl
@@ -0,0 +1,6 @@
+CKEDITOR.addTemplates("default",
+{
+ imagesPath: ' ',
+ templates:
+ {{ templates }}
+});
\ No newline at end of file
diff --git a/main/template/default/javascript/editor/tinymce/elfinder.tpl b/main/template/default/javascript/editor/tinymce/elfinder.tpl
index 89f4846553..010516631f 100644
--- a/main/template/default/javascript/editor/tinymce/elfinder.tpl
+++ b/main/template/default/javascript/editor/tinymce/elfinder.tpl
@@ -29,7 +29,7 @@
$().ready(function() {
var elf = $('#elfinder').elfinder({
// set your elFinder options here
- url : '{{ url('editor_connector') }}', // connector URL (REQUIRED)
+ url : '{{ url('editor.controller:connectorAction') }}', // connector URL (REQUIRED)
getFileCallback: function(file) { // editor callback
// actually file.url - doesnt work for me, but file does. (elfinder 2.0-rc1)
FileBrowserDialogue.mySubmit(file); // pass selected file path to TinyMCE
diff --git a/src/ChamiloLMS/Component/Editor/CkEditor/CkEditor.php b/src/ChamiloLMS/Component/Editor/CkEditor/CkEditor.php
index 40914276ed..96d52c2bf3 100644
--- a/src/ChamiloLMS/Component/Editor/CkEditor/CkEditor.php
+++ b/src/ChamiloLMS/Component/Editor/CkEditor/CkEditor.php
@@ -4,6 +4,7 @@ namespace ChamiloLMS\Component\Editor\CkEditor;
use ChamiloLMS\Component\Editor\Editor;
use ChamiloLMS\Component\Editor\CkEditor\Toolbar;
+use Symfony\Component\Routing\Generator\UrlGenerator;
/**
* Class CkEditor
@@ -59,4 +60,44 @@ class CkEditor extends Editor
return $html;
}
+
+ /**
+ * @param array
+ * @return null
+ */
+ public function formatTemplates($templates)
+ {
+ if (empty($templates)) {
+ return null;
+ }
+ /** @var \Entity\SystemTemplate $template */
+ $templateList = array();
+
+ $search = array('{CSS}', '{IMG_DIR}', '{REL_PATH}', '{COURSE_DIR}');
+ //$url = $this->urlGenerator->generate('get_document_template_action', array('file' => 'file'));
+ $replace = array(
+ '',
+ api_get_path(REL_CODE_PATH).'img/',
+ api_get_path(REL_PATH),
+ api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH),
+ api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH)
+ );
+
+ foreach ($templates as $template) {
+ $image = $template->getImage();
+ $image = !empty($image) ? $image : 'empty.gif';
+
+ $image = $this->urlGenerator->generate('get_document_template_action', array('file' => $image), UrlGenerator::ABSOLUTE_URL);
+
+ $content = str_replace($search, $replace, $template->getContent());
+
+ $templateList[] = array(
+ 'title' => $this->translator->trans($template->getTitle()),
+ 'description' => $this->translator->trans($template->getComment()),
+ 'image' => $image,
+ 'html' => $content
+ );
+ }
+ return json_encode($templateList);
+ }
}
diff --git a/src/ChamiloLMS/Component/Editor/CkEditor/Toolbar/Basic.php b/src/ChamiloLMS/Component/Editor/CkEditor/Toolbar/Basic.php
index 232a4e692a..2d16d66af8 100644
--- a/src/ChamiloLMS/Component/Editor/CkEditor/Toolbar/Basic.php
+++ b/src/ChamiloLMS/Component/Editor/CkEditor/Toolbar/Basic.php
@@ -56,6 +56,7 @@ class Basic extends Toolbar
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
$config['filebrowserBrowseUrl'] = api_get_path(WEB_PUBLIC_PATH).'editor/filemanager';
+ $config['templates_files'] = array(api_get_path(WEB_PUBLIC_PATH).'editor/templates');
/*filebrowserFlashBrowseUrl
filebrowserFlashUploadUrl
diff --git a/src/ChamiloLMS/Component/Editor/Editor.php b/src/ChamiloLMS/Component/Editor/Editor.php
index 1805f50ee2..97a4fa7f53 100644
--- a/src/ChamiloLMS/Component/Editor/Editor.php
+++ b/src/ChamiloLMS/Component/Editor/Editor.php
@@ -219,4 +219,20 @@ class Editor
}
}
}
+
+ /**
+ * @return null
+ */
+ public function getTemplate()
+ {
+ return null;
+ }
+
+ /**
+ * @return null
+ */
+ public function formatTemplates($templates)
+ {
+ return null;
+ }
}
diff --git a/src/ChamiloLMS/Controller/BaseController.php b/src/ChamiloLMS/Controller/BaseController.php
index f2cb89b939..2aa572e128 100644
--- a/src/ChamiloLMS/Controller/BaseController.php
+++ b/src/ChamiloLMS/Controller/BaseController.php
@@ -65,7 +65,15 @@ abstract class BaseController extends FlintController
*/
protected function getTemplate()
{
- return $this->app['template'];
+ return $this->get('template');
+ }
+
+ /**
+ * @return \ChamiloLMS\Component\Editor\Editor
+ */
+ protected function getHtmlEditor()
+ {
+ return $this->get('html_editor');
}
/**
diff --git a/src/ChamiloLMS/Controller/EditorController.php b/src/ChamiloLMS/Controller/EditorController.php
index 097347b539..66b9995b83 100644
--- a/src/ChamiloLMS/Controller/EditorController.php
+++ b/src/ChamiloLMS/Controller/EditorController.php
@@ -5,29 +5,46 @@ namespace ChamiloLMS\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
use ChamiloLMS\Component\Editor\Connector;
+use Symfony\Component\Routing\Annotation\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
+//use ChamiloLMS\Controller\CommonController;
+
+
/**
* @package ChamiloLMS.Controller
* @author Julio Montoya
*/
-class EditorController
+class EditorController extends CommonController
{
/**
- * @param Application $app
- * @return Response
+ * @Route("/filemanager")
+ * @Method({"GET"})
*/
- public function filemanagerAction(Application $app)
+ public function fileManagerAction()
{
- $response = $app['template']->render_template($app['html_editor']->getTemplate());
+ $response = $this->getTemplate()->renderTemplate($this->getHtmlEditor()->getTemplate());
+ return new Response($response, 200, array());
+ }
+
+ /**
+ * @Route("/templates")
+ * @Method({"GET"})
+ */
+ public function getTemplatesAction()
+ {
+ $templates = $this->getManager()->getRepository('Entity\SystemTemplate')->findAll();
+ $templates = $this->getHtmlEditor()->formatTemplates($templates);
+ $this->getTemplate()->assign('templates', $templates);
+ $response = $this->getTemplate()->renderTemplate('javascript/editor/ckeditor/templates.tpl');
return new Response($response, 200, array());
}
/**
- *
+ * @Route("/connector")
+ * @Method({"GET"})
*/
public function connectorAction()
{
@@ -45,4 +62,5 @@ class EditorController
$connector = new \elFinderConnector(new \elFinder($opts));
$connector->run();
}
+
}