<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: config.php,v 1.5 2005/04/29 09:10:11 henoheno Exp $
-// Copywrite (C) 2003-2005 PukiWiki Developers Team
+// config.php
+// Copyright 2003-2021 PukiWiki Development Team
// License: GPL v2 or (at your option) any later version
//
// Parse a PukiWiki page as a configuration page
function Config($name)
{
+ $this->__construct($name);
+ }
+ function __construct($name)
+ {
$this->name = $name;
$this->page = PKWK_CONFIG_PREFIX . $name;
}
if (! is_page($this->page)) return FALSE;
$this->objs = array();
- $obj = & new ConfigTable('');
+ $obj = new ConfigTable('');
$matches = array();
foreach (get_source($this->page) as $line) {
if ($line == '') continue;
- $head = $line{0}; // The first letter
+ $head = $line[0]; // The first letter
$level = strspn($line, $head);
if ($level > 3) {
if ($level == 1) {
$this->objs[$obj->title] = $obj;
- $obj = & new ConfigTable($line);
+ $obj = new ConfigTable($line);
} else {
if (! is_a($obj, 'ConfigTable_Direct'))
- $obj = & new ConfigTable_Direct('', $obj);
+ $obj = new ConfigTable_Direct('', $obj);
$obj->set_key($line);
}
} else if ($head == '-' && $level > 1) {
if (! is_a($obj, 'ConfigTable_Direct'))
- $obj = & new ConfigTable_Direct('', $obj);
+ $obj = new ConfigTable_Direct('', $obj);
$obj->add_value($line);
} else if ($head == '|' && preg_match('/^\|(.+)\|\s*$/', $line, $matches)) {
// Table row
if (! is_a($obj, 'ConfigTable_Sequential'))
- $obj = & new ConfigTable_Sequential('', $obj);
+ $obj = new ConfigTable_Sequential('', $obj);
// Trim() each table cell
$obj->add_value(array_map('trim', explode('|', $matches[1])));
} else {
function & get_object($title)
{
if (! isset($this->objs[$title]))
- $this->objs[$title] = & new ConfigTable('*' . trim($title) . "\n");
+ $this->objs[$title] = new ConfigTable('*' . trim($title) . "\n");
return $this->objs[$title];
}
function ConfigTable($title, $obj = NULL)
{
+ $this->__construct($title, $obj);
+ }
+ function __construct($title, $obj = NULL)
+ {
if ($obj !== NULL) {
$this->title = $obj->title;
$this->before = array_merge($obj->before, $obj->after);
return $retval;
}
}
-?>