Commit d1cea9f9 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 01bbb87c
...@@ -408,15 +408,15 @@ class Text_Wiki { ...@@ -408,15 +408,15 @@ class Text_Wiki {
* in further calls it will be effectively ignored. * in further calls it will be effectively ignored.
* @return &object a reference to the Text_Wiki unique instantiation. * @return &object a reference to the Text_Wiki unique instantiation.
*/ */
function &singleton($parser = 'Default', $rules = null) function singleton($parser = 'Default', $rules = null)
{ {
static $only = array(); static $only = array();
if (!isset($only[$parser])) { if (!isset($only[$parser])) {
$ret = & Text_Wiki::factory($parser, $rules); $ret = Text_Wiki::factory($parser, $rules);
if (Text_Wiki::isError($ret)) { if (Text_Wiki::isError($ret)) {
return $ret; return $ret;
} }
$only[$parser] =& $ret; $only[$parser] = $ret;
} }
return $only[$parser]; return $only[$parser];
} }
...@@ -432,7 +432,7 @@ class Text_Wiki { ...@@ -432,7 +432,7 @@ class Text_Wiki {
* {@see Text_Wiki::singleton} for a list of rules * {@see Text_Wiki::singleton} for a list of rules
* @return Text_Wiki a Parser object extended from Text_Wiki * @return Text_Wiki a Parser object extended from Text_Wiki
*/ */
function &factory($parser = 'Default', $rules = null) function factory($parser = 'Default', $rules = null)
{ {
$class = 'Text_Wiki_' . $parser; $class = 'Text_Wiki_' . $parser;
$file = str_replace('_', '/', $class).'.php'; $file = str_replace('_', '/', $class).'.php';
...@@ -445,7 +445,7 @@ class Text_Wiki { ...@@ -445,7 +445,7 @@ class Text_Wiki {
} }
} }
$obj =& new $class($rules); $obj = new $class($rules);
return $obj; return $obj;
} }
...@@ -920,7 +920,7 @@ class Text_Wiki { ...@@ -920,7 +920,7 @@ class Text_Wiki {
// load may have failed; only parse if // load may have failed; only parse if
// an object is in the array now // an object is in the array now
if (is_object($this->parseObj[$name])) { if (isset($this->parseObj[$name]) && is_object($this->parseObj[$name])) {
$this->parseObj[$name]->parse(); $this->parseObj[$name]->parse();
} }
} }
...@@ -1222,7 +1222,7 @@ class Text_Wiki { ...@@ -1222,7 +1222,7 @@ class Text_Wiki {
} }
} }
$this->parseObj[$rule] =& new $class($this); $this->parseObj[$rule] = new $class($this);
} }
...@@ -1258,7 +1258,7 @@ class Text_Wiki { ...@@ -1258,7 +1258,7 @@ class Text_Wiki {
} }
} }
$this->renderObj[$rule] =& new $class($this); $this->renderObj[$rule] = new $class($this);
} }
...@@ -1291,7 +1291,7 @@ class Text_Wiki { ...@@ -1291,7 +1291,7 @@ class Text_Wiki {
} }
} }
$this->formatObj[$format] =& new $class($this); $this->formatObj[$format] = new $class($this);
} }
......
...@@ -71,7 +71,7 @@ class Text_Wiki_Parse_Code extends Text_Wiki_Parse { ...@@ -71,7 +71,7 @@ class Text_Wiki_Parse_Code extends Text_Wiki_Parse {
{ {
// are there additional attribute arguments? // are there additional attribute arguments?
$args = trim($matches[1]); $args = trim($matches[1]);
if ($args == '') { if ($args == '') {
$options = array( $options = array(
'text' => $matches[2], 'text' => $matches[2],
......
...@@ -58,35 +58,39 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render { ...@@ -58,35 +58,39 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
$css_html = $this->formatConf(' class="%s"', 'css_html'); $css_html = $this->formatConf(' class="%s"', 'css_html');
$css_filename = $this->formatConf(' class="%s"', 'css_filename'); $css_filename = $this->formatConf(' class="%s"', 'css_filename');
if ($type == 'php') { if ($type == 'php' || true) {
if (substr($options['text'], 0, 5) != '<?php') { if (substr($options['text'], 0, 5) != '<?php') {
// PHP code example: // PHP code example:
// add the PHP tags // add the PHP tags
$text = "<?php\n" . $options['text'] . "\n?>"; // <?php $text = "<?php
" . $options['text'] . "\n?>"; // <?php
} }
// convert tabs to four spaces // convert tabs to four spaces
$text = str_replace("\t", " ", $text); $text = str_replace("\t", "&nbsp;&nbsp;%nbsp;&nbsp;", $text);
// colorize the code block (also converts HTML entities and adds // colorize the code block (also converts HTML entities and adds
// <code>...</code> tags) // <code>...</code> tags)
ob_start(); $h = new PHP_Highlight;
highlight_string($text); $h->loadString($text);
$text = ob_get_contents(); $text = $h->toHtml(true);
ob_end_clean();
// replace <br /> tags with simple newlines. // replace <br /> tags with simple newlines.
// replace non-breaking space with simple spaces. // replace non-breaking space with simple spaces.
// translate HTML <font> and color to XHTML <span> and style. // translate HTML <font> and color to XHTML <span> and style.
// courtesy of research by A. Kalin :-). // courtesy of research by A. Kalin :-).
/**
$map = array( $map = array(
'<br />' => "\n", '<br />' => "\n",
'&nbsp;' => ' ', '&nbsp;' => ' ',
"\n" => "<br \>",
'<font' => '<span', '<font' => '<span',
'</font>' => '</span>', '</font>' => '</span>',
'color="' => 'style="color:' 'color="' => 'style="color:'
); );
$text = strtr($text, $map); $text = strtr($text, $map);
*/
// get rid of the last newline inside the code block // get rid of the last newline inside the code block
// (becuase higlight_string puts one there) // (becuase higlight_string puts one there)
...@@ -100,7 +104,10 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render { ...@@ -100,7 +104,10 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
} }
// done // done
$text = "<pre$css>$text</pre>"; $text = "<table border=1 class='dashed' cellpadding=0 cellspacing=0>
<tr><td><b>$text
</b></td></tr>
</table>";
} elseif ($type == 'html' || $type == 'xhtml') { } elseif ($type == 'html' || $type == 'xhtml') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment