]> git.mjollnir.org Git - moodle.git/commitdiff
added helpbuttons to htmleditors where needed. Further work on htmleditor helpbutton...
authorjamiesensei <jamiesensei>
Fri, 5 Jan 2007 04:51:46 +0000 (04:51 +0000)
committerjamiesensei <jamiesensei>
Fri, 5 Jan 2007 04:51:46 +0000 (04:51 +0000)
18 files changed:
blog/edit_form.php
course/request_form.php
lib/form/editorhelp.php
lib/form/htmleditor.php
lib/form/textarea.php
lib/weblib.php
mod/assignment/type/online/assignment.class.php
mod/assignment/type/upload/assignment.class.php
mod/chat/mod_form.php
mod/choice/mod_form.php
mod/data/mod_form.php
mod/forum/mod_form.php
mod/glossary/comment_form.php
mod/glossary/edit_form.php
mod/glossary/mod_form.php
mod/journal/mod_form.php
mod/label/mod_form.php
mod/quiz/mod_form.php

index 1daddab321b976680c6c204174d67e5e5c97e7ab..9ae7cba30b0ecfd097b83b1fa50b6efb5c69f38c 100644 (file)
@@ -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'));
 
index 8d09ce139eb2650c1f74b497755afe2c4ee5e2af..715b29e28c10ee51f04f6b9167521555bd9c0eda 100644 (file)
@@ -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');
index 9a574b60ca09892e5332a3f8a9f64e5a51410450..1f82f57652df8acf1062a8b50aa56344bbb3b77b 100644 (file)
@@ -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);
         }
index 88fdf8f2dc1764604086034235fa9a2be7913ebe..8d50419bb0405ea8617e96bfe5867f2d96bcc72d 100644 (file)
@@ -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);
index 597cb328bd6a7df501420c79773414591151f914..348d3c039d9fe2c98cc6569477cec98151b61640 100644 (file)
@@ -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);
index e072dcfebd53ba9a3b06ed591371556ab5392c06..975e830624212d59b868a57540511268b0ed5704 100644 (file)
@@ -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);
-}
-/*    $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.
@@ -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() {
index 08d5925d1a618bf526687d687674854f470985d5..0c510f11f55ef42570c3eab4c7ee447ad2f3e989 100644 (file)
@@ -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')));
index 42eabe80b9f0b762562b8f5335bb816c0746a2f5..2d4e4f58a3e5825e1fafbd83d3b7733b8a0f6b43 100644 (file)
@@ -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);
index b8f688f3beaef17e7e3f180fac462b4139ff6adf..2afd8dd418ed383aeebe72e81d839b620f863e77 100644 (file)
@@ -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'));
index 013414f92f45d4388ebdb32af8d155ef83123c61..1342ef750ded3324ba42d49b7d14de3dbe49aef9 100644 (file)
@@ -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'));
 
index 4a5fff23be4b2a5b0563d742115a65b52258efd6..4eebcdc10a3a958156ba4b8cece1ee6ede3282f5 100644 (file)
@@ -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));
 
index e5e1a9b31c7b8c48ad6fc2e8374c0e26372f6aec..395674dc6a8aa3d21fa92741885c8de191799135 100644 (file)
@@ -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');
index a72674084b4f36a290496a181df9cde7206776e4..67579010e8528c871585b0bc395f5deb15c92104 100644 (file)
@@ -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')));
index cb4ee15f2fa3373a8261294057048e006b5432a9..f30a9face98857e5a80dfad0b69ab51fbf107ab7 100644 (file)
@@ -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');
 
index 52ea260a229af300f4a175936d88614db40c54d3..28b0f25d4f5aab111f53ee77319543a9858f7172 100644 (file)
@@ -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);
index d1d02feb37bd561928492801218fbad76c0129e3..896ff2616de7663879fd51fb396edc0766e974d4 100644 (file)
@@ -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'));
 
index 226df4efd6cd1340d058393d51fb0f01c5ea5630..cd619509209a54bd374b9648167c2457115aeb94 100644 (file)
@@ -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();
 
index d75b074fcca0c103b7dcdb96bffc32aae413b3ac..d0703b3ab178a57d915f149cba3323e95cd44f1b 100644 (file)
@@ -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'));