]> git.mjollnir.org Git - moodle.git/commitdiff
Made textarea field use use_html_editor() and print_editor_config() from
authorvyshane <vyshane>
Tue, 14 Mar 2006 08:32:14 +0000 (08:32 +0000)
committervyshane <vyshane>
Tue, 14 Mar 2006 08:32:14 +0000 (08:32 +0000)
/lib/weblib.php. Removed these functions from
/lib/mod/field/textarea/field.class.php. Will commit updates to these
functions to Moodle 1.5 Stable. Database module will only be compatible with
the latest Moodle 1.5 Stable and onwards.

mod/data/templates.php

index 11241600903eb50348cc9610038ab1949f0e043b..19df48b98ddc4be49f93ed8eb1fc04a57d2aeb5b 100755 (executable)
 
     $strdata = get_string('modulenameplural','data');
     
+    // For the javascript for inserting template tags: initialise the default textarea to
+    // 'edit_template' - it is always present in all different possible views.
+    $bodytag = 'onload="';
+    $bodytag .= 'currEditor = edit_template; ';
+    $bodytag .= 'currTextarea = document.tempform.template;';
+    $bodytag .= '" ';
+    
     print_header_simple($data->name, '', "<a href='index.php?id=$course->id'>$strdata</a> -> $data->name",
-                        '', '', true, '', navmenu($course, $cm), '', '');
+                        '', '', true, '', navmenu($course, $cm), '', $bodytag);
     
     print_heading(format_string($data->name));
     
-     ///processing submitted data, i.e updating form
+     /// Processing submitted data, i.e updating form.
     if (($mytemplate = data_submitted($CFG->wwwroot.'/mod/data/templates.php')) && confirm_sesskey()){
 
-        //generate default template
+        // Generate default template.
         if (!empty($mytemplate->defaultform)){
             data_generate_default_form($data->id, $mode);
         }
                 $newtemplate->listtemplatefooter = $mytemplate->listtemplatefooter;
             }
 
-            //check for multiple tags, only need to check for add template
+            // Check for multiple tags, only need to check for add template.
             if ($mode != 'addtemplate' or data_tags_check($data->id, $newtemplate->{$mode})){
                 update_record('data',$newtemplate);
             }
         }
     }
 
-/// Print the tabs
+/// Print the tabs.
     $currenttab = 'templates';
     include('tabs.php'); 
 
-/// Print the browsing interface
+/// Print the browsing interface.
 
     echo '<div align="center">'.get_string('header'.$mode,'data').'</div><br />';
 
     echo '<form name="tempform" action="templates.php?d='.$data->id.'&amp;mode='.$mode.'" method="post">';
     echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />';
-    //print button to autogen all forms, if all templates are empty
+    // Print button to autogen all forms, if all templates are empty
 
     $data = get_record('data', 'id', $d);    //reload because of possible updates so far!
 
     }
         
     print_simple_box_start('center','80%');
-    echo '<table><tr><td colspan="2">';
+    echo '<table cellpadding="4" cellspacing="0" border="0">';
+
 
-    ///add all the available fields for this data
+/// Add the HTML editor(s).
+    echo '<td>';
+    $usehtmleditor = can_use_html_editor();
+    if ($mode == 'listtemplate'){
+        // Print the list template header.
+        echo '<tr>';
+        echo '<td>&nbsp;</td>';
+        echo '<td>';
+        echo '<div align="center">'.get_string('header','data').'</div>';
+        print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplateheader', $data->listtemplateheader);
+        echo '</td>';
+        echo '</tr>';
+    }
+    
+    // Print the main template.
+    // Add all the available fields for this data.
+    echo '<tr><td valign="top">';
     echo get_string('availabletags','data');
     helpbutton('tags', get_string('tags','data'), 'data');
-    echo '</td></tr><tr><td valign="top">';
     
     echo '<select name="fields1[]" size="10" ';
+    
+    // Javascript to insert the field tags into the textarea.
     echo 'onclick="';
-    echo 'if (typeof(editor) != \'undefined\' && editor._editMode == \'wysiwyg\') {';
-    echo '    editor.insertHTML(this.options[selectedIndex].value); ';     // HTMLArea-specific.
+    echo 'if (typeof(currEditor) != \'undefined\' && currEditor._editMode == \'wysiwyg\') {';
+    echo '    currEditor.insertHTML(this.options[selectedIndex].value); ';     // HTMLArea-specific.
     echo '} else {';
-    echo 'insertAtCursor(document.tempform.template, this.options[selectedIndex].value);';   // Hack for inserting when in HTMLArea code view or for normal textareas.
-    echo '}">';
+    echo 'insertAtCursor(currTextarea, this.options[selectedIndex].value);';   // For inserting when in HTMLArea code view or for normal textareas.
+    echo '}';
+    echo '">';
     
     foreach ($fields as $field) {
         echo '<option value="[['.$field->name.']]">'.$field->name.' ('. get_string($field->type, 'data'). ')</option>';
     }
     
-    //print special tags
+    // Print special tags.
     echo '<option value="##edit##">##' .get_string('edit', 'data'). '##</option>';
     echo '<option value="##more##">##' .get_string('more', 'data'). '##</option>';
     echo '<option value="##delete##">##' .get_string('delete', 'data'). '##</option>';
     echo '<option value="##approve##">##' .get_string('approve', 'data'). '##</option>';
     echo '<option value="##comments##">##' .get_string('comments', 'data'). '##</option>';
     echo '</select>';
-
-    ///add the HTML editor(s)
-    echo '</td><td>';
-    $usehtmleditor = can_use_html_editor();
-    if ($mode == 'listtemplate'){
-        echo '<div align="center">'.get_string('header','data').'</div>';
-        print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplateheader', $data->listtemplateheader);
-    }
+    echo '</td>';
+    
+    echo '<td>';
     if ($mode == 'listtemplate'){
-        echo '<div align="center">'.get_string('multientry','data').'</div>';
+        echo '<div align="center">'.get_string('multientry','data').'</div>';        
     }
     print_textarea($usehtmleditor, 20, 72, 0, 0, 'template', $data->{$mode});
+    echo '</td>';
+    echo '</tr>';
+    
     if ($mode == 'listtemplate'){
+        echo '<tr>';
+        echo '<td>&nbsp;</td>';
+        echo '<td>';
         echo '<div align="center">'.get_string('footer','data').'</div>';
         print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplatefooter', $data->listtemplatefooter);
+        echo '</td>';
+        echo '</tr>';
     }
-    echo '</td></tr>';
 
     echo '<tr><td align="center" colspan="2">';
     echo '<input type="submit" value="'.get_string('savetemplate','data').'" />&nbsp;';
     }
     
     echo '</td></tr></table>';
+    
+    
     print_simple_box_end();
     echo '</form>';
     if ($usehtmleditor) {
     }
 
 /// Finish the page
-    
     print_footer($course);
-
-?>
+?>
\ No newline at end of file