From: jamiesensei Date: Fri, 5 Jan 2007 04:51:46 +0000 (+0000) Subject: added helpbuttons to htmleditors where needed. Further work on htmleditor helpbutton... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=18a7736107923aec98ec5673e511aac084bec855;p=moodle.git added helpbuttons to htmleditors where needed. Further work on htmleditor helpbutton code. --- diff --git a/blog/edit_form.php b/blog/edit_form.php index 1daddab321..9ae7cba30b 100644 --- a/blog/edit_form.php +++ b/blog/edit_form.php @@ -23,6 +23,7 @@ class blog_edit_form extends moodleform { $mform->addElement('htmleditor', 'summary', get_string('entrybody', 'blog'), array('rows'=>25)); $mform->setType('summary', PARAM_RAW); $mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client'); + $mform->setHelpButton('summary', array('writing', 'richtext'), false, 'editorhelpbutton'); $mform->addElement('format', 'format', get_string('format')); diff --git a/course/request_form.php b/course/request_form.php index 8d09ce139e..715b29e28c 100644 --- a/course/request_form.php +++ b/course/request_form.php @@ -17,6 +17,8 @@ class course_request_form extends moodleform { $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows'=>'15', 'cols'=>'50')); $mform->addRule('summary', get_string('missingsummary'), 'required', null, 'client'); $mform->setType('summary', PARAM_RAW); + $mform->setHelpButton('summary', array('text', get_string('helptext'))); + $mform->addElement('textarea', 'reason', get_string('courserequestreason'), array('rows'=>'15', 'cols'=>'50')); $mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client'); diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php index 9a574b60ca..1f82f57652 100644 --- a/lib/form/editorhelp.php +++ b/lib/form/editorhelp.php @@ -21,6 +21,9 @@ for ($i=1; ; $i++){ case 'richtext' : $topics[$i] = helplink('richtext', get_string('helprichtext')); break; + case 'text' : + $topics[$i] = helplink('text', get_string('helptext')); + break; default : error('Unknown help topic '.$item); } diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php index 88fdf8f2dc..8d50419bb0 100644 --- a/lib/form/htmleditor.php +++ b/lib/form/htmleditor.php @@ -50,8 +50,11 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{ if ('editorhelpbutton' == $function){ $key = array_search('richtext', $helpbuttonargs); if ($key !== FALSE){ - $helpbuttonargs[$key]='emoticons'; + array_splice($helpbuttonargs, $key, 1, array('text', 'emoticons')); } + } elseif ('helpbutton' == $function && $helpbuttonargs[0] == 'richtext' && ((!isset($helpbuttonargs[2])) || $helpbuttonargs[2] == 'moodle')){ + //replace single 'richtext' help button with text and emoticon button when htmleditor off. + return $this->setHelpButton(array('text', 'emoticons'), 'editorhelpbutton'); } } return parent::setHelpButton($helpbuttonargs, $function); diff --git a/lib/form/textarea.php b/lib/form/textarea.php index 597cb328bd..348d3c039d 100644 --- a/lib/form/textarea.php +++ b/lib/form/textarea.php @@ -28,6 +28,7 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{ * @param string $function function name to call to get html */ function setHelpButton($helpbuttonargs, $function='helpbutton'){ + global $SESSION; if (!is_array($helpbuttonargs)){ $helpbuttonargs=array($helpbuttonargs); }else{ @@ -41,7 +42,7 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{ } elseif ('editorhelpbutton' == $function){ if (in_array('emoticons', $helpbuttonargs)){ $SESSION->inserttextform = $this->_formid; - $SESSION->inserttextfield = 'id_'.$this->getAttribute('id'); + $SESSION->inserttextfield = $this->getAttribute('name'); } } $this->_helpbutton=call_user_func_array($function, $helpbuttonargs); diff --git a/lib/weblib.php b/lib/weblib.php index e072dcfebd..975e830624 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4609,6 +4609,13 @@ function print_error ($errorcode, $module='', $link='', $a=NULL) { get_string('moreinformation').'

'; error($message, $link); } +/** + * Returns a string of html with an image of a help icon linked to a help page on a number of help topics. + * Should be used only with htmleditor or textarea. + * @param mixed $helptopics variable amount of params accepted. Each param may be a string or an array of arguments for + * helpbutton. + * @return string + */ function editorhelpbutton(){ global $CFG, $SESSION; $items = func_get_args(); @@ -4636,13 +4643,13 @@ function editorhelpbutton(){ $titles[] = get_string("helpquestions"); break; case 'emoticons' : - $SESSION->inserttextform = 'mod-forum-post'; - $SESSION->inserttextfield = 'message'; - $titles[] = get_string("helpemoticons"); break; case 'richtext' : - $titles[] = get_string("helprichtext"); + $titles[] = get_string('helprichtext'); + break; + case 'text' : + $titles[] = get_string('helptext'); break; default : error('Unknown help topic '.$item); @@ -4662,23 +4669,8 @@ function editorhelpbutton(){ $paramstring = join('&', $urlparams); $linkobject = ''.$alttag.''; - return link_to_popup_window(s("/lib/form/editorhelp.php?".$paramstring), $alttag, $linkobject, 400, 500, $alttag, 'none', true); -} -/* $helptext = '"; - return helpbutton('', get_string('editorhelp'), 'moodle', true, false, $helptext, true); -}*/ + return link_to_popup_window(s('/lib/form/editorhelp.php?'.$paramstring), $alttag, $linkobject, 400, 500, $alttag, 'none', true); +} /** * Print a help button. @@ -5277,7 +5269,7 @@ function print_side_block_end($attributes = array()) { function print_speller_code ($usehtmleditor=false, $return=false) { global $CFG; $str = ''; - + $str .= "\n".'