cvs: pear /Text_Wiki/Text Wiki.php /Text_Wiki/doc test_Text_Wiki.php
| From: | Del Elson | Date: | Mon, 27 Feb 2006 10:33:51 +0000 |
| Subject: | cvs: pear /Text_Wiki/Text Wiki.php /Text_Wiki/doc test_Text_Wiki.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38681@lists.php.net to get a copy of this message | ||
delatbabel Mon Feb 27 10:33:51 2006 UTC
Modified files:
/pear/Text_Wiki/Text Wiki.php
/pear/Text_Wiki/doc test_Text_Wiki.php
Log:
Fix for non-default instantiations of the constructor.
http://cvs.php.net/viewcvs.cgi/pear/Text_Wiki/Text/Wiki.php?r1=1.38&r2=1.39&diff_format=u
Index: pear/Text_Wiki/Text/Wiki.php
diff -u pear/Text_Wiki/Text/Wiki.php:1.38 pear/Text_Wiki/Text/Wiki.php:1.39
--- pear/Text_Wiki/Text/Wiki.php:1.38 Mon Feb 27 01:20:36 2006
+++ pear/Text_Wiki/Text/Wiki.php Mon Feb 27 10:33:51 2006
@@ -9,7 +9,7 @@
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL
License 2.1
- * @version CVS: $Id: Wiki.php,v 1.38 2006/02/27 01:20:36 delatbabel Exp $
+ * @version CVS: $Id: Wiki.php,v 1.39 2006/02/27 10:33:51 delatbabel Exp $
* @link http://pear.php.net/package/Text_Wiki
*/
@@ -342,9 +342,12 @@
*
* @access public
*
- * @param array $rules The set of rules to load for this object.
+ * @param array $rules The set of rules to load for this object. Defaults
+ * to null, which will load the default ruleset for this parser.
* @param string $parser The parser to be used (defaults to 'Default').
- *
+ * For non-Default parsers, consider using the singleton() method instead
+ * as the fetching of the rulesets from non-Default parsers causes an
+ * extra object instantiation, which is slower.
*/
function Text_Wiki($rules = null, $parser = 'Default')
@@ -355,8 +358,27 @@
$this->addPath(
'parse',
- $this->fixPath(dirname(__FILE__)) . 'Wiki/Parse/' . $parser .
'/'
+ $this->fixPath(dirname(__FILE__)) . 'Wiki/Parse/Default/'
);
+ if ($parser != 'Default') {
+ $this->addPath(
+ 'parse',
+ $this->fixPath(dirname(__FILE__)) . 'Wiki/Parse/' . $parser .
'/'
+ );
+
+ //
+ // Get ruleset from class by creating a throw-away object. It
+ // would be good to be able to return the object, but this would
+ // (a) risk causing recursion and (b) break PHP 4 < 4.3 that can't
+ // return an object from a constructor of the wrong type.
+ //
+ if (empty($rules)) {
+ include_once 'Text/Wiki/' . $parser . '.php';
+ $class = 'Text_Wiki_' . $parser;
+ $testobject =& new $class;
+ $this->rules = $testobject->rules;
+ }
+ }
$this->addPath(
'render',
http://cvs.php.net/viewcvs.cgi/pear/Text_Wiki/doc/test_Text_Wiki.php?r1=1.14&r2=1.15&diff_format=u
Index: pear/Text_Wiki/doc/test_Text_Wiki.php
diff -u pear/Text_Wiki/doc/test_Text_Wiki.php:1.14 pear/Text_Wiki/doc/test_Text_Wiki.php:1.15
--- pear/Text_Wiki/doc/test_Text_Wiki.php:1.14 Mon Feb 27 09:19:50 2006
+++ pear/Text_Wiki/doc/test_Text_Wiki.php Mon Feb 27 10:33:51 2006
@@ -7,7 +7,7 @@
require_once 'Text/Wiki.php';
/**
* Eventually set an include path if all parsers/renderers not installed
- * $Id: test_Text_Wiki.php,v 1.14 2006/02/27 09:19:50 delatbabel Exp $
+ * $Id: test_Text_Wiki.php,v 1.15 2006/02/27 10:33:51 delatbabel Exp $
*/
$parser = $render = $source = '';
$plist = array('Default', 'BBCode', 'Cowiki', 'Doku',
'Mediawiki', 'Tiki');
@@ -55,6 +55,17 @@
// instantiate a Text_Wiki object from the given class
$wiki = & Text_Wiki::singleton(null, $parser);
+// Wiki.php 1.37 and prior, use this:
+#$wiki = & Text_Wiki::singleton($parser);
+
+// include this line of code instead to test creating an object
+// using the constructor rather than the singleton method.
+#$wiki = new Text_Wiki(null, $parser);
+
+#print "<pre>\n";
+#print_r($wiki);
+#print "</pre>\n";
+
// when rendering XHTML, make sure wiki links point to a
// specific base URL
//$wiki->setRenderConf('xhtml', 'wikilink', 'view_url',