From 18a7736107923aec98ec5673e511aac084bec855 Mon Sep 17 00:00:00 2001
From: jamiesensei
Date: Fri, 5 Jan 2007 04:51:46 +0000
Subject: [PATCH] added helpbuttons to htmleditors where needed. Further work
on htmleditor helpbutton code.
---
blog/edit_form.php | 1 +
course/request_form.php | 2 +
lib/form/editorhelp.php | 3 ++
lib/form/htmleditor.php | 5 ++-
lib/form/textarea.php | 3 +-
lib/weblib.php | 38 ++++++++-----------
.../type/online/assignment.class.php | 1 +
.../type/upload/assignment.class.php | 1 +
mod/chat/mod_form.php | 1 +
mod/choice/mod_form.php | 1 +
mod/data/mod_form.php | 1 +
mod/forum/mod_form.php | 1 +
mod/glossary/comment_form.php | 1 +
mod/glossary/edit_form.php | 1 +
mod/glossary/mod_form.php | 1 +
mod/journal/mod_form.php | 1 +
mod/label/mod_form.php | 1 +
mod/quiz/mod_form.php | 1 +
18 files changed, 39 insertions(+), 25 deletions(-)
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 = '
';
- return link_to_popup_window(s("/lib/form/editorhelp.php?".$paramstring), $alttag, $linkobject, 400, 500, $alttag, 'none', true);
-}
-/* $helptext = '- ';
- $helptext .= helpbutton("reading", get_string("helpreading"), "moodle", true, false, '', true);
- $helptext .= "
- ";
- $helptext .= helpbutton("writing", get_string("helpwriting"), "moodle", true, false, '', true);
- $helptext .= "
- ";
- $helptext .= helpbutton("questions", get_string("helpquestions"), "moodle", true, false, '', true);
- $helptext .= "
- ";
- if ($usehtmleditor) {
- $helptext .= helpbutton("richtext", get_string("helprichtext"), "moodle", true, false, '', true);
- } else {
- $helptext .= emoticonhelpbutton("theform", "message", 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".'