]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741: clean up some old code. This needs to be confirmed backward-compatible.
authorscyrma <scyrma>
Fri, 29 Aug 2008 09:54:44 +0000 (09:54 +0000)
committerscyrma <scyrma>
Fri, 29 Aug 2008 09:54:44 +0000 (09:54 +0000)
lib/deprecatedlib.php
lib/form/htmleditor.php
lib/weblib.php

index c71b5272e156d083bca5aff20711ba66f5a64566..a0d3062ab9f85d6d5f6f4edbdfafc173ba591311 100644 (file)
@@ -1046,3 +1046,6 @@ function table_column($table, $oldfield, $field, $type='integer', $size='10',
     error('table_column() was removed, please use new ddl functions');
 }
 
+function use_html_editor($name='', $editorhidebuttons='', $id='') {
+    error('use_html_editor() not available anymore');
+}
index 88d148864e2453ed58a6abe1413eaea17939fb67..22e39f6e0f75e00e64171524a9698711be3e2e4d 100644 (file)
@@ -77,7 +77,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
                                     $this->_options['height'],
                                     $this->getName(),
                                     preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
-                                    $this->_options['course'],
+                                    0, // unused anymore
                                     true,
                                     $this->getAttribute('id'));
         }
index ab7ae009ff1118628627f6b9ad72dc4a5349288b..cb2296498edeec3e7df9f5e31c4ae341951a3296 100644 (file)
@@ -4809,19 +4809,17 @@ function print_recent_activity_note($time, $user, $text, $link, $return=false, $
  * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
  * @param string $name Name to use for the textarea element.
  * @param string $value Initial content to display in the textarea.
- * @param int $courseid Course ID to pass to the file manager (defaults to global $COURSE->id).
+ * @param int $obsolete deprecated
  * @param bool $return If false, will output string. If true, will return string value.
  * @param string $id CSS ID to add to the textarea element.
  * @param string $editorclass CSS classes to add to the textarea element when using the htmleditor. Use 'form-textarea-simple' to get a basic editor. Defaults to 'form-textarea-advanced' (complete editor). If this is null or invalid, the htmleditor will not show for this field.
  */
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='', $editorclass='form-textarea-advanced') {
-/// $width and height are legacy fields and no longer used as pixels like they used to be.
-/// However, you can set them to zero to override the mincols and minrows values below.
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='', $editorclass='form-textarea-advanced') {
+    /// $width and height are legacy fields and no longer used as pixels like they used to be.
+    /// However, you can set them to zero to override the mincols and minrows values below.
 
     global $CFG, $COURSE, $HTTPSPAGEREQUIRED, $THEME;
-    //static $scriptcount = 0; // For loading the htmlarea script only once.
 
-    //var_dump(unserialize($COURSE->modinfo));
     $mincols = 65;
     $minrows = 10;
     $str = '';
@@ -4830,38 +4828,12 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
         $id = 'edit-'.$name;
     }
 
-    if ( empty($CFG->editorsrc) ) { // for backward compatibility.
-        if (empty($courseid)) {
-            $courseid = $COURSE->id;
+    if ( empty($CFG->editorsrc) && $usehtmleditor ) { // for backward compatibility.
+        if ($height && ($rows < $minrows)) {
+            $rows = $minrows;
         }
-
-        if ($usehtmleditor) {
-
-//            if (!empty($courseid) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid))) {
-//                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '&amp;httpsrequired=1';
-//                // needed for course file area browsing in image insert plugin
-//                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-//                        $CFG->httpswwwroot .'/lib/editor/htmlarea/htmlarea.php?id='.$courseid.$httpsrequired.'"></script>'."\n" : '';
-//            } else {
-//                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '?httpsrequired=1';
-//                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-//                         $CFG->httpswwwroot .'/lib/editor/htmlarea/htmlarea.php'.$httpsrequired.'"></script>'."\n" : '';
-
-//            }
-//            $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-//                    $CFG->httpswwwroot .'/lib/editor/htmlarea/lang/en.php"></script>'."\n" : '';
-//            $scriptcount++;
-
-            if ($height) {    // Usually with legacy calls
-                if ($rows < $minrows) {
-                    $rows = $minrows;
-                }
-            }
-            if ($width) {    // Usually with legacy calls
-                if ($cols < $mincols) {
-                    $cols = $mincols;
-                }
-            }
+        if ($width && ($cols < $mincols)) {
+            $cols = $mincols;
         }
     }
 
@@ -4909,103 +4881,6 @@ document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
     echo $str;
 }
 
-/**
- * Sets up the HTML editor on textareas in the current page.
- * If a field name is provided, then it will only be
- * applied to that field - otherwise it will be used
- * on every textarea in the page.
- *
- * In most cases no arguments need to be supplied
- *
- * @param string $name Form element to replace with HTMl editor by name
- */
-function use_html_editor($name='', $editorhidebuttons='', $id='') {
-    global $THEME;
-
-    $editor = 'editor_'.md5($name); //name might contain illegal characters
-    if ($id === '') {
-        $id = 'edit-'.$name;
-    }
-    echo "\n".'<script type="text/javascript" defer="defer">'."\n";
-    echo '//<![CDATA['."\n\n"; // Extra \n is to fix odd wiki problem, MDL-8185
-    echo "$editor = new HTMLArea('$id');\n";
-    echo "var config = $editor.config;\n";
-
-    echo print_editor_config($editorhidebuttons);
-
-    if (empty($THEME->htmleditorpostprocess)) {
-        if (empty($name)) {
-            echo "\nHTMLArea.replaceAll($editor.config);\n";
-        } else {
-            echo "\n$editor.generate();\n";
-        }
-    } else {
-        if (empty($name)) {
-            echo "\nvar HTML_name = '';";
-        } else {
-            echo "\nvar HTML_name = \"$name;\"";
-        }
-        echo "\nvar HTML_editor = $editor;";
-    }
-    echo '//]]>'."\n";
-    echo '</script>'."\n";
-}
-
-function print_editor_config($editorhidebuttons='', $return=false) {
-    global $CFG;
-
-    $str = "config.pageStyle = \"body {";
-
-    if (!(empty($CFG->editorbackgroundcolor))) {
-        $str .= " background-color: $CFG->editorbackgroundcolor;";
-    }
-
-    if (!(empty($CFG->editorfontfamily))) {
-        $str .= " font-family: $CFG->editorfontfamily;";
-    }
-
-    if (!(empty($CFG->editorfontsize))) {
-        $str .= " font-size: $CFG->editorfontsize;";
-    }
-
-    $str .= " }\";\n";
-    $str .= "config.killWordOnPaste = ";
-    $str .= (empty($CFG->editorkillword)) ? "false":"true";
-    $str .= ';'."\n";
-    $str .= 'config.fontname = {'."\n";
-
-    $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
-    $i = 1;                     // Counter is used to get rid of the last comma.
-
-    foreach ($fontlist as $fontline) {
-        if (!empty($fontline)) {
-            if ($i > 1) {
-                $str .= ','."\n";
-            }
-            list($fontkey, $fontvalue) = split(':', $fontline);
-            $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'";
-
-            $i++;
-        }
-    }
-    $str .= '};';
-
-    if (!empty($editorhidebuttons)) {
-        $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n";
-    } else if (!empty($CFG->editorhidebuttons)) {
-        $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n";
-    }
-
-    if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
-        $str .= print_speller_code($CFG->htmleditor, true);
-    }
-
-    if ($return) {
-        return $str;
-    }
-    echo $str;
-}
-
 /**
  * Returns a turn edit on/off button for course in a self contained form.
  * Used to be an icon, but it's now a simple form button