cvs: pear /XML_CSSML CSSML.php package.xml /XML_CSSML/CSSML libxslt.php xslt.php

From: Date: Fri, 30 Sep 2005 08:43:27 +0000
Subject: cvs: pear /XML_CSSML CSSML.php package.xml /XML_CSSML/CSSML libxslt.php xslt.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35162@lists.php.net to get a copy of this message
dufuz Fri Sep 30 04:43:27 2005 EDT Modified files: /pear/XML_CSSML CSSML.php package.xml /pear/XML_CSSML/CSSML libxslt.php xslt.php Log: Fixed Bug #830 Assignment to $this Fixed Bug #902 PEAR QA: improvement for get_class()-usage # These changes have not been tested and I expect the respective release person to do those testings before doing a release (*points at QA*), I'm only trying to get this outstanding bugs out of the way for now since Dan is being inactive.

http://cvs.php.net/diff.php/pear/XML_CSSML/CSSML.php?r1=1.6&r2=1.7&ty=u Index: pear/XML_CSSML/CSSML.php diff -u pear/XML_CSSML/CSSML.php:1.6 pear/XML_CSSML/CSSML.php:1.7 --- pear/XML_CSSML/CSSML.php:1.6 Sat Jan 4 06:56:29 2003 +++ pear/XML_CSSML/CSSML.php Fri Sep 30 04:43:22 2005 @@ -17,7 +17,7 @@ // | Authors: Dan Allen <dan@mojavelinux.com> | // +----------------------------------------------------------------------+ -// $Id: CSSML.php,v 1.6 2003/01/04 11:56:29 mj Exp $ +// $Id: CSSML.php,v 1.7 2005/09/30 08:43:22 dufuz Exp $ // }}} // {{{ description @@ -44,10 +44,29 @@ // }}} // {{{ functions +/** + * Replace function is_a() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.is_a + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.7 $ + * @since PHP 4.2.0 + * @require PHP 4.0.0 (user_error) (is_subclass_of) + */ if (!function_exists('is_a')) { - function is_a($in_data, $in_detect) + function is_a($object, $class) { - return (bool) (is_object($in_data) && (get_class($in_data) == strtolower($in_detect) || is_subclass_of($in_data, strtolower($in_detect)))); + if (!is_object($object)) { + return false; + } + + if (get_class($object) == strtolower($class)) { + return true; + } else { + return is_subclass_of($object, $class); + } } } @@ -126,9 +145,14 @@ */ function XML_CSSML($in_driver, $in_CSSML = null, $in_type = 'string', $in_params = null) { - $this = $this->factory($in_driver, $in_CSSML, $in_type, $in_params); + if (version_compare(phpversion(), '5.0.0') == -1) { + $this = $this->factory($in_driver, $in_CSSML, $in_type, $in_params); + } else { + // error handling for PHP5 + return PEAR::raiseError(null, XML_CSSML_ERROR, null, E_USER_WARNING, 'This does not work on PHP 5 anymore, use the factory method instead', 'XML_CSSML_Error', true); + } } - + // }}} // {{{ factory() @@ -136,10 +160,11 @@ { $interface_path = 'CSSML/' . $in_driver . '.php'; $interface_class = 'XML_CSSML_' . $in_driver; - + @include_once $interface_path; - - return new $interface_class($in_CSSML, $in_type, $in_params); + + $obj =& new $interface_class($in_CSSML, $in_type, $in_params); + return $obj; } // }}} @@ -154,7 +179,7 @@ * generating the CSS document * * @return void - * + * */ function load() { @@ -162,13 +187,13 @@ return PEAR::raiseError(null, XML_CSSML_ALREADY_EXISTS, null, E_USER_WARNING, $this->CSSMLDoc, 'XML_CSSML_Error', true); } } - + // }}} // {{{ setParams() /** * Set the params (params) that will be used when calling the stylesheet parser. - * This pertains particularly to variables such as browser code, image path and + * This pertains particularly to variables such as browser code, image path and * the filter. It works by passing an associative array with any number of the * possible parameters for the stylesheet. If a variable is not set, the default * will be used @@ -176,12 +201,12 @@ * @param array $in_params Associative array of the params * * @return void - * + * */ function setParams($in_params) { if (isset($in_params['browser'])) { - $this->browser = $in_params['browser']; + $this->browser = $in_params['browser']; } if (isset($in_params['filter'])) { @@ -216,7 +241,7 @@ * @return css string if output method is STDOUT, else void * @access public */ - function process() + function process() { if (!$this->loaded) { return PEAR::raiseError(null, XML_CSSML_NOT_LOADED, null, E_USER_WARNING, 'use load() function', 'XML_CSSML_Error', true); @@ -250,7 +275,7 @@ * @access public * @return string error message, or false if not error code */ - function errorMessage($in_value) + function errorMessage($in_value) { // make the variable static so that it only has to do the defining on the first call static $errorMessages; @@ -265,14 +290,14 @@ XML_CSSML_INVALID_DATA => 'invalid cssml data to parse', XML_CSSML_INVALID_DOCUMENT => 'cssml domdocument could not be created', XML_CSSML_INVALID_FILE => 'output file does not exist', - ); + ); } // If this is an error object, then grab the corresponding error code if (XML_CSSML::isError($in_value)) { $in_value = $in_value->getCode(); } - + // return the textual error message corresponding to the code return isset($errorMessages[$in_value]) ? $errorMessages[$in_value] : $errorMessages[XML_CSSML_ERROR]; } @@ -306,7 +331,7 @@ { $vars = get_class_vars('XML_CSSML'); - foreach($vars as $var => $value) { + foreach ($vars as $var => $value) { $this->$var = null; } } http://cvs.php.net/diff.php/pear/XML_CSSML/package.xml?r1=1.7&r2=1.8&ty=u Index: pear/XML_CSSML/package.xml diff -u pear/XML_CSSML/package.xml:1.7 pear/XML_CSSML/package.xml:1.8 --- pear/XML_CSSML/package.xml:1.7 Sun Sep 15 05:45:31 2002 +++ pear/XML_CSSML/package.xml Fri Sep 30 04:43:22 2005 @@ -14,30 +14,15 @@ <email>dallen@php.net</email> </maintainer> </maintainers> - <license>PHP License</license> <release> - <version>0.1</version> - <state>beta</state> - <date>2002-04-29</date> - <notes> - This is the initial independent release of the XML_CSSML package. It includes support for both the domxml_xslt functions and the sablotron xslt extension. The main file includes a factory function, which calls the relevant container object depending on the extension the user wishes to use. It can either create an output css file or it can return the string. It has support for browser specific styles using the codes of Net_UserAgent_Detect as well as a filter to extract only applicable styles. There is an example file in the docs/ to better understand the usage. - </notes> - </release> - <release> - <version>1.0</version> - <state>stable</state> - <date>2002-05-20</date> - <notes> - This is the first stable release of the XML_CSSML package. The hopes of this package are to erase the awkwardness of having to create many stylesheets for many pages and sections of a site, and having to infiltrate it with language constructions. One can think of CSSML as being a template for CSS documents, in fact that is the best description it has been given so far. - </notes> - </release> - <release> - <version>1.1</version> - <state>stable</state> - <date>2002-05-20</date> - <notes> - Restructuring the directory using Stig's suggestion for how to organize "Driver" sub-classes. - </notes> + <license>PHP License</license> + <version>1.1.1</version> + <state>stable</state> + <date>2005-?-?</date> + <notes> +Fixed Bug #830 Assignment to $this +Fixed Bug #902 PEAR QA: improvement for get_class()-usage + </notes> </release> <filelist> <dir name="/" baseinstalldir="XML"> @@ -55,4 +40,33 @@ </dir> </dir> </filelist> + <changelog> + <release> + <license>PHP License</license> + <version>0.1</version> + <state>beta</state> + <date>2002-04-29</date> + <notes> + This is the initial independent release of the XML_CSSML package. It includes support for both the domxml_xslt functions and the sablotron xslt extension. The main file includes a factory function, which calls the relevant container object depending on the extension the user wishes to use. It can either create an output css file or it can return the string. It has support for browser specific styles using the codes of Net_UserAgent_Detect as well as a filter to extract only applicable styles. There is an example file in the docs/ to better understand the usage. + </notes> + </release> + <release> + <license>PHP License</license> + <version>1.0</version> + <state>stable</state> + <date>2002-05-20</date> + <notes> + This is the first stable release of the XML_CSSML package. The hopes of this package are to erase the awkwardness of having to create many stylesheets for many pages and sections of a site, and having to infiltrate it with language constructions. One can think of CSSML as being a template for CSS documents, in fact that is the best description it has been given so far. + </notes> + </release> + <release> + <license>PHP License</license> + <version>1.1</version> + <state>stable</state> + <date>2002-05-20</date> + <notes> + Restructuring the directory using Stig's suggestion for how to organize "Driver" sub-classes. + </notes> + </release> + </changelog> </package> http://cvs.php.net/diff.php/pear/XML_CSSML/CSSML/libxslt.php?r1=1.3&r2=1.4&ty=u Index: pear/XML_CSSML/CSSML/libxslt.php diff -u pear/XML_CSSML/CSSML/libxslt.php:1.3 pear/XML_CSSML/CSSML/libxslt.php:1.4 --- pear/XML_CSSML/CSSML/libxslt.php:1.3 Sat Jan 4 06:56:29 2003 +++ pear/XML_CSSML/CSSML/libxslt.php Fri Sep 30 04:43:26 2005 @@ -17,7 +17,7 @@ // | Authors: Dan Allen <dan@mojavelinux.com> | // +----------------------------------------------------------------------+ -// $Id: libxslt.php,v 1.3 2003/01/04 11:56:29 mj Exp $ +// $Id: libxslt.php,v 1.4 2005/09/30 08:43:26 dufuz Exp $ // }}} // {{{ description @@ -30,8 +30,8 @@ /** * The XML_CSSML_domxml is a container class which - * provides the libxslt xsl functions to parse a CSSML - * document into a stylesheet with the ability to output + * provides the libxslt xsl functions to parse a CSSML + * document into a stylesheet with the ability to output * to a file or return * * @author Dan Allen <dan@mojavelinux.com> @@ -41,7 +41,8 @@ */ // }}} -class XML_CSSML_libxslt extends XML_CSSML { +class XML_CSSML_libxslt extends XML_CSSML +{ // {{{ constructor function XML_CSSML_libxslt($in_CSSML = null, $in_type = 'string', $in_params = null) @@ -83,7 +84,7 @@ $resultData = $result->document_element(); $output = $resultData->get_content(); } - + return isset($output) ? $output : true; } @@ -113,7 +114,7 @@ return PEAR::raiseError(null, XML_CSSML_INVALID_DATA, null, E_USER_WARNING, "Request data: $in_CSSML", 'XML_CSSML_Error', true); } - if (get_class($this->CSSMLDoc) != 'DomDocument') { + if (!is_a($this->CSSMLDoc), 'DomDocument')) { return PEAR::raiseError(null, XML_CSSML_INVALID_DOCUMENT, null, E_USER_WARNING, "Request data: $in_CSSML", 'XML_CSSML_Error', true); } http://cvs.php.net/diff.php/pear/XML_CSSML/CSSML/xslt.php?r1=1.2&r2=1.3&ty=u Index: pear/XML_CSSML/CSSML/xslt.php diff -u pear/XML_CSSML/CSSML/xslt.php:1.2 pear/XML_CSSML/CSSML/xslt.php:1.3 --- pear/XML_CSSML/CSSML/xslt.php:1.2 Sat Jan 4 06:56:30 2003 +++ pear/XML_CSSML/CSSML/xslt.php Fri Sep 30 04:43:26 2005 @@ -17,7 +17,7 @@ // | Authors: Dan Allen <dan@mojavelinux.com> | // +----------------------------------------------------------------------+ -// $Id: xslt.php,v 1.2 2003/01/04 11:56:30 mj Exp $ +// $Id: xslt.php,v 1.3 2005/09/30 08:43:26 dufuz Exp $ // }}} // {{{ description @@ -30,8 +30,8 @@ /** * The XML_CSSML_xslt is a container class which - * provides the sablotron xsl functions to parse a CSSML - * document into a stylesheet with the ability to output + * provides the sablotron xsl functions to parse a CSSML + * document into a stylesheet with the ability to output * to a file or return * * @author Dan Allen <dan@mojavelinux.com> @@ -41,7 +41,8 @@ */ // }}} -class XML_CSSML_xslt extends XML_CSSML { +class XML_CSSML_xslt extends XML_CSSML +{ // {{{ properties /** @@ -94,9 +95,9 @@ $fp = fopen($this->output, 'w'); fwrite($fp, $result); fclose($fp); - $result = true; + $result = true; } - + return $result; } @@ -112,12 +113,10 @@ if ($in_type == 'file' && @file_exists($in_CSSML)) { $this->CSSMLDoc = $in_CSSML; - } - elseif ($in_type == 'string' && is_string($in_CSSML)) { + } elseif ($in_type == 'string' && is_string($in_CSSML)) { $this->CSSMLDoc = 'arg:/_xml'; $this->arguments = array('/_xml' => $in_CSSML); - } - else { + } else { return PEAR::raiseError(null, XML_CSSML_INVALID_DATA, null, E_USER_WARNING, "Request data: $in_CSSML", 'XML_CSSML_Error', true); }
« previous php.pear.cvs (#35162) next »