Fixing ckeditor templates see #6173

1.10.x
Julio Montoya 12 years ago
parent a6492a81ed
commit cea8bb55c4
  1. 19
      main/document/create_document.php
  2. 33
      main/document/edit_document.php
  3. 154
      main/inc/Entity/SystemTemplate.php
  4. 9
      main/inc/lib/api.lib.php
  5. 23
      main/inc/lib/template.lib.php
  6. 27
      main/inc/routes.php
  7. 2
      main/inc/services.php
  8. 10
      main/newscorm/learnpath.class.php
  9. 134
      main/newscorm/lp_add_item.php
  10. 2
      main/template/default/javascript/editor/ckeditor/elfinder.tpl
  11. 6
      main/template/default/javascript/editor/ckeditor/templates.tpl
  12. 2
      main/template/default/javascript/editor/tinymce/elfinder.tpl
  13. 41
      src/ChamiloLMS/Component/Editor/CkEditor/CkEditor.php
  14. 1
      src/ChamiloLMS/Component/Editor/CkEditor/Toolbar/Basic.php
  15. 16
      src/ChamiloLMS/Component/Editor/Editor.php
  16. 10
      src/ChamiloLMS/Controller/BaseController.php
  17. 34
      src/ChamiloLMS/Controller/EditorController.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.': <br /><br/>'.$str_info, false);
}
// HTML-editor
echo '<div class="row-fluid" style="overflow:hidden">
<div id="template_col" class="span2" style="width:162px">
<div id="frmModel" style="overflow: visible;"></div>
</div>
<div id="hide_bar_template"></div>
<div id="doc_form" class="span9">
'.$form->return_form().'
</div>
</div>';
echo $form->return_form();
Display :: display_footer();
}

@ -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 = '<a href="../metadata/index.php?eid='.urlencode(
'Document.'.$document_data['id']
).'">'.get_lang('AddMetadata').'</a>';
$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>';
//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).' <span class="dropbox_date">'.api_format_date(
$last_edit_date
).'</span>';
$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).' <span class="dropbox_date">'.api_format_date($last_edit_date).'</span>';
$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 '<div class="row-fluid" style="overflow:hidden">
<div id="template_col" class="span2" style="width:162px">
<div id="frmModel" style="overflow: visible;"></div>
</div>
<div id="hide_bar_template"></div>
<div id="doc_form" class="span9">
'.$form->return_form().'
</div>
</div>';
echo $form->return_form();
}
Display::display_footer();

@ -0,0 +1,154 @@
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SystemTemplate
*
* @ORM\Table(name="system_template")
* @ORM\Entity
*/
class SystemTemplate
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=250, precision=0, scale=0, nullable=false, unique=false)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", precision=0, scale=0, nullable=false, unique=false)
*/
private $comment;
/**
* @var string
*
* @ORM\Column(name="image", type="string", length=250, precision=0, scale=0, nullable=false, unique=false)
*/
private $image;
/**
* @var string
*
* @ORM\Column(name="content", type="text", precision=0, scale=0, nullable=false, unique=false)
*/
private $content;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->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;
}
}

@ -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".

@ -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);
}
/**

@ -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'));

@ -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);
}
);

@ -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 .= '<iframe id="learnpath_preview_frame" frameborder="0" height="400" width="100%" scrolling="auto" src="'.api_get_path(
WEB_COURSE_PATH
).$_course['path'].'/document'.str_replace('%2F', '/', urlencode($row_doc['path'])).'?'.api_get_cidreq(
).'"></iframe>';
$url = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.str_replace('%2F', '/', urlencode($row_doc['path'])).'?'.api_get_cidreq();
$return .= '<iframe id="learnpath_preview_frame" frameborder="0" height="400" width="100%" scrolling="auto" src="'.$url.'"></iframe>';
} else {
$return .= file_get_contents(api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$row_doc['path']);
}

@ -23,78 +23,11 @@ include 'learnpath_functions.inc.php';
include 'resourcelinker.inc.php';
$language_file = 'learnpath';
/** @var \learnpath $learnPath */
$learnPath = $_SESSION['oLP'];
$htmlHeadXtra[] = '
<script>
var temp = false;
var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';
function FCKeditor_OnComplete( editorInstance ) {
editorInstance.Events.AttachEvent( \'OnSelectionChange\', check_for_title) ;
document.getElementById(\'frmModel\').innerHTML = "<iframe id=\'frame_template\' name=\'my_frame_template\' height=890px width=220px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
loaded = true;
}
function check_for_title() {
if (temp) {
// This functions shows that you can interact directly with the editor area
// DOM. In this way you have the freedom to do anything you want with it.
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(\'content_lp\') ;
// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;
var iLength ;
var contentText ;
var contentTextArray;
var bestandsnaamNieuw = "";
var bestandsnaamOud = "";
// The are two diffent ways to get the text (without HTML markups).
// It is browser specific.
if( document.all ) // If Internet Explorer.
{
contentText = oDOM.body.innerText ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
contentText = r.toString() ;
}
var index=contentText.indexOf("/*<![CDATA");
contentText=contentText.substr(0,index);
// Compose title if there is none
contentTextArray = contentText.split(\' \') ;
var x=0;
for(x=0; (x<5 && x<contentTextArray.length); x++) {
if(x < 4) {
bestandsnaamNieuw += contentTextArray[x] + \' \';
} else {
bestandsnaamNieuw += contentTextArray[x];
}
}
}
temp=true;
}
function InnerDialogLoaded() {
if (document.all) {
// if is iexplorer
var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
} else {
var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
}
return B.ClickFrame();
};'."\n".
$_SESSION['oLP']->get_js_dropdown_array() .
<script>'.$learnPath->get_js_dropdown_array() .
'function load_cbo(id){' ."\n" .
'if (!id) {return false;}'.
@ -129,8 +62,7 @@ $(function() {
/* Constants and variables */
//Already set in lp_controller.php
//$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// Already set in lp_controller.php
$isStudentView = isset($_REQUEST['isStudentView']) ? $_REQUEST['isStudentView'] : null;
$learnpath_id = isset($_REQUEST['lp_id']) ? intval($_REQUEST['lp_id']) : null;
@ -141,7 +73,7 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
// Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' && $type == 'learnpathitem') {
$htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
$htmlHeadXtra[] = "<script type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
}
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 '<div class="row" style="overflow:hidden">';
echo '<div id="lp_sidebar" class="col-md-4">';
echo $_SESSION['oLP']->return_new_tree(null, true);
echo $learnPath->return_new_tree(null, true);
$message = isset($_REQUEST['message']) ? $_REQUEST['message'] : null;
// Show the template list.
if ($type == 'document' && !isset($_GET['file'])) {
// Show the template list.
echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
}
echo '</div>';
//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;
}
}

@ -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();

@ -0,0 +1,6 @@
CKEDITOR.addTemplates("default",
{
imagesPath: ' ',
templates:
{{ templates }}
});

@ -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

@ -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);
}
}

@ -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

@ -219,4 +219,20 @@ class Editor
}
}
}
/**
* @return null
*/
public function getTemplate()
{
return null;
}
/**
* @return null
*/
public function formatTemplates($templates)
{
return null;
}
}

@ -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');
}
/**

@ -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 <gugli100@gmail.com>
*/
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();
}
}

Loading…
Cancel
Save