]> git.mjollnir.org Git - moodle.git/commitdiff
Move Library parsing code into text_to_html
authormoodler <moodler>
Wed, 27 Aug 2003 06:08:34 +0000 (06:08 +0000)
committermoodler <moodler>
Wed, 27 Aug 2003 06:08:34 +0000 (06:08 +0000)
lib/weblib.php

index b44f438f893f4f0e29c472ab07dab26fae072525..f7ba5483beaabd132c40f1ce0f851918b91d5a0d 100644 (file)
@@ -485,12 +485,6 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
             if (!isset($options->para)) {
                 $options->para=true;
             }
-            if (!empty($CFG->librarypath)) {
-                if (file_exists("$CFG->dirroot/$CFG->librarypath/librarylib.php")) {
-                    include_once("$CFG->dirroot/$CFG->librarypath/librarylib.php");
-                    $text = librarytexttohtml($text);
-                }
-            }
             return text_to_html($text, $options->smiley, $options->para);
             break;
     }
@@ -597,6 +591,8 @@ function text_to_html($text, $smiley=true, $para=true) {
 /// Given plain text, makes it into HTML as nicely as possible.
 /// May contain HTML tags already
 
+    global $CFG;
+
 /// Remove any whitespace that may be between HTML tags
     $text = eregi_replace(">([[:space:]]+)<", "><", $text);
 
@@ -609,6 +605,14 @@ function text_to_html($text, $smiley=true, $para=true) {
 /// Make returns into HTML newlines.
     $text = nl2br($text);
 
+/// Insert links to library pages if Library is being used
+    if (!empty($CFG->librarypath)) {
+        if (file_exists("$CFG->dirroot/$CFG->librarypath/librarylib.php")) {
+            include_once("$CFG->dirroot/$CFG->librarypath/librarylib.php");
+            $text = librarytexttohtml($text);
+        }       
+    }       
+
 /// Turn smileys into images.
     if ($smiley) {
         replace_smilies($text);