Add FCKEditor for add extra content to admin panels - refs BT#9325

1.9.x
Angel Fernando Quiroz Campos 11 years ago
parent 32b72aff69
commit 8cf85ce7c6
  1. 45
      main/admin/index.php
  2. 2
      main/inc/ajax/admin.ajax.php
  3. 50
      main/inc/lib/fckeditor/toolbars/default/admin_panels.php
  4. 34
      main/inc/lib/fckeditor/toolbars/extended/admin_panels.php
  5. 22
      main/template/default/admin/settings_index.tpl

@ -399,6 +399,51 @@ if ($useCookieValidation) {
$tpl->assign('web_admin_ajax_url', $admin_ajax_url);
$tpl->assign('blocks', $blocks);
if (api_is_platform_admin()) {
$extraDataForm = new FormValidator(
'block_extra_data',
'post',
'#',
null,
array(
'id' => 'block-extra-data',
'class' => 'form-inline'
)
);
$extraDataForm->add_html_editor(
'extra_content',
null,
false,
false,
array(
'name' => 'extra-content',
'ToolbarSet' => 'AdminPanels',
'Width' => 530,
'Height' => 300
)
);
$extraDataForm->addElement(
'hidden',
'block',
null,
array(
'id' => 'extra-block'
)
);
$extraDataForm->add_button(
'submit',
get_lang('Save'),
array(
'id' => 'btn-block-editor-save',
'class' => 'btn btn-primary'
)
);
$tpl->assign('extraDataForm', $extraDataForm->toHtml());
}
// The template contains the call to the AJAX version checker
$admin_template = $tpl->get_template('admin/settings_index.tpl');
$content = $tpl->fetch($admin_template);

@ -37,7 +37,7 @@ switch ($action) {
break;
case 'save_block_extra':
$content = isset($_POST['content']) ? Security::remove_XSS($_POST['content']) : null;
$content = isset($_POST['extra_content']) ? Security::remove_XSS($_POST['extra_content']) : null;
$blockName = isset($_POST['block']) ? Security::remove_XSS($_POST['block']) : null;
if (empty($blockName)) {

@ -0,0 +1,50 @@
<?php
/* For licensing terms, see /license.txt */
/**
* AdminPanels FCKEditor's toolbar
* For more information: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo
*/
// Hide/show SpellCheck buttom
if ((api_get_setting('allow_spellcheck') == 'true')) {
$VSpellCheck = 'SpellCheck';
} else {
$VSpellCheck = '';
}
// This is the visible toolbar set when the editor has "normal" size.
$config['ToolbarSets']['Normal'] = array(
array('NewPage', '-', 'PasteWord'),
array('Undo', 'Redo'),
array('Link', 'Image', 'flvPlayer', 'Flash', 'MP3', 'mimetex'),
'/',
array('Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'),
array('UnorderedList', 'OrderedList', 'Rule'),
array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull'),
array('FontFormat', 'FontName', 'FontSize'),
array('FitWindow')
);
// Sets whether the toolbar can be collapsed/expanded or not.
// Possible values: true , false
$config['ToolbarCanCollapse'] = true;
// Sets how the editor's toolbar should start - expanded or collapsed.
// Possible values: true , false
$config['ToolbarStartExpanded'] = false;
//This option sets the location of the toolbar.
// Possible values: 'In' , 'None' , 'Out:[TargetId]' , 'Out:[TargetWindow]([TargetId])'
//$config['ToolbarLocation'] = 'In';
// A setting for blocking copy/paste functions of the editor.
// This setting activates on leaners only. For users with other statuses there is no blocking copy/paste.
// Possible values: true , false
//$config['BlockCopyPaste'] = false;
// Here new width and height of the editor may be set.
// Possible values, examples: 300 , '250' , '100%' , ...
//$config['Width'] = '100%';
//$config['Height'] = '400';

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* AdminPanels FCKEditor's toolbar
* For more information: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo
*/
// Hide/show SpellCheck buttom
if ((api_get_setting('allow_spellcheck') == 'true')) {
$VSpellCheck = 'SpellCheck';
} else {
$VSpellCheck = '';
}
// This is the visible toolbar set when the editor is maximized.
// If it has not been defined, then the toolbar set for the "normal" size is used.
$config['ToolbarSets']['Maximized'] = array(
array('NewPage', '-', 'Preview', 'Print'),
array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteWord'),
array('Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'),
array('Link', 'Unlink', 'Anchor', 'Glossary'),
array('Image', 'imgmapPopup', 'flvPlayer', 'EmbedMovies', 'YouTube', 'Flash', 'MP3', 'googlemaps', 'Smiley', 'SpecialChar', 'insertHtml', 'mimetex', 'asciimath', 'asciisvg', 'fckeditor_wiris_openFormulaEditor', 'fckeditor_wiris_openCAS'),
'/',
array('TableOC', 'Table', 'TableInsertRowAfter', 'TableDeleteRows', 'TableInsertColumnAfter', 'TableDeleteColumns', 'TableInsertCellAfter', 'TableDeleteCells', 'TableMergeCells', 'TableHorizontalSplitCell', 'TableVerticalSplitCell', 'TableCellProp', '-', 'CreateDiv'),
array('UnorderedList', 'OrderedList', 'Rule', '-', 'Outdent', 'Indent', 'Blockquote'),
array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull'),
array('Bold', 'Italic', 'Underline', 'StrikeThrough', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'),
array($VSpellCheck),
array('Style', 'FontFormat', 'FontName', 'FontSize'),
array('PageBreak', 'ShowBlocks', 'Source'),
array('FitWindow')
);

@ -7,6 +7,8 @@ $(document).ready(function() {
}
});
{% if _u.is_admin %}
(function(){
$('.edit-block a').on('click', function(e) {
e.preventDefault();
@ -21,7 +23,7 @@ $(document).ready(function() {
});
$.when(extraContent).done(function(content) {
$('#extra-content').val(content);
FCKeditorAPI.GetInstance('extra_content').SetData(content);
$('#extra-block').val($self.data('id'));
$('#modal-extra-title').text($self.data('label'));
@ -32,15 +34,23 @@ $(document).ready(function() {
$('#btn-block-editor-save').on('click', function(e) {
e.preventDefault();
var formParams = $.param({
a: 'save_block_extra',
extra_content: FCKeditorAPI.GetInstance('extra_content').GetHTML(),
block: $('#extra-block').val()
});
var save = $.ajax('{{ _p.web_ajax }}admin.ajax.php', {
type: 'post',
data: $('#block-extra-data').serialize() + '&a=save_block_extra'
data: formParams
});
$.when(save).done(function() {
window.location.reload();
});
});
})();
{% endif %}
});
</script>
@ -94,13 +104,7 @@ $(document).ready(function() {
<h3 id="modal-extra-title">{{ 'Blocks' | get_lang }}</h3>
</div>
<div class="modal-body">
<form action="#" method="post" id="block-extra-data">
<textarea rows="5" name="content" class="input-block-level" id="extra-content"></textarea>
<input type="hidden" name="block" id="extra-block" value="">
</form>
</div>
<div class="modal-footer">
<button id="btn-block-editor-save" class="btn btn-primary">{{ 'Save' | get_lang }}</button>
{{ extraDataForm }}
</div>
</div>
{% endif %}

Loading…
Cancel
Save