Source for file Jump.php
Documentation is available at Jump.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This action performs HTTP redirect to a specific page.
* 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.
* @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.
* @package HTML_QuickForm_Controller
* @author Alexey Borzov <avb@php.net>
* @version Release: 1.0.9
* 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)
if (false === ($qm = strpos($uri, '?'))) {
* 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
function _normalizePath ($path)
if ('.' == $pathAry[$i]) {
if ($i < count($pathAry) - 1 ) {
} elseif ('..' == $pathAry[$i] && $i > 1 && '..' != $pathAry[$i - 1 ]) {
if ($i < count($pathAry) -1 ) {
} while ($i < count($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
function _resolveRelativeURL ($url)
$https = !empty ($_SERVER['HTTPS']) && ('off' != $_SERVER['HTTPS']);
$scheme = ($https? 'https:': 'http:');
if ('//' == substr($url, 0 , 2 )) {
$host = $scheme . '//' . $_SERVER['SERVER_NAME'] .
(($https && 443 == $_SERVER['SERVER_PORT'] ||
!$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']);
return $host . $_SERVER['REQUEST_URI'];
} elseif ('/' == $url[0 ]) {
list ($basePath, $baseQuery) = $this->_splitUri ($_SERVER['REQUEST_URI']);
list ($actPath, $actQuery) = $this->_splitUri ($url);
return $host . $basePath . $actQuery;
$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
$pageName = $page->getAttribute ('id');
if (!$page->controller ->isValid ($pageName)) {
$pageName = $page->controller ->findInvalid ();
$current = & $page->controller ->getPage ($pageName);
// 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
$action = $this->_resolveRelativeURL ($action);
$url = $action . (false === strpos($action, '?')? '?': '&') .
$current->getButtonName ('display') . '=true' .
((!defined('SID') || '' == SID || ini_get('session.use_only_cookies'))? '': '&' . SID );
Documentation generated on Tue, 22 Jul 2008 08:00:07 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|