From 19dd3171b11324f8bc80d68254370dfd62976f34 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 27 Aug 2004 15:50:18 +0000 Subject: [PATCH] Merged Howard's changes from HEAD --- lib/weblib.php | 8 ++++---- lib/wiki.php | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 19d590d139a..600fe1df8bb 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -623,7 +623,7 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL break; case FORMAT_WIKI: - $text = wiki_to_html($text); + $text = wiki_to_html($text,$courseid); $text = rebuildnolinktag($text); if (!isset($options->noclean)) { $text = clean_text($text, $format); @@ -908,14 +908,14 @@ function text_to_html($text, $smiley=true, $para=true, $newlines=true) { } } -function wiki_to_html($text) { +function wiki_to_html($text,$courseid) { /// Given Wiki formatted text, make it into XHTML using external function - global $CFG, $course; + global $CFG; require_once("$CFG->libdir/wiki.php"); $wiki = new Wiki; - return $wiki->format($text); + return $wiki->format($text,$courseid); } function markdown_to_html($text) { diff --git a/lib/wiki.php b/lib/wiki.php index 2d88fe296fb..a16790093fc 100644 --- a/lib/wiki.php +++ b/lib/wiki.php @@ -54,6 +54,7 @@ class Wiki { var $spelling_on; var $list_backtrack; var $output; // output buffer + var $courseid; function close_block( $state ) { // provide appropriate closure for block according to state @@ -270,23 +271,23 @@ class Wiki { " wwwroot."/mod/\\1/view.php?id=\\2\">\\3 ", $line ); // Replace picture resource link - global $course; // This is a bit risky - it won't work everywhere + // global $course; // This is a bit risky - it won't work everywhere if ($CFG->slasharguments) { $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", - "wwwroot/file.php/$course->id/\\1\\2\" alt=\"\\3\" />", $line ); + "wwwroot/file.php/$this->courseid/\\1\\2\" alt=\"\\3\" />", $line ); } else { $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", - "wwwroot/file.php\?file=$course->id/\\1\\2\" alt=\"\\3\" />", $line ); + "wwwroot/file.php\?file=$this->courseid/\\1\\2\" alt=\"\\3\" />", $line ); } // Replace everything else resource link if ($CFG->slasharguments) { $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", - "wwwroot/file.php/$course->id/\\1\" >\\2", $line ); + "wwwroot/file.php/$this->courseid/\\1\" >\\2", $line ); } else { $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", - "wwwroot/file.php\?file=$course->id/\\1\" >\\2", $line ); + "wwwroot/file.php\?file=$this->courseid/\\1\" >\\2", $line ); } replace_smilies( $line ); @@ -327,7 +328,7 @@ class Wiki { } - function format( $content ) { + function format( $content, $courseid ) { // main entry point for processing TikiText // $content is string containing text with Tiki formatting // return: string containing XHTML formatting @@ -339,6 +340,7 @@ class Wiki { $this->list_depth = 0; $this->list_backtrack = array(); $this->spelling_on = false; + $this->courseid = $courseid; // split content into array of single lines $lines = explode( "\n",$content );