/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: convert_html.php,v 1.1 2004/08/01 01:54:35 henoheno Exp $
+// $Id: convert_html.php,v 1.2 2004/09/19 14:05:30 henoheno Exp $
//
function convert_html($lines)
}
}
+ // PHP5 mod: $this cannot be reassigned
+function &Factory_Inline($text)
+{
+ if (substr($text,0,1) == '~') { // ¹ÔƬ~¡£¥Ñ¥é¥°¥é¥Õ³«»Ï
+ return new Paragraph(' '.substr($text,1));
+ }
+ return new Inline($text);
+}
+
+ // PHP5 mod: $this cannot be reassigned
+function &Factory_DList(&$root, $text)
+{
+ $out = explode('|', ltrim($text), 2);
+ if (count($out) < 2) {
+ return Factory_Inline($text);
+ }
+
+ return new DList($out);
+}
+
+ // PHP5 mod: $this cannot be reassigned
+function &Factory_Table(&$root, $text)
+{
+ if (!preg_match("/^\|(.+)\|([hHfFcC]?)$/",$text,$out)) {
+ return Factory_Inline($text);
+ }
+ return new Table($out);
+}
+
+ // PHP5 mod: $this cannot be reassigned
+function &Factory_YTable(&$root,$text)
+{
+ $_value = csv_explode(',', substr($text,1));
+ if (count($_value) == 0) {
+ return Factory_Inline($text);
+ }
+ return new YTable($_value);
+}
+
+ // PHP5 mod: $this cannot be reassigned
+function &Factory_Div(&$root,$text)
+{
+ if (!preg_match("/^\#([^\(]+)(?:\((.*)\))?/", $text, $out) or !exist_plugin_convert($out[1])) {
+ return new Paragraph($text);
+ }
+ return new Div($out);
+}
+
class Inline extends Element
{ // ¥¤¥ó¥é¥¤¥óÍ×ÁÇ
{
parent::Element();
- if (substr($text,0,1) == '~') // ¹ÔƬ~¡£¥Ñ¥é¥°¥é¥Õ³«»Ï
- {
- $this = new Paragraph(' '.substr($text,1));
- $this->last = &$this;
-
- return;
- }
$this->elements[] = trim((substr($text, 0, 1) == "\n") ? $text : make_link($text));
}
{
$text = ' '.substr($text, 1);
}
- $this->insert(new Inline($text));
+ $this->insert(Factory_Inline($text));
}
function canContain($obj)
$this->level = min(3, strspn($text, '*'));
list($text, $this->msg_top, $this->id) = $root->getAnchor($text, $this->level);
- $this->insert(new Inline($text));
+ $this->insert(Factory_Inline($text));
$this->level++; // h2,h3,h4
}
parent::insert(new ListElement($this->level, $tag2));
if ($text != '')
{
- $this->last = &$this->last->insert(new Inline($text));
+ $this->last = &$this->last->insert(Factory_Inline($text));
}
}
class DList extends ListContainer
{ // :
- function DList(&$root, $text)
+ function DList($out)
{
- $out = explode('|', $text, 2);
- if (count($out) < 2)
- {
- $this = new Inline($text);
- $this->last = &$this;
-
- return;
- }
parent::ListContainer('dl', 'dt', ':', $out[0]);
$this->last = &Element::insert(new ListElement($this->level, 'dd'));
if ($out[1] != '')
{
- $this->last = &$this->last->insert(new Inline($out[1]));
+ $this->last = &$this->last->insert(Factory_Inline($out[1]));
}
}
}
$this->last = &$this->end($root, $level);
if ($text != '')
{
- $this->last = &$this->last->insert(new Inline($text));
+ $this->last = &$this->last->insert(Factory_Inline($text));
}
}
else
{
- $this->insert(new Inline($text));
+ $this->insert(Factory_Inline($text));
}
}
if ($text != '' and $text{0} == '#')
{
// ¥»¥ëÆâÍƤ¬'#'¤Ç»Ï¤Þ¤ë¤È¤¤ÏDiv¥¯¥é¥¹¤òÄ̤·¤Æ¤ß¤ë
- $obj = &new Div($this, $text);
+ $obj = &Factory_Div($this, $text);
if (is_a($obj, 'Paragraph'))
{
$obj = &$obj->elements[0];
}
else
{
- $obj = &new Inline($text);
+ $obj = &Factory_Inline($text);
}
$this->insert($obj);
}
var $types;
var $col; // number of column
- function Table(&$root, $text)
+ function Table($out)
{
parent::Element();
- $out = array();
- if (!preg_match("/^\|(.+)\|([hHfFcC]?)$/", $text, $out))
- {
- $this = new Inline($text);
- $this->last = &$this;
-
- return;
- }
$cells = explode('|', $out[1]);
$this->col = count($cells);
$this->type = strtolower($out[2]);
{ // ,
var $col;
- function YTable(&$root, $text)
+ function YTable($_value)
{
parent::Element();
- $_value = csv_explode(',', substr($text,1));
- if (count($_value) == 0)
- {
- $this = new Inline($text);
- $this->last = &$this;
-
- return;
- }
$align = $value = $matches = array();
foreach($_value as $val)
{
var $name;
var $param;
- function Div(&$root, $text)
+ function Div($out)
{
parent::Element();
- if (!preg_match("/^\#([^\(]+)(?:\((.*)\))?/", $text, $out) or !exist_plugin_convert($out[1]))
- {
- $this = new Paragraph($text);
- $this->last = &$this;
-
- return;
- }
list(, $this->name, $this->param) = array_pad($out,3,'');
}
var $classes = array(
'-' => 'UList',
'+' => 'OList',
+ '>' => 'BQuote',
+ '<' => 'BQuote'
+ );
+ var $factories = array(
':' => 'DList',
'|' => 'Table',
',' => 'YTable',
- '>' => 'BQuote',
- '<' => 'BQuote',
'#' => 'Div'
);
$this->last = &$this->last->add(new $classname($this,$line));
continue;
}
+ // Other Character
+ if (array_key_exists($head, $this->factories))
+ {
+ $factoryname = 'Factory_'. $this->factories[$head];
+ $this->last = &$this->last->add($factoryname($this,$line));
+ continue;
+ }
// Default
- $this->last = &$this->last->add(new Inline($line));
+ $this->last = &$this->last->add(Factory_Inline($line));
}
}
make_heading($text);
$text = "\n<a href=\"#$id\">$text</a>\n";
parent::ListContainer('ul', 'li', '-', str_repeat('-',$level));
- $this->insert(new Inline($text));
+ $this->insert(Factory_Inline($text));
}
function setParent(&$parent)
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: make_link.php,v 1.1 2004/08/01 01:54:35 henoheno Exp $
+// $Id: make_link.php,v 1.2 2004/09/19 14:05:30 henoheno Exp $
//
// ¥ê¥ó¥¯¤òÉղ乤ë
{
$converter = new InlineConverter();
}
- $_converter = $converter; // copy
+ $_converter = $converter->get_clone($converter);
return $_converter->convert($string, ($page != '') ? $page : $vars['page']);
}
//¥¤¥ó¥é¥¤¥óÍ×ÁǤòÃÖ´¹¤¹¤ë
var $pos;
var $result;
+ function get_clone($obj) {
+ static $clone_func;
+
+ if (!isset($clone_func)) {
+ if (version_compare(PHP_VERSION,'5.0.0','<')) {
+ $clone_func = create_function('$a','return $a;');
+ } else {
+ $clone_func = create_function('$a','return clone $a;');
+ }
+ }
+ return $clone_func($obj);
+ }
+ function __clone() {
+ $converters = array();
+ foreach ($this->converters as $key=>$converter) {
+ $converters[$key] = $this->get_clone($converter);
+ }
+ $this->converters = $converters;
+ }
function InlineConverter($converters=NULL,$excludes=NULL)
{
if ($converters === NULL)
$obj = $this->get_converter($match);
if ($obj->set($match,$page) !== FALSE)
{
- $arr[] = $obj; // copy
+ $arr[] = $this->get_clone($obj);
if ($obj->body != '')
{
$arr = array_merge($arr,$this->get_objects($obj->body,$page));
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: showrss.inc.php,v 1.13 2004/07/31 03:09:20 henoheno Exp $
+// $Id: showrss.inc.php,v 1.14 2004/09/19 14:05:30 henoheno Exp $
//
// Modified version by PANDA <panda@arino.jp>
//
var $item;
var $is_item;
var $tag;
+ var $encoding;
function parse($buf)
{
$this->is_item = FALSE;
$this->tag = '';
- $xml_parser = xml_parser_create();
+ // ʸ»ú¥³¡¼¥É¸¡½Ð
+ $this->encoding = mb_detect_encoding($buf);
+ if (!in_array(strtolower($this->encoding),array('us-ascii','iso-8859-1','utf-8'))) {
+ $buf = mb_convert_encoding($buf,'utf-8',$this->encoding);
+ $this->encoding = 'utf-8';
+ }
+ $xml_parser = xml_parser_create($this->encoding);
xml_set_element_handler($xml_parser,array(&$this,'start_element'),array(&$this,'end_element'));
xml_set_character_data_handler($xml_parser,array(&$this,'character_data'));
$str = htmlspecialchars($str);
// ʸ»ú¥³¡¼¥ÉÊÑ´¹
- $str = mb_convert_encoding($str, SOURCE_ENCODING, 'auto');
+ $str = mb_convert_encoding($str, SOURCE_ENCODING, $this->encoding);
return trim($str);
}