First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* The action for a 'back' button of wizard-type multipage form.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Back.php,v 1.6 2007/05/18 09:34:18 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* The action for a 'back' button of wizard-type multipage form.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Back extends HTML_QuickForm_Action
|
||||
{
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
// save the form values and validation status to the session
|
||||
$page->isFormBuilt() or $page->buildForm();
|
||||
$pageName = $page->getAttribute('id');
|
||||
$data =& $page->controller->container();
|
||||
$data['values'][$pageName] = $page->exportValues();
|
||||
if (!$page->controller->isModal()) {
|
||||
if (PEAR::isError($valid = $page->validate())) {
|
||||
return $valid;
|
||||
}
|
||||
$data['valid'][$pageName] = $valid;
|
||||
}
|
||||
|
||||
// get the previous page and go to it
|
||||
// we don't check validation status here, 'jump' handler should
|
||||
if (null === ($prevName = $page->controller->getPrevName($pageName))) {
|
||||
return $page->handle('jump');
|
||||
} else {
|
||||
$prev =& $page->controller->getPage($prevName);
|
||||
return $prev->handle('jump');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This action allows to go to a specific page of a multipage form.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Direct.php,v 1.4 2007/05/18 09:34:18 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* This action allows to go to a specific page of a multipage form.
|
||||
*
|
||||
* Please note that the name for this action in addAction() should NOT be
|
||||
* 'direct', but the name of the page you wish to go to.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Direct extends HTML_QuickForm_Action
|
||||
{
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
// save the form values and validation status to the session
|
||||
$page->isFormBuilt() or $page->buildForm();
|
||||
$pageName = $page->getAttribute('id');
|
||||
$data =& $page->controller->container();
|
||||
$data['values'][$pageName] = $page->exportValues();
|
||||
if (PEAR::isError($valid = $page->validate())) {
|
||||
return $valid;
|
||||
}
|
||||
$data['valid'][$pageName] = $valid;
|
||||
|
||||
$target =& $page->controller->getPage($actionName);
|
||||
if (PEAR::isError($target)) {
|
||||
return $target;
|
||||
} else {
|
||||
return $target->handle('jump');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This action handles output of the form.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Display.php,v 1.7 2007/05/18 09:34:18 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* This action handles output of the form.
|
||||
*
|
||||
* If you want to customize the form display, subclass this class and
|
||||
* override the _renderForm() method, you don't need to change the perform()
|
||||
* method itself.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Display extends HTML_QuickForm_Action
|
||||
{
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
$pageName = $page->getAttribute('id');
|
||||
// If the original action was 'display' and we have values in container then we load them
|
||||
// BTW, if the page was invalid, we should later call validate() to get the errors
|
||||
list(, $oldName) = $page->controller->getActionName();
|
||||
if ('display' == $oldName) {
|
||||
// If the controller is "modal" we should not allow direct access to a page
|
||||
// unless all previous pages are valid (see also bug #2323)
|
||||
if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
|
||||
$target =& $page->controller->getPage($page->controller->findInvalid());
|
||||
return $target->handle('jump');
|
||||
}
|
||||
$data =& $page->controller->container();
|
||||
if (!empty($data['values'][$pageName])) {
|
||||
$page->loadValues($data['values'][$pageName]);
|
||||
$validate = false === $data['valid'][$pageName];
|
||||
}
|
||||
}
|
||||
// set "common" defaults and constants
|
||||
$page->controller->applyDefaults($pageName);
|
||||
$page->isFormBuilt() or $page->buildForm();
|
||||
// if we had errors we should show them again
|
||||
if (isset($validate) && $validate) {
|
||||
if (PEAR::isError($err = $page->validate())) {
|
||||
return $err;
|
||||
}
|
||||
}
|
||||
return $this->_renderForm($page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actually outputs the form.
|
||||
*
|
||||
* If you want to customize the form's appearance (you most certainly will),
|
||||
* then you should override this method. There is no need to override perform()
|
||||
*
|
||||
* @access private
|
||||
* @param HTML_QuickForm_Page the page being processed
|
||||
*/
|
||||
function _renderForm(&$page)
|
||||
{
|
||||
$page->display();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This action performs HTTP redirect to a specific page.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Jump.php,v 1.6 2008/07/22 11:05:20 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* This action performs HTTP redirect to a specific page.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Jump extends HTML_QuickForm_Action
|
||||
{
|
||||
/**
|
||||
* Splits (part of) the URI into path and query components
|
||||
*
|
||||
* @param string String of the form 'foo?bar'
|
||||
* @return array Array of the form array('foo', '?bar)
|
||||
* @access private
|
||||
*/
|
||||
function _splitUri($uri)
|
||||
{
|
||||
if (false === ($qm = strpos($uri, '?'))) {
|
||||
return array($uri, '');
|
||||
} else {
|
||||
return array(substr($uri, 0, $qm), substr($uri, $qm));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the '..' and '.' segments from the path component
|
||||
*
|
||||
* @param string Path component of the URL, possibly with '.' and '..' segments
|
||||
* @return string Path component of the URL with '.' and '..' segments removed
|
||||
* @access private
|
||||
*/
|
||||
function _normalizePath($path)
|
||||
{
|
||||
$pathAry = explode('/', $path);
|
||||
$i = 1;
|
||||
|
||||
do {
|
||||
if ('.' == $pathAry[$i]) {
|
||||
if ($i < count($pathAry) - 1) {
|
||||
array_splice($pathAry, $i, 1);
|
||||
} else {
|
||||
$pathAry[$i] = '';
|
||||
$i++;
|
||||
}
|
||||
|
||||
} elseif ('..' == $pathAry[$i] && $i > 1 && '..' != $pathAry[$i - 1]) {
|
||||
if ($i < count($pathAry) -1) {
|
||||
array_splice($pathAry, $i - 1, 2);
|
||||
$i--;
|
||||
} else {
|
||||
array_splice($pathAry, $i - 1, 2, '');
|
||||
}
|
||||
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
} while ($i < count($pathAry));
|
||||
|
||||
return implode('/', $pathAry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves relative URL using current page's URL as base
|
||||
*
|
||||
* The method follows procedure described in section 4 of RFC 1808 and
|
||||
* passes the examples provided in section 5 of said RFC. Values from
|
||||
* $_SERVER array are used for calculation of "current URL"
|
||||
*
|
||||
* @param string Relative URL, probably from form's action attribute
|
||||
* @return string Absolute URL
|
||||
* @access private
|
||||
*/
|
||||
function _resolveRelativeURL($url)
|
||||
{
|
||||
$https = !empty($_SERVER['HTTPS']) && ('off' != $_SERVER['HTTPS']);
|
||||
$scheme = ($https? 'https:': 'http:');
|
||||
if ('//' == substr($url, 0, 2)) {
|
||||
return $scheme . $url;
|
||||
|
||||
} else {
|
||||
$host = $scheme . '//' . $_SERVER['SERVER_NAME'] .
|
||||
(($https && 443 == $_SERVER['SERVER_PORT'] ||
|
||||
!$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']);
|
||||
if ('' == $url) {
|
||||
return $host . $_SERVER['REQUEST_URI'];
|
||||
|
||||
} elseif ('/' == $url[0]) {
|
||||
return $host . $url;
|
||||
|
||||
} else {
|
||||
list($basePath, $baseQuery) = $this->_splitUri($_SERVER['REQUEST_URI']);
|
||||
list($actPath, $actQuery) = $this->_splitUri($url);
|
||||
if ('' == $actPath) {
|
||||
return $host . $basePath . $actQuery;
|
||||
} else {
|
||||
$path = substr($basePath, 0, strrpos($basePath, '/') + 1) . $actPath;
|
||||
return $host . $this->_normalizePath($path) . $actQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
// check whether the page is valid before trying to go to it
|
||||
if ($page->controller->isModal()) {
|
||||
// we check whether *all* pages up to current are valid
|
||||
// if there is an invalid page we go to it, instead of the
|
||||
// requested one
|
||||
$pageName = $page->getAttribute('id');
|
||||
if (!$page->controller->isValid($pageName)) {
|
||||
$pageName = $page->controller->findInvalid();
|
||||
}
|
||||
$current =& $page->controller->getPage($pageName);
|
||||
|
||||
} else {
|
||||
$current =& $page;
|
||||
}
|
||||
// generate the URL for the page 'display' event and redirect to it
|
||||
$action = $current->getAttribute('action');
|
||||
// Bug #13087: RFC 2616 requires an absolute URI in Location header
|
||||
if (!preg_match('!^https?://!i', $action)) {
|
||||
$action = $this->_resolveRelativeURL($action);
|
||||
}
|
||||
$url = $action . (false === strpos($action, '?')? '?': '&') .
|
||||
$current->getButtonName('display') . '=true' .
|
||||
((!defined('SID') || '' == SID || ini_get('session.use_only_cookies'))? '': '&' . SID);
|
||||
header('Location: ' . $url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* The action for a 'next' button of wizard-type multipage form.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Next.php,v 1.6 2007/05/18 09:34:18 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* The action for a 'next' button of wizard-type multipage form.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Next extends HTML_QuickForm_Action
|
||||
{
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
// save the form values and validation status to the session
|
||||
$page->isFormBuilt() or $page->buildForm();
|
||||
$pageName = $page->getAttribute('id');
|
||||
$data =& $page->controller->container();
|
||||
$data['values'][$pageName] = $page->exportValues();
|
||||
if (PEAR::isError($valid = $page->validate())) {
|
||||
return $valid;
|
||||
}
|
||||
$data['valid'][$pageName] = $valid;
|
||||
|
||||
// Modal form and page is invalid: don't go further
|
||||
if ($page->controller->isModal() && !$data['valid'][$pageName]) {
|
||||
return $page->handle('display');
|
||||
}
|
||||
// More pages?
|
||||
if (null !== ($nextName = $page->controller->getNextName($pageName))) {
|
||||
$next =& $page->controller->getPage($nextName);
|
||||
return $next->handle('jump');
|
||||
// Consider this a 'finish' button, if there is no explicit one
|
||||
} elseif($page->controller->isModal()) {
|
||||
if ($page->controller->isValid()) {
|
||||
return $page->handle('process');
|
||||
} else {
|
||||
// this should redirect to the first invalid page
|
||||
return $page->handle('jump');
|
||||
}
|
||||
} else {
|
||||
return $page->handle('display');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* The action for a 'submit' button.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2003-2007 The PHP Group
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: Submit.php,v 1.5 2007/05/18 09:34:18 avb Exp $
|
||||
* @link http://pear.php.net/package/HTML_QuickForm_Controller
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing an action to perform on HTTP request.
|
||||
*/
|
||||
require_once 'HTML/QuickForm/Action.php';
|
||||
|
||||
/**
|
||||
* The action for a 'submit' button.
|
||||
*
|
||||
* @category HTML
|
||||
* @package HTML_QuickForm_Controller
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version Release: 1.0.9
|
||||
*/
|
||||
class HTML_QuickForm_Action_Submit extends HTML_QuickForm_Action
|
||||
{
|
||||
function perform(&$page, $actionName)
|
||||
{
|
||||
// save the form values and validation status to the session
|
||||
$page->isFormBuilt() or $page->buildForm();
|
||||
$pageName = $page->getAttribute('id');
|
||||
$data =& $page->controller->container();
|
||||
$data['values'][$pageName] = $page->exportValues();
|
||||
if (PEAR::isError($valid = $page->validate())) {
|
||||
return $valid;
|
||||
}
|
||||
$data['valid'][$pageName] = $valid;
|
||||
|
||||
// All pages are valid, process
|
||||
if ($page->controller->isValid()) {
|
||||
return $page->handle('process');
|
||||
|
||||
// Current page is invalid, display it
|
||||
} elseif (!$data['valid'][$pageName]) {
|
||||
return $page->handle('display');
|
||||
|
||||
// Some other page is invalid, redirect to it
|
||||
} else {
|
||||
$target =& $page->controller->getPage($page->controller->findInvalid());
|
||||
return $target->handle('jump');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue