added helpbuttons to htmleditors where needed. Further work on htmleditor helpbutton code.
This commit is contained in:
@@ -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'));
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+14
-22
@@ -4609,6 +4609,13 @@ function print_error ($errorcode, $module='', $link='', $a=NULL) {
|
||||
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();
|
||||
@@ -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 = '<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);
|
||||
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);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 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".'<script type="text/javascript">'."\n";
|
||||
$str .= '//<![CDATA['."\n";
|
||||
if(!$usehtmleditor) {
|
||||
@@ -5631,7 +5623,7 @@ function disable_debugging() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns string to add a frame attribute, if required
|
||||
*/
|
||||
function frametarget() {
|
||||
|
||||
@@ -247,6 +247,7 @@ class mod_assignment_online_edit_form extends moodleform {
|
||||
// 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')));
|
||||
|
||||
@@ -921,6 +921,7 @@ class mod_assignment_upload_notes_form extends moodleform {
|
||||
// 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);
|
||||
|
||||
@@ -17,6 +17,7 @@ class mod_chat_mod_form extends moodleform_mod {
|
||||
|
||||
$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'));
|
||||
|
||||
@@ -18,6 +18,7 @@ class mod_choice_mod_form extends moodleform_mod {
|
||||
$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'));
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class mod_data_mod_form extends moodleform_mod {
|
||||
$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));
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
$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');
|
||||
|
||||
@@ -10,6 +10,7 @@ class mod_glossary_comment_form extends moodleform {
|
||||
$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')));
|
||||
|
||||
@@ -24,6 +24,7 @@ class mod_glossary_entry_form extends moodleform {
|
||||
$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');
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class mod_glossary_mod_form extends moodleform_mod {
|
||||
$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);
|
||||
|
||||
@@ -18,6 +18,7 @@ class mod_journal_mod_form extends moodleform_mod {
|
||||
$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'));
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class mod_label_mod_form extends moodleform_mod {
|
||||
$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();
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
|
||||
$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'));
|
||||
|
||||
Reference in New Issue
Block a user