$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'));
$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');
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);
}
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);
* @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{
} 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);
get_string('moreinformation').'</a></p>';
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();
$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);
$paramstring = join('&', $urlparams);
$linkobject = '<img alt="'.$alttag.'" src="'.$CFG->pixpath .'/help.gif" />';
- return link_to_popup_window(s("/lib/form/editorhelp.php?".$paramstring), $alttag, $linkobject, 400, 500, $alttag, 'none', true);
-}
-/* $helptext = '<ul><li>';
- $helptext .= helpbutton("reading", get_string("helpreading"), "moodle", true, false, '', true);
- $helptext .= "</li><li>";
- $helptext .= helpbutton("writing", get_string("helpwriting"), "moodle", true, false, '', true);
- $helptext .= "</li><li>";
- $helptext .= helpbutton("questions", get_string("helpquestions"), "moodle", true, false, '', true);
- $helptext .= "</li><li>";
- if ($usehtmleditor) {
- $helptext .= helpbutton("richtext", get_string("helprichtext"), "moodle", true, false, '', true);
- } else {
- $helptext .= emoticonhelpbutton("theform", "message", true);
- }
- $helptext .= "</li></ul>";
- 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.
function print_speller_code ($usehtmleditor=false, $return=false) {
global $CFG;
$str = '';
-
+
$str .= "\n".'<script type="text/javascript">'."\n";
$str .= '//<![CDATA['."\n";
if(!$usehtmleditor) {
}
-/**
+/**
* Returns string to add a frame attribute, if required
*/
function frametarget() {
// visible elements
$mform->addElement('htmleditor', 'text', get_string('submission', 'assignment'), array('cols'=>85, 'rows'=>30));
$mform->setType('text', PARAM_RAW); // to be cleaned before display
+ $mform->setHelpButton('text', array('reading', 'writing', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('format', 'format', get_string('format'));
$mform->setHelpButton('format', array('textformat', get_string('helpformatting')));
// visible elements
$mform->addElement('htmleditor', 'text', get_string('notes', 'assignment'), array('cols'=>85, 'rows'=>30));
$mform->setType('text', PARAM_RAW); // to be cleaned before display
+ $mform->setHelpButton('text', array('reading', 'writing'), false, 'editorhelpbutton');
// hidden params
$mform->addElement('hidden', 'id', 0);
$mform->addElement('htmleditor', 'intro', get_string('chatintro', 'chat'));
$mform->setType('intro', PARAM_RAW);
+ $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
$mform->addElement('date_time_selector', 'chattime', get_string('chattime', 'chat'));
$mform->addElement('htmleditor', 'text', get_string('choicetext', 'choice'));
$mform->setType('text', PARAM_RAW);
$mform->addRule('text', null, 'required', null, 'client');
+ $mform->setHelpButton('text', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('format', 'format', get_string('format'));
$mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', null, 'required', null, 'client');
+ $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
$mform->addElement('htmleditor', 'intro', get_string('forumintro', 'forum'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
+ $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$options = array();
$options[0] = get_string('no');
$mform->addElement('htmleditor', 'entrycomment',get_string('comment', 'glossary'));
$mform->addRule('entrycomment', get_string('required'), 'required', null, 'client');
$mform->setType('entrycomment', PARAM_RAW); // processed by trusttext or cleaned before the display
+ $mform->setHelpButton('entrycomment', array('writing', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('format', 'format', get_string('format'));
$mform->setHelpButton('format', array('textformat', get_string('helpformatting')));
$mform->addElement('htmleditor', 'definition', get_string('definition', 'glossary'), array('rows'=>20));
$mform->setType('definition', PARAM_RAW);
$mform->addRule('definition', null, 'required', null, 'client');
+ $mform->setHelpButton('definition', array('writing', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('format');
$mform->addElement('htmleditor', 'intro', get_string('description'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
+ $mform->setHelpButton('intro', array('writing', 'questions', 'text'), false, 'editorhelpbutton');
$mform->addElement('text', 'entbypage', get_string('entbypage', 'glossary'));
$mform->setDefault('entbypage', 10);
$mform->addElement('htmleditor', 'intro', get_string('journalquestion', 'journal'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
+ $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('format', 'format', get_string('format'));
$mform->addElement('htmleditor', 'content', get_string('labeltext', 'label'));
$mform->setType('content', PARAM_RAW);
$mform->addRule('content', get_string('required'), 'required', null, 'client');
+ $mform->setHelpButton('content', array('questions', 'richtext'), false, 'editorhelpbutton');
$this->standard_hidden_coursemodule_elements();
$mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz"));
$mform->setType('intro', PARAM_RAW);
+ $mform->setHelpButton('intro', array('richtext', get_string('helprichtext')));
//-------------------------------------------------------------------------------
$mform->addElement('header', 'timinghdr', get_string('timing', 'form'));