Skip to content
Browse files

Adding hide buttons feature.

  • Loading branch information...
1 parent f090961 commit 955dbfaeef7c9249b59838c66c66d6c78cd6daf3 julmis committed
Showing with 143 additions and 30 deletions.
  1. +111 −17 admin/editor.html
  2. +26 −13 admin/editor.php
  3. +1 −0 lib/defaults.php
  4. +5 −0 lib/weblib.php
View
128 admin/editor.html
@@ -1,8 +1,8 @@
<form method="post" action="<?php print($GLOBALS['ME']);?>">
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
+<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
<table border="0" cellpadding="4" cellspacing="2">
-<tr valign="top">
- <td align="right"><p>htmleditor:</td>
+<tr>
+ <td align="right" valign="top"><p>htmleditor:</p></td>
<td>
<?php
unset($options);
@@ -16,22 +16,22 @@
</td>
</tr>
<tr>
- <td align="right" valign="top">editorbackgroundcolor:</td>
- <td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>"></td>
+ <td align="right" valign="top"><p>editorbackgroundcolor:</p></td>
+ <td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>" /></td>
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
</tr>
<tr>
- <td align="right" valign="top">editorfontfamily:</td>
- <td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>"></td>
+ <td align="right" valign="top"><p>editorfontfamily:</p></td>
+ <td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>" /></td>
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
</tr>
<tr>
- <td align="right" valign="top">editorfontsize:</td>
- <td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>"></td>
+ <td align="right" valign="top"><p>editorfontsize:</p></td>
+ <td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>" /></td>
<td valign="top"><?php print_string("edhelpfontsize");?></td>
</tr>
<tr>
- <td align="right" valign="top">editorkillword:</td>
+ <td align="right" valign="top"><p>editorkillword:</p></td>
<td valign="top"><select name="killword">
<option value="1"<?php print(!$CFG->editorkillword)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
<option value="0"<?php print(!$CFG->editorkillword)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
@@ -39,7 +39,7 @@
<td valign="top"><?php print_string("edhelpcleanword");?></td>
</tr>
<tr>
- <td align="right" valign="top">editorspelling:</td>
+ <td align="right" valign="top"><p>editorspelling:</p></td>
<td valign="top"><select name="spelling"<?php
if (empty($CFG->aspellpath)) {
echo " disabled=\"disabled\"";
@@ -58,8 +58,8 @@
?>
<tr>
<td>&nbsp;</td>
- <td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>">
- <input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>"></td>
+ <td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>" />
+ <input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>" /></td>
</tr>
<?php
}
@@ -67,17 +67,111 @@
?>
<tr>
<td>&nbsp;</td>
- <td colspan="2"><input type="text" name="fontname[]" size="15" value="">
- <input type="text" name="fontnamevalue[]" size="30" value=""></td>
+ <td colspan="2"><input type="text" name="fontname[]" size="15" value="" />
+ <input type="text" name="fontnamevalue[]" size="30" value="" /></td>
+</tr>
+<tr>
+ <td valign="top" align="right"><p>editorhidebuttons:</p></td>
+ <td colspan="2">
+ <?php
+ $buttons = explode(chr(32), $CFG->editorhidebuttons);
+ ?>
+ <table border="0" cellpadding="2" cellspacing="1">
+ <tr>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_bold.gif" width="18" height="18" alt="<?php print_string("bold","editor");?>" title="<?php print_string("bold","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_italic.gif" width="18" height="18" alt="<?php print_string("italic","editor");?>" title="<?php print_string("italic","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_underline.gif" width="18" height="18" alt="<?php print_string("underline","editor");?>" title="<?php print_string("underline","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_strike.gif" width="18" height="18" alt="<?php print_string("strikethrough","editor");?>" title="<?php print_string("strikethrough","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_sub.gif" width="18" height="18" alt="<?php print_string("subscript","editor");?>" title="<?php print_string("subscript","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_format_sup.gif" width="18" height="18" alt="<?php print_string("superscript","editor");?>" title="<?php print_string("superscript","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_copy.gif" width="18" height="18" alt="<?php print_string("copy","editor");?>" title="<?php print_string("copy","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_cut.gif" width="18" height="18" alt="<?php print_string("cut","editor");?>" title="<?php print_string("cut","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_paste.gif" width="18" height="18" alt="<?php print_string("paste","editor");?>" title="<?php print_string("paste","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_wordclean.gif" width="18" height="18" alt="<?php print_string("wordclean","editor");?>" title="<?php print_string("wordclean","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_undo.gif" width="18" height="18" alt="<?php print_string("undo","editor");?>" title="<?php print_string("undo","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_redo.gif" width="18" height="18" alt="<?php print_string("redo","editor");?>" title="<?php print_string("redo","editor");?>" /></td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="buttons[bold]"<?php print(in_array("bold", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[italic]"<?php print(in_array("italic", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[underline]"<?php print(in_array("underline", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[strikethrough]"<?php print(in_array("strikethrough", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[subscript]"<?php print(in_array("subscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[superscript]"<?php print(in_array("superscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[copy]"<?php print(in_array("copy", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[cut]"<?php print(in_array("cut", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[paste]"<?php print(in_array("paste", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[clean]"<?php print(in_array("clean", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[undo]"<?php print(in_array("undo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[redo]"<?php print(in_array("redo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ </tr>
+ <tr>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_align_left.gif" width="18" height="18" alt="<?php print_string("justifyleft","editor");?>" title="<?php print_string("justifyleft","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_align_center.gif" width="18" height="18" alt="<?php print_string("justifycenter","editor");?>" title="<?php print_string("justifycenter","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_align_right.gif" width="18" height="18" alt="<?php print_string("justifyright","editor");?>" title="<?php print_string("justifyright","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_align_justify.gif" width="18" height="18" alt="<?php print_string("justifyfull","editor");?>" title="<?php print_string("justifyfull","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_left_to_right.gif" width="18" height="18" alt="<?php print_string("lefttoright","editor");?>" title="<?php print_string("lefttoright","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_right_to_left.gif" width="18" height="18" alt="<?php print_string("righttoleft","editor");?>" title="<?php print_string("righttoleft","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_list_num.gif" width="18" height="18" alt="<?php print_string("orderedlist","editor");?>" title="<?php print_string("orderedlist","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_list_bullet.gif" width="18" height="18" alt="<?php print_string("unorderedlist","editor");?>" title="<?php print_string("unorderedlist","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_indent_less.gif" width="18" height="18" alt="<?php print_string("outdent","editor");?>" title="<?php print_string("outdent","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_indent_more.gif" width="18" height="18" alt="<?php print_string("indent","editor");?>" title="<?php print_string("indent","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_color_fg.gif" width="18" height="18" alt="<?php print_string("forecolor","editor");?>" title="<?php print_string("forecolor","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_color_bg.gif" width="18" height="18" alt="<?php print_string("hilitecolor","editor");?>" title="<?php print_string("hilitecolor","editor");?>" /></td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="buttons[justifyleft]"<?php print(in_array("justifyleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[justifycenter]"<?php print(in_array("justifycenter", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[justifyright]"<?php print(in_array("justifyright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[justifyfull]"<?php print(in_array("justifyfull", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[lefttoright]"<?php print(in_array("lefttoright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[righttoleft]"<?php print(in_array("righttoleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[insertorderedlist]"<?php print(in_array("insertorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[insertunorderedlist]"<?php print(in_array("insertunorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[outdent]"<?php print(in_array("outdent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[indent]"<?php print(in_array("indent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[forecolor]"<?php print(in_array("forecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[hilitecolor]"<?php print(in_array("hilitecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ </tr>
+ <tr>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_hr.gif" width="18" height="18" alt="<?php print_string("horizontalrule","editor");?>" title="<?php print_string("horizontalrule","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_anchor.gif" width="18" height="18" alt="<?php print_string("createanchor","editor");?>" title="<?php print_string("createanchor","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_link.gif" width="18" height="18" alt="<?php print_string("insertlink","editor");?>" title="<?php print_string("insertlink","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_unlink.gif" width="18" height="18" alt="<?php print_string("removelink","editor");?>" title="<?php print_string("removelink","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_image.gif" width="18" height="18" alt="<?php print_string("insertimage","editor");?>" title="<?php print_string("insertimage","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/insert_table.gif" width="18" height="18" alt="<?php print_string("inserttable","editor");?>" title="<?php print_string("inserttable","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/em.icon.smile.gif" width="18" height="18" alt="<?php print_string("insertsmile","editor");?>" title="<?php print_string("insertsmile","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/icon_ins_char.gif" width="18" height="18" alt="<?php print_string("insertchar","editor");?>" title="<?php print_string("insertchar","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/spell-check.gif" width="18" height="18" alt="<?php print_string("spellcheck","editor");?>" title="<?php print_string("spellcheck","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/ed_html.gif" width="18" height="18" alt="<?php print_string("htmlmode","editor");?>" title="<?php print_string("htmlmode","editor");?>" /></td>
+ <td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/images/fullscreen_maximize.gif" width="18" height="18" alt="<?php print_string("popupeditor","editor");?>" title="<?php print_string("popupeditor","editor");?>" /></td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="buttons[inserthorizontalrule]"<?php print(in_array("inserthorizontalrule", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[createanchor]"<?php print(in_array("createanchor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[createlink]"<?php print(in_array("createlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[unlink]"<?php print(in_array("unlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[insertimage]"<?php print(in_array("insertimage", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[inserttable]"<?php print(in_array("inserttable", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[insertsmile]"<?php print(in_array("insertsmile", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[insertchar]"<?php print(in_array("insertchar", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[spellcheck]"<?php print(in_array("spellcheck", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[htmlmode]"<?php print(in_array("htmlmode", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td><input type="checkbox" name="buttons[popupeditor]"<?php print(in_array("popupeditor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+ </td>
</tr>
<tr>
- <td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>"></td>
+ <td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>" /></td>
</tr>
</table>
</form>
<form method="post" action="<?php print($GLOBALS['ME']);?>">
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
+<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
<center>
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
</center>
View
39 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;
}
}
View
1 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,
View
5 lib/weblib.php
@@ -3374,6 +3374,11 @@ function print_editor_config() {
$i++;
}
echo '};';
+
+ if (!empty($CFG->editorhidebuttons)) {
+ echo "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n";
+ }
+
if(!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
print_speller_code($usehtmleditor=true);
}

0 comments on commit 955dbfa

Please sign in to comment.
Something went wrong with that request. Please try again.