MDL-5671 html editor can now be switched off on the fly while editing database templates

This commit is contained in:
skodak 2006-12-10 19:08:46 +00:00
parent 2840c21611
commit 0c097262c7
2 changed files with 19 additions and 2 deletions

View file

@ -61,6 +61,8 @@ $string['download'] = 'Download';
$string['edit'] = 'Edit'; $string['edit'] = 'Edit';
$string['editcomment'] = 'Edit comment'; $string['editcomment'] = 'Edit comment';
$string['editentry'] = 'Edit entry'; $string['editentry'] = 'Edit entry';
$string['editorenable'] = 'Enable editor';
$string['editordisable'] = 'Disable editor';
$string['emptyadd'] = 'The Add template is empty, generating a default form...'; $string['emptyadd'] = 'The Add template is empty, generating a default form...';
$string['emptyaddform'] = 'You did not fill out any fields!'; $string['emptyaddform'] = 'You did not fill out any fields!';
$string['entries'] = 'Entries'; $string['entries'] = 'Entries';

View file

@ -92,11 +92,17 @@
/// Processing submitted data, i.e updating form. /// Processing submitted data, i.e updating form.
$resettemplate = false; $resettemplate = false;
/// html editor is by default disabled
$editor = isset($SESSION->data_use_editor) ? $SESSION->data_use_editor : (can_use_html_editor() ? 1 : 0);
if (($mytemplate = data_submitted($CFG->wwwroot.'/mod/data/templates.php')) && confirm_sesskey()) { if (($mytemplate = data_submitted($CFG->wwwroot.'/mod/data/templates.php')) && confirm_sesskey()) {
$newtemplate->id = $data->id; $newtemplate->id = $data->id;
$newtemplate->{$mode} = $mytemplate->template; $newtemplate->{$mode} = $mytemplate->template;
if (!empty($mytemplate->defaultform)) { if (!empty($mytemplate->switcheditor)) {
$editor = $editor ? 0 : 1;
$SESSION->data_use_editor = $editor;
} else if (!empty($mytemplate->defaultform)) {
// Reset the template to default, but don't save yet. // Reset the template to default, but don't save yet.
$resettemplate = true; $resettemplate = true;
$data->{$mode} = data_generate_default_template($data, $mode, 0, false, false); $data->{$mode} = data_generate_default_template($data, $mode, 0, false, false);
@ -151,7 +157,7 @@
/// Add the HTML editor(s). /// Add the HTML editor(s).
$usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate'); $usehtmleditor = $editor && can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate');
if ($mode == 'listtemplate'){ if ($mode == 'listtemplate'){
// Print the list template header. // Print the list template header.
echo '<tr>'; echo '<tr>';
@ -198,6 +204,15 @@
} }
echo '</select>'; echo '</select>';
echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />'; echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />';
if (can_use_html_editor()) {
echo '<br /><br />';
if ($editor) {
$switcheditor = get_string('editordisable', 'data');
} else {
$switcheditor = get_string('editorenable', 'data');
}
echo '<input type="submit" name="switcheditor" value="'.s($switcheditor).'" />';
}
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';