From 955dbfaeef7c9249b59838c66c66d6c78cd6daf3 Mon Sep 17 00:00:00 2001 From: julmis Date: Sat, 16 Oct 2004 09:11:00 +0000 Subject: [PATCH] Adding hide buttons feature. --- admin/editor.html | 128 ++++++++++++++++++++++++++++++++++++++++------ admin/editor.php | 39 +++++++++----- lib/defaults.php | 1 + lib/weblib.php | 5 ++ 4 files changed, 143 insertions(+), 30 deletions(-) diff --git a/admin/editor.html b/admin/editor.html index 00a7a2c3c8..ea643afff6 100644 --- a/admin/editor.html +++ b/admin/editor.html @@ -1,8 +1,8 @@
- + - - + + - - + + - - + + - - + + - + - + - + - + + + + + - +

htmleditor:

htmleditor:

editorbackgroundcolor:

editorbackgroundcolor:

editorfontfamily:

editorfontfamily:

editorfontsize:

editorfontsize:

editorkillword:

editorkillword:

editorspelling:

editorspelling:

  - +
  - +

editorhidebuttons:

+ editorhidebuttons); + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" />
/> /> /> /> /> /> /> /> /> /> /> />
<?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" />
/> /> /> /> /> /> /> /> /> /> /> />
<?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /><?php print_string(" title="" /> 
/> /> /> /> /> /> /> /> /> /> /> 
+
">" />
- +
diff --git a/admin/editor.php b/admin/editor.php index 614fecb9ef..33502699fc 100644 --- a/admin/editor.php +++ b/admin/editor.php @@ -15,13 +15,13 @@ if ($data = data_submitted()) { // do we want default values? - if(isset($data->resettodefaults)) { - if(!(reset_to_defaults())) { + if (isset($data->resettodefaults)) { + if (!(reset_to_defaults())) { error("Editor settings could not be restored!"); } } else { - if(!(editor_update_config($data))) { + if (!(editor_update_config($data))) { error("Editor settings could not be updated!"); } } @@ -54,14 +54,14 @@ function editor_convert_to_array ($string) { /// Converts $CFG->editorfontlist to array - if(empty($string) || !is_string($string)) { + if (empty($string) || !is_string($string)) { return false; } $fonts = array(); $lines = explode(";", $string); - foreach($lines as $line) { - if(!empty($line)) { + foreach ($lines as $line) { + if (!empty($line)) { list($fontkey, $fontvalue) = explode(":", $line); $fonts[$fontkey] = $fontvalue; } @@ -73,7 +73,7 @@ function editor_convert_to_array ($string) { function editor_update_config ($data) { /// Updates the editor config values. - if(!is_object($data)) { + if (!is_object($data)) { return false; } @@ -88,8 +88,9 @@ function editor_update_config ($data) { $fontlist = ''; // make font string - for($i = 0; $i < count($data->fontname); $i++) { - if(!empty($data->fontname[$i])) { + $cnt = count($data->fontname); + for ($i = 0; $i < $cnt; $i++) { + if (!empty($data->fontname[$i])) { $fontlist .= str_replace($nochars, "", $data->fontname[$i]) .":"; $fontlist .= str_replace($nochars, "", $data->fontnamevalue[$i]) .";"; } @@ -106,8 +107,17 @@ function editor_update_config ($data) { $updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0; $updatedata['editorfontlist'] = $fontlist; - foreach($updatedata as $name => $value) { - if(!(set_config($name, $value))) { + $hidebuttons = ''; + if (!empty($data->buttons) && is_array($data->buttons)) { + foreach ($data->buttons as $key => $value) { + $hidebuttons .= $key . " "; + } + + $updatedata['editorhidebuttons'] = trim($hidebuttons); + } + + foreach ($updatedata as $name => $value) { + if (!(set_config($name, $value))) { return false; } } @@ -116,6 +126,8 @@ function editor_update_config ($data) { } function reset_to_defaults () { +/// Reset the values to default + global $CFG; include_once($CFG->dirroot .'/lib/defaults.php'); @@ -127,9 +139,10 @@ function reset_to_defaults () { $updatedata['editorkillword'] = $defaults['editorkillword']; $updatedata['editorspelling'] = $defaults['editorspelling']; $updatedata['editorfontlist'] = $defaults['editorfontlist']; + $updatedata['editorhidebuttons'] = $defaults['editorhidebuttons']; - foreach($updatedata as $name => $value) { - if(!(set_config($name, $value))) { + foreach ($updatedata as $name => $value) { + if (!(set_config($name, $value))) { return false; } } diff --git a/lib/defaults.php b/lib/defaults.php index 228e3562a9..697222bb53 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -26,6 +26,7 @@ 'editorkillword' => 1, 'editorspelling' => 0, 'editorfontlist' => 'Trebuchet:Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial:arial,helvetica,sans-serif;Courier New:courier new,courier,monospace;Georgia:georgia,times new roman,times,serif;Tahoma:tahoma,arial,helvetica,sans-serif;Times New Roman:times new roman,times,serif;Verdana:verdana,arial,helvetica,sans-serif;Impact:impact;Wingdings:wingdings', + 'editorhidebuttons' => '', 'filteruploadedfiles' => true, 'forcelogin' => false, 'forceloginforprofiles' => false, diff --git a/lib/weblib.php b/lib/weblib.php index a9ca3d10cd..a96283e846 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3374,6 +3374,11 @@ function print_side_block_end() { $i++; } echo '};'; + + if (!empty($CFG->editorhidebuttons)) { + echo "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n"; + } + if(!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) { print_speller_code($usehtmleditor=true); } -- 2.39.5