Source for file Helper.php
Documentation is available at Helper.php
* HTML/JavaScript Generation Helper
* @author Joshua Eichorn <josh@bluga.net>
* @copyright 2005 Joshua Eichorn
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.4
* HTML/JavaScript Generation Helper
* @author Joshua Eichorn <josh@bluga.net>
* @copyright 2005 Joshua Eichorn
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.4
* @link http://pear.php.net/package/HTML_AJAX
* URL where an HTML_AJAX_Server instance is serving up clients and taking ajax requests
* JS libraries to include
var $jsLibraries = array ('Util','Main','Request','HttpClient','Dispatcher','Behavior','Loading','JSON','iframe');
* Remote class stubs to include
* Combine jsLibraries into a single require and remove duplicates
* Include all needed libraries, stubs, and set defaultServer
$libs = array (0=>array ());
$list = implode(',',$combinedLibs);
$ret .= " <script type='text/javascript' src='{$this->serverUrl}{ $sep}client={ $list}'></script>\n";
foreach($libs as $list) {
$ret .= "<script type='text/javascript' src='{ $this->serverUrl}{ $sep}client={ $list}'></script>\n";
if (count($this->stubs) > 0 ) {
$stubs = implode(',',$this->stubs);
$ret .= "<script type='text/javascript' src='{ $this->serverUrl}{ $sep}stub={ $stubs}'></script>\n";
* Create a custom Loading message
* @param string $body HTML body of the loading div
* @param string $class CSS class of the div
* @param string $style style tag of the loading div
function loadingMessage($body, $class = 'HTML_AJAX_Loading',
$style = 'position: absolute; top: 0; right: 0; background-color: red; width: 80px; padding: 4px; display: none')
return "<div id='HTML_AJAX_LOADING' class='{ $class}' style=\"{ $style}\">{ $body}</div>\n";
* Update the contents of an element using ajax
* @param string $id id of the element to update
* @param string|array $update Either a url to update with or a array like array('class','method')
* @param string $type replace or append
* @param boolean $enclose
function updateElement($id, $update, $type, $enclose = false) {
foreach($update as $item) {
$updateStr .= $comma.$this->escape($item);
$updateStr = $this->escape($update);
$ret = "HTML_AJAX.{ $type}(". $this->escape($id). ",{ $updateStr});\n";
* Escape a string and add quotes allowing it to be a javascript paramater
* @todo do something here besides a quick hack
function escape($input) {
return "'".addslashes($input)."'";
* Enclose a string in a script block
function encloseInScript($input) {
return '<script type="text/javascript">'.$input."</script>\n";
function jsonEncode($input) {
require_once 'HTML/AJAX/Serializer/JSON.php';
$s = new HTML_AJAX_Serializer_JSON();
return $s->serialize ($input);
* Check the request headers to see if this is an AJAX request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Documentation generated on Fri, 04 Apr 2008 18:30:16 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|