cvs: pear /Text_Wiki/Text Wiki.php

From: Date: Sun, 29 May 2005 19:17:42 +0000
Subject: cvs: pear /Text_Wiki/Text Wiki.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-32233@lists.php.net to get a copy of this message
pmjones Sun May 29 15:17:42 2005 EDT Modified files: /pear/Text_Wiki/Text Wiki.php Log: fixed bug 4175 "Wrong transform method" by generating PEAR_Error objects when a parse, format, or render rule cannot be found. http://cvs.php.net/diff.php/pear/Text_Wiki/Text/Wiki.php?r1=1.29&r2=1.30&ty=u Index: pear/Text_Wiki/Text/Wiki.php diff -u pear/Text_Wiki/Text/Wiki.php:1.29 pear/Text_Wiki/Text/Wiki.php:1.30 --- pear/Text_Wiki/Text/Wiki.php:1.29 Thu Feb 24 12:26:29 2005 +++ pear/Text_Wiki/Text/Wiki.php Sun May 29 15:17:42 2005 @@ -12,7 +12,7 @@ * * @license LGPL * -* @version $Id: Wiki.php,v 1.29 2005/02/24 17:26:29 pmjones Exp $ +* @version $Id: Wiki.php,v 1.30 2005/05/29 19:17:42 pmjones Exp $ * */ @@ -40,15 +40,11 @@ * * @package Text_Wiki * -<<<<<<< Wiki.php -* @version 0.25.0 -* -* @license LGPL -======= * @author Paul M. Jones <pmjones@php.net> * +* @license LGPL +* * @version @package_version@ ->>>>>>> 1.28 * */ @@ -875,8 +871,11 @@ // when in a delimited section, capture the token key number $key = ''; - // load the format object - $this->loadFormatObj($format); + // load the format object, or crap out if we can't find it + $result = $this->loadFormatObj($format); + if ($this->isError($result)) { + return $result; + } // pre-rendering activity if (is_object($this->formatObj[$format])) { @@ -1097,7 +1096,10 @@ } else { // can't find the class $this->parseObj[$rule] = null; - return false; + // can't find the class + return $this->error( + "Parse rule '$rule' not found" + ); } } @@ -1131,7 +1133,9 @@ include_once $loc; } else { // can't find the class - return false; + return $this->error( + "Render rule '$rule' in format '$format' not found" + ); } } @@ -1162,7 +1166,9 @@ include_once $loc; } else { // can't find the class - return false; + return $this->error( + "Rendering format class '$class' not found" + ); } } @@ -1275,6 +1281,45 @@ return $path; } } + + + /** + * + * Simple error-object generator. + * + * @access public + * + * @param string $message The error message. + * + * @return object PEAR_Error + * + */ + + function &error($message) + { + if (! class_exists('PEAR_Error')) { + include_once 'PEAR.php'; + } + return PEAR::throwError($message, $code, $info); + } + + + /** + * + * Simple error checker. + * + * @access public + * + * @param mixed $obj Check if this is a PEAR_Error object or not. + * + * @return bool True if a PEAR_Error, false if not. + * + */ + + function isError(&$obj) + { + return is_a($obj, 'PEAR_Error'); + } } ?> \ No newline at end of file

« previous php.pear.cvs (#32233) next »