cvs: phd /phpdotnet/phd BuildOptionsParser.php Config.php Format.php Index.php ObjectStorage.php Reader.php Render.php /phpdotnet/phd/Format
Factory.php /phpdotnet/phd/Package/Default Factory.php XHTML.php
| From: | Moacir de Oliveira Miranda Júnior | Date: | Sat, 20 Jun 2009 06:55:42 +0000 |
| Subject: | cvs: phd /phpdotnet/phd BuildOptionsParser.php Config.php Format.php Index.php ObjectStorage.php Reader.php Render.php /phpdotnet/phd/Format Factory.php /phpdotnet/phd/Package/Default Factory.php XHTML.php |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4169@lists.php.net to get a copy of this message | ||
moacir Sat Jun 20 06:55:42 2009 UTC
Modified files:
/phd/phpdotnet/phd Config.php BuildOptionsParser.php Format.php
Index.php ObjectStorage.php Reader.php
Render.php
/phd/phpdotnet/phd/Format Factory.php
/phd/phpdotnet/phd/Package/Default Factory.php XHTML.php
Log:
fixing class names bugs
http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Config.php?r1=1.60&r2=1.61&diff_format=u Index: phd/phpdotnet/phd/Config.php diff -u phd/phpdotnet/phd/Config.php:1.60 phd/phpdotnet/phd/Config.php:1.61 --- phd/phpdotnet/phd/Config.php:1.60 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Config.php Sat Jun 20 06:55:41 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Config.php,v 1.60 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: Config.php,v 1.61 2009/06/20 06:55:41 moacir Exp $ */ define("PHD_VERSION", "phd-from-cvs"); @@ -67,22 +67,6 @@ Config::set_user_error_output(STDERR); Config::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists('getopt')) { - //Use PEAR's PHP_Compat package - @include_once('PHP/Compat/Function/getopt.php'); -} -if (!function_exists('getopt')) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please install PEAR's PHP_Compat package."); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -110,39 +94,6 @@ } /* }}} */ -abstract class OptionParser -{ - abstract public function getOptionList(); - - public function handlerForOption($opt) - { - if (method_exists($this, "option_{$opt}")) { - return array($this, "option_{$opt}"); - } else { - return NULL; - } - } - - public function getopt() - { - $opts = $this->getOptionList(); - $args = getopt(implode("", array_values($opts)), array_keys($opts)); - if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); - } - - foreach ($args as $k => $v) { - $handler = $this->handlerForOption($k); - if (is_callable($handler)) { - call_user_func($handler, $k, $v); - } else { - var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); - } - } - } -} - /* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ function val($a, $k) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/BuildOptionsParser.php?r1=1.15&r2=1.16&diff_format=u Index: phd/phpdotnet/phd/BuildOptionsParser.php diff -u phd/phpdotnet/phd/BuildOptionsParser.php:1.15 phd/phpdotnet/phd/BuildOptionsParser.php:1.16 --- phd/phpdotnet/phd/BuildOptionsParser.php:1.15 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/BuildOptionsParser.php Sat Jun 20 06:55:41 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: BuildOptionsParser.php,v 1.15 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: BuildOptionsParser.php,v 1.16 2009/06/20 06:55:41 moacir Exp $ */ class BuildOptionsParser extends OptionParser { @@ -332,7 +332,53 @@ } } -$optParser = new BuildOptionsParser; -$optParser->getopt(); +abstract class OptionParser +{ + abstract public function getOptionList(); + + public function handlerForOption($opt) + { + if (method_exists($this, "option_{$opt}")) { + return array($this, "option_{$opt}"); + } else { + return NULL; + } + } + + public function getopt() + { + $opts = $this->getOptionList(); + $args = getopt(implode("", array_values($opts)), array_keys($opts)); + if ($args === false) { + trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + } + + foreach ($args as $k => $v) { + $handler = $this->handlerForOption($k); + if (is_callable($handler)) { + call_user_func($handler, $k, $v); + } else { + var_dump($k, $v); + trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + } + } + } +} + +/* {{{ Workaround/fix for Windows prior to PHP5.3 */ +if (!function_exists('getopt')) { + //Use PEAR's PHP_Compat package + @include_once('PHP/Compat/Function/getopt.php'); +} +if (!function_exists('getopt')) { + function getopt($short, $long) { + global $argv; + printf("I'm sorry, you are running an operating system that does not support getopt()\n"); + printf("Please install PEAR's PHP_Compat package."); + + return array(); + } +} +/* }}} */ ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Format.php diff -u phd/phpdotnet/phd/Format.php:1.2 phd/phpdotnet/phd/Format.php:1.3 --- phd/phpdotnet/phd/Format.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format.php Sat Jun 20 06:55:41 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -abstract class EnterpriseFormat extends ObjectStorage { +abstract class Format extends ObjectStorage { const SDESC = 1; const LDESC = 2; @@ -18,7 +18,7 @@ public function __construct() { if (file_exists(Config::output_dir() . "index.sqlite")) { - $this->sqlite = new SQLite3(Config::output_dir() . 'index.sqlite'); + $this->sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite'); $this->sortIDs(); } } @@ -27,7 +27,7 @@ abstract public function UNDEF($open, $name, $attrs, $props); abstract public function TEXT($value); abstract public function CDATA($value); - abstract public function createLink($for, &$desc = null, $type = EnterpriseFormat::SDESC); + abstract public function createLink($for, &$desc = null, $type = Format::SDESC); abstract public function appendData($data); abstract public function update($event, $value = null); @@ -81,7 +81,7 @@ } final public function attach($obj, $inf = array()) { if (!($obj instanceof $this) && get_class($obj) != get_class($this)) { - throw new InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($obj)); + throw new \InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($obj)); } $obj->notify(Render::STANDALONE, false); return parent::attach($obj, $inf); @@ -105,7 +105,7 @@ final public function parse($xml) { $parsed = ""; - $reader = new EnterpriseReader(); + $reader = new Reader(); $render = new Render(); $reader->XML("<notatag>" . $xml . "</notatag>"); @@ -121,28 +121,31 @@ } final public static function autogen($text, $lang) { + if ($lang === NULL) { + $lang = Config::language(); + } if (isset(self::$autogen[$lang])) { if (isset(self::$autogen[$lang][$text])) { return self::$autogen[$lang][$text]; } if ($lang == Config::fallback_language()) { - throw new InvalidArgumentException("Cannot autogenerate text for '$text'"); + throw new \InvalidArgumentException("Cannot autogenerate text for '$text'"); } return self::autogen($text, Config::fallback_language()); } $filename = Config::lang_dir() . $lang . ".xml"; - $r = new XMLReader; + $r = new \XMLReader(); if (!file_exists($filename) || !$r->open($filename)) { if ($lang == Config::fallback_language()) { - throw new Exception("Cannot open $filename"); + throw new \Exception("Cannot open $filename"); } return self::autogen($text, Config::fallback_language()); } $autogen = array(); while ($r->read()) { - if ($r->nodeType != XMLReader::ELEMENT) { + if ($r->nodeType != \XMLReader::ELEMENT) { continue; } if ($r->name == "term") { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Index.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/Index.php diff -u phd/phpdotnet/phd/Index.php:1.4 phd/phpdotnet/phd/Index.php:1.5 --- phd/phpdotnet/phd/Index.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Index.php Sat Jun 20 06:55:41 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -class Index extends Format_Enterprise +class Index extends Format { private $myelementmap = array( 'article' => 'format_container_chunk', @@ -75,7 +75,7 @@ } public function CDATA($value) { } - public function createLink($for, &$desc = null, $type = Format_Enterprise::SDESC) { + public function createLink($for, &$desc = null, $type = Format::SDESC) { } public function appendData($data) { } @@ -83,7 +83,7 @@ // or if xml input file has changed since the last indexing final static public function requireIndexing() { if (!Config::index() && file_exists(Config::output_dir() . "index.sqlite")) { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $indexingCount = $db->query('SELECT COUNT(time) FROM indexing')->fetchArray(SQLITE3_NUM); if ($indexingCount[0] > 0) { $indexing = $db->query('SELECT time FROM indexing')->fetchArray(SQLITE3_ASSOC); @@ -110,11 +110,11 @@ case Render::INIT: if ($value) { if (file_exists(Config::output_dir() . "index.sqlite")) { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $db->exec('DELETE FROM ids'); $db->exec('DELETE FROM indexing'); } else { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $create = <<<SQL CREATE TABLE ids ( docbook_id TEXT PRIMARY KEY, @@ -155,14 +155,14 @@ } public function UNDEF($open, $name, $attrs, $props) { /*if ($open) { - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; $this->storeInfo($name, $id, $this->currentchunk); } return false; } - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { + if(isset($attrs[Reader::XMLNS_XML]["id"])) { $this->appendID(); }*/ return false; @@ -238,8 +238,8 @@ if ($props["sibling"] === $name) { return $this->format_chunk($open, $name, $attrs, $props); } - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; return $this->storeInfo($name, $id, $this->currentchunk, false); } return $this->UNDEF($open, $name, $attrs, $props); @@ -249,8 +249,8 @@ return $this->format_chunk($open, $name, $attrs, $props); } $sectionChunks[] = $x; - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; return $this->appendID(false); } return $this->UNDEF($open, $name, $attrs, $props); @@ -260,8 +260,8 @@ } public function format_chunk($open, $name, $attrs, $props) { if ($open) { - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; } else { $id = uniqid("phd"); } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/ObjectStorage.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/ObjectStorage.php diff -u phd/phpdotnet/phd/ObjectStorage.php:1.4 phd/phpdotnet/phd/ObjectStorage.php:1.5 --- phd/phpdotnet/phd/ObjectStorage.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/ObjectStorage.php Sat Jun 20 06:55:42 2009 @@ -6,20 +6,20 @@ protected static $r = array(); public function attach($obj, $inf = array()) { - if (!($obj instanceof Format_Enterprise)) { + if (!($obj instanceof Format)) { throw new InvalidArgumentException( - 'Only classess inheriting ' . __NAMESPACE__ . '\\Format_Enterprise supported' + 'Only classess inheriting ' . __NAMESPACE__ . '\\Format supported' ); } if (empty($inf)) { $inf = array( - XMLReader::ELEMENT => $obj->getElementMap(), - XMLReader::TEXT => $obj->getTextMap(), + \XMLReader::ELEMENT => $obj->getElementMap(), + \XMLReader::TEXT => $obj->getTextMap(), ); } parent::attach($obj, $inf); } - final protected static function setReader(Reader_Enterprise $r) { + final protected static function setReader(Reader $r) { self::$r[] = $r; } final protected function getReader() { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Reader.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Reader.php diff -u phd/phpdotnet/phd/Reader.php:1.2 phd/phpdotnet/phd/Reader.php:1.3 --- phd/phpdotnet/phd/Reader.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Reader.php Sat Jun 20 06:55:42 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Reader.php,v 1.2 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: Reader.php,v 1.3 2009/06/20 06:55:42 moacir Exp $ */ //6271 class Reader extends \XMLReader @@ -14,103 +14,103 @@ } public function close() { - return XMLReader::close(); + return parent::close(); } public function getAttribute($name) { - return XMLReader::getAttribute($name); + return parent::getAttribute($name); } public function getAttributeNo($index) { - return XMLReader::getAttributeNo($index); + return parent::getAttributeNo($index); } public function getAttributeNs($name, $namespaceURI) { - return XMLReader::getAttributeNs($name, $namespaceURI); + return parent::getAttributeNs($name, $namespaceURI); } public function getParserProperty($property) { - return XMLReader::getParserProperty($property); + return parent::getParserProperty($property); } public function isValid() { - return XMLReader::isValid(); + return parent::isValid(); } public function lookupNamespace($prefix) { - return XMLReader::lookupNamespace($prefix); + return parent::lookupNamespace($prefix); } public function moveToAttributeNo($index) { - return XMLReader::moveToAttributeNo($index); + return parent::moveToAttributeNo($index); } public function moveToAttribute($name) { - return XMLReader::moveToAttribute($name); + return parent::moveToAttribute($name); } public function moveToAttributeNs($name, $namespaceURI) { - return XMLReader::moveToAttributeNs($name, $namespaceURI); + return parent::moveToAttributeNs($name, $namespaceURI); } public function moveToElement() { - return XMLReader::moveToElement(); + return parent::moveToElement(); } public function moveToFirstAttribute() { - return XMLReader::moveToFirstAttribute(); + return parent::moveToFirstAttribute(); } public function moveToNextAttribute() { - return XMLReader::moveToNextAttribute(); + return parent::moveToNextAttribute(); } public function open($URI, $encoding = null, $options = null) { - return XMLReader::open($URI, $encoding, $options); + return parent::open($URI, $encoding, $options); } public function read() { - return XMLReader::read(); + return parent::read(); } public function next($localname = null) { - return XMLReader::next($localname); + return parent::next($localname); } public function readInnerXml() { - return XMLReader::readInnerXml(); + return parent::readInnerXml(); } public function readOuterXml() { - return XMLReader::readOuterXml(); + return parent::readOuterXml(); } public function readString() { - return XMLReader::readString(); + return parent::readString(); } public function setSchema($filename) { - return XMLReader::setSchema($filename); + return parent::setSchema($filename); } public function setParserProperty($property, $value) { - return XMLReader::setParserProperty($property, $value); + return parent::setParserProperty($property, $value); } public function setRelaxNGSchema($filename) { - return XMLReader::setRelaxNGSchema($filename); + return parent::setRelaxNGSchema($filename); } public function setRelaxNGSchemaSource($source) { - return XMLReader::setRelaxNGSchemaSource($source); + return parent::setRelaxNGSchemaSource($source); } public function XML($source, $encoding = null, $options = null) { - return XMLReader::XML($source, $encoding, $options); + return parent::XML($source, $encoding, $options); } public function expand() { - return XMLReader::expand(); + return parent::expand(); } } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Render.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/Render.php diff -u phd/phpdotnet/phd/Render.php:1.4 phd/phpdotnet/phd/Render.php:1.5 --- phd/phpdotnet/phd/Render.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Render.php Sat Jun 20 06:55:42 2009 @@ -51,10 +51,10 @@ $data = $retval = $name = $open = false; switch($type) { - case XMLReader::ELEMENT: /* {{{ */ + case \XMLReader::ELEMENT: /* {{{ */ $open = true; /* break intentionally omitted */ - case XMLReader::END_ELEMENT: + case \XMLReader::END_ELEMENT: $name = $r->name; $depth = $r->depth; $attrs = array( @@ -86,7 +86,7 @@ continue; foreach($this as $format) { - $map = $this[$format][XMLReader::ELEMENT]; + $map = $this[$format][\XMLReader::ELEMENT]; if (isset($map[$name]) === false) { $data = $format->UNDEF($open, $name, $attrs, $props); @@ -113,7 +113,7 @@ $format->appendData($data); foreach($format as $theme) { - $map = $format[$theme][XMLReader::ELEMENT]; + $map = $format[$theme][\XMLReader::ELEMENT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -137,13 +137,13 @@ break; /* }}} */ - case XMLReader::TEXT: /* {{{ */ + case \XMLReader::TEXT: /* {{{ */ $value = $r->value; $eldepth = $r->depth - 1; $name = $this->STACK[$eldepth]; foreach($this as $format) { - $map = $this[$format][XMLReader::TEXT]; + $map = $this[$format][\XMLReader::TEXT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -167,7 +167,7 @@ } foreach($format as $theme) { - $map = $format[$theme][XMLReader::TEXT]; + $map = $format[$theme][\XMLReader::TEXT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -188,7 +188,7 @@ break; /* }}} */ - case XMLReader::CDATA: /* {{{ */ + case \XMLReader::CDATA: /* {{{ */ /* Different formats may want to escape the CDATA sections differently */ $value = $r->value; foreach($this as $format) { @@ -201,8 +201,8 @@ break; /* }}} */ - case XMLReader::WHITESPACE: /* {{{ */ - case XMLReader::SIGNIFICANT_WHITESPACE: + case \XMLReader::WHITESPACE: /* {{{ */ + case \XMLReader::SIGNIFICANT_WHITESPACE: /* WS is always WS */ $retval = $r->value; foreach($this as $format) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format/Factory.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Format/Factory.php diff -u phd/phpdotnet/phd/Format/Factory.php:1.3 phd/phpdotnet/phd/Format/Factory.php:1.4 --- phd/phpdotnet/phd/Format/Factory.php:1.3 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format/Factory.php Sat Jun 20 06:55:42 2009 @@ -15,15 +15,12 @@ public static final function createFactory() { - global $ROOT; $package = Config::package(); - $classname = "{$package}Factory"; - - require_once $ROOT . "/packages/$package/$classname.class.php"; + $classname = __NAMESPACE__ . "\\Package_" . $package . "_Factory"; $factory = new $classname(); if (!($factory instanceof Format_Factory)) { - throw new Exception("All Factories must inherit PhDFormatFactory"); + throw new \Exception("All Factories must inherit Format_Factory"); } return $factory; } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/Factory.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Package/Default/Factory.php diff -u phd/phpdotnet/phd/Package/Default/Factory.php:1.2 phd/phpdotnet/phd/Package/Default/Factory.php:1.3 --- phd/phpdotnet/phd/Package/Default/Factory.php:1.2 Fri Jun 19 21:48:54 2009 +++ phd/phpdotnet/phd/Package/Default/Factory.php Sat Jun 20 06:55:42 2009 @@ -4,7 +4,7 @@ class Package_Default_Factory extends Format_Factory { public function createXhtmlFormat() { - return new Format_Default_XHTML(); + return new Package_Default_XHTML(); } /* public function createBigXhtmlFormat() { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/XHTML.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Package/Default/XHTML.php diff -u phd/phpdotnet/phd/Package/Default/XHTML.php:1.2 phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 --- phd/phpdotnet/phd/Package/Default/XHTML.php:1.2 Fri Jun 19 21:48:54 2009 +++ phd/phpdotnet/phd/Package/Default/XHTML.php Sat Jun 20 06:55:42 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -class Format_Default_XHTML extends Format_Abstract_XHTML +class Package_Default_XHTML extends Format_Abstract_XHTML { private $formatname = "XHTML"; private $myelementmap = array( /* {{{ */
http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Config.php?r1=1.60&r2=1.61&diff_format=u Index: phd/phpdotnet/phd/Config.php diff -u phd/phpdotnet/phd/Config.php:1.60 phd/phpdotnet/phd/Config.php:1.61 --- phd/phpdotnet/phd/Config.php:1.60 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Config.php Sat Jun 20 06:55:41 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Config.php,v 1.60 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: Config.php,v 1.61 2009/06/20 06:55:41 moacir Exp $ */ define("PHD_VERSION", "phd-from-cvs"); @@ -67,22 +67,6 @@ Config::set_user_error_output(STDERR); Config::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists('getopt')) { - //Use PEAR's PHP_Compat package - @include_once('PHP/Compat/Function/getopt.php'); -} -if (!function_exists('getopt')) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please install PEAR's PHP_Compat package."); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -110,39 +94,6 @@ } /* }}} */ -abstract class OptionParser -{ - abstract public function getOptionList(); - - public function handlerForOption($opt) - { - if (method_exists($this, "option_{$opt}")) { - return array($this, "option_{$opt}"); - } else { - return NULL; - } - } - - public function getopt() - { - $opts = $this->getOptionList(); - $args = getopt(implode("", array_values($opts)), array_keys($opts)); - if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); - } - - foreach ($args as $k => $v) { - $handler = $this->handlerForOption($k); - if (is_callable($handler)) { - call_user_func($handler, $k, $v); - } else { - var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); - } - } - } -} - /* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ function val($a, $k) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/BuildOptionsParser.php?r1=1.15&r2=1.16&diff_format=u Index: phd/phpdotnet/phd/BuildOptionsParser.php diff -u phd/phpdotnet/phd/BuildOptionsParser.php:1.15 phd/phpdotnet/phd/BuildOptionsParser.php:1.16 --- phd/phpdotnet/phd/BuildOptionsParser.php:1.15 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/BuildOptionsParser.php Sat Jun 20 06:55:41 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: BuildOptionsParser.php,v 1.15 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: BuildOptionsParser.php,v 1.16 2009/06/20 06:55:41 moacir Exp $ */ class BuildOptionsParser extends OptionParser { @@ -332,7 +332,53 @@ } } -$optParser = new BuildOptionsParser; -$optParser->getopt(); +abstract class OptionParser +{ + abstract public function getOptionList(); + + public function handlerForOption($opt) + { + if (method_exists($this, "option_{$opt}")) { + return array($this, "option_{$opt}"); + } else { + return NULL; + } + } + + public function getopt() + { + $opts = $this->getOptionList(); + $args = getopt(implode("", array_values($opts)), array_keys($opts)); + if ($args === false) { + trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + } + + foreach ($args as $k => $v) { + $handler = $this->handlerForOption($k); + if (is_callable($handler)) { + call_user_func($handler, $k, $v); + } else { + var_dump($k, $v); + trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + } + } + } +} + +/* {{{ Workaround/fix for Windows prior to PHP5.3 */ +if (!function_exists('getopt')) { + //Use PEAR's PHP_Compat package + @include_once('PHP/Compat/Function/getopt.php'); +} +if (!function_exists('getopt')) { + function getopt($short, $long) { + global $argv; + printf("I'm sorry, you are running an operating system that does not support getopt()\n"); + printf("Please install PEAR's PHP_Compat package."); + + return array(); + } +} +/* }}} */ ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Format.php diff -u phd/phpdotnet/phd/Format.php:1.2 phd/phpdotnet/phd/Format.php:1.3 --- phd/phpdotnet/phd/Format.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format.php Sat Jun 20 06:55:41 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -abstract class EnterpriseFormat extends ObjectStorage { +abstract class Format extends ObjectStorage { const SDESC = 1; const LDESC = 2; @@ -18,7 +18,7 @@ public function __construct() { if (file_exists(Config::output_dir() . "index.sqlite")) { - $this->sqlite = new SQLite3(Config::output_dir() . 'index.sqlite'); + $this->sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite'); $this->sortIDs(); } } @@ -27,7 +27,7 @@ abstract public function UNDEF($open, $name, $attrs, $props); abstract public function TEXT($value); abstract public function CDATA($value); - abstract public function createLink($for, &$desc = null, $type = EnterpriseFormat::SDESC); + abstract public function createLink($for, &$desc = null, $type = Format::SDESC); abstract public function appendData($data); abstract public function update($event, $value = null); @@ -81,7 +81,7 @@ } final public function attach($obj, $inf = array()) { if (!($obj instanceof $this) && get_class($obj) != get_class($this)) { - throw new InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($obj)); + throw new \InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($obj)); } $obj->notify(Render::STANDALONE, false); return parent::attach($obj, $inf); @@ -105,7 +105,7 @@ final public function parse($xml) { $parsed = ""; - $reader = new EnterpriseReader(); + $reader = new Reader(); $render = new Render(); $reader->XML("<notatag>" . $xml . "</notatag>"); @@ -121,28 +121,31 @@ } final public static function autogen($text, $lang) { + if ($lang === NULL) { + $lang = Config::language(); + } if (isset(self::$autogen[$lang])) { if (isset(self::$autogen[$lang][$text])) { return self::$autogen[$lang][$text]; } if ($lang == Config::fallback_language()) { - throw new InvalidArgumentException("Cannot autogenerate text for '$text'"); + throw new \InvalidArgumentException("Cannot autogenerate text for '$text'"); } return self::autogen($text, Config::fallback_language()); } $filename = Config::lang_dir() . $lang . ".xml"; - $r = new XMLReader; + $r = new \XMLReader(); if (!file_exists($filename) || !$r->open($filename)) { if ($lang == Config::fallback_language()) { - throw new Exception("Cannot open $filename"); + throw new \Exception("Cannot open $filename"); } return self::autogen($text, Config::fallback_language()); } $autogen = array(); while ($r->read()) { - if ($r->nodeType != XMLReader::ELEMENT) { + if ($r->nodeType != \XMLReader::ELEMENT) { continue; } if ($r->name == "term") { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Index.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/Index.php diff -u phd/phpdotnet/phd/Index.php:1.4 phd/phpdotnet/phd/Index.php:1.5 --- phd/phpdotnet/phd/Index.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Index.php Sat Jun 20 06:55:41 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -class Index extends Format_Enterprise +class Index extends Format { private $myelementmap = array( 'article' => 'format_container_chunk', @@ -75,7 +75,7 @@ } public function CDATA($value) { } - public function createLink($for, &$desc = null, $type = Format_Enterprise::SDESC) { + public function createLink($for, &$desc = null, $type = Format::SDESC) { } public function appendData($data) { } @@ -83,7 +83,7 @@ // or if xml input file has changed since the last indexing final static public function requireIndexing() { if (!Config::index() && file_exists(Config::output_dir() . "index.sqlite")) { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $indexingCount = $db->query('SELECT COUNT(time) FROM indexing')->fetchArray(SQLITE3_NUM); if ($indexingCount[0] > 0) { $indexing = $db->query('SELECT time FROM indexing')->fetchArray(SQLITE3_ASSOC); @@ -110,11 +110,11 @@ case Render::INIT: if ($value) { if (file_exists(Config::output_dir() . "index.sqlite")) { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $db->exec('DELETE FROM ids'); $db->exec('DELETE FROM indexing'); } else { - $db = new SQLite3(Config::output_dir() . 'index.sqlite'); + $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $create = <<<SQL CREATE TABLE ids ( docbook_id TEXT PRIMARY KEY, @@ -155,14 +155,14 @@ } public function UNDEF($open, $name, $attrs, $props) { /*if ($open) { - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; $this->storeInfo($name, $id, $this->currentchunk); } return false; } - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { + if(isset($attrs[Reader::XMLNS_XML]["id"])) { $this->appendID(); }*/ return false; @@ -238,8 +238,8 @@ if ($props["sibling"] === $name) { return $this->format_chunk($open, $name, $attrs, $props); } - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; return $this->storeInfo($name, $id, $this->currentchunk, false); } return $this->UNDEF($open, $name, $attrs, $props); @@ -249,8 +249,8 @@ return $this->format_chunk($open, $name, $attrs, $props); } $sectionChunks[] = $x; - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; return $this->appendID(false); } return $this->UNDEF($open, $name, $attrs, $props); @@ -260,8 +260,8 @@ } public function format_chunk($open, $name, $attrs, $props) { if ($open) { - if(isset($attrs[Reader_Enterprise::XMLNS_XML]["id"])) { - $id = $attrs[Reader_Enterprise::XMLNS_XML]["id"]; + if(isset($attrs[Reader::XMLNS_XML]["id"])) { + $id = $attrs[Reader::XMLNS_XML]["id"]; } else { $id = uniqid("phd"); } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/ObjectStorage.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/ObjectStorage.php diff -u phd/phpdotnet/phd/ObjectStorage.php:1.4 phd/phpdotnet/phd/ObjectStorage.php:1.5 --- phd/phpdotnet/phd/ObjectStorage.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/ObjectStorage.php Sat Jun 20 06:55:42 2009 @@ -6,20 +6,20 @@ protected static $r = array(); public function attach($obj, $inf = array()) { - if (!($obj instanceof Format_Enterprise)) { + if (!($obj instanceof Format)) { throw new InvalidArgumentException( - 'Only classess inheriting ' . __NAMESPACE__ . '\\Format_Enterprise supported' + 'Only classess inheriting ' . __NAMESPACE__ . '\\Format supported' ); } if (empty($inf)) { $inf = array( - XMLReader::ELEMENT => $obj->getElementMap(), - XMLReader::TEXT => $obj->getTextMap(), + \XMLReader::ELEMENT => $obj->getElementMap(), + \XMLReader::TEXT => $obj->getTextMap(), ); } parent::attach($obj, $inf); } - final protected static function setReader(Reader_Enterprise $r) { + final protected static function setReader(Reader $r) { self::$r[] = $r; } final protected function getReader() { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Reader.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Reader.php diff -u phd/phpdotnet/phd/Reader.php:1.2 phd/phpdotnet/phd/Reader.php:1.3 --- phd/phpdotnet/phd/Reader.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Reader.php Sat Jun 20 06:55:42 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Reader.php,v 1.2 2009/06/19 21:48:53 cweiske Exp $ */ +/* $Id: Reader.php,v 1.3 2009/06/20 06:55:42 moacir Exp $ */ //6271 class Reader extends \XMLReader @@ -14,103 +14,103 @@ } public function close() { - return XMLReader::close(); + return parent::close(); } public function getAttribute($name) { - return XMLReader::getAttribute($name); + return parent::getAttribute($name); } public function getAttributeNo($index) { - return XMLReader::getAttributeNo($index); + return parent::getAttributeNo($index); } public function getAttributeNs($name, $namespaceURI) { - return XMLReader::getAttributeNs($name, $namespaceURI); + return parent::getAttributeNs($name, $namespaceURI); } public function getParserProperty($property) { - return XMLReader::getParserProperty($property); + return parent::getParserProperty($property); } public function isValid() { - return XMLReader::isValid(); + return parent::isValid(); } public function lookupNamespace($prefix) { - return XMLReader::lookupNamespace($prefix); + return parent::lookupNamespace($prefix); } public function moveToAttributeNo($index) { - return XMLReader::moveToAttributeNo($index); + return parent::moveToAttributeNo($index); } public function moveToAttribute($name) { - return XMLReader::moveToAttribute($name); + return parent::moveToAttribute($name); } public function moveToAttributeNs($name, $namespaceURI) { - return XMLReader::moveToAttributeNs($name, $namespaceURI); + return parent::moveToAttributeNs($name, $namespaceURI); } public function moveToElement() { - return XMLReader::moveToElement(); + return parent::moveToElement(); } public function moveToFirstAttribute() { - return XMLReader::moveToFirstAttribute(); + return parent::moveToFirstAttribute(); } public function moveToNextAttribute() { - return XMLReader::moveToNextAttribute(); + return parent::moveToNextAttribute(); } public function open($URI, $encoding = null, $options = null) { - return XMLReader::open($URI, $encoding, $options); + return parent::open($URI, $encoding, $options); } public function read() { - return XMLReader::read(); + return parent::read(); } public function next($localname = null) { - return XMLReader::next($localname); + return parent::next($localname); } public function readInnerXml() { - return XMLReader::readInnerXml(); + return parent::readInnerXml(); } public function readOuterXml() { - return XMLReader::readOuterXml(); + return parent::readOuterXml(); } public function readString() { - return XMLReader::readString(); + return parent::readString(); } public function setSchema($filename) { - return XMLReader::setSchema($filename); + return parent::setSchema($filename); } public function setParserProperty($property, $value) { - return XMLReader::setParserProperty($property, $value); + return parent::setParserProperty($property, $value); } public function setRelaxNGSchema($filename) { - return XMLReader::setRelaxNGSchema($filename); + return parent::setRelaxNGSchema($filename); } public function setRelaxNGSchemaSource($source) { - return XMLReader::setRelaxNGSchemaSource($source); + return parent::setRelaxNGSchemaSource($source); } public function XML($source, $encoding = null, $options = null) { - return XMLReader::XML($source, $encoding, $options); + return parent::XML($source, $encoding, $options); } public function expand() { - return XMLReader::expand(); + return parent::expand(); } } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Render.php?r1=1.4&r2=1.5&diff_format=u Index: phd/phpdotnet/phd/Render.php diff -u phd/phpdotnet/phd/Render.php:1.4 phd/phpdotnet/phd/Render.php:1.5 --- phd/phpdotnet/phd/Render.php:1.4 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Render.php Sat Jun 20 06:55:42 2009 @@ -51,10 +51,10 @@ $data = $retval = $name = $open = false; switch($type) { - case XMLReader::ELEMENT: /* {{{ */ + case \XMLReader::ELEMENT: /* {{{ */ $open = true; /* break intentionally omitted */ - case XMLReader::END_ELEMENT: + case \XMLReader::END_ELEMENT: $name = $r->name; $depth = $r->depth; $attrs = array( @@ -86,7 +86,7 @@ continue; foreach($this as $format) { - $map = $this[$format][XMLReader::ELEMENT]; + $map = $this[$format][\XMLReader::ELEMENT]; if (isset($map[$name]) === false) { $data = $format->UNDEF($open, $name, $attrs, $props); @@ -113,7 +113,7 @@ $format->appendData($data); foreach($format as $theme) { - $map = $format[$theme][XMLReader::ELEMENT]; + $map = $format[$theme][\XMLReader::ELEMENT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -137,13 +137,13 @@ break; /* }}} */ - case XMLReader::TEXT: /* {{{ */ + case \XMLReader::TEXT: /* {{{ */ $value = $r->value; $eldepth = $r->depth - 1; $name = $this->STACK[$eldepth]; foreach($this as $format) { - $map = $this[$format][XMLReader::TEXT]; + $map = $this[$format][\XMLReader::TEXT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -167,7 +167,7 @@ } foreach($format as $theme) { - $map = $format[$theme][XMLReader::TEXT]; + $map = $format[$theme][\XMLReader::TEXT]; if (isset($map[$name])) { $tag = $map[$name]; @@ -188,7 +188,7 @@ break; /* }}} */ - case XMLReader::CDATA: /* {{{ */ + case \XMLReader::CDATA: /* {{{ */ /* Different formats may want to escape the CDATA sections differently */ $value = $r->value; foreach($this as $format) { @@ -201,8 +201,8 @@ break; /* }}} */ - case XMLReader::WHITESPACE: /* {{{ */ - case XMLReader::SIGNIFICANT_WHITESPACE: + case \XMLReader::WHITESPACE: /* {{{ */ + case \XMLReader::SIGNIFICANT_WHITESPACE: /* WS is always WS */ $retval = $r->value; foreach($this as $format) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format/Factory.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Format/Factory.php diff -u phd/phpdotnet/phd/Format/Factory.php:1.3 phd/phpdotnet/phd/Format/Factory.php:1.4 --- phd/phpdotnet/phd/Format/Factory.php:1.3 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format/Factory.php Sat Jun 20 06:55:42 2009 @@ -15,15 +15,12 @@ public static final function createFactory() { - global $ROOT; $package = Config::package(); - $classname = "{$package}Factory"; - - require_once $ROOT . "/packages/$package/$classname.class.php"; + $classname = __NAMESPACE__ . "\\Package_" . $package . "_Factory"; $factory = new $classname(); if (!($factory instanceof Format_Factory)) { - throw new Exception("All Factories must inherit PhDFormatFactory"); + throw new \Exception("All Factories must inherit Format_Factory"); } return $factory; } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/Factory.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Package/Default/Factory.php diff -u phd/phpdotnet/phd/Package/Default/Factory.php:1.2 phd/phpdotnet/phd/Package/Default/Factory.php:1.3 --- phd/phpdotnet/phd/Package/Default/Factory.php:1.2 Fri Jun 19 21:48:54 2009 +++ phd/phpdotnet/phd/Package/Default/Factory.php Sat Jun 20 06:55:42 2009 @@ -4,7 +4,7 @@ class Package_Default_Factory extends Format_Factory { public function createXhtmlFormat() { - return new Format_Default_XHTML(); + return new Package_Default_XHTML(); } /* public function createBigXhtmlFormat() { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/XHTML.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Package/Default/XHTML.php diff -u phd/phpdotnet/phd/Package/Default/XHTML.php:1.2 phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 --- phd/phpdotnet/phd/Package/Default/XHTML.php:1.2 Fri Jun 19 21:48:54 2009 +++ phd/phpdotnet/phd/Package/Default/XHTML.php Sat Jun 20 06:55:42 2009 @@ -1,7 +1,7 @@ <?php namespace phpdotnet\phd; -class Format_Default_XHTML extends Format_Abstract_XHTML +class Package_Default_XHTML extends Format_Abstract_XHTML { private $formatname = "XHTML"; private $myelementmap = array( /* {{{ */