Fix document edition

pull/2881/head
Julio Montoya 6 years ago
parent 2e1607c206
commit d63de1c0f3
  1. 13
      main/document/edit_document.php
  2. 2
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 16
      src/CoreBundle/Component/Editor/CkEditor/CkEditor.php
  4. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php
  5. 8
      src/CoreBundle/Component/Editor/Editor.php

@ -280,10 +280,6 @@ if ($is_allowed_to_edit) {
$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
$read_only_flag = empty($read_only_flag) ? 0 : 1;
if ($file_type != 'link') {
//$file_size = filesize($document_data['absolute_path']);
}
if ($read_only_flag == 0) {
if (!empty($content)) {
$node = $document->getResourceNode();
@ -300,14 +296,6 @@ if ($is_allowed_to_edit) {
$em->merge($node);
$em->flush();
}
} else {
if ($document_id) {
//update_existing_document($_course, $document_id, $file_size, $read_only_flag);
}
}
} else {
if ($document_id) {
//update_existing_document($_course, $document_id, $file_size, $read_only_flag);
}
}
@ -384,6 +372,7 @@ if ($owner_id == api_get_user_id() ||
// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
// This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
$defaults['content'] = str_replace('<!--[', '<!-- [', $content);
// HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
$showSystemFolders = api_get_course_setting('show_system_folders');
$condition = stripos($dir, '/HotPotatoes_files') === false;

@ -93,7 +93,7 @@ class FormValidator extends HTML_QuickForm
*/
$renderer->setElementTemplate($templateSimple, 'buttons_in_action');
$templateSimpleRight = '<div class="form-actions"> <div class="float-right">{label} {element}</div></div>';
$templateSimpleRight = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
$renderer->setElementTemplate($templateSimpleRight, 'buttons_in_action_right');
}

@ -16,12 +16,14 @@ class CkEditor extends Editor
/**
* Return the HTML code required to run editor.
*
* @param string $value
*
* @return string
*/
public function createHtml()
public function createHtml($value)
{
$html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'" class="ckeditor">
'.$this->value.'
'.$value.'
</textarea>';
$html .= $this->editorReplace();
@ -31,18 +33,22 @@ class CkEditor extends Editor
/**
* Return the HTML code required to run editor.
*
* @param string $value
*
* @return string
*/
public function createHtmlStyle()
public function createHtmlStyle($value): string
{
$style = '';
if (trim($this->value) === '<html><head><title></title></head><body></body></html>' || $this->value === '') {
$value = trim($value);
if ($value === '' || $value === '<html><head><title></title></head><body></body></html>') {
$style = api_get_bootstrap_and_font_awesome();
$style .= api_get_css(ChamiloApi::getEditorDocStylePath());
}
$html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'" class="ckeditor">
'.$style.htmlspecialchars($this->value, ENT_COMPAT).'
'.$style.$value.'
</textarea>';
$html .= $this->editorReplace();

@ -124,10 +124,10 @@ class Documents extends Basic
[
api_get_configuration_value('translate_html') ? 'Language' : '',
'ShowBlocks',
'Source',
],
api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
['Toolbarswitch'],
['Source'],
];
}
}

@ -88,11 +88,13 @@ class Editor
/**
* Return the HTML code required to run editor.
*
* @param string $value
*
* @return string
*/
public function createHtml()
public function createHtml($value)
{
$html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'">'.$this->value.'</textarea>';
$html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'">'.$value.'</textarea>';
return $html;
}
@ -113,7 +115,7 @@ class Editor
*/
public function getConfigAttribute($key)
{
return $this->config[$key] ?? null;
return isset($this->config[$key]) ? $this->config[$key] : null;
}
/**

Loading…
Cancel
Save