]> git.mjollnir.org Git - moodle.git/commitdiff
petr's patch to fix problem with htmlarea breaking clientside validation. Also using...
authorjamiesensei <jamiesensei>
Tue, 5 Dec 2006 13:21:40 +0000 (13:21 +0000)
committerjamiesensei <jamiesensei>
Tue, 5 Dec 2006 13:21:40 +0000 (13:21 +0000)
lib/editor/htmlarea/htmlarea.php
lib/formslib.php
lib/weblib.php
message/send.php
mod/lesson/action/editpage.php

index 208277140647973b5b2d73dc16add7ffc63f56c2..c6a29080120c3df8915073f7a3457377e9f1601a 100644 (file)
@@ -634,12 +634,14 @@ HTMLArea.prototype.generate = function () {
             }
             // Moodle hack end.
             var a = this.__msh_prevOnSubmit;
+            var ret = true;
             // call previous submit methods if they were there.
             if (typeof a != "undefined") {
                 for (var i = a.length; --i >= 0;) {
-                    a[i]();
+                    ret = a[i]() && ret;
                 }
             }
+            return ret;
         };
         if (typeof f.onreset == "function") {
             var funcref = f.onreset;
index 57a7a5cf3331a3b937fefe1822d1ec3b3a471b43..0bdbcc01170c29f1cacc9c48363eb54ed04a0f33 100644 (file)
@@ -810,12 +810,16 @@ function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element)
             $element->updateAttributes(array('onBlur' => $onBlur . $valFunc,
                                              'onChange' => $onChange . $valFunc));
         }
+//  do not rely on frm function parameter, because htmlarea breaks it when overloading the onsubmit method 
         $js .= '
 function validate_' . $this->_attributes['id'] . '(frm) {
   if (skipClientValidation) {
      return true;
   }
   var ret = true;
+
+  var frm = document.getElementById(\''. $this->_attributes['id'] .'\')
+
 ' . $validateJS . ';
   return ret;
 }
index 8f755acb5e1bfbcb9c8d3e9fd0cb3fedeeb67b04..e14fcb7e97903e8b08edf26b33fab369dada03c8 100644 (file)
@@ -3578,7 +3578,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
             }
         }
     }
-    $str .= '<textarea class="form=textarea" id="edit-'. $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
+    $str .= '<textarea class="form=textarea" id="id_'. $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
     if ($usehtmleditor) {
         $str .= htmlspecialchars($value); // needed for editing of cleaned text!
     } else {
@@ -3621,7 +3621,7 @@ function print_richedit_javascript($form, $name, $source='no') {
 function use_html_editor($name='', $editorhidebuttons='') {
     $editor = 'editor_'.md5($name); //name might contain illegal characters
     echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
-    echo "$editor = new HTMLArea('edit-$name');\n";
+    echo "$editor = new HTMLArea('id_$name');\n";
     echo "var config = $editor.config;\n";
 
     echo print_editor_config($editorhidebuttons);
index 152555bed8aaf015d8de3df9b17c1c951a37b022..24e262837798b4d6f5772315bb617a011078ee69 100644 (file)
     echo '</center>';
     
     echo "\n<script type=\"text/javascript\">\n<!--\n";                  /// Focus on the textarea
-    echo 'document.getElementById("edit-message").focus();'."\n";
+    echo 'document.getElementById("id_message").focus();'."\n";
     echo "\n-->\n</script>\n\n";
 
     echo '</body></html>';
index ae2e7870d8ed6e95c3827064de4be632780b1d05..fdd8f33998434575abf38db5962e6b23683c0ee6 100644 (file)
             switch ($page->qtype) {
                 case LESSON_MATCHING:
                     if ($n == 0) {
-                        echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('correctresponse', 'lesson').":</label></b>\n";
+                        echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('correctresponse', 'lesson').":</label></b>\n";
                         if ($flags & LESSON_ANSWER_EDITOR) {
                             echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                                 "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
                             print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                         }
                     } elseif ($n == 1) {
-                        echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('wrongresponse', 'lesson').":</label></b>\n";
+                        echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('wrongresponse', 'lesson').":</label></b>\n";
                         if ($flags & LESSON_ANSWER_EDITOR) {
                             echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                                 "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
                         }
                     } else {
                         $ncorrected = $n - 1;
-                        echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $ncorrected:</label></b>\n";
+                        echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('answer', 'lesson')." $ncorrected:</label></b>\n";
                         if ($flags & LESSON_ANSWER_EDITOR) {
                             echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                                 "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />"; 
                             print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                         }
                         echo "</td></tr>\n";
-                        echo "<tr><td><b><label for=\"edit-response[$n]\">".get_string('matchesanswer', 'lesson')." $ncorrected:</label></b>\n";
+                        echo "<tr><td><b><label for=\"id_response[$n]\">".get_string('matchesanswer', 'lesson')." $ncorrected:</label></b>\n";
                         if ($flags & LESSON_RESPONSE_EDITOR) {
                             echo " [<label for=\"responseeditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                                 "<input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" checked=\"checked\" />";
                 case LESSON_MULTICHOICE:
                 case LESSON_SHORTANSWER:
                 case LESSON_NUMERICAL:                    
-                    echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $nplus1:</label></b>\n";
+                    echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('answer', 'lesson')." $nplus1:</label></b>\n";
                     if ($flags & LESSON_ANSWER_EDITOR and $page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
                         echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                             "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
                         }
                     }
                     echo "</td></tr>\n";
-                    echo "<tr><td><b><label for=\"edit-response[$n]\">".get_string('response', 'lesson')." $nplus1:</label></b>\n";
+                    echo "<tr><td><b><label for=\"id_response[$n]\">".get_string('response', 'lesson')." $nplus1:</label></b>\n";
                     if ($flags & LESSON_RESPONSE_EDITOR) {
                         echo " [<label for=\"responseeditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                             "<input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" checked=\"checked\" />";
                     echo "</td></tr>\n";
                     break;
                 case LESSON_BRANCHTABLE:
-                    echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string("description", "lesson")." $nplus1:</label></b>\n";
+                    echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string("description", "lesson")." $nplus1:</label></b>\n";
                     if ($flags & LESSON_ANSWER_EDITOR) {
                         echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
                             "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";