Now gets it's courseid properly from the caller
authorthepurpleblob <thepurpleblob>
Fri, 27 Aug 2004 14:22:01 +0000 (14:22 +0000)
committerthepurpleblob <thepurpleblob>
Fri, 27 Aug 2004 14:22:01 +0000 (14:22 +0000)
lib/wiki.php

index 2d88fe296fb37bb37824b472476a187717bab4e5..a16790093fc3da77ddbd616eb435dbaec3a71a92 100644 (file)
@@ -54,6 +54,7 @@ class Wiki {
   var $spelling_on;\r
   var $list_backtrack;\r
   var $output; // output buffer\r
+  var $courseid;\r
 \r
   function close_block( $state ) {\r
     // provide appropriate closure for block according to state\r
@@ -270,23 +271,23 @@ class Wiki {
          " <a href=\"".$CFG->wwwroot."/mod/\\1/view.php?id=\\2\">\\3</a> ", $line );\r
 \r
       // Replace picture resource link \r
-      global $course;    // This is a bit risky - it won't work everywhere\r
+      // global $course;    // This is a bit risky - it won't work everywhere\r
 \r
       if ($CFG->slasharguments) {\r
         $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)",\r
-          "<img src=\"$CFG->wwwroot/file.php/$course->id/\\1\\2\" alt=\"\\3\" />", $line );\r
+          "<img src=\"$CFG->wwwroot/file.php/$this->courseid/\\1\\2\" alt=\"\\3\" />", $line );\r
       } else {\r
         $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)",\r
-          "<img src=\"$CFG->wwwroot/file.php\?file=$course->id/\\1\\2\" alt=\"\\3\" />", $line );\r
+          "<img src=\"$CFG->wwwroot/file.php\?file=$this->courseid/\\1\\2\" alt=\"\\3\" />", $line );\r
       }\r
 \r
       // Replace everything else resource link\r
       if ($CFG->slasharguments) {\r
         $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)",\r
-          "<a href=\"$CFG->wwwroot/file.php/$course->id/\\1\" >\\2</a>", $line );\r
+          "<a href=\"$CFG->wwwroot/file.php/$this->courseid/\\1\" >\\2</a>", $line );\r
       } else {\r
         $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)",\r
-          "<a href=\"$CFG->wwwroot/file.php\?file=$course->id/\\1\" >\\2</a>", $line );\r
+          "<a href=\"$CFG->wwwroot/file.php\?file=$this->courseid/\\1\" >\\2</a>", $line );\r
       }\r
 \r
       replace_smilies( $line );\r
@@ -327,7 +328,7 @@ class Wiki {
   }\r
 \r
 \r
-  function format( $content ) {\r
+  function format( $content, $courseid ) {\r
     // main entry point for processing TikiText\r
     // $content is string containing text with Tiki formatting\r
     // return: string containing XHTML formatting\r
@@ -339,6 +340,7 @@ class Wiki {
     $this->list_depth = 0;\r
     $this->list_backtrack = array();\r
     $this->spelling_on = false;\r
+    $this->courseid = $courseid;\r
 \r
     // split content into array of single lines\r
     $lines = explode( "\n",$content );\r