cvs: pear /HTML_Progress2/Progress2/Ajax Common.php

From: Date: Mon, 15 Jan 2007 17:23:08 +0000
Subject: cvs: pear /HTML_Progress2/Progress2/Ajax Common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44230@lists.php.net to get a copy of this message
farell Mon Jan 15 17:23:08 2007 UTC Modified files: /pear/HTML_Progress2/Progress2/Ajax Common.php Log: - add getters method to Ajax driver base class - request method should be now in uppercase http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/Progress2/Ajax/Common.php?r1=1.1&r2=1.2&diff_format=u Index: pear/HTML_Progress2/Progress2/Ajax/Common.php diff -u pear/HTML_Progress2/Progress2/Ajax/Common.php:1.1 pear/HTML_Progress2/Progress2/Ajax/Common.php:1.2 --- pear/HTML_Progress2/Progress2/Ajax/Common.php:1.1 Mon Jan 15 13:11:59 2007 +++ pear/HTML_Progress2/Progress2/Ajax/Common.php Mon Jan 15 17:23:08 2007 @@ -15,7 +15,7 @@ * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Common.php,v 1.1 2007/01/15 13:11:59 farell Exp $ + * @version CVS: $Id: Common.php,v 1.2 2007/01/15 17:23:08 farell Exp $ * @link http://pear.php.net/package/HTML_Progress2 * @since File available since Release 2.3.0a1 */ @@ -114,7 +114,7 @@ function __construct(&$obj) { $this->_progress = $obj; - $this->method = 'get'; + $this->method = 'GET'; $this->timeout = 2000; $this->url_args = array('registerTask', 'TaskId'); } @@ -143,6 +143,47 @@ } /** + * get URL that handle Ajax requests. + * + * Retrieve server script URLs that will handle Ajax client requests. + * + * @param int $action (optional) fullpath to server script + * 0: without query string + * 1: with query string to negociate task id action + * 2: with query string to proceed task id + * @return string + * @since 2.3.0a1 + * @access public + * @throws HTML_PROGRESS2_ERROR_INVALID_INPUT + */ + function getRequestUri($action = 0) + { + if (!is_int($action)) { + return $this->_progress->raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception', + array('var' => '$action', + 'was' => gettype($action), + 'expected' => 'integer', + 'paramnum' => 1)); + + } elseif ($action < 0 || $action > 2) { + return $this->_progress->raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception', + array('var' => '$action', + 'was' => gettype($action), + 'expected' => '0 | 1 | 2', + 'paramnum' => 1)); + } + + $url = $this->url; + + if ($action == 1) { + $url = $url .'?'. $this->url_args[0] .'='. urlencode($this->_progress->getIdent()); + } elseif ($action == 2) { + $url = $url .'?'. $this->url_args[1] .'='; + } + return $url; + } + + /** * set HTTP Ajax requests method. * * Defines the request method to send Ajax client data to remote server. @@ -163,7 +204,7 @@ 'expected' => 'string', 'paramnum' => 1)); - } elseif (!in_array(strtoupper($type), array('GET', 'POST'))) { + } elseif (!in_array($type, array('GET', 'POST'))) { return $this->_progress->raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, @@ -174,6 +215,20 @@ } /** + * get HTTP Ajax requests method. + * + * Retrieve the request method to send Ajax client data to remote server. + * + * @return string GET or POST + * @since 2.3.0a1 + * @access public + */ + function getRequestMethod() + { + return $this->method; + } + + /** * set timeout between each polling loop. * * Defines the time to wait before requesting new fresh data from remote server @@ -206,6 +261,20 @@ } /** + * get the timeout between each polling loop. + * + * Retrieve the time to wait before requesting new fresh data from remote server + * + * @return int + * @since 2.3.0a1 + * @access public + */ + function getRequestTimeout() + { + return $this->timeout; + } + + /** * set action arguments to handle task id. * * Defines url mapped action to handle task id. @@ -239,6 +308,22 @@ } /** + * get action arguments to handle task id. + * + * Retrieve url mapped action to handle task id. + * + * @return array 0: argument name to handle action of task id creation + * 1: argument name to handle identify of task id + * @since 2.3.0a1 + * @access public + * @throws HTML_PROGRESS2_ERROR_INVALID_INPUT + */ + function getUrlArguments() + { + return $this->url_args; + } + + /** * Returns javascript progress meter handler. * * Ajax code to handle the progress meter polling sequence.

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