1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
zYne 2007-02-23 19:45:22 +00:00
parent 01bbb87cdf
commit d1cea9f9a3
3 changed files with 25 additions and 18 deletions

18
vendor/Text/Wiki.php vendored
View File

@ -408,15 +408,15 @@ class Text_Wiki {
* in further calls it will be effectively ignored.
* @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();
if (!isset($only[$parser])) {
$ret = & Text_Wiki::factory($parser, $rules);
$ret = Text_Wiki::factory($parser, $rules);
if (Text_Wiki::isError($ret)) {
return $ret;
}
$only[$parser] =& $ret;
$only[$parser] = $ret;
}
return $only[$parser];
}
@ -432,7 +432,7 @@ class Text_Wiki {
* {@see Text_Wiki::singleton} for a list of rules
* @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;
$file = str_replace('_', '/', $class).'.php';
@ -445,7 +445,7 @@ class Text_Wiki {
}
}
$obj =& new $class($rules);
$obj = new $class($rules);
return $obj;
}
@ -920,7 +920,7 @@ class Text_Wiki {
// load may have failed; only parse if
// 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();
}
}
@ -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 {
}
}
$this->renderObj[$rule] =& new $class($this);
$this->renderObj[$rule] = new $class($this);
}
@ -1291,7 +1291,7 @@ class Text_Wiki {
}
}
$this->formatObj[$format] =& new $class($this);
$this->formatObj[$format] = new $class($this);
}

View File

@ -71,7 +71,7 @@ class Text_Wiki_Parse_Code extends Text_Wiki_Parse {
{
// are there additional attribute arguments?
$args = trim($matches[1]);
if ($args == '') {
$options = array(
'text' => $matches[2],

View File

@ -58,35 +58,39 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
$css_html = $this->formatConf(' class="%s"', 'css_html');
$css_filename = $this->formatConf(' class="%s"', 'css_filename');
if ($type == 'php') {
if ($type == 'php' || true) {
if (substr($options['text'], 0, 5) != '<?php') {
// PHP code example:
// add the PHP tags
$text = "<?php\n" . $options['text'] . "\n?>"; // <?php
$text = "<?php
" . $options['text'] . "\n?>"; // <?php
}
// 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
// <code>...</code> tags)
ob_start();
highlight_string($text);
$text = ob_get_contents();
ob_end_clean();
$h = new PHP_Highlight;
$h->loadString($text);
$text = $h->toHtml(true);
// replace <br /> tags with simple newlines.
// replace non-breaking space with simple spaces.
// translate HTML <font> and color to XHTML <span> and style.
// courtesy of research by A. Kalin :-).
/**
$map = array(
'<br />' => "\n",
'&nbsp;' => ' ',
"\n" => "<br \>",
'<font' => '<span',
'</font>' => '</span>',
'color="' => 'style="color:'
);
$text = strtr($text, $map);
*/
// get rid of the last newline inside the code block
// (becuase higlight_string puts one there)
@ -100,7 +104,10 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
}
// 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') {