cvs: pear /HTML_Progress2 ChangeLog Progress2.php

From: Date: Mon, 15 Jan 2007 13:08:23 +0000
Subject: cvs: pear /HTML_Progress2 ChangeLog Progress2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44224@lists.php.net to get a copy of this message
farell Mon Jan 15 13:08:23 2007 UTC Modified files: /pear/HTML_Progress2 ChangeLog Progress2.php Log: - fix typo error in phpdoc tags - add two new error code for ajax drivers - add new methods : registerAjax(), and fileExists() http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/ChangeLog?r1=1.23&r2=1.24&diff_format=u Index: pear/HTML_Progress2/ChangeLog diff -u pear/HTML_Progress2/ChangeLog:1.23 pear/HTML_Progress2/ChangeLog:1.24 --- pear/HTML_Progress2/ChangeLog:1.23 Fri Jan 12 18:01:47 2007 +++ pear/HTML_Progress2/ChangeLog Mon Jan 15 13:08:23 2007 @@ -1,6 +1,6 @@ 2007-0m-dd Laurent Laville <pear@laurent-laville.org> - * VERSION: Final version (alpha) 2.3.0a1 released. + * VERSION: first alpha version (alpha) 2.3.0a1 released. - drop support of cell id mask identifier (begin private) style should be apply only by cell classname attribute @@ -10,6 +10,9 @@ - Improve Javascript function setProgress() which does not need anymore the third parameter. - Improve Javascript function call to setElementStyle() and removed unecessary arguments TIP: this function allow to build smooth progress bar (without cell: HTML_Progress2::setCellCount(0) + - fix typo error (millisecond term) in phpdoc tags + - add two new error code for ajax drivers: HTML_PROGRESS2_ERROR_INVALID_RESOURCE, HTML_PROGRESS2_ERROR_ABSTRACT + - add new methods : registerAjax(), and fileExists() 2007-01-03 Laurent Laville <pear@laurent-laville.org> http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/Progress2.php?r1=1.36&r2=1.37&diff_format=u Index: pear/HTML_Progress2/Progress2.php diff -u pear/HTML_Progress2/Progress2.php:1.36 pear/HTML_Progress2/Progress2.php:1.37 --- pear/HTML_Progress2/Progress2.php:1.36 Fri Jan 12 18:01:47 2007 +++ pear/HTML_Progress2/Progress2.php Mon Jan 15 13:08:23 2007 @@ -15,7 +15,7 @@ * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2005-2007 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Progress2.php,v 1.36 2007/01/12 18:01:47 farell Exp $ + * @version CVS: $Id: Progress2.php,v 1.37 2007/01/15 13:08:23 farell Exp $ * @link http://pear.php.net/package/HTML_Progress2 * @since File available since Release 2.0.0RC1 */ @@ -97,6 +97,23 @@ */ define ('HTML_PROGRESS2_ERROR_INVALID_OPTION', -103); +/** + * Basic error code that indicate an invalid resource + * + * @var integer + * @since 2.3.0a1 + */ +define ('HTML_PROGRESS2_ERROR_INVALID_RESOURCE', -104); + +/** + * Basic error code that indicate an abstract method used + * in Ajax driver. This one is code incompleted. + * + * @var integer + * @since 2.3.0a1 + */ +define ('HTML_PROGRESS2_ERROR_ABSTRACT', -105); + /** * HTML loading bar with only PHP and JS interface. @@ -205,7 +222,7 @@ var $_observerCount; /** - * Delay in milisecond before each progress cells display. + * Delay in millisecond before each progress cells display. * 1000 ms === sleep(1) * <strong>usleep()</strong> function does not run on Windows platform. * @@ -2337,11 +2354,11 @@ /** * Sets delay execution of the progress meter. * - * The delay (in milisecond) cannot exceed 1000 (1 second), that is enough + * The delay (in millisecond) cannot exceed 1000 (1 second), that is enough * to smooth an animation. User process should slow down animation and in most * case the default value (zero) will be efficient. * - * @param integer $delay Delay in milisecond. + * @param integer $delay Delay in millisecond. * * @return void * @since 2.0.0 @@ -3176,6 +3193,85 @@ } /** + * Register an Ajax engine in use for progress bar polling. + * + * Until version 2.2.0 Progress2 has only COMET (streaming) ability. With + * first alpha of 2.3.0 version, Progress2 has now Ajax (polling) ability. + * A default driver is available and you may register your own Ajax engine easily. + * + * @param string $engine (optional) Ajax engine driver name + * + * @return object|false instance of HTML_Progress2_Ajax_Common, + * false on error + * @since 2.3.0a1 + * @access public + * @throws HTML_PROGRESS2_ERROR_INVALID_INPUT, + * HTML_PROGRESS2_ERROR_INVALID_RESOURCE + */ + function registerAjax($engine = 'StdDOMxml') + { + if (!is_string($engine)) { + return $this->raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception', + array('var' => '$engine', + 'was' => gettype($engine), + 'expected' => 'string', + 'paramnum' => 1)); + } + + $class = 'HTML_Progress2_Ajax_' . ucfirst($engine); + + // Attempt to include a custom version of the named class, but don't treat + // a failure as fatal. The caller may have already included their own + // version of the named class. + if (!class_exists($class)) { + // Try to include the driver. + $file = str_replace('_', '/', $class) . '.php'; + if (HTML_Progress2::fileExists($file)) { + include_once $file; + } + } + // See if the class exists now. + if (class_exists($class)) { + // Try to instantiate the class. + $instance =& new $class($this); + } else { + $instance = false; + } + // See if the class is a valid base driver. + if (!is_subclass_of($instance, 'HTML_Progress2_Ajax_Common')) { + return $this->raiseError(HTML_PROGRESS2_ERROR_INVALID_RESOURCE, 'error', + array('var' => '$engine', + 'resource' => $file, + 'expected' => 'Ajax driver', + 'paramnum' => 1)); + } + return $instance; + } + + /** + * Checks whether the file exists in the include path + * + * Method used to check if a file (Ajax engine driver) is available + * and readable. + * + * @param string $fileName file name + * + * @return bool + * @since 2.3.0a1 + * @access protected + * @static + */ + function fileExists($fileName) + { + $fp = @fopen($fileName, 'r', true); + if (is_resource($fp)) { + fclose($fp); + return true; + } + return false; + } + + /** * Refresh the progress meter display. * * @param integer $value new value of the progress meter

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