first commit
This commit is contained in:
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxCallableObject.inc.php
|
||||
|
||||
Contains the xajaxCallableObject class
|
||||
|
||||
Title: xajaxCallableObject class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxCallableObject.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxCallableObject
|
||||
|
||||
A class that stores a reference to an object whose methods can be called from
|
||||
the client via a xajax request. <xajax> will call
|
||||
<xajaxCallableObject->generateClientScript> so that stub functions can be
|
||||
generated and sent to the browser.
|
||||
*/
|
||||
final class xajaxCallableObject
|
||||
{
|
||||
/*
|
||||
Object: obj
|
||||
|
||||
A reference to the callable object.
|
||||
*/
|
||||
private $obj;
|
||||
|
||||
/*
|
||||
Array: aConfiguration
|
||||
|
||||
An associative array that will contain configuration options for zero
|
||||
or more of the objects methods. These configuration options will
|
||||
define the call options for each request. The call options will be
|
||||
passed to the client browser when the function stubs are generated.
|
||||
*/
|
||||
private $aConfiguration;
|
||||
|
||||
/*
|
||||
Function: xajaxCallableObject
|
||||
|
||||
Constructs and initializes the <xajaxCallableObject>
|
||||
|
||||
obj - (object): The object to reference.
|
||||
*/
|
||||
public function __construct($obj)
|
||||
{
|
||||
$this->obj = $obj;
|
||||
$this->aConfiguration = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getName
|
||||
|
||||
Returns the name of this callable object. This is typically the
|
||||
class name of the object.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return get_class($this->obj);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Used to set configuration options / call options for each method.
|
||||
|
||||
sMethod - (string): The name of the method.
|
||||
sName - (string): The name of the configuration option.
|
||||
sValue - (string): The value to be set.
|
||||
*/
|
||||
public function configure($sMethod, $sName, $sValue)
|
||||
{
|
||||
$sMethod = strtolower($sMethod);
|
||||
|
||||
if (false == isset($this->aConfiguration[$sMethod]))
|
||||
$this->aConfiguration[$sMethod] = array();
|
||||
|
||||
$this->aConfiguration[$sMethod][$sName] = $sValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateRequests
|
||||
|
||||
Produces an array of <xajaxRequest> objects, one for each method
|
||||
exposed by this callable object.
|
||||
|
||||
sXajaxPrefix - (string): The prefix to be prepended to the
|
||||
javascript function names; this will correspond to the name
|
||||
used for the function stubs that are generated by the
|
||||
<xajaxCallableObject->generateClientScript> call.
|
||||
*/
|
||||
public function generateRequests($sXajaxPrefix)
|
||||
{
|
||||
$aRequests = array();
|
||||
|
||||
$sClass = get_class($this->obj);
|
||||
|
||||
foreach (get_class_methods($this->obj) as $sMethodName)
|
||||
{
|
||||
$bInclude = true;
|
||||
// exclude magic __call, __construct, __destruct methods
|
||||
if (2 < strlen($sMethodName))
|
||||
if ("__" == substr($sMethodName, 0, 2))
|
||||
$bInclude = false;
|
||||
// exclude constructor
|
||||
if ($sClass == $sMethodName)
|
||||
$bInclude = false;
|
||||
if ($bInclude)
|
||||
$aRequests[strtolower($sMethodName)] =
|
||||
new xajaxRequest("{$sXajaxPrefix}{$sClass}.{$sMethodName}");
|
||||
}
|
||||
|
||||
return $aRequests;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by <xajaxCallableObject->generateClientScript> while <xajax> is
|
||||
generating the javascript to be sent to the browser.
|
||||
|
||||
sXajaxPrefix - (string): The prefix to be prepended to the
|
||||
javascript function names.
|
||||
*/
|
||||
public function generateClientScript($sXajaxPrefix)
|
||||
{
|
||||
$sClass = get_class($this->obj);
|
||||
|
||||
echo "{$sXajaxPrefix}{$sClass} = {};\n";
|
||||
|
||||
foreach (get_class_methods($this->obj) as $sMethodName)
|
||||
{
|
||||
$bInclude = true;
|
||||
// exclude magic __call, __construct, __destruct methods
|
||||
if (2 < strlen($sMethodName))
|
||||
if ("__" == substr($sMethodName, 0, 2))
|
||||
$bInclude = false;
|
||||
// exclude constructor
|
||||
if ($sClass == $sMethodName)
|
||||
$bInclude = false;
|
||||
if ($bInclude)
|
||||
{
|
||||
echo "{$sXajaxPrefix}{$sClass}.{$sMethodName} = function() { ";
|
||||
echo "return xajax.request( ";
|
||||
echo "{ xjxcls: '{$sClass}', xjxmthd: '{$sMethodName}' }, ";
|
||||
echo "{ parameters: arguments";
|
||||
|
||||
$sSeparator = ", ";
|
||||
if (isset($this->aConfiguration['*']))
|
||||
foreach ($this->aConfiguration['*'] as $sKey => $sValue)
|
||||
echo "{$sSeparator}{$sKey}: {$sValue}";
|
||||
if (isset($this->aConfiguration[strtolower($sMethodName)]))
|
||||
foreach ($this->aConfiguration[strtolower($sMethodName)] as $sKey => $sValue)
|
||||
echo "{$sSeparator}{$sKey}: {$sValue}";
|
||||
|
||||
echo " } ); ";
|
||||
echo "};\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: isClass
|
||||
|
||||
Determins if the specified class name matches the class name of the
|
||||
object referenced by <xajaxCallableObject->obj>.
|
||||
|
||||
sClass - (string): The name of the class to check.
|
||||
|
||||
Returns:
|
||||
|
||||
boolean - True of the specified class name matches the class of
|
||||
the object being referenced; false otherwise.
|
||||
*/
|
||||
public function isClass($sClass)
|
||||
{
|
||||
if (get_class($this->obj) === $sClass)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: hasMethod
|
||||
|
||||
Determines if the specified method name is one of the methods of the
|
||||
object referenced by <xajaxCallableObject->obj>.
|
||||
|
||||
sMethod - (object): The name of the method to check.
|
||||
|
||||
Returns:
|
||||
|
||||
boolean - True of the referenced object contains the specified method,
|
||||
false otherwise.
|
||||
*/
|
||||
public function hasMethod($sMethod)
|
||||
{
|
||||
return method_exists($this->obj, $sMethod) || method_exists($this->obj, "__call");
|
||||
}
|
||||
|
||||
/*
|
||||
Function: call
|
||||
|
||||
Call the specified method of the object being referenced using the specified
|
||||
array of arguments.
|
||||
|
||||
sMethod - (string): The name of the method to call.
|
||||
aArgs - (array): The arguments to pass to the method.
|
||||
*/
|
||||
public function call($sMethod, $aArgs)
|
||||
{
|
||||
$objResponseManager = xajaxResponseManager::getInstance();
|
||||
$objResponseManager->append(
|
||||
call_user_func_array(
|
||||
array($this->obj, $sMethod),
|
||||
$aArgs
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxEvent.inc.php
|
||||
|
||||
Definition of the xajax Event object.
|
||||
|
||||
Title: xajaxEvent
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxEvent.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
// require_once is necessary here as the function plugin also includes this
|
||||
//SkipAIO
|
||||
require_once dirname(__FILE__) . '/xajaxUserFunction.inc.php';
|
||||
//EndSkipAIO
|
||||
|
||||
/*
|
||||
Class: xajaxEvent
|
||||
|
||||
A container class which holds a reference to handler functions and configuration
|
||||
options associated with a registered event.
|
||||
*/
|
||||
final class xajaxEvent
|
||||
{
|
||||
/*
|
||||
String: sName
|
||||
|
||||
The name of the event.
|
||||
*/
|
||||
private $sName;
|
||||
|
||||
/*
|
||||
Array: aConfiguration
|
||||
|
||||
Configuration / call options to be used when initiating a xajax request
|
||||
to trigger this event.
|
||||
*/
|
||||
private $aConfiguration;
|
||||
|
||||
/*
|
||||
Array: aHandlers
|
||||
|
||||
A list of <xajaxUserFunction> objects associated with this registered
|
||||
event. Each of these functions will be called when the event is triggered.
|
||||
*/
|
||||
private $aHandlers;
|
||||
|
||||
/*
|
||||
Function: xajaxEvent
|
||||
|
||||
Construct and initialize this <xajaxEvent> object.
|
||||
*/
|
||||
public function __construct($sName)
|
||||
{
|
||||
$this->sName = $sName;
|
||||
$this->aConfiguration = array();
|
||||
$this->aHandlers = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getName
|
||||
|
||||
Returns the name of the event.
|
||||
|
||||
Returns:
|
||||
|
||||
string - the name of the event.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Sets/stores configuration options that will be used when generating
|
||||
the client script that is sent to the browser.
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
$this->aConfiguration[$sName] = $mValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addHandler
|
||||
|
||||
Adds a <xajaxUserFunction> object to the list of handlers that will
|
||||
be fired when the event is triggered.
|
||||
*/
|
||||
public function addHandler($xuf)
|
||||
{
|
||||
$this->aHandlers[] = $xuf;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateRequest
|
||||
|
||||
Generates a <xajaxRequest> object that corresponds to the
|
||||
event so that the client script can easily invoke this event.
|
||||
|
||||
sXajaxPrefix - (string): The prefix that will be prepended to
|
||||
the client script stub function associated with this event.
|
||||
|
||||
sEventPrefix - (string): The prefix prepended to the client script
|
||||
function stub and <xajaxRequest> script.
|
||||
*/
|
||||
public function generateRequest($sXajaxPrefix, $sEventPrefix)
|
||||
{
|
||||
$sEvent = $this->sName;
|
||||
return new xajaxRequest("{$sXajaxPrefix}{$sEventPrefix}{$sEvent}");
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Generates a block of javascript code that declares a stub function
|
||||
that can be used to easily trigger the event from the browser.
|
||||
*/
|
||||
public function generateClientScript($sXajaxPrefix, $sEventPrefix)
|
||||
{
|
||||
$sMode = '';
|
||||
$sMethod = '';
|
||||
|
||||
if (isset($this->aConfiguration['mode']))
|
||||
$sMode = $this->aConfiguration['mode'];
|
||||
|
||||
if (isset($this->aConfiguration['method']))
|
||||
$sMethod = $this->aConfiguration['method'];
|
||||
|
||||
if (0 < strlen($sMode))
|
||||
$sMode = ", mode: '{$sMode}'";
|
||||
|
||||
if (0 < strlen($sMethod))
|
||||
$sMethod = ", method: '{$sMethod}'";
|
||||
|
||||
$sEvent = $this->sName;
|
||||
echo "{$sXajaxPrefix}{$sEventPrefix}{$sEvent} = function() { return xajax.request( { xjxevt: '{$sEvent}' }, { parameters: arguments{$sMode}{$sMethod} } ); };\n";
|
||||
}
|
||||
|
||||
/*
|
||||
Function: fire
|
||||
|
||||
Called by the <xajaxEventPlugin> when the event has been triggered.
|
||||
*/
|
||||
public function fire($aArgs)
|
||||
{
|
||||
$objResponseManager = xajaxResponseManager::getInstance();
|
||||
|
||||
foreach (array_keys($this->aHandlers) as $sKey)
|
||||
$this->aHandlers[$sKey]->call($aArgs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxUserFunction.inc.php
|
||||
|
||||
Contains the xajaxUserFunction class
|
||||
|
||||
Title: xajaxUserFunction class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxUserFunction.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxUserFunction
|
||||
|
||||
Construct instances of this class to define functions that will be registered
|
||||
with the <xajax> request processor. This class defines the parameters that
|
||||
are needed for the definition of a xajax enabled function. While you can
|
||||
still specify functions by name during registration, it is advised that you
|
||||
convert to using this class when you wish to register external functions or
|
||||
to specify call options as well.
|
||||
*/
|
||||
final class xajaxUserFunction
|
||||
{
|
||||
/*
|
||||
String: sAlias
|
||||
|
||||
An alias to use for this function. This is useful when you want
|
||||
to call the same xajax enabled function with a different set of
|
||||
call options from what was already registered.
|
||||
*/
|
||||
private $sAlias;
|
||||
|
||||
/*
|
||||
Object: uf
|
||||
|
||||
A string or array which defines the function to be registered.
|
||||
*/
|
||||
private $uf;
|
||||
|
||||
/*
|
||||
String: sInclude
|
||||
|
||||
The path and file name of the include file that contains the function.
|
||||
*/
|
||||
private $sInclude;
|
||||
|
||||
/*
|
||||
Array: aConfiguration
|
||||
|
||||
An associative array containing call options that will be sent to the
|
||||
browser curing client script generation.
|
||||
*/
|
||||
private $aConfiguration;
|
||||
|
||||
/*
|
||||
Function: xajaxUserFunction
|
||||
|
||||
Constructs and initializes the <xajaxUserFunction> object.
|
||||
|
||||
$uf - (mixed): A function specification in one of the following formats:
|
||||
|
||||
- a three element array:
|
||||
(string) Alternate function name: when a method of a class has the same
|
||||
name as another function in the system, you can provide an alias to
|
||||
help avoid collisions.
|
||||
(object or class name) Class: the name of the class or an instance of
|
||||
the object which contains the function to be called.
|
||||
(string) Method: the name of the method that will be called.
|
||||
- a two element array:
|
||||
(object or class name) Class: the name of the class or an instance of
|
||||
the object which contains the function to be called.
|
||||
(string) Method: the name of the method that will be called.
|
||||
- a string:
|
||||
the name of the function that is available at global scope (not in a
|
||||
class.
|
||||
|
||||
$sInclude - deprecated syntax - use ->configure('include','/path/to/file'); instead
|
||||
$sInclude - (string, optional): The path and file name of the include file
|
||||
that contains the class or function to be called.
|
||||
|
||||
$aConfiguration - marked as deprecated - might become reactivated as argument #2
|
||||
$aConfiguration - (array, optional): An associative array of call options
|
||||
that will be used when sending the request from the client.
|
||||
|
||||
Examples:
|
||||
|
||||
$myFunction = array('alias', 'myClass', 'myMethod');
|
||||
$myFunction = array('alias', &$myObject, 'myMethod');
|
||||
$myFunction = array('myClass', 'myMethod');
|
||||
$myFunction = array(&$myObject, 'myMethod');
|
||||
$myFunction = 'myFunction';
|
||||
|
||||
$myUserFunction = new xajaxUserFunction($myFunction, 'myFile.inc.php', array(
|
||||
'method' => 'get',
|
||||
'mode' => 'synchronous'
|
||||
));
|
||||
|
||||
$xajax->register(XAJAX_FUNCTION, $myUserFunction);
|
||||
*/
|
||||
public function xajaxUserFunction($uf) // /*deprecated parameters */ $sInclude=NULL, $aConfiguration=array())
|
||||
{
|
||||
$this->sAlias = '';
|
||||
$this->uf = $uf;
|
||||
$this->aConfiguration = array();
|
||||
|
||||
/*deprecated parameters */
|
||||
// $this->sInclude = $sInclude;
|
||||
// foreach ($aConfiguration as $sKey => $sValue)
|
||||
// $this->configure($sKey, $sValue);
|
||||
|
||||
if (is_array($this->uf) && 2 < count($this->uf))
|
||||
{
|
||||
$this->sAlias = $this->uf[0];
|
||||
$this->uf = array_slice($this->uf, 1);
|
||||
}
|
||||
|
||||
//SkipDebug
|
||||
if (is_array($this->uf) && 2 != count($this->uf))
|
||||
trigger_error(
|
||||
'Invalid function declaration for xajaxUserFunction.',
|
||||
E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getName
|
||||
|
||||
Get the name of the function being referenced.
|
||||
|
||||
Returns:
|
||||
|
||||
string - the name of the function contained within this object.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
// Do not use sAlias here!
|
||||
if (is_array($this->uf))
|
||||
return $this->uf[1];
|
||||
return $this->uf;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Call this to set call options for this instance.
|
||||
*/
|
||||
public function configure($sName, $sValue)
|
||||
{
|
||||
if ('alias' == $sName)
|
||||
$this->sAlias = $sValue;
|
||||
if ('include' == $sName)
|
||||
$this->sInclude = $sValue;
|
||||
else
|
||||
$this->aConfiguration[$sName] = $sValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateRequest
|
||||
|
||||
Constructs and returns a <xajaxRequest> object which is capable
|
||||
of generating the javascript call to invoke this xajax enabled
|
||||
function.
|
||||
*/
|
||||
public function generateRequest($sXajaxPrefix)
|
||||
{
|
||||
$sAlias = $this->getName();
|
||||
if (0 < strlen($this->sAlias))
|
||||
$sAlias = $this->sAlias;
|
||||
return new xajaxRequest("{$sXajaxPrefix}{$sAlias}");
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPlugin> that is referencing this function
|
||||
reference during the client script generation phase. This function
|
||||
will generate the javascript function stub that is sent to the
|
||||
browser on initial page load.
|
||||
*/
|
||||
public function generateClientScript($sXajaxPrefix)
|
||||
{
|
||||
$sFunction = $this->getName();
|
||||
$sAlias = $sFunction;
|
||||
if (0 < strlen($this->sAlias))
|
||||
$sAlias = $this->sAlias;
|
||||
echo "{$sXajaxPrefix}{$sAlias} = function() { ";
|
||||
echo "return xajax.request( ";
|
||||
echo "{ xjxfun: '{$sFunction}' }, ";
|
||||
echo "{ parameters: arguments";
|
||||
|
||||
$sSeparator = ", ";
|
||||
foreach ($this->aConfiguration as $sKey => $sValue)
|
||||
echo "{$sSeparator}{$sKey}: {$sValue}";
|
||||
|
||||
echo " } ); ";
|
||||
echo "};\n";
|
||||
}
|
||||
|
||||
/*
|
||||
Function: call
|
||||
|
||||
Called by the <xajaxPlugin> that references this function during the
|
||||
request processing phase. This function will call the specified
|
||||
function, including an external file if needed and passing along
|
||||
the specified arguments.
|
||||
*/
|
||||
public function call($aArgs=array())
|
||||
{
|
||||
$objResponseManager = xajaxResponseManager::getInstance();
|
||||
|
||||
if (NULL != $this->sInclude)
|
||||
{
|
||||
ob_start();
|
||||
require_once $this->sInclude;
|
||||
$sOutput = ob_get_clean();
|
||||
|
||||
//SkipDebug
|
||||
if (0 < strlen($sOutput))
|
||||
{
|
||||
$sOutput = 'From include file: ' . $this->sInclude . ' => ' . $sOutput;
|
||||
$objResponseManager->debug($sOutput);
|
||||
}
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
$mFunction = $this->uf;
|
||||
$objResponseManager->append(call_user_func_array($mFunction, $aArgs));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxCallableObjectPlugin.inc.php
|
||||
|
||||
Contains the xajaxCallableObjectPlugin class
|
||||
|
||||
Title: xajaxCallableObjectPlugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxCallableObjectPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Constant: XAJAX_CALLABLE_OBJECT
|
||||
Specifies that the item being registered via the <xajax->register> function is a
|
||||
object who's methods will be callable from the browser.
|
||||
*/
|
||||
if (!defined ('XAJAX_CALLABLE_OBJECT')) define ('XAJAX_CALLABLE_OBJECT', 'callable object');
|
||||
|
||||
//SkipAIO
|
||||
require dirname(__FILE__) . '/support/xajaxCallableObject.inc.php';
|
||||
//EndSkipAIO
|
||||
|
||||
/*
|
||||
Class: xajaxCallableObjectPlugin
|
||||
*/
|
||||
final class xajaxCallableObjectPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
/*
|
||||
Array: aCallableObjects
|
||||
*/
|
||||
private $aCallableObjects;
|
||||
|
||||
/*
|
||||
String: sXajaxPrefix
|
||||
*/
|
||||
private $sXajaxPrefix;
|
||||
|
||||
/*
|
||||
String: sDefer
|
||||
*/
|
||||
private $sDefer;
|
||||
|
||||
private $bDeferScriptGeneration;
|
||||
|
||||
/*
|
||||
String: sRequestedClass
|
||||
*/
|
||||
private $sRequestedClass;
|
||||
|
||||
/*
|
||||
String: sRequestedMethod
|
||||
*/
|
||||
private $sRequestedMethod;
|
||||
|
||||
/*
|
||||
Function: xajaxCallableObjectPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->aCallableObjects = array();
|
||||
|
||||
$this->sXajaxPrefix = 'xajax_';
|
||||
$this->sDefer = '';
|
||||
$this->bDeferScriptGeneration = false;
|
||||
|
||||
$this->sRequestedClass = NULL;
|
||||
$this->sRequestedMethod = NULL;
|
||||
|
||||
if (!empty($_GET['xjxcls'])) $this->sRequestedClass = $_GET['xjxcls'];
|
||||
if (!empty($_GET['xjxmthd'])) $this->sRequestedMethod = $_GET['xjxmthd'];
|
||||
if (!empty($_POST['xjxcls'])) $this->sRequestedClass = $_POST['xjxcls'];
|
||||
if (!empty($_POST['xjxmthd'])) $this->sRequestedMethod = $_POST['xjxmthd'];
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
if ('wrapperPrefix' == $sName) {
|
||||
$this->sXajaxPrefix = $mValue;
|
||||
} else if ('scriptDefferal' == $sName) {
|
||||
if (true === $mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
} else if ('deferScriptGeneration' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
else if ('deferred' === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
*/
|
||||
public function register($aArgs)
|
||||
{
|
||||
if (1 < count($aArgs))
|
||||
{
|
||||
$sType = $aArgs[0];
|
||||
|
||||
if (XAJAX_CALLABLE_OBJECT == $sType)
|
||||
{
|
||||
$xco = $aArgs[1];
|
||||
|
||||
//SkipDebug
|
||||
if (false === is_object($xco))
|
||||
{
|
||||
trigger_error("To register a callable object, please provide an instance of the desired class.", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
if (false === ($xco instanceof xajaxCallableObject))
|
||||
$xco = new xajaxCallableObject($xco);
|
||||
|
||||
if (2 < count($aArgs))
|
||||
if (is_array($aArgs[2]))
|
||||
foreach ($aArgs[2] as $sKey => $aValue)
|
||||
foreach ($aValue as $sName => $sValue)
|
||||
$xco->configure($sKey, $sName, $sValue);
|
||||
|
||||
$this->aCallableObjects[] = $xco;
|
||||
|
||||
return $xco->generateRequests($this->sXajaxPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
*/
|
||||
public function generateClientScript()
|
||||
{
|
||||
if (false === $this->bDeferScriptGeneration || 'deferred' === $this->bDeferScriptGeneration)
|
||||
{
|
||||
if (0 < count($this->aCallableObjects))
|
||||
{
|
||||
$sCrLf = "\n";
|
||||
|
||||
echo $sCrLf;
|
||||
echo '<';
|
||||
echo 'script type="text/javascript" ';
|
||||
echo $this->sDefer;
|
||||
echo 'charset="UTF-8">';
|
||||
echo $sCrLf;
|
||||
echo '/* <';
|
||||
echo '![CDATA[ */';
|
||||
echo $sCrLf;
|
||||
|
||||
foreach(array_keys($this->aCallableObjects) as $sKey)
|
||||
$this->aCallableObjects[$sKey]->generateClientScript($this->sXajaxPrefix);
|
||||
|
||||
echo '/* ]]> */';
|
||||
echo $sCrLf;
|
||||
echo '<';
|
||||
echo '/script>';
|
||||
echo $sCrLf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
*/
|
||||
public function canProcessRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedClass)
|
||||
return false;
|
||||
if (NULL == $this->sRequestedMethod)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
*/
|
||||
public function processRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedClass)
|
||||
return false;
|
||||
if (NULL == $this->sRequestedMethod)
|
||||
return false;
|
||||
|
||||
$objArgumentManager = xajaxArgumentManager::getInstance();
|
||||
$aArgs = $objArgumentManager->process();
|
||||
|
||||
foreach (array_keys($this->aCallableObjects) as $sKey)
|
||||
{
|
||||
$xco = $this->aCallableObjects[$sKey];
|
||||
|
||||
if ($xco->isClass($this->sRequestedClass))
|
||||
{
|
||||
if ($xco->hasMethod($this->sRequestedMethod))
|
||||
{
|
||||
$xco->call($this->sRequestedMethod, $aArgs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'Invalid request for a callable object.';
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager = xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new xajaxCallableObjectPlugin(), 102);
|
||||
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxDefaultIncludePlugin.inc.php
|
||||
|
||||
Contains the default script include plugin class.
|
||||
|
||||
Title: xajax default script include plugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxDefaultIncludePlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxIncludeClientScript
|
||||
|
||||
Generates the SCRIPT tags necessary to 'include' the xajax javascript
|
||||
library on the browser.
|
||||
|
||||
This is called when the page is first loaded.
|
||||
*/
|
||||
final class xajaxIncludeClientScriptPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
private $sJsURI;
|
||||
private $aJsFiles;
|
||||
private $sDefer;
|
||||
private $sRequestURI;
|
||||
private $sStatusMessages;
|
||||
private $sWaitCursor;
|
||||
private $sVersion;
|
||||
private $sDefaultMode;
|
||||
private $sDefaultMethod;
|
||||
private $bDebug;
|
||||
private $bVerboseDebug;
|
||||
private $nScriptLoadTimeout;
|
||||
private $bUseUncompressedScripts;
|
||||
private $bDeferScriptGeneration;
|
||||
private $sLanguage;
|
||||
private $nResponseQueueSize;
|
||||
private $sDebugOutputID;
|
||||
|
||||
public function xajaxIncludeClientScriptPlugin()
|
||||
{
|
||||
$this->sJsURI = '';
|
||||
$this->aJsFiles = array();
|
||||
$this->sDefer = '';
|
||||
$this->sRequestURI = '';
|
||||
$this->sStatusMessages = 'false';
|
||||
$this->sWaitCursor = 'true';
|
||||
$this->sVersion = 'unknown';
|
||||
$this->sDefaultMode = 'asynchronous';
|
||||
$this->sDefaultMethod = 'POST'; // W3C: Method is case sensitive
|
||||
$this->bDebug = false;
|
||||
$this->bVerboseDebug = false;
|
||||
$this->nScriptLoadTimeout = 2000;
|
||||
$this->bUseUncompressedScripts = false;
|
||||
$this->bDeferScriptGeneration = false;
|
||||
$this->sLanguage = null;
|
||||
$this->nResponseQueueSize = null;
|
||||
$this->sDebugOutputID = null;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
if ('javascript URI' == $sName) {
|
||||
$this->sJsURI = $mValue;
|
||||
} else if ("javascript files" == $sName) {
|
||||
$this->aJsFiles = $mValue;
|
||||
} else if ("scriptDefferal" == $sName) {
|
||||
if (true === $mValue) $this->sDefer = "defer ";
|
||||
else $this->sDefer = "";
|
||||
} else if ("requestURI" == $sName) {
|
||||
$this->sRequestURI = $mValue;
|
||||
} else if ("statusMessages" == $sName) {
|
||||
if (true === $mValue) $this->sStatusMessages = "true";
|
||||
else $this->sStatusMessages = "false";
|
||||
} else if ("waitCursor" == $sName) {
|
||||
if (true === $mValue) $this->sWaitCursor = "true";
|
||||
else $this->sWaitCursor = "false";
|
||||
} else if ("version" == $sName) {
|
||||
$this->sVersion = $mValue;
|
||||
} else if ("defaultMode" == $sName) {
|
||||
if ("asynchronous" == $mValue || "synchronous" == $mValue)
|
||||
$this->sDefaultMode = $mValue;
|
||||
} else if ("defaultMethod" == $sName) {
|
||||
if ("POST" == $mValue || "GET" == $mValue) // W3C: Method is case sensitive
|
||||
$this->sDefaultMethod = $mValue;
|
||||
} else if ("debug" == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDebug = $mValue;
|
||||
} else if ("verboseDebug" == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bVerboseDebug = $mValue;
|
||||
} else if ("scriptLoadTimeout" == $sName) {
|
||||
$this->nScriptLoadTimeout = $mValue;
|
||||
} else if ("useUncompressedScripts" == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bUseUncompressedScripts = $mValue;
|
||||
} else if ('deferScriptGeneration' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
else if ('deferred' == $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
} else if ('language' == $sName) {
|
||||
$this->sLanguage = $mValue;
|
||||
} else if ('responseQueueSize' == $sName) {
|
||||
$this->nResponseQueueSize = $mValue;
|
||||
} else if ('debugOutputID' == $sName) {
|
||||
$this->sDebugOutputID = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
*/
|
||||
public function generateClientScript()
|
||||
{
|
||||
if (false === $this->bDeferScriptGeneration)
|
||||
{
|
||||
$this->printJavascriptConfig();
|
||||
$this->printJavascriptInclude();
|
||||
}
|
||||
else if (true === $this->bDeferScriptGeneration)
|
||||
{
|
||||
$this->printJavascriptInclude();
|
||||
}
|
||||
else if ('deferred' == $this->bDeferScriptGeneration)
|
||||
{
|
||||
$this->printJavascriptConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getJavascriptConfig
|
||||
|
||||
Generates the xajax settings that will be used by the xajax javascript
|
||||
library when making requests back to the server.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The javascript code necessary to configure the settings on
|
||||
the browser.
|
||||
*/
|
||||
public function getJavascriptConfig()
|
||||
{
|
||||
ob_start();
|
||||
$this->printJavascriptConfig();
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printJavascriptConfig
|
||||
|
||||
See <xajaxIncludeClientScriptPlugin::getJavascriptConfig>
|
||||
*/
|
||||
public function printJavascriptConfig()
|
||||
{
|
||||
$sCrLf = "\n";
|
||||
|
||||
$sJsURI = $this->sJsURI;
|
||||
|
||||
if ($sJsURI != '' && substr($sJsURI, -1) != '/')
|
||||
$sJsURI .= '/';
|
||||
|
||||
echo $sCrLf;
|
||||
echo '<';
|
||||
echo 'script type="text/javascript" ';
|
||||
echo $this->sDefer;
|
||||
echo 'charset="UTF-8">';
|
||||
echo $sCrLf;
|
||||
echo '/* <';
|
||||
echo '![CDATA[ */';
|
||||
echo $sCrLf;
|
||||
echo 'try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.requestURI = "';
|
||||
echo $this->sRequestURI;
|
||||
echo '";';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.statusMessages = ';
|
||||
echo $this->sStatusMessages;
|
||||
echo ';';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.waitCursor = ';
|
||||
echo $this->sWaitCursor;
|
||||
echo ';';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.version = "';
|
||||
echo $this->sVersion;
|
||||
echo '";';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.defaultMode = "';
|
||||
echo $this->sDefaultMode;
|
||||
echo '";';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.defaultMethod = "';
|
||||
echo $this->sDefaultMethod;
|
||||
echo '";';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.JavaScriptURI = "';
|
||||
echo $this->sJsURI;
|
||||
echo '";';
|
||||
|
||||
|
||||
if (false === (null === $this->nResponseQueueSize))
|
||||
{
|
||||
echo $sCrLf;
|
||||
echo 'xajax.config.responseQueueSize = ';
|
||||
echo $this->nResponseQueueSize;
|
||||
echo ';';
|
||||
}
|
||||
|
||||
if (true === $this->bDebug)
|
||||
{
|
||||
if (false === (null === $this->sDebugOutputID))
|
||||
{
|
||||
echo $sCrLf;
|
||||
echo 'xajax.debug = {};';
|
||||
echo $sCrLf;
|
||||
echo 'xajax.debug.outputID = "';
|
||||
echo $this->sDebugOutputID;
|
||||
echo '";';
|
||||
}
|
||||
}
|
||||
|
||||
echo $sCrLf;
|
||||
echo '/* ]]> */';
|
||||
echo $sCrLf;
|
||||
echo '<';
|
||||
echo '/script>';
|
||||
echo $sCrLf;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getJavascriptInclude
|
||||
|
||||
Generates SCRIPT tags necessary to load the javascript libraries on
|
||||
the browser.
|
||||
|
||||
sJsURI - (string): The relative or fully qualified PATH that will be
|
||||
used to compose the URI to the specified javascript files.
|
||||
aJsFiles - (array): List of javascript files to include.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The SCRIPT tags that will cause the browser to load the
|
||||
specified files.
|
||||
*/
|
||||
public function getJavascriptInclude()
|
||||
{
|
||||
ob_start();
|
||||
$this->printJavascriptInclude();
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printJavascriptInclude
|
||||
|
||||
See <xajaxIncludeClientScriptPlugin::getJavascriptInclude>
|
||||
*/
|
||||
public function printJavascriptInclude()
|
||||
{
|
||||
$aJsFiles = $this->aJsFiles;
|
||||
$sJsURI = $this->sJsURI;
|
||||
|
||||
if (0 == count($aJsFiles)) {
|
||||
$aJsFiles[] = array($this->_getScriptFilename('xajax_js/xajax_core.js'), 'xajax');
|
||||
|
||||
if (true === $this->bDebug)
|
||||
$aJsFiles[] = array($this->_getScriptFilename('xajax_js/xajax_debug.js'), 'xajax.debug');
|
||||
|
||||
if (true === $this->bVerboseDebug)
|
||||
$aJsFiles[] = array($this->_getScriptFilename('xajax_js/xajax_verbose.js'), 'xajax.debug.verbose');
|
||||
|
||||
if (null !== $this->sLanguage)
|
||||
$aJsFiles[] = array($this->_getScriptFilename('xajax_js/xajax_lang_' . $this->sLanguage . '.js'), 'xajax');
|
||||
}
|
||||
|
||||
if ($sJsURI != '' && substr($sJsURI, -1) != '/')
|
||||
$sJsURI .= '/';
|
||||
|
||||
$sCrLf = "\n";
|
||||
|
||||
foreach ($aJsFiles as $aJsFile) {
|
||||
echo '<';
|
||||
echo 'script type="text/javascript" src="';
|
||||
echo $sJsURI;
|
||||
echo $aJsFile[0];
|
||||
echo '" ';
|
||||
echo $this->sDefer;
|
||||
echo 'charset="UTF-8"><';
|
||||
echo '/script>';
|
||||
echo $sCrLf;
|
||||
}
|
||||
|
||||
if (0 < $this->nScriptLoadTimeout) {
|
||||
foreach ($aJsFiles as $aJsFile) {
|
||||
echo '<';
|
||||
echo 'script type="text/javascript" ';
|
||||
echo $this->sDefer;
|
||||
echo 'charset="UTF-8">';
|
||||
echo $sCrLf;
|
||||
echo '/* <';
|
||||
echo '![CDATA[ */';
|
||||
echo $sCrLf;
|
||||
echo 'window.setTimeout(';
|
||||
echo $sCrLf;
|
||||
echo ' function() {';
|
||||
echo $sCrLf;
|
||||
echo ' var scriptExists = false;';
|
||||
echo $sCrLf;
|
||||
echo ' try { if (';
|
||||
echo $aJsFile[1];
|
||||
echo '.isLoaded) scriptExists = true; }';
|
||||
echo $sCrLf;
|
||||
echo ' catch (e) {}';
|
||||
echo $sCrLf;
|
||||
echo ' if (!scriptExists) {';
|
||||
echo $sCrLf;
|
||||
echo ' alert("Error: the ';
|
||||
echo $aJsFile[1];
|
||||
echo ' Javascript component could not be included. Perhaps the URL is incorrect?\nURL: ';
|
||||
echo $sJsURI;
|
||||
echo $aJsFile[0];
|
||||
echo '");';
|
||||
echo $sCrLf;
|
||||
echo ' }';
|
||||
echo $sCrLf;
|
||||
echo ' }, ';
|
||||
echo $this->nScriptLoadTimeout;
|
||||
echo ');';
|
||||
echo $sCrLf;
|
||||
echo '/* ]]> */';
|
||||
echo $sCrLf;
|
||||
echo '<';
|
||||
echo '/script>';
|
||||
echo $sCrLf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _getScriptFilename
|
||||
|
||||
Returns the name of the script file, based on the current settings.
|
||||
|
||||
sFilename - (string): The base filename.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The filename as it should be specified in the script tags
|
||||
on the browser.
|
||||
*/
|
||||
private function _getScriptFilename($sFilename)
|
||||
{
|
||||
if ($this->bUseUncompressedScripts) {
|
||||
return str_replace('.js', '_uncompressed.js', $sFilename);
|
||||
}
|
||||
return $sFilename;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Register the xajaxIncludeClientScriptPlugin object with the xajaxPluginManager.
|
||||
*/
|
||||
$objPluginManager = xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new xajaxIncludeClientScriptPlugin(), 99);
|
||||
231
resources/xajax/xajax_core/plugin_layer/xajaxEventPlugin.inc.php
Normal file
231
resources/xajax/xajax_core/plugin_layer/xajaxEventPlugin.inc.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxEventPlugin.inc.php
|
||||
|
||||
Contains the xajaxEventPlugin class
|
||||
|
||||
Title: xajaxEventPlugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxEventPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Constant: XAJAX_EVENT
|
||||
Specifies that the item being registered via the <xajax->register> function
|
||||
is an event.
|
||||
|
||||
Constant: XAJAX_EVENT_HANDLER
|
||||
Specifies that the item being registered via the <xajax->register> function
|
||||
is an event handler.
|
||||
*/
|
||||
if (!defined ('XAJAX_EVENT')) define ('XAJAX_EVENT', 'xajax event');
|
||||
if (!defined ('XAJAX_EVENT_HANDLER')) define ('XAJAX_EVENT_HANDLER', 'xajax event handler');
|
||||
|
||||
//SkipAIO
|
||||
require dirname(__FILE__) . '/support/xajaxEvent.inc.php';
|
||||
//EndSkipAIO
|
||||
|
||||
/*
|
||||
Class: xajaxEventPlugin
|
||||
|
||||
Plugin that adds server side event handling capabilities to xajax. Events can
|
||||
be registered, then event handlers attached.
|
||||
*/
|
||||
class xajaxEventPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
/*
|
||||
Array: aEvents
|
||||
*/
|
||||
var $aEvents;
|
||||
|
||||
/*
|
||||
String: sXajaxPrefix
|
||||
*/
|
||||
var $sXajaxPrefix;
|
||||
|
||||
/*
|
||||
String: sEventPrefix
|
||||
*/
|
||||
var $sEventPrefix;
|
||||
|
||||
/*
|
||||
String: sDefer
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
var $bDeferScriptGeneration;
|
||||
|
||||
/*
|
||||
String: sRequestedEvent
|
||||
*/
|
||||
var $sRequestedEvent;
|
||||
|
||||
/*
|
||||
Function: xajaxEventPlugin
|
||||
*/
|
||||
function xajaxEventPlugin()
|
||||
{
|
||||
$this->aEvents = array();
|
||||
|
||||
$this->sXajaxPrefix = 'xajax_';
|
||||
$this->sEventPrefix = 'event_';
|
||||
$this->sDefer = '';
|
||||
$this->bDeferScriptGeneration = false;
|
||||
|
||||
$this->sRequestedEvent = NULL;
|
||||
|
||||
if (isset($_GET['xjxevt'])) $this->sRequestedEvent = $_GET['xjxevt'];
|
||||
if (isset($_POST['xjxevt'])) $this->sRequestedEvent = $_POST['xjxevt'];
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('wrapperPrefix' == $sName) {
|
||||
$this->sXajaxPrefix = $mValue;
|
||||
} else if ('eventPrefix' == $sName) {
|
||||
$this->sEventPrefix = $mValue;
|
||||
} else if ('scriptDefferal' == $sName) {
|
||||
if (true === $mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
} else if ('deferScriptGeneration' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
else if ('deferred' === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
$sType - (string): type of item being registered
|
||||
$sEvent - (string): the name of the event
|
||||
$ufHandler - (function name or reference): a reference to the user function to call
|
||||
$aConfiguration - (array): an array containing configuration options
|
||||
*/
|
||||
function register($aArgs)
|
||||
{
|
||||
if (1 < count($aArgs))
|
||||
{
|
||||
$sType = $aArgs[0];
|
||||
|
||||
if (XAJAX_EVENT == $sType)
|
||||
{
|
||||
$sEvent = $aArgs[1];
|
||||
|
||||
if (false === isset($this->aEvents[$sEvent]))
|
||||
{
|
||||
$xe = new xajaxEvent($sEvent);
|
||||
|
||||
if (2 < count($aArgs))
|
||||
if (is_array($aArgs[2]))
|
||||
foreach ($aArgs[2] as $sKey => $sValue)
|
||||
$xe->configure($sKey, $sValue);
|
||||
|
||||
$this->aEvents[$sEvent] =& $xe;
|
||||
|
||||
return $xe->generateRequest($this->sXajaxPrefix, $this->sEventPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
if (XAJAX_EVENT_HANDLER == $sType)
|
||||
{
|
||||
$sEvent = $aArgs[1];
|
||||
|
||||
if (isset($this->aEvents[$sEvent]))
|
||||
{
|
||||
if (isset($aArgs[2]))
|
||||
{
|
||||
$xuf =& $aArgs[2];
|
||||
|
||||
if (false === ($xuf instanceof xajaxUserFunction))
|
||||
$xuf = new xajaxUserFunction($xuf);
|
||||
|
||||
$objEvent =& $this->aEvents[$sEvent];
|
||||
$objEvent->addHandler($xuf);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if (false === $this->bDeferScriptGeneration || 'deferred' === $this->bDeferScriptGeneration)
|
||||
{
|
||||
if (0 < count($this->aEvents))
|
||||
{
|
||||
echo "\n<script type='text/javascript' ";
|
||||
echo $this->sDefer;
|
||||
echo "charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
foreach (array_keys($this->aEvents) as $sKey)
|
||||
$this->aEvents[$sKey]->generateClientScript($this->sXajaxPrefix, $this->sEventPrefix);
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
*/
|
||||
function canProcessRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedEvent)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
*/
|
||||
function processRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedEvent)
|
||||
return false;
|
||||
|
||||
$objArgumentManager =& xajaxArgumentManager::getInstance();
|
||||
$aArgs = $objArgumentManager->process();
|
||||
|
||||
|
||||
|
||||
foreach (array_keys($this->aEvents) as $sKey)
|
||||
{
|
||||
$objEvent =& $this->aEvents[$sKey];
|
||||
|
||||
if ($objEvent->getName() == $this->sRequestedEvent)
|
||||
{
|
||||
$objEvent->fire($aArgs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Invalid event request received; no event was registered with this name.';
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new xajaxEventPlugin(), 103);
|
||||
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxFunctionPlugin.inc.php
|
||||
|
||||
Contains the xajaxFunctionPlugin class
|
||||
|
||||
Title: xajaxFunctionPlugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxFunctionPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Constant: XAJAX_FUNCTION
|
||||
Specifies that the item being registered via the <xajax->register> function
|
||||
is a php function available at global scope, or a specific function from
|
||||
an instance of an object.
|
||||
*/
|
||||
if (!defined ('XAJAX_FUNCTION')) define ('XAJAX_FUNCTION', 'function');
|
||||
|
||||
// require_once is necessary here as the xajaxEvent class will include this also
|
||||
//SkipAIO
|
||||
require_once dirname(__FILE__) . '/support/xajaxUserFunction.inc.php';
|
||||
//EndSkipAIO
|
||||
|
||||
/*
|
||||
Class: xajaxFunctionPlugin
|
||||
*/
|
||||
class xajaxFunctionPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
/*
|
||||
Array: aFunctions
|
||||
|
||||
An array of <xajaxUserFunction> object that are registered and
|
||||
available via a <xajax.request> call.
|
||||
*/
|
||||
var $aFunctions;
|
||||
|
||||
/*
|
||||
String: sXajaxPrefix
|
||||
|
||||
A configuration setting that is stored locally and used during
|
||||
the client script generation phase.
|
||||
*/
|
||||
var $sXajaxPrefix;
|
||||
|
||||
/*
|
||||
String: sDefer
|
||||
|
||||
Configuration option that can be used to request that the
|
||||
javascript file is loaded after the page has been fully loaded.
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
var $bDeferScriptGeneration;
|
||||
|
||||
/*
|
||||
String: sRequestedFunction
|
||||
|
||||
This string is used to temporarily hold the name of the function
|
||||
that is being requested (during the request processing phase).
|
||||
|
||||
Since canProcessRequest loads this value from the get or post
|
||||
data, it is unnecessary to load it again.
|
||||
*/
|
||||
var $sRequestedFunction;
|
||||
|
||||
/*
|
||||
Function: xajaxFunctionPlugin
|
||||
|
||||
Constructs and initializes the <xajaxFunctionPlugin>. The GET and POST
|
||||
data is searched for xajax function call parameters. This will later
|
||||
be used to determine if the request is for a registered function in
|
||||
<xajaxFunctionPlugin->canProcessRequest>
|
||||
*/
|
||||
function xajaxFunctionPlugin()
|
||||
{
|
||||
$this->aFunctions = array();
|
||||
|
||||
$this->sXajaxPrefix = 'xajax_';
|
||||
$this->sDefer = '';
|
||||
$this->bDeferScriptGeneration = false;
|
||||
|
||||
$this->sRequestedFunction = NULL;
|
||||
|
||||
if (isset($_GET['xjxfun'])) $this->sRequestedFunction = $_GET['xjxfun'];
|
||||
if (isset($_POST['xjxfun'])) $this->sRequestedFunction = $_POST['xjxfun'];
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Sets/stores configuration options used by this plugin.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('wrapperPrefix' == $sName) {
|
||||
$this->sXajaxPrefix = $mValue;
|
||||
} else if ('scriptDefferal' == $sName) {
|
||||
if (true === $mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
} else if ('deferScriptGeneration' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
else if ('deferred' === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
Provides a mechanism for functions to be registered and made available to
|
||||
the page via the javascript <xajax.request> call.
|
||||
*/
|
||||
function register($aArgs)
|
||||
{
|
||||
if (1 < count($aArgs))
|
||||
{
|
||||
$sType = $aArgs[0];
|
||||
|
||||
if (XAJAX_FUNCTION == $sType)
|
||||
{
|
||||
$xuf = $aArgs[1];
|
||||
|
||||
if (false === ($xuf instanceof xajaxUserFunction))
|
||||
$xuf = new xajaxUserFunction($xuf);
|
||||
|
||||
if (2 < count($aArgs))
|
||||
{
|
||||
if (is_array($aArgs[2]))
|
||||
{
|
||||
foreach ($aArgs[2] as $sName => $sValue)
|
||||
{
|
||||
$xuf->configure($sName, $sValue);
|
||||
}
|
||||
} else {
|
||||
$xuf->configure('include', $aArgs[2]);
|
||||
}
|
||||
}
|
||||
$this->aFunctions[] = $xuf;
|
||||
|
||||
return $xuf->generateRequest($this->sXajaxPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the client script generation
|
||||
phase. This is used to generate a block of javascript code that will
|
||||
contain function declarations that can be used on the browser through
|
||||
javascript to initiate xajax requests.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if (false === $this->bDeferScriptGeneration || 'deferred' === $this->bDeferScriptGeneration)
|
||||
{
|
||||
if (0 < count($this->aFunctions))
|
||||
{
|
||||
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
foreach (array_keys($this->aFunctions) as $sKey)
|
||||
$this->aFunctions[$sKey]->generateClientScript($this->sXajaxPrefix);
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
|
||||
Determines whether or not the current request can be processed
|
||||
by this plugin.
|
||||
|
||||
Returns:
|
||||
|
||||
boolean - True if the current request can be handled by this plugin;
|
||||
false otherwise.
|
||||
*/
|
||||
function canProcessRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedFunction)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
|
||||
Called by the <xajaxPluginManager> when a request needs to be
|
||||
processed.
|
||||
|
||||
Returns:
|
||||
|
||||
mixed - True when the request has been processed successfully.
|
||||
An error message when an error has occurred.
|
||||
*/
|
||||
function processRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedFunction)
|
||||
return false;
|
||||
|
||||
$objArgumentManager = xajaxArgumentManager::getInstance();
|
||||
$aArgs = $objArgumentManager->process();
|
||||
|
||||
foreach (array_keys($this->aFunctions) as $sKey)
|
||||
{
|
||||
$xuf = $this->aFunctions[$sKey];
|
||||
|
||||
if ($xuf->getName() == $this->sRequestedFunction)
|
||||
{
|
||||
$xuf->call($aArgs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Invalid function request received; no request processor found with this name.';
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager = xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new xajaxFunctionPlugin(), 100);
|
||||
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxScriptPlugin.inc.php
|
||||
|
||||
Contains the xajaxScriptPlugin class declaration.
|
||||
|
||||
Title: xajaxScriptPlugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxScriptPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxScriptPlugin
|
||||
|
||||
Contains the code that can produce script and style data during deferred script
|
||||
generation. This allows the xajax generated javascript and style sheet information
|
||||
to be loaded via an external file reference instead of inlined into the page
|
||||
source.
|
||||
*/
|
||||
class xajaxScriptPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
/*
|
||||
String: sRequest
|
||||
*/
|
||||
var $sRequest;
|
||||
|
||||
/*
|
||||
String: sHash
|
||||
*/
|
||||
var $sHash;
|
||||
|
||||
/*
|
||||
String: sRequestURI
|
||||
*/
|
||||
var $sRequestURI;
|
||||
|
||||
/*
|
||||
Boolean: bDeferScriptGeneration
|
||||
*/
|
||||
var $bDeferScriptGeneration;
|
||||
|
||||
/*
|
||||
Boolean: bValidateHash
|
||||
*/
|
||||
var $bValidateHash;
|
||||
|
||||
/*
|
||||
Boolean: bWorking
|
||||
*/
|
||||
var $bWorking;
|
||||
|
||||
/*
|
||||
Function: xajaxScriptPlugin
|
||||
|
||||
Construct and initialize the xajax script plugin object. During
|
||||
initialization, this plugin will look for hash codes in the
|
||||
GET data (parameters passed on the request URI) and store them
|
||||
for later use.
|
||||
*/
|
||||
function xajaxScriptPlugin()
|
||||
{
|
||||
$this->sRequestURI = '';
|
||||
$this->bDeferScriptGeneration = false;
|
||||
$this->bValidateHash = true;
|
||||
|
||||
$this->bWorking = false;
|
||||
|
||||
$this->sRequest = '';
|
||||
$this->sHash = null;
|
||||
|
||||
if (isset($_GET['xjxGenerateJavascript'])) {
|
||||
$this->sRequest = 'script';
|
||||
$this->sHash = $_GET['xjxGenerateJavascript'];
|
||||
}
|
||||
|
||||
if (isset($_GET['xjxGenerateStyle'])) {
|
||||
$this->sRequest = 'style';
|
||||
$this->sHash = $_GET['xjxGenerateStyle'];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Sets/stores configuration options used by this plugin. See also:
|
||||
<xajax::configure>. This plugin will watch for and store the current
|
||||
setting for the following configuration options:
|
||||
|
||||
- <requestURI> (string): The requestURI of the current script file.
|
||||
- <deferScriptGeneration> (boolean): A flag that indicates whether
|
||||
script deferral is in effect or not.
|
||||
- <deferScriptValidateHash> (boolean): A flag that indicates whether
|
||||
or not the script hash should be validated.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('requestURI' == $sName) {
|
||||
$this->sRequestURI = $mValue;
|
||||
} else if ('deferScriptGeneration' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDeferScriptGeneration = $mValue;
|
||||
} else if ('deferScriptValidateHash' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bValidateHash = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> when the text of the client script
|
||||
(or style) declarations are needed.
|
||||
|
||||
This function will only output script or style information if the
|
||||
request URI contained an appropriate hash code and script deferral
|
||||
is in effect.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if ($this->bWorking)
|
||||
return;
|
||||
|
||||
if (true === $this->bDeferScriptGeneration)
|
||||
{
|
||||
$this->bWorking = true;
|
||||
|
||||
$sQueryBase = '?';
|
||||
if (0 < strpos($this->sRequestURI, '?'))
|
||||
$sQueryBase = '&';
|
||||
|
||||
$aScripts = $this->_getSections('script');
|
||||
if (0 < count($aScripts))
|
||||
{
|
||||
// echo "<!--" . print_r($aScripts, true) . "-->";
|
||||
|
||||
$sHash = md5(implode($aScripts));
|
||||
$sQuery = $sQueryBase . "xjxGenerateJavascript=" . $sHash;
|
||||
|
||||
echo "\n<script type='text/javascript' src='" . $this->sRequestURI . $sQuery . "' charset='UTF-8'></script>\n";
|
||||
}
|
||||
|
||||
$aStyles = $this->_getSections('style');
|
||||
if (0 < count($aStyles))
|
||||
{
|
||||
// echo "<!--" . print_r($aStyles, true) . "-->";
|
||||
|
||||
$sHash = md5(implode($aStyles));
|
||||
$sQuery = $sQueryBase . "xjxGenerateStyle=" . $sHash;
|
||||
|
||||
echo "\n<link href='" . $this->sRequestURI . $sQuery . "' rel='Stylesheet' />\n";
|
||||
}
|
||||
|
||||
$this->bWorking = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
|
||||
Called by the <xajaxPluginManager> to determine if this plugin can
|
||||
process the current request. This will return true when the
|
||||
requestURI contains an appropriate hash code.
|
||||
*/
|
||||
function canProcessRequest()
|
||||
{
|
||||
return ('' != $this->sRequest);
|
||||
}
|
||||
|
||||
function _getSections($sType)
|
||||
{
|
||||
$objPluginManager = xajaxPluginManager::getInstance();
|
||||
|
||||
$objPluginManager->configure('deferScriptGeneration', 'deferred');
|
||||
|
||||
$aSections = array();
|
||||
|
||||
// buffer output
|
||||
|
||||
ob_start();
|
||||
$objPluginManager->generateClientScript();
|
||||
$sScript = ob_get_clean();
|
||||
|
||||
// parse out blocks
|
||||
|
||||
$aParts = explode('</' . $sType . '>', $sScript);
|
||||
foreach ($aParts as $sPart)
|
||||
{
|
||||
$aValues = explode('<' . $sType, $sPart, 2);
|
||||
if (2 == count($aValues))
|
||||
{
|
||||
list($sJunk, $sPart) = $aValues;
|
||||
|
||||
$aValues = explode('>', $sPart, 2);
|
||||
if (2 == count($aValues))
|
||||
{
|
||||
list($sJunk, $sPart) = $aValues;
|
||||
|
||||
if (0 < strlen($sPart))
|
||||
$aSections[] = $sPart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager->configure('deferScriptGeneration', $this->bDeferScriptGeneration);
|
||||
|
||||
return $aSections;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
|
||||
Called by the <xajaxPluginManager> when the current request should be
|
||||
processed. This plugin will generate the javascript or style sheet information
|
||||
that would normally be output by the other xajax plugin objects, when script
|
||||
deferral is in effect. If script deferral is disabled, this function returns
|
||||
without performing any functions.
|
||||
*/
|
||||
function processRequest()
|
||||
{
|
||||
if ($this->canProcessRequest())
|
||||
{
|
||||
$aSections = $this->_getSections($this->sRequest);
|
||||
|
||||
// echo "<!--" . print_r($aSections, true) . "-->";
|
||||
|
||||
// validate the hash
|
||||
$sHash = md5(implode($aSections));
|
||||
if (false == $this->bValidateHash || $sHash == $this->sHash)
|
||||
{
|
||||
$sType = 'text/javascript';
|
||||
if ('style' == $this->sRequest)
|
||||
$sType = 'text/css';
|
||||
|
||||
$objResponse = new xajaxCustomResponse($sType);
|
||||
|
||||
foreach ($aSections as $sSection)
|
||||
$objResponse->append($sSection . "\n");
|
||||
|
||||
$objResponseManager = xajaxResponseManager::getInstance();
|
||||
$objResponseManager->append($objResponse);
|
||||
|
||||
header ('Expires: ' . gmdate('D, d M Y H:i:s', time() + (60*60*24)) . ' GMT');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return 'Invalid script or style request.';
|
||||
trigger_error('Hash mismatch: ' . $this->sRequest . ': ' . $sHash . ' <==> ' . $this->sHash, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Register the plugin with the xajax plugin manager.
|
||||
*/
|
||||
$objPluginManager = xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new xajaxScriptPlugin(), 9999);
|
||||
1096
resources/xajax/xajax_core/xajax.inc.php
Normal file
1096
resources/xajax/xajax_core/xajax.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
335
resources/xajax/xajax_core/xajaxArgumentManager.inc.php
Normal file
335
resources/xajax/xajax_core/xajaxArgumentManager.inc.php
Normal file
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxArgumentManager.inc.php
|
||||
|
||||
Contains the xajaxArgumentManager class
|
||||
|
||||
Title: xajaxArgumentManager class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxArgumentManager.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
if (!defined('XAJAX_METHOD_UNKNOWN')) define('XAJAX_METHOD_UNKNOWN', 0);
|
||||
if (!defined('XAJAX_METHOD_GET')) define('XAJAX_METHOD_GET', 1);
|
||||
if (!defined('XAJAX_METHOD_POST')) define('XAJAX_METHOD_POST', 2);
|
||||
|
||||
/*
|
||||
Class: xajaxArgumentManager
|
||||
|
||||
This class processes the input arguments from the GET or POST data of
|
||||
the request. If this is a request for the initial page load, no arguments
|
||||
will be processed. During a xajax request, any arguments found in the
|
||||
GET or POST will be converted to a PHP array.
|
||||
*/
|
||||
final class xajaxArgumentManager
|
||||
{
|
||||
/*
|
||||
Array: aArgs
|
||||
|
||||
An array of arguments received via the GET or POST parameter
|
||||
xjxargs.
|
||||
*/
|
||||
private $aArgs;
|
||||
|
||||
/*
|
||||
Boolean: bDecodeUTF8Input
|
||||
|
||||
A configuration option used to indicate whether input data should be
|
||||
UTF8 decoded automatically.
|
||||
*/
|
||||
private $bDecodeUTF8Input;
|
||||
|
||||
/*
|
||||
String: sCharacterEncoding
|
||||
|
||||
The character encoding in which the input data will be received.
|
||||
*/
|
||||
private $sCharacterEncoding;
|
||||
|
||||
/*
|
||||
Integer: nMethod
|
||||
|
||||
Stores the method that was used to send the arguments from the client. Will
|
||||
be one of: XAJAX_METHOD_UNKNOWN, XAJAX_METHOD_GET, XAJAX_METHOD_POST
|
||||
*/
|
||||
private $nMethod;
|
||||
|
||||
/*
|
||||
Array: aSequence
|
||||
|
||||
Stores the decoding sequence table.
|
||||
*/
|
||||
private $aSequence;
|
||||
|
||||
/*
|
||||
Function: __convertStringToBool
|
||||
|
||||
Converts a string to a bool var.
|
||||
|
||||
Parameters:
|
||||
$sValue - (string):
|
||||
|
||||
Returns:
|
||||
(bool) : true / false
|
||||
|
||||
*/
|
||||
|
||||
private function __convertStringToBool($sValue)
|
||||
{
|
||||
if (0 == strcasecmp($sValue, 'true'))
|
||||
return true;
|
||||
if (0 == strcasecmp($sValue, 'false'))
|
||||
return false;
|
||||
if (is_numeric($sValue))
|
||||
{
|
||||
if (0 == $sValue)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function __argumentStripSlashes($sArg)
|
||||
{
|
||||
if (false == is_string($sArg))
|
||||
return;
|
||||
|
||||
$sArg = stripslashes($sArg);
|
||||
}
|
||||
|
||||
private function __convertValue($value)
|
||||
{
|
||||
$cType = substr($value, 0, 1);
|
||||
$sValue = substr($value, 1);
|
||||
switch ($cType) {
|
||||
case 'S': $value = false === $sValue ? '' : $sValue; break;
|
||||
case 'B': $value = $this->__convertStringToBool($sValue); break;
|
||||
case 'N': $value = $sValue == floor($sValue) ? (int)$sValue : (float)$sValue; break;
|
||||
case '*': $value = null; break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function __decodeXML($xml)
|
||||
{
|
||||
$return = array();
|
||||
$nodes = $xml->e;
|
||||
foreach ($nodes as $node) {
|
||||
$key = (string) $node->k;
|
||||
if (isset($node->v->xjxobj)) {
|
||||
$value = $this->__decodeXML($node->v->xjxobj);
|
||||
} else {
|
||||
$value = $this->__convertValue( (string) $node->v );
|
||||
}
|
||||
$return[$key] = $value;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
private function __argumentDecode( &$sArg )
|
||||
{
|
||||
|
||||
if ('' == $sArg ) return;
|
||||
|
||||
$data = json_decode( $sArg , true );
|
||||
if ( null !== $data ) {
|
||||
$sArg = $data;
|
||||
} else {
|
||||
$sArg = $this->__convertValue( $sArg );
|
||||
}
|
||||
}
|
||||
|
||||
private function __argumentDecodeUTF8_iconv( &$mArg )
|
||||
{
|
||||
|
||||
|
||||
if ( is_array( $mArg ) )
|
||||
{
|
||||
foreach ( array_keys( $mArg ) as $sKey )
|
||||
{
|
||||
$sNewKey = $sKey;
|
||||
$this->__argumentDecodeUTF8_iconv($sNewKey);
|
||||
|
||||
if ($sNewKey != $sKey)
|
||||
{
|
||||
$mArg[$sNewKey] = $mArg[$sKey];
|
||||
unset($mArg[$sKey]);
|
||||
$sKey = $sNewKey;
|
||||
}
|
||||
|
||||
$this->__argumentDecodeUTF8_iconv($mArg[$sKey]);
|
||||
}
|
||||
}
|
||||
else if (is_string($mArg))
|
||||
$mArg = iconv("UTF-8", $this->sCharacterEncoding.'//TRANSLIT', $mArg);
|
||||
}
|
||||
|
||||
private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg)
|
||||
{
|
||||
if (is_array($mArg))
|
||||
{
|
||||
foreach (array_keys($mArg) as $sKey)
|
||||
{
|
||||
$sNewKey = $sKey;
|
||||
$this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey);
|
||||
|
||||
if ($sNewKey != $sKey)
|
||||
{
|
||||
$mArg[$sNewKey] = $mArg[$sKey];
|
||||
unset($mArg[$sKey]);
|
||||
$sKey = $sNewKey;
|
||||
}
|
||||
|
||||
$this->__argumentDecodeUTF8_mb_convert_encoding($mArg[$sKey]);
|
||||
}
|
||||
}
|
||||
else if (is_string($mArg))
|
||||
$mArg = mb_convert_encoding($mArg, $this->sCharacterEncoding, "UTF-8");
|
||||
}
|
||||
|
||||
private function __argumentDecodeUTF8_utf8_decode(&$mArg)
|
||||
{
|
||||
if (is_array($mArg))
|
||||
{
|
||||
foreach (array_keys($mArg) as $sKey)
|
||||
{
|
||||
$sNewKey = $sKey;
|
||||
$this->__argumentDecodeUTF8_utf8_decode($sNewKey);
|
||||
|
||||
if ($sNewKey != $sKey)
|
||||
{
|
||||
$mArg[$sNewKey] = $mArg[$sKey];
|
||||
unset($mArg[$sKey]);
|
||||
$sKey = $sNewKey;
|
||||
}
|
||||
|
||||
$this->__argumentDecodeUTF8_utf8_decode($mArg[$sKey]);
|
||||
}
|
||||
}
|
||||
else if (is_string($mArg))
|
||||
$mArg = utf8_decode($mArg);
|
||||
}
|
||||
|
||||
/*
|
||||
Constructor: xajaxArgumentManager
|
||||
|
||||
Initializes configuration settings to their default values and reads
|
||||
the argument data from the GET or POST data.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->aArgs = array();
|
||||
$this->bDecodeUTF8Input = false;
|
||||
$this->sCharacterEncoding = 'UTF-8';
|
||||
$this->nMethod = XAJAX_METHOD_UNKNOWN;
|
||||
|
||||
if (isset($_POST['xjxargs'])) {
|
||||
$this->nMethod = XAJAX_METHOD_POST;
|
||||
$this->aArgs = $_POST['xjxargs'];
|
||||
} else if (isset($_GET['xjxargs'])) {
|
||||
$this->nMethod = XAJAX_METHOD_GET;
|
||||
$this->aArgs = $_GET['xjxargs'];
|
||||
}
|
||||
if (1 == get_magic_quotes_gpc())
|
||||
array_walk($this->aArgs, array(&$this, '__argumentStripSlashes'));
|
||||
|
||||
array_walk($this->aArgs, array(&$this, '__argumentDecode'));
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getInstance
|
||||
|
||||
Returns:
|
||||
|
||||
object - A reference to an instance of this class. This function is
|
||||
used to implement the singleton pattern.
|
||||
*/
|
||||
public static function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new xajaxArgumentManager();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Accepts configuration settings from the main <xajax> object.
|
||||
|
||||
Parameters:
|
||||
|
||||
|
||||
The <xajaxArgumentManager> tracks the following configuration settings:
|
||||
|
||||
<decodeUTF8Input> - (boolean): See <xajaxArgumentManager->bDecodeUTF8Input>
|
||||
<characterEncoding> - (string): See <xajaxArgumentManager->sCharacterEncoding>
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
if ('decodeUTF8Input' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bDecodeUTF8Input = $mValue;
|
||||
} else if ('characterEncoding' == $sName) {
|
||||
$this->sCharacterEncoding = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getRequestMethod
|
||||
|
||||
Returns the method that was used to send the arguments from the client.
|
||||
*/
|
||||
public function getRequestMethod()
|
||||
{
|
||||
return $this->nMethod;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: process
|
||||
|
||||
Returns the array of arguments that were extracted and parsed from
|
||||
the GET or POST data.
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
if ($this->bDecodeUTF8Input)
|
||||
{
|
||||
|
||||
$sFunction = '';
|
||||
|
||||
if (function_exists('iconv'))
|
||||
$sFunction = "iconv";
|
||||
else if (function_exists('mb_convert_encoding'))
|
||||
$sFunction = "mb_convert_encoding";
|
||||
else if ($this->sCharacterEncoding == "ISO-8859-1")
|
||||
$sFunction = "utf8_decode";
|
||||
else {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('ARGMGR:ERR:03')
|
||||
, E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
|
||||
$mFunction = array(&$this, '__argumentDecodeUTF8_' . $sFunction);
|
||||
|
||||
array_walk($this->aArgs, $mFunction);
|
||||
$this->bDecodeUTF8Input = false;
|
||||
}
|
||||
|
||||
return $this->aArgs;
|
||||
}
|
||||
}
|
||||
148
resources/xajax/xajax_core/xajaxCompress.inc.php
Normal file
148
resources/xajax/xajax_core/xajaxCompress.inc.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Function: xajaxCompressFile
|
||||
|
||||
<xajax> will call this function internally to compress the javascript code for
|
||||
more efficient delivery.
|
||||
|
||||
Parameters:
|
||||
|
||||
$sFile - (stirng): The file to be compressed.
|
||||
*/
|
||||
function xajaxCompressFile($sFile)
|
||||
{
|
||||
//remove windows cariage returns
|
||||
$sFile = str_replace("\r",'',$sFile);
|
||||
|
||||
//array to store replaced literal strings
|
||||
$literal_strings = array();
|
||||
|
||||
//explode the string into lines
|
||||
$lines = explode("\n",$sFile);
|
||||
//loop through all the lines, building a new string at the same time as removing literal strings
|
||||
$clean = '';
|
||||
$inComment = false;
|
||||
$literal = '';
|
||||
$inQuote = false;
|
||||
$escaped = false;
|
||||
$quoteChar = '';
|
||||
|
||||
$iLen = count($lines);
|
||||
for($i=0; $i<$iLen; ++$i)
|
||||
{
|
||||
$line = $lines[$i];
|
||||
$inNormalComment = false;
|
||||
|
||||
//loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
|
||||
$jLen = strlen($line);
|
||||
for($j=0; $j<$jLen; ++$j)
|
||||
{
|
||||
$c = substr($line,$j,1);
|
||||
$d = substr($line,$j,2);
|
||||
|
||||
//look for start of quote
|
||||
if(!$inQuote && !$inComment)
|
||||
{
|
||||
//is this character a quote or a comment
|
||||
if(($c=='"' || $c=="'") && !$inComment && !$inNormalComment)
|
||||
{
|
||||
$inQuote = true;
|
||||
$inComment = false;
|
||||
$escaped = false;
|
||||
$quoteChar = $c;
|
||||
$literal = $c;
|
||||
}
|
||||
else if($d=="/*" && !$inNormalComment)
|
||||
{
|
||||
$inQuote = false;
|
||||
$inComment = true;
|
||||
$escaped = false;
|
||||
$quoteChar = $d;
|
||||
$literal = $d;
|
||||
$j++;
|
||||
}
|
||||
else if($d=="//") //ignore string markers that are found inside comments
|
||||
{
|
||||
$inNormalComment = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$inNormalComment)
|
||||
$clean .= $c;
|
||||
}
|
||||
}
|
||||
else //allready in a string so find end quote
|
||||
{
|
||||
if($c == $quoteChar && !$escaped && !$inComment)
|
||||
{
|
||||
$inQuote = false;
|
||||
$literal .= $c;
|
||||
|
||||
//subsitute in a marker for the string
|
||||
$clean .= "___" . count($literal_strings) . "___";
|
||||
|
||||
//push the string onto our array
|
||||
array_push($literal_strings,$literal);
|
||||
|
||||
}
|
||||
else if($inComment && $d=="*/")
|
||||
{
|
||||
$inComment = false;
|
||||
$literal .= $d;
|
||||
++$j;
|
||||
}
|
||||
else if($c == "\\" && !$escaped)
|
||||
$escaped = true;
|
||||
else
|
||||
$escaped = false;
|
||||
|
||||
$literal .= $c;
|
||||
}
|
||||
}
|
||||
if($inComment) $literal .= "\n";
|
||||
$clean .= "\n";
|
||||
}
|
||||
//explode the clean string into lines again
|
||||
$lines = explode("\n",$clean);
|
||||
|
||||
//now process each line at a time
|
||||
$iLen = count($lines);
|
||||
for($i=0; $i<$iLen; ++$i)
|
||||
{
|
||||
$line = $lines[$i];
|
||||
|
||||
//remove comments
|
||||
$line = preg_replace("/\/\/(.*)/","",$line);
|
||||
|
||||
//strip leading and trailing whitespace
|
||||
$line = trim($line);
|
||||
|
||||
//remove all whitespace with a single space
|
||||
$line = preg_replace("/\s+/"," ",$line);
|
||||
|
||||
//remove any whitespace that occurs after/before an operator
|
||||
$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
|
||||
|
||||
$lines[$i] = $line;
|
||||
}
|
||||
|
||||
//implode the lines
|
||||
$sFile = implode("\n",$lines);
|
||||
|
||||
//make sure there is a max of 1 \n after each line
|
||||
$sFile = preg_replace("/[\n]+/","\n",$sFile);
|
||||
|
||||
//strip out line breaks that immediately follow a semi-colon
|
||||
$sFile = preg_replace("/;\n/",";",$sFile);
|
||||
|
||||
//curly brackets aren't on their own
|
||||
$sFile = preg_replace("/[\n]*\{[\n]*/","{",$sFile);
|
||||
|
||||
//finally loop through and replace all the literal strings:
|
||||
$iLen = count($literal_strings);
|
||||
for($i=0; $i<$iLen; ++$i)
|
||||
$sFile = str_replace('___'.$i.'___',$literal_strings[$i],$sFile);
|
||||
|
||||
return $sFile;
|
||||
}
|
||||
795
resources/xajax/xajax_core/xajaxControl.inc.php
Normal file
795
resources/xajax/xajax_core/xajaxControl.inc.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxControl.inc.php
|
||||
|
||||
Contains the base class for all controls.
|
||||
|
||||
Title: xajaxControl class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxControl.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
require_once('xajaxRequest.inc.php');
|
||||
|
||||
/*
|
||||
Constant: XAJAX_HTML_CONTROL_DOCTYPE_FORMAT
|
||||
|
||||
Defines the doctype of the current document; this will effect how the HTML is formatted
|
||||
when the html control library is used to construct html documents and fragments. This can
|
||||
be one of the following values:
|
||||
|
||||
'XHTML' - (default) Typical effects are that certain elements are closed with '/>'
|
||||
'HTML' - Typical differences are that closing tags for certain elements cannot be '/>'
|
||||
*/
|
||||
if (false == defined('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT')) define('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT', 'XHTML');
|
||||
|
||||
/*
|
||||
Constant: XAJAX_HTML_CONTROL_DOCTYPE_VERSION
|
||||
*/
|
||||
if (false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VERSION')) define('XAJAX_HTML_CONTROL_DOCTYPE_VERSION', '1.0');
|
||||
|
||||
/*
|
||||
Constant: XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION
|
||||
*/
|
||||
if (false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION')) define('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION', 'TRANSITIONAL');
|
||||
|
||||
|
||||
define('XAJAX_DOMRESPONSE_APPENDCHILD', 100);
|
||||
define('XAJAX_DOMRESPONSE_INSERTBEFORE', 101);
|
||||
define('XAJAX_DOMRESPONSE_INSERTAFTER', 102);
|
||||
/*
|
||||
Class: xajaxControl
|
||||
|
||||
The base class for all xajax enabled controls. Derived classes will generate the
|
||||
HTML and javascript code that will be sent to the browser via <xajaxControl->printHTML>
|
||||
or sent to the browser in a <xajaxResponse> via <xajaxControl->getHTML>.
|
||||
*/
|
||||
class xajaxControl
|
||||
{
|
||||
/*
|
||||
String: sTag
|
||||
*/
|
||||
protected $sTag;
|
||||
|
||||
/*
|
||||
Boolean: sEndTag
|
||||
|
||||
'required' - (default) Indicates the control must have a full end tag
|
||||
'optional' - The control may have an abbr. begin tag or a full end tag
|
||||
'forbidden' - The control must have an abbr. begin tag and no end tag
|
||||
*/
|
||||
protected $sEndTag;
|
||||
|
||||
/*
|
||||
Array: aAttributes
|
||||
|
||||
An associative array of attributes that will be used in the generation
|
||||
of the HMTL code for this control.
|
||||
*/
|
||||
protected $aAttributes;
|
||||
|
||||
/*
|
||||
Array: aEvents
|
||||
|
||||
An associative array of events that will be assigned to this control. Each
|
||||
event declaration will include a reference to a <xajaxRequest> object; it's
|
||||
script will be extracted using <xajaxRequest->printScript> or
|
||||
<xajaxRequest->getScript>.
|
||||
*/
|
||||
protected $aEvents;
|
||||
|
||||
/*
|
||||
String: sClass
|
||||
|
||||
Contains a declaration of the class of this control. %inline controls do not
|
||||
need to be indented, %block controls should be indented.
|
||||
*/
|
||||
protected $sClass;
|
||||
|
||||
/*
|
||||
Function: xajaxControl
|
||||
|
||||
Parameters:
|
||||
|
||||
$aConfiguration - (array): An associative array that contains a variety
|
||||
of configuration options for this <xajaxControl> object.
|
||||
|
||||
Note:
|
||||
This array may contain the following entries:
|
||||
|
||||
'attributes' - (array): An associative array containing attributes
|
||||
that will be passed to the <xajaxControl->setAttribute> function.
|
||||
|
||||
'children' - (array): An array of <xajaxControl> derived objects that
|
||||
will be the children of this control.
|
||||
*/
|
||||
protected function __construct($sTag, $aConfiguration=array())
|
||||
{
|
||||
$this->sTag = $sTag;
|
||||
|
||||
$this->clearAttributes();
|
||||
|
||||
if (isset($aConfiguration['attributes']))
|
||||
if (is_array($aConfiguration['attributes']))
|
||||
foreach ($aConfiguration['attributes'] as $sKey => $sValue)
|
||||
$this->setAttribute($sKey, $sValue);
|
||||
|
||||
$this->clearEvents();
|
||||
|
||||
if (isset($aConfiguration['event']))
|
||||
call_user_func_array(
|
||||
array($this, 'setEvent'),
|
||||
$aConfiguration['event']
|
||||
);
|
||||
|
||||
else if (isset($aConfiguration['events']))
|
||||
if (is_array($aConfiguration['events']))
|
||||
foreach ($aConfiguration['events'] as $aEvent)
|
||||
call_user_func_array(
|
||||
array($this, 'setEvent'),
|
||||
$aEvent
|
||||
);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'forbidden';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getClass
|
||||
|
||||
Returns the *adjusted* class of the element
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->sClass;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearAttributes
|
||||
|
||||
Removes all attributes assigned to this control.
|
||||
*/
|
||||
public function clearAttributes()
|
||||
{
|
||||
$this->aAttributes = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setAttribute
|
||||
|
||||
Call to set various control specific attributes to be included in the HTML
|
||||
script that is returned when <xajaxControl->printHTML> or <xajaxControl->getHTML>
|
||||
is called.
|
||||
|
||||
Parameters:
|
||||
$sName - (string): The attribute name to set the value.
|
||||
$sValue - (string): The value to be set.
|
||||
*/
|
||||
public function setAttribute($sName, $sValue)
|
||||
{
|
||||
//SkipDebug
|
||||
if (class_exists('clsValidator'))
|
||||
{
|
||||
$objValidator = clsValidator::getInstance();
|
||||
if (false == $objValidator->attributeValid($this->sTag, $sName)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:IAERR:01')
|
||||
. $sName
|
||||
. $objLanguageManager->getText('XJXCTL:IAERR:02')
|
||||
. $this->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:IAERR:03')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
$this->aAttributes[$sName] = $sValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getAttribute
|
||||
|
||||
Call to obtain the value currently associated with the specified attribute
|
||||
if set.
|
||||
|
||||
Parameters:
|
||||
|
||||
sName - (string): The name of the attribute to be returned.
|
||||
|
||||
Returns:
|
||||
|
||||
mixed : The value associated with the attribute, or null.
|
||||
*/
|
||||
public function getAttribute($sName)
|
||||
{
|
||||
if (false == isset($this->aAttributes[$sName]))
|
||||
return null;
|
||||
|
||||
return $this->aAttributes[$sName];
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearEvents
|
||||
|
||||
Clear the events that have been associated with this object.
|
||||
*/
|
||||
public function clearEvents()
|
||||
{
|
||||
$this->aEvents = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setEvent
|
||||
|
||||
Call this function to assign a <xajaxRequest> object as the handler for
|
||||
the specific DOM event. The <xajaxRequest->printScript> function will
|
||||
be called to generate the javascript for this request.
|
||||
|
||||
Parameters:
|
||||
|
||||
sEvent - (string): A string containing the name of the event to be assigned.
|
||||
objRequest - (xajaxRequest object): The <xajaxRequest> object to be associated
|
||||
with the specified event.
|
||||
aParameters - (array, optional): An array containing parameter declarations
|
||||
that will be passed to this <xajaxRequest> object just before the javascript
|
||||
is generated.
|
||||
sBeforeRequest - (string, optional): a string containing a snippet of javascript code
|
||||
to execute prior to calling the xajaxRequest function
|
||||
sAfterRequest - (string, optional): a string containing a snippet of javascript code
|
||||
to execute after calling the xajaxRequest function
|
||||
*/
|
||||
public function setEvent($sEvent, $objRequest, $aParameters=array(), $sBeforeRequest='', $sAfterRequest='; return false;')
|
||||
{
|
||||
//SkipDebug
|
||||
if (false == ($objRequest instanceof xajaxRequest)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:IRERR:01')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
if (class_exists('clsValidator')) {
|
||||
$objValidator = clsValidator::getInstance();
|
||||
if (false == $objValidator->attributeValid($this->sTag, $sEvent)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:IEERR:01')
|
||||
. $sEvent
|
||||
. $objLanguageManager->getText('XJXCTL:IEERR:02')
|
||||
. $this->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:IEERR:03')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
$objRequest = clone($objRequest);
|
||||
|
||||
$this->aEvents[$sEvent] = array(
|
||||
$objRequest,
|
||||
$aParameters,
|
||||
$sBeforeRequest,
|
||||
$sAfterRequest
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getHTML
|
||||
|
||||
Generates and returns the HTML representation of this control and
|
||||
it's children.
|
||||
|
||||
Returns:
|
||||
|
||||
string : The HTML representation of this control.
|
||||
*/
|
||||
public function getHTML($bFormat=false)
|
||||
{
|
||||
ob_start();
|
||||
if ($bFormat)
|
||||
$this->printHTML();
|
||||
else
|
||||
$this->printHTML(false);
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printHTML
|
||||
|
||||
Generates and prints the HTML representation of this control and
|
||||
it's children.
|
||||
|
||||
Returns:
|
||||
|
||||
string : The HTML representation of this control.
|
||||
*/
|
||||
public function printHTML($sIndent='')
|
||||
{
|
||||
//SkipDebug
|
||||
if (class_exists('clsValidator'))
|
||||
{
|
||||
$objValidator = clsValidator::getInstance();
|
||||
$sMissing = '';
|
||||
if (false == $objValidator->checkRequiredAttributes($this->sTag, $this->aAttributes, $sMissing)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:MAERR:01')
|
||||
. $sMissing
|
||||
. $objLanguageManager->getText('XJXCTL:MAERR:02')
|
||||
. $this->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:MAERR:03')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
$sClass = $this->getClass();
|
||||
|
||||
if ('%inline' != $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo $sIndent;
|
||||
|
||||
echo '<';
|
||||
echo $this->sTag;
|
||||
echo ' ';
|
||||
$this->_printAttributes();
|
||||
$this->_printEvents();
|
||||
|
||||
if ('forbidden' == $this->sEndTag)
|
||||
{
|
||||
if ('HTML' == XAJAX_HTML_CONTROL_DOCTYPE_FORMAT)
|
||||
echo '>';
|
||||
else if ('XHTML' == XAJAX_HTML_CONTROL_DOCTYPE_FORMAT)
|
||||
echo '/>';
|
||||
|
||||
if ('%inline' != $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo "\n";
|
||||
|
||||
return;
|
||||
}
|
||||
else if ('optional' == $this->sEndTag)
|
||||
{
|
||||
echo '/>';
|
||||
|
||||
if ('%inline' == $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo "\n";
|
||||
|
||||
return;
|
||||
}
|
||||
//SkipDebug
|
||||
else
|
||||
{
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:IETERR:01')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
public function getResponse($count, $parent, $flag=XAJAX_DOMRESPONSE_APPENDCHILD)
|
||||
{
|
||||
$variable = "xjxElm[{$count}]";
|
||||
|
||||
$response = $this->beginGetResponse($variable, $count);
|
||||
$this->getResponseAttributes($response, $variable);
|
||||
$this->getResponseEvents($response, $variable);
|
||||
$this->endGetResponse($response, $variable, $count, $parent, $flag);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function beginGetResponse($variable, $count)
|
||||
{
|
||||
$response = new xajaxResponse();
|
||||
|
||||
if ($count == 0)
|
||||
$response->domStartResponse();
|
||||
|
||||
$response->domCreateElement($variable, $this->sTag);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getResponseAttributes($response, $variable)
|
||||
{
|
||||
foreach ($this->aAttributes as $sKey => $sValue)
|
||||
if ('disabled' != $sKey || 'false' != $sValue)
|
||||
$response->domSetAttribute($variable, $sKey, $sValue);
|
||||
}
|
||||
|
||||
protected function endGetResponse($response, $variable, $count, $parent, $flag)
|
||||
{
|
||||
if ($flag == XAJAX_DOMRESPONSE_APPENDCHILD)
|
||||
$response->domAppendChild($parent, $variable);
|
||||
else if ($flag == XAJAX_DOMRESPONSE_INSERTBEFORE)
|
||||
$response->domInsertBefore($parent, $variable);
|
||||
else if ($flag == XAJAX_DOMRESPONSE_INSERTAFTER)
|
||||
$response->domInsertAfter($parent, $variable);
|
||||
|
||||
if ($count == 0)
|
||||
$response->domEndResponse();
|
||||
}
|
||||
|
||||
protected function getResponseEvents($response, $variable)
|
||||
{
|
||||
foreach (array_keys($this->aEvents) as $sKey)
|
||||
{
|
||||
$aEvent = $this->aEvents[$sKey];
|
||||
$objRequest = $aEvent[0];
|
||||
$aParameters = $aEvent[1];
|
||||
$sBeforeRequest = $aEvent[2];
|
||||
$sAfterRequest = $aEvent[3];
|
||||
|
||||
foreach ($aParameters as $aParameter)
|
||||
{
|
||||
$nParameter = $aParameter[0];
|
||||
$sType = $aParameter[1];
|
||||
$sValue = $aParameter[2];
|
||||
$objRequest->setParameter($nParameter, $sType, $sValue);
|
||||
}
|
||||
|
||||
$objRequest->useDoubleQuote();
|
||||
|
||||
$response->script(
|
||||
"{$variable}.{$sKey} = function(evt) { " .
|
||||
"if (!evt) var evt = window.event; " .
|
||||
$sBeforeRequest .
|
||||
$objRequest->getScript() .
|
||||
$sAfterRequest .
|
||||
" } "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _printAttributes()
|
||||
{
|
||||
// NOTE: Special case here: disabled='false' does not work in HTML; does work in javascript
|
||||
foreach ($this->aAttributes as $sKey => $sValue)
|
||||
if ('disabled' != $sKey || 'false' != $sValue)
|
||||
echo "{$sKey}='{$sValue}' ";
|
||||
}
|
||||
|
||||
protected function _printEvents()
|
||||
{
|
||||
foreach (array_keys($this->aEvents) as $sKey)
|
||||
{
|
||||
$aEvent = $this->aEvents[$sKey];
|
||||
$objRequest = $aEvent[0];
|
||||
$aParameters = $aEvent[1];
|
||||
$sBeforeRequest = $aEvent[2];
|
||||
$sAfterRequest = $aEvent[3];
|
||||
|
||||
foreach ($aParameters as $aParameter)
|
||||
{
|
||||
$nParameter = $aParameter[0];
|
||||
$sType = $aParameter[1];
|
||||
$sValue = $aParameter[2];
|
||||
$objRequest->setParameter($nParameter, $sType, $sValue);
|
||||
}
|
||||
|
||||
$objRequest->useDoubleQuote();
|
||||
|
||||
echo "{$sKey}='{$sBeforeRequest}";
|
||||
|
||||
$objRequest->printScript();
|
||||
|
||||
echo "{$sAfterRequest}' ";
|
||||
}
|
||||
}
|
||||
|
||||
public function backtrace()
|
||||
{
|
||||
// debug_backtrace was added to php in version 4.3.0
|
||||
// version_compare was added to php in version 4.0.7
|
||||
if (0 <= version_compare(PHP_VERSION, '4.3.0'))
|
||||
return '<div><div>Backtrace:</div><pre>'
|
||||
. print_r(debug_backtrace(), true)
|
||||
. '</pre></div>';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: xajaxControlContainer
|
||||
|
||||
This class is used as the base class for controls that will contain
|
||||
other child controls.
|
||||
*/
|
||||
class xajaxControlContainer extends xajaxControl
|
||||
{
|
||||
/*
|
||||
Array: aChildren
|
||||
|
||||
An array of child controls.
|
||||
*/
|
||||
protected $aChildren;
|
||||
|
||||
/*
|
||||
Boolean: sChildClass
|
||||
|
||||
Will contain '%inline' if all children are class = '%inline', '%block' if all children are '%block' or
|
||||
'%flow' if both '%inline' and '%block' elements are detected.
|
||||
*/
|
||||
protected $sChildClass;
|
||||
|
||||
/*
|
||||
Function: xajaxControlContainer
|
||||
|
||||
Called to construct and configure this control.
|
||||
|
||||
Parameters:
|
||||
|
||||
aConfiguration - (array): See <xajaxControl->xajaxControl> for more
|
||||
information.
|
||||
*/
|
||||
protected function __construct($sTag, $aConfiguration=array())
|
||||
{
|
||||
parent::__construct($sTag, $aConfiguration);
|
||||
|
||||
$this->clearChildren();
|
||||
|
||||
if (isset($aConfiguration['child']))
|
||||
$this->addChild($aConfiguration['child']);
|
||||
|
||||
else if (isset($aConfiguration['children']))
|
||||
$this->addChildren($aConfiguration['children']);
|
||||
|
||||
$this->sEndTag = 'required';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getClass
|
||||
|
||||
Returns the *adjusted* class of the element
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
$sClass = xajaxControl::getClass();
|
||||
|
||||
if (0 < count($this->aChildren) && '%flow' == $sClass)
|
||||
return $this->getContentClass();
|
||||
else if (0 == count($this->aChildren) || '%inline' == $sClass || '%block' == $sClass)
|
||||
return $sClass;
|
||||
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:ICERR:01')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getContentClass
|
||||
|
||||
Returns the *adjusted* class of the content (children) of this element
|
||||
*/
|
||||
public function getContentClass()
|
||||
{
|
||||
$sClass = '';
|
||||
|
||||
foreach (array_keys($this->aChildren) as $sKey)
|
||||
{
|
||||
if ('' == $sClass)
|
||||
$sClass = $this->aChildren[$sKey]->getClass();
|
||||
else if ($sClass != $this->aChildren[$sKey]->getClass())
|
||||
return '%flow';
|
||||
}
|
||||
|
||||
if ('' == $sClass)
|
||||
return '%inline';
|
||||
|
||||
return $sClass;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearChildren
|
||||
|
||||
Clears the list of child controls associated with this control.
|
||||
*/
|
||||
public function clearChildren()
|
||||
{
|
||||
$this->sChildClass = '%inline';
|
||||
$this->aChildren = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addChild
|
||||
|
||||
Adds a control to the array of child controls. Child controls
|
||||
must be derived from <xajaxControl>.
|
||||
*/
|
||||
public function addChild($objControl)
|
||||
{
|
||||
//SkipDebug
|
||||
if (false == ($objControl instanceof xajaxControl )) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:ICLERR:01')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
if (class_exists('clsValidator'))
|
||||
{
|
||||
$objValidator = clsValidator::getInstance();
|
||||
if (false == $objValidator->childValid($this->sTag, $objControl->sTag)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:ICLERR:02')
|
||||
. $objControl->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:ICLERR:03')
|
||||
. $this->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:ICLERR:04')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
$this->aChildren[] = $objControl;
|
||||
}
|
||||
|
||||
public function addChildren($aChildren)
|
||||
{
|
||||
//SkipDebug
|
||||
if (false == is_array($aChildren)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:ICHERR:01')
|
||||
. $this->backtrace()
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
foreach (array_keys($aChildren) as $sKey)
|
||||
$this->addChild($aChildren[$sKey]);
|
||||
}
|
||||
|
||||
public function printHTML($sIndent='')
|
||||
{
|
||||
//SkipDebug
|
||||
if (class_exists('clsValidator'))
|
||||
{
|
||||
$objValidator = clsValidator::getInstance();
|
||||
$sMissing = '';
|
||||
if (false == $objValidator->checkRequiredAttributes($this->sTag, $this->aAttributes, $sMissing)) {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXCTL:MRAERR:01')
|
||||
. $sMissing
|
||||
. $objLanguageManager->getText('XJXCTL:MRAERR:02')
|
||||
. $this->sTag
|
||||
. $objLanguageManager->getText('XJXCTL:MRAERR:03')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
//EndSkipDebug
|
||||
|
||||
$sClass = $this->getClass();
|
||||
|
||||
if ('%inline' != $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo $sIndent;
|
||||
|
||||
echo '<';
|
||||
echo $this->sTag;
|
||||
echo ' ';
|
||||
$this->_printAttributes();
|
||||
$this->_printEvents();
|
||||
|
||||
if (0 == count($this->aChildren))
|
||||
{
|
||||
if ('optional' == $this->sEndTag)
|
||||
{
|
||||
echo '/>';
|
||||
|
||||
if ('%inline' != $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo "\n";
|
||||
|
||||
return;
|
||||
}
|
||||
//SkipDebug
|
||||
else if ('required' != $this->sEndTag)
|
||||
trigger_error("Invalid end tag designation; should be optional or required.\n"
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
echo '>';
|
||||
|
||||
$sContentClass = $this->getContentClass();
|
||||
|
||||
if ('%inline' != $sContentClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo "\n";
|
||||
|
||||
$this->_printChildren($sIndent);
|
||||
|
||||
if ('%inline' != $sContentClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo $sIndent;
|
||||
|
||||
echo '<' . '/';
|
||||
echo $this->sTag;
|
||||
echo '>';
|
||||
|
||||
if ('%inline' != $sClass)
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
protected function _printChildren($sIndent='')
|
||||
{
|
||||
if (false == ($this instanceof clsDocument ))
|
||||
// this odd syntax is necessary to detect request for no formatting
|
||||
if (false === (false === $sIndent))
|
||||
$sIndent .= "\t";
|
||||
|
||||
// children
|
||||
foreach (array_keys($this->aChildren) as $sKey)
|
||||
{
|
||||
$objChild = $this->aChildren[$sKey];
|
||||
$objChild->printHTML($sIndent);
|
||||
}
|
||||
}
|
||||
|
||||
public function getResponse($count, $parent, $flag=XAJAX_DOMRESPONSE_APPENDCHILD)
|
||||
{
|
||||
$variable = "xjxElm[{$count}]";
|
||||
|
||||
$response = $this->beginGetResponse($variable, $count);
|
||||
$this->getResponseAttributes($response, $variable);
|
||||
$this->getResponseEvents($response, $variable);
|
||||
$this->getResponseChildren($response, $variable, $count);
|
||||
$this->endGetResponse($response, $variable, $count, $parent, $flag);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getResponseChildren($response, $variable, $count)
|
||||
{
|
||||
foreach (array_keys($this->aChildren) as $sKey)
|
||||
{
|
||||
$objChild = $this->aChildren[$sKey];
|
||||
$response->appendResponse(
|
||||
$objChild->getResponse($count+1, $variable)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
resources/xajax/xajax_core/xajaxLanguageManager.inc.php
Normal file
188
resources/xajax/xajax_core/xajaxLanguageManager.inc.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxLanguageManager.inc.php
|
||||
|
||||
Contains the code that manages the inclusion of alternate language support
|
||||
files; so debug and error messages can be shown in a language other than
|
||||
the default (english) language.
|
||||
|
||||
Title: xajaxLanguageManager class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxLanguageManager.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxLanguageManager
|
||||
|
||||
This class contains the default language (english) and the code used to supply
|
||||
debug and error messages upon request; as well as the code used to load alternate
|
||||
language text as requested via the <xajax::configure> function.
|
||||
*/
|
||||
final class xajaxLanguageManager
|
||||
{
|
||||
/*
|
||||
Array: aMessages
|
||||
|
||||
An array of the currently registered languages.
|
||||
*/
|
||||
private $aMessages;
|
||||
|
||||
/*
|
||||
String: sLanguage
|
||||
|
||||
The currently configured language.
|
||||
*/
|
||||
private $sLanguage;
|
||||
|
||||
/*
|
||||
Function: xajaxLanguageManager
|
||||
|
||||
Construct and initialize the one and only xajax language manager object.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->aMessages = array();
|
||||
|
||||
$this->aMessages['en'] = array(
|
||||
'LOGHDR:01' => '** xajax Error Log - ',
|
||||
'LOGHDR:02' => " **\n",
|
||||
'LOGHDR:03' => "\n\n\n",
|
||||
'LOGERR:01' => "** Logging Error **\n\nxajax was unable to write to the error log file:\n",
|
||||
'LOGMSG:01' => "** PHP Error Messages: **",
|
||||
'CMPRSJS:RDERR:01' => 'The xajax uncompressed Javascript file could not be found in the <b>',
|
||||
'CMPRSJS:RDERR:02' => '</b> folder. Error ',
|
||||
'CMPRSJS:WTERR:01' => 'The xajax compressed javascript file could not be written in the <b>',
|
||||
'CMPRSJS:WTERR:02' => '</b> folder. Error ',
|
||||
'CMPRSPHP:WTERR:01' => 'The xajax compressed file <b>',
|
||||
'CMPRSPHP:WTERR:02' => '</b> could not be written to. Error ',
|
||||
'CMPRSAIO:WTERR:01' => 'The xajax compressed file <b>',
|
||||
'CMPRSAIO:WTERR:02' => '/xajaxAIO.inc.php</b> could not be written to. Error ',
|
||||
'DTCTURI:01' => 'xajax Error: xajax failed to automatically identify your Request URI.',
|
||||
'DTCTURI:02' => 'Please set the Request URI explicitly when you instantiate the xajax object.',
|
||||
'ARGMGR:ERR:01' => 'Malformed object argument received: ',
|
||||
'ARGMGR:ERR:02' => ' <==> ',
|
||||
'ARGMGR:ERR:03' => 'The incoming xajax data could not be converted from UTF-8',
|
||||
'XJXCTL:IAERR:01' => 'Invalid attribute [',
|
||||
'XJXCTL:IAERR:02' => '] for element [',
|
||||
'XJXCTL:IAERR:03' => '].',
|
||||
'XJXCTL:IRERR:01' => 'Invalid request object passed to xajaxControl::setEvent',
|
||||
'XJXCTL:IEERR:01' => 'Invalid attribute (event name) [',
|
||||
'XJXCTL:IEERR:02' => '] for element [',
|
||||
'XJXCTL:IEERR:03' => '].',
|
||||
'XJXCTL:MAERR:01' => 'Missing required attribute [',
|
||||
'XJXCTL:MAERR:02' => '] for element [',
|
||||
'XJXCTL:MAERR:03' => '].',
|
||||
'XJXCTL:IETERR:01' => "Invalid end tag designation; should be forbidden or optional.\n",
|
||||
'XJXCTL:ICERR:01' => "Invalid class specified for html control; should be %inline, %block or %flow.\n",
|
||||
'XJXCTL:ICLERR:01' => 'Invalid control passed to addChild; should be derived from xajaxControl.',
|
||||
'XJXCTL:ICLERR:02' => 'Invalid control passed to addChild [',
|
||||
'XJXCTL:ICLERR:03' => '] for element [',
|
||||
'XJXCTL:ICLERR:04' => "].\n",
|
||||
'XJXCTL:ICHERR:01' => 'Invalid parameter passed to xajaxControl::addChildren; should be array of xajaxControl objects',
|
||||
'XJXCTL:MRAERR:01' => 'Missing required attribute [',
|
||||
'XJXCTL:MRAERR:02' => '] for element [',
|
||||
'XJXCTL:MRAERR:03' => '].',
|
||||
'XJXPLG:GNERR:01' => 'Response plugin should override the getName function.',
|
||||
'XJXPLG:PERR:01' => 'Response plugin should override the process function.',
|
||||
'XJXPM:IPLGERR:01' => 'Attempt to register invalid plugin: ',
|
||||
'XJXPM:IPLGERR:02' => ' should be derived from xajaxRequestPlugin or xajaxResponsePlugin.',
|
||||
'XJXPM:MRMERR:01' => 'Failed to locate registration method for the following: ',
|
||||
'XJXRSP:EDERR:01' => 'Passing character encoding to the xajaxResponse constructor is deprecated, instead use $xajax->configure("characterEncoding", ...);',
|
||||
'XJXRSP:MPERR:01' => 'Invalid or missing plugin name detected in call to xajaxResponse::plugin',
|
||||
'XJXRSP:CPERR:01' => "The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.",
|
||||
'XJXRSP:LCERR:01' => "The xajax response object could not load commands as the data provided was not a valid array.",
|
||||
'XJXRSP:AKERR:01' => 'Invalid tag name encoded in array.',
|
||||
'XJXRSP:IEAERR:01' => 'Improperly encoded array.',
|
||||
'XJXRSP:NEAERR:01' => 'Non-encoded array detected.',
|
||||
'XJXRSP:MBEERR:01' => 'The xajax response output could not be converted to HTML entities because the mb_convert_encoding function is not available',
|
||||
'XJXRSP:MXRTERR' => 'Error: Cannot mix types in a single response.',
|
||||
'XJXRSP:MXCTERR' => 'Error: Cannot mix content types in a single response.',
|
||||
'XJXRSP:MXCEERR' => 'Error: Cannot mix character encodings in a single response.',
|
||||
'XJXRSP:MXOEERR' => 'Error: Cannot mix output entities (true/false) in a single response.',
|
||||
'XJXRM:IRERR' => 'An invalid response was returned while processing this request.',
|
||||
'XJXRM:MXRTERR' => 'Error: You cannot mix response types while processing a single request: '
|
||||
);
|
||||
|
||||
$this->sLanguage = 'en';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getInstance
|
||||
|
||||
Implements the singleton pattern: provides a single instance of the xajax
|
||||
language manager object to all object which request it.
|
||||
*/
|
||||
public static function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new xajaxLanguageManager();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Called by the main xajax object as configuration options are set. See also:
|
||||
<xajax::configure>. The <xajaxLanguageManager> tracks the following configuration
|
||||
options.
|
||||
Parameters:
|
||||
|
||||
- language (string, default 'en'): The currently selected language.
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
if ('language' == $sName) {
|
||||
if ($mValue !== $this->sLanguage) {
|
||||
$sFolder = dirname(__FILE__);
|
||||
@include $sFolder . '/xajax_lang_' . $mValue . '.inc.php';
|
||||
// require $sFolder . '/xajax_lang_' . $mValue . '.inc.php';
|
||||
$this->sLanguage = $mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
Called to register an array of alternate language messages.
|
||||
|
||||
Parameters:
|
||||
|
||||
sLanguage - (string): the character code which represents the language being registered.
|
||||
aMessages - (array): the array of translated debug and error messages
|
||||
*/
|
||||
public function register($sLanguage, $aMessages) {
|
||||
$this->aMessages[$sLanguage] = $aMessages;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getText
|
||||
|
||||
Called by the main xajax object and other objects during the initial page generation
|
||||
or request processing phase to obtain language specific debug and error messages.
|
||||
|
||||
sMessage - (string): A code indicating the message text being requested.
|
||||
*/
|
||||
public function getText($sMessage)
|
||||
{
|
||||
if (isset($this->aMessages[$this->sLanguage]))
|
||||
if (isset($this->aMessages[$this->sLanguage][$sMessage]))
|
||||
return $this->aMessages[$this->sLanguage][$sMessage];
|
||||
|
||||
return '(Unknown language or message identifier)'
|
||||
. $this->sLanguage
|
||||
. '::'
|
||||
. $sMessage;
|
||||
}
|
||||
}
|
||||
191
resources/xajax/xajax_core/xajaxPlugin.inc.php
Normal file
191
resources/xajax/xajax_core/xajaxPlugin.inc.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxPlugin.inc.php
|
||||
|
||||
Contains the xajaxPlugin class
|
||||
|
||||
Title: xajaxPlugin class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxPlugin
|
||||
|
||||
The base class for all xajax plugins.
|
||||
*/
|
||||
class xajaxPlugin
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Class: xajaxRequestPlugin
|
||||
|
||||
The base class for all xajax request plugins.
|
||||
|
||||
Request plugins handle the registration, client script generation and processing of
|
||||
xajax enabled requests. Each plugin should have a unique signature for both
|
||||
the registration and processing of requests. During registration, the user will
|
||||
specify a type which will allow the plugin to detect and handle it. During client
|
||||
script generation, the plugin will generate a <xajax.request> stub with the
|
||||
prescribed call options and request signature. During request processing, the
|
||||
plugin will detect the signature generated previously and process the request
|
||||
accordingly.
|
||||
*/
|
||||
class xajaxRequestPlugin extends xajaxPlugin
|
||||
{
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Called by the <xajaxPluginManager> when a configuration setting is changing.
|
||||
Plugins should store a local copy of the settings they wish to use during
|
||||
registration, client script generation or request processing.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
Called by the <xajaxPluginManager> when a user script when a function, event
|
||||
or callable object is to be registered. Additional plugins may support other
|
||||
registration types.
|
||||
*/
|
||||
function register($aArgs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by <xajaxPluginManager> when the page's HTML is being sent to the browser.
|
||||
This allows each plugin to inject some script / style or other appropriate tags
|
||||
into the HEAD of the document. Each block must be appropriately enclosed, meaning
|
||||
javascript code must be enclosed in SCRIPT and /SCRIPT tags.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
|
||||
Called by the <xajaxPluginManager> when a request has been received to determine
|
||||
if the request is for a xajax enabled function or for the initial page load.
|
||||
*/
|
||||
function canProcessRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
|
||||
Called by the <xajaxPluginManager> when a request is being processed. This
|
||||
will only occur when <xajax> has determined that the current request is a valid
|
||||
(registered) xajax enabled function via <xajax->canProcessRequest>.
|
||||
|
||||
Returns:
|
||||
false
|
||||
*/
|
||||
function processRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: xajaxResponsePlugin
|
||||
|
||||
Base class for all xajax response plugins.
|
||||
|
||||
A response plugin provides additional services not already provided by the
|
||||
<xajaxResponse> class with regard to sending response commands to the
|
||||
client. In addition, a response command may send javascript to the browser
|
||||
at page load to aid in the processing of it's response commands.
|
||||
*/
|
||||
class xajaxResponsePlugin extends xajaxPlugin
|
||||
{
|
||||
/*
|
||||
Object: objResponse
|
||||
|
||||
A reference to the current <xajaxResponse> object that is being used
|
||||
to build the response that will be sent to the client browser.
|
||||
*/
|
||||
var $objResponse;
|
||||
|
||||
/*
|
||||
Function: setResponse
|
||||
|
||||
Called by the <xajaxResponse> object that is currently being used
|
||||
to build the response that will be sent to the client browser.
|
||||
|
||||
Parameters:
|
||||
|
||||
objResponse - (object): A reference to the <xajaxResponse> object
|
||||
*/
|
||||
function setResponse($objResponse)
|
||||
{
|
||||
$this->objResponse = $objResponse;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addCommand
|
||||
|
||||
Used internally to add a command to the response command list. This
|
||||
will call <xajaxResponse->addPluginCommand> using the reference provided
|
||||
in <xajaxResponsePlugin->setResponse>.
|
||||
*/
|
||||
function addCommand($aAttributes, $sData)
|
||||
{
|
||||
$this->objResponse->addPluginCommand($this, $aAttributes, $sData);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getName
|
||||
|
||||
Called by the <xajaxPluginManager> when the user script requests a plugin.
|
||||
This name must match the plugin name requested in the called to
|
||||
<xajaxResponse->plugin>.
|
||||
*/
|
||||
function getName()
|
||||
{
|
||||
//SkipDebug
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXPLG:GNERR:01')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
/*
|
||||
Function: process
|
||||
|
||||
Called by <xajaxResponse> when a user script requests the service of a
|
||||
response plugin. The parameters provided by the user will be used to
|
||||
determine which response command and parameters will be sent to the
|
||||
client upon completion of the xajax request process.
|
||||
*/
|
||||
function process()
|
||||
{
|
||||
//SkipDebug
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXPLG:PERR:01')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
}
|
||||
370
resources/xajax/xajax_core/xajaxPluginManager.inc.php
Normal file
370
resources/xajax/xajax_core/xajaxPluginManager.inc.php
Normal file
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxPluginManager.inc.php
|
||||
|
||||
Contains the xajax plugin manager.
|
||||
|
||||
Title: xajax plugin manager
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxPluginManager.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
//SkipAIO
|
||||
require(dirname(__FILE__) . '/xajaxPlugin.inc.php');
|
||||
//EndSkipAIO
|
||||
|
||||
/*
|
||||
Class: xajaxPluginManager
|
||||
*/
|
||||
final class xajaxPluginManager
|
||||
{
|
||||
/*
|
||||
Array: aRequestPlugins
|
||||
*/
|
||||
private $aRequestPlugins;
|
||||
|
||||
/*
|
||||
Array: aResponsePlugins
|
||||
*/
|
||||
private $aResponsePlugins;
|
||||
|
||||
/*
|
||||
Array: aConfigurable
|
||||
*/
|
||||
private $aConfigurable;
|
||||
|
||||
/*
|
||||
Array: aRegistrars
|
||||
*/
|
||||
private $aRegistrars;
|
||||
|
||||
/*
|
||||
Array: aProcessors
|
||||
*/
|
||||
private $aProcessors;
|
||||
|
||||
/*
|
||||
Array: aClientScriptGenerators
|
||||
*/
|
||||
private $aClientScriptGenerators;
|
||||
|
||||
/*
|
||||
Function: xajaxPluginManager
|
||||
|
||||
Construct and initialize the one and only xajax plugin manager.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->aRequestPlugins = array();
|
||||
$this->aResponsePlugins = array();
|
||||
|
||||
$this->aConfigurable = array();
|
||||
$this->aRegistrars = array();
|
||||
$this->aProcessors = array();
|
||||
$this->aClientScriptGenerators = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getInstance
|
||||
|
||||
Implementation of the singleton pattern: returns the one and only instance of the
|
||||
xajax plugin manager.
|
||||
|
||||
Returns:
|
||||
|
||||
object : a reference to the one and only instance of the
|
||||
plugin manager.
|
||||
*/
|
||||
public static function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new xajaxPluginManager();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: loadPlugins
|
||||
|
||||
Loads plugins from the folders specified.
|
||||
|
||||
Parameters:
|
||||
$aFolders - (array): Array of folders to check for plugins
|
||||
*/
|
||||
public function loadPlugins($aFolders)
|
||||
{
|
||||
foreach ($aFolders as $sFolder) {
|
||||
if (is_dir($sFolder))
|
||||
if ($handle = opendir($sFolder)) {
|
||||
while (!(false === ($sName = readdir($handle)))) {
|
||||
$nLength = strlen($sName);
|
||||
if (8 < $nLength) {
|
||||
$sFileName = substr($sName, 0, $nLength - 8);
|
||||
$sExtension = substr($sName, $nLength - 8, 8);
|
||||
if ('.inc.php' == $sExtension) {
|
||||
require $sFolder . '/' . $sFileName . $sExtension;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _insertIntoArray
|
||||
|
||||
Inserts an entry into an array given the specified priority number.
|
||||
If a plugin already exists with the given priority, the priority is
|
||||
automatically incremented until a free spot is found. The plugin
|
||||
is then inserted into the empty spot in the array.
|
||||
|
||||
Parameters:
|
||||
|
||||
$aPlugins - (array): Plugins array
|
||||
$objPlugin - (object): A reference to an instance of a plugin.
|
||||
$nPriority - (number): The desired priority, used to order
|
||||
the plugins.
|
||||
|
||||
*/
|
||||
private function _insertIntoArray(&$aPlugins, $objPlugin, $nPriority)
|
||||
{
|
||||
while (isset($aPlugins[$nPriority]))
|
||||
$nPriority++;
|
||||
|
||||
$aPlugins[$nPriority] = $objPlugin;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: registerPlugin
|
||||
|
||||
Registers a plugin.
|
||||
|
||||
Parameters:
|
||||
|
||||
objPlugin - (object): A reference to an instance of a plugin.
|
||||
|
||||
Note:
|
||||
Below is a table for priorities and their description:
|
||||
0 thru 999: Plugins that are part of or extensions to the xajax core
|
||||
1000 thru 8999: User created plugins, typically, these plugins don't care about order
|
||||
9000 thru 9999: Plugins that generally need to be last or near the end of the plugin list
|
||||
*/
|
||||
public function registerPlugin($objPlugin, $nPriority=1000)
|
||||
{
|
||||
if ($objPlugin instanceof xajaxRequestPlugin)
|
||||
{
|
||||
$this->_insertIntoArray($this->aRequestPlugins, $objPlugin, $nPriority);
|
||||
|
||||
if (method_exists($objPlugin, 'register'))
|
||||
$this->_insertIntoArray($this->aRegistrars, $objPlugin, $nPriority);
|
||||
|
||||
if (method_exists($objPlugin, 'canProcessRequest'))
|
||||
if (method_exists($objPlugin, 'processRequest'))
|
||||
$this->_insertIntoArray($this->aProcessors, $objPlugin, $nPriority);
|
||||
}
|
||||
else if ( $objPlugin instanceof xajaxResponsePlugin)
|
||||
{
|
||||
$this->aResponsePlugins[] = $objPlugin;
|
||||
}
|
||||
else
|
||||
{
|
||||
//SkipDebug
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXPM:IPLGERR:01')
|
||||
. get_class($objPlugin)
|
||||
. $objLanguageManager->getText('XJXPM:IPLGERR:02')
|
||||
, E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
if (method_exists($objPlugin, 'configure'))
|
||||
$this->_insertIntoArray($this->aConfigurable, $objPlugin, $nPriority);
|
||||
|
||||
if (method_exists($objPlugin, 'generateClientScript'))
|
||||
$this->_insertIntoArray($this->aClientScriptGenerators, $objPlugin, $nPriority);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
|
||||
Calls each of the request plugins and determines if the
|
||||
current request can be processed by one of them. If no processor identifies
|
||||
the current request, then the request must be for the initial page load.
|
||||
|
||||
See <xajax->canProcessRequest> for more information.
|
||||
*/
|
||||
public function canProcessRequest()
|
||||
{
|
||||
$bHandled = false;
|
||||
|
||||
$aKeys = array_keys($this->aProcessors);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey) {
|
||||
$mResult = $this->aProcessors[$sKey]->canProcessRequest();
|
||||
if (true === $mResult)
|
||||
$bHandled = true;
|
||||
else if (is_string($mResult))
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
return $bHandled;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
|
||||
Calls each of the request plugins to request that they process the
|
||||
current request. If the plugin processes the request, it will
|
||||
return true.
|
||||
*/
|
||||
public function processRequest()
|
||||
{
|
||||
$bHandled = false;
|
||||
|
||||
$aKeys = array_keys($this->aProcessors);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey) {
|
||||
$mResult = $this->aProcessors[$sKey]->processRequest();
|
||||
if (true === $mResult)
|
||||
$bHandled = true;
|
||||
else if (is_string($mResult))
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
return $bHandled;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Call each of the request plugins passing along the configuration
|
||||
setting specified.
|
||||
|
||||
Parameters:
|
||||
|
||||
sName - (string): The name of the configuration setting to set.
|
||||
mValue - (mixed): The value to be set.
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
$aKeys = array_keys($this->aConfigurable);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey)
|
||||
$this->aConfigurable[$sKey]->configure($sName, $mValue);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
Call each of the request plugins and give them the opportunity to
|
||||
handle the registration of the specified function, event or callable object.
|
||||
|
||||
Parameters:
|
||||
$aArgs - (array) :
|
||||
*/
|
||||
public function register($aArgs)
|
||||
{
|
||||
$aKeys = array_keys($this->aRegistrars);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey)
|
||||
{
|
||||
$objPlugin = $this->aRegistrars[$sKey];
|
||||
$mResult = $objPlugin->register($aArgs);
|
||||
if ( $mResult instanceof xajaxRequest )
|
||||
return $mResult;
|
||||
if (is_array($mResult))
|
||||
return $mResult;
|
||||
if (is_bool($mResult))
|
||||
if (true === $mResult)
|
||||
return true;
|
||||
}
|
||||
//SkipDebug
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('XJXPM:MRMERR:01')
|
||||
. print_r($aArgs, true)
|
||||
, E_USER_ERROR
|
||||
);
|
||||
//EndSkipDebug
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Call each of the request and response plugins giving them the
|
||||
opportunity to output some javascript to the page being generated. This
|
||||
is called only when the page is being loaded initially. This is not
|
||||
called when processing a request.
|
||||
*/
|
||||
public function generateClientScript()
|
||||
{
|
||||
$aKeys = array_keys($this->aClientScriptGenerators);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey)
|
||||
$this->aClientScriptGenerators[$sKey]->generateClientScript();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getResponsePlugin
|
||||
|
||||
Locate the specified response plugin by name and return
|
||||
a reference to it if one exists.
|
||||
|
||||
Parameters:
|
||||
$sName - (string): Name of the plugin.
|
||||
|
||||
Returns:
|
||||
mixed : Returns plugin or false if not found.
|
||||
*/
|
||||
public function getResponsePlugin($sName)
|
||||
{
|
||||
$aKeys = array_keys($this->aResponsePlugins);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey)
|
||||
if ( $this->aResponsePlugins[$sKey] instanceof $sName )
|
||||
return $this->aResponsePlugins[$sKey];
|
||||
$bFailure = false;
|
||||
return $bFailure;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getRequestPlugin
|
||||
|
||||
Locate the specified response plugin by name and return
|
||||
a reference to it if one exists.
|
||||
|
||||
Parameters:
|
||||
$sName - (string): Name of the plugin.
|
||||
|
||||
Returns:
|
||||
mixed : Returns plugin or false if not found.
|
||||
*/
|
||||
public function getRequestPlugin($sName)
|
||||
{
|
||||
$aKeys = array_keys($this->aRequestPlugins);
|
||||
sort($aKeys);
|
||||
foreach ($aKeys as $sKey) {
|
||||
if ( get_class($this->aRequestPlugins[$sKey]) == $sName ) {
|
||||
return $this->aRequestPlugins[$sKey];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$bFailure = false;
|
||||
return $bFailure;
|
||||
}
|
||||
}
|
||||
359
resources/xajax/xajax_core/xajaxRequest.inc.php
Normal file
359
resources/xajax/xajax_core/xajaxRequest.inc.php
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxRequest.inc.php
|
||||
|
||||
Contains the xajaxRequest class
|
||||
|
||||
Title: xajaxRequest class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxRequest.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Constant: XAJAX_FORM_VALUES
|
||||
Specifies that the parameter will consist of an array of form values.
|
||||
*/
|
||||
if (!defined ('XAJAX_FORM_VALUES')) define ('XAJAX_FORM_VALUES', 'get form values');
|
||||
/*
|
||||
Constant: XAJAX_INPUT_VALUE
|
||||
Specifies that the parameter will contain the value of an input control.
|
||||
*/
|
||||
if (!defined ('XAJAX_INPUT_VALUE')) define ('XAJAX_INPUT_VALUE', 'get input value');
|
||||
/*
|
||||
Constant: XAJAX_CHECKED_VALUE
|
||||
Specifies that the parameter will consist of a boolean value of a checkbox.
|
||||
*/
|
||||
if (!defined ('XAJAX_CHECKED_VALUE')) define ('XAJAX_CHECKED_VALUE', 'get checked value');
|
||||
/*
|
||||
Constant: XAJAX_ELEMENT_INNERHTML
|
||||
Specifies that the parameter value will be the innerHTML value of the element.
|
||||
*/
|
||||
if (!defined ('XAJAX_ELEMENT_INNERHTML')) define ('XAJAX_ELEMENT_INNERHTML', 'get element innerHTML');
|
||||
/*
|
||||
Constant: XAJAX_QUOTED_VALUE
|
||||
Specifies that the parameter will be a quoted value (string).
|
||||
*/
|
||||
if (!defined ('XAJAX_QUOTED_VALUE')) define ('XAJAX_QUOTED_VALUE', 'quoted value');
|
||||
/*
|
||||
Constant: XAJAX_JS_VALUE
|
||||
Specifies that the parameter will be a non-quoted value (evaluated by the
|
||||
browsers javascript engine at run time.
|
||||
*/
|
||||
if (!defined ('XAJAX_JS_VALUE')) define ('XAJAX_JS_VALUE', 'unquoted value');
|
||||
|
||||
/*
|
||||
Class: xajaxRequest
|
||||
|
||||
Used to store and generate the client script necessary to invoke
|
||||
a xajax request from the browser to the server script.
|
||||
|
||||
This object is typically generated by the <xajax->register> method
|
||||
and can be used to quickly generate the javascript that is used
|
||||
to initiate a xajax request to the registered function, object, event
|
||||
or other xajax call.
|
||||
*/
|
||||
class xajaxRequest
|
||||
{
|
||||
/*
|
||||
String: sName
|
||||
|
||||
The name of the function.
|
||||
*/
|
||||
private $sName;
|
||||
|
||||
/*
|
||||
String: sQuoteCharacter
|
||||
|
||||
A string containing either a single or a double quote character
|
||||
that will be used during the generation of the javascript for
|
||||
this function. This can be set prior to calling <xajaxRequest->printScript>
|
||||
*/
|
||||
private $sQuoteCharacter;
|
||||
|
||||
/*
|
||||
Array: aParameters
|
||||
|
||||
An array of parameters that will be used to populate the argument list
|
||||
for this function when the javascript is output in <xajaxRequest->printScript>
|
||||
*/
|
||||
private $aParameters;
|
||||
|
||||
/*
|
||||
Function: xajaxRequest
|
||||
|
||||
Construct and initialize this request.
|
||||
|
||||
sName - (string): The name of this request.
|
||||
*/
|
||||
public function __construct($sName)
|
||||
{
|
||||
$this->aParameters = array();
|
||||
$this->sQuoteCharacter = '"';
|
||||
$this->sName = $sName;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: useSingleQuote
|
||||
|
||||
Call this to instruct the request to use single quotes when generating
|
||||
the javascript.
|
||||
*/
|
||||
public function useSingleQuote()
|
||||
{
|
||||
$this->sQuoteCharacter = "'";
|
||||
}
|
||||
|
||||
/*
|
||||
Function: useDoubleQuote
|
||||
|
||||
Call this to instruct the request to use double quotes while generating
|
||||
the javascript.
|
||||
*/
|
||||
public function useDoubleQuote()
|
||||
{
|
||||
$this->sQuoteCharacter = '"';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearParameters
|
||||
|
||||
Clears the parameter list associated with this request.
|
||||
*/
|
||||
public function clearParameters()
|
||||
{
|
||||
$this->aParameters = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addParameter
|
||||
|
||||
Adds a parameter value to the parameter list for this request.
|
||||
|
||||
sType - (string): The type of the value to be used.
|
||||
sValue - (string: The value to be used.
|
||||
|
||||
See Also:
|
||||
See <xajaxRequest->setParameter> for details.
|
||||
*/
|
||||
public function addParameter()
|
||||
{
|
||||
$aArgs = func_get_args();
|
||||
|
||||
if (1 < count($aArgs))
|
||||
$this->setParameter(
|
||||
count($this->aParameters),
|
||||
$aArgs[0],
|
||||
$aArgs[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setParameter
|
||||
|
||||
Sets a specific parameter value.
|
||||
|
||||
Parameters:
|
||||
|
||||
nParameter - (number): The index of the parameter to set
|
||||
sType - (string): The type of value
|
||||
sValue - (string): The value as it relates to the specified type
|
||||
|
||||
Note:
|
||||
|
||||
Types should be one of the following <XAJAX_FORM_VALUES>, <XAJAX_QUOTED_VALUE>,
|
||||
<XAJAX_JS_VALUE>, <XAJAX_INPUT_VALUE>, <XAJAX_CHECKED_VALUE>.
|
||||
The value should be as follows:
|
||||
<XAJAX_FORM_VALUES> - Use the ID of the form you want to process.
|
||||
<XAJAX_QUOTED_VALUE> - The string data to be passed.
|
||||
<XAJAX_JS_VALUE> - A string containing valid javascript (either a javascript
|
||||
variable name that will be in scope at the time of the call or a
|
||||
javascript function call whose return value will become the parameter.
|
||||
|
||||
*/
|
||||
public function setParameter()
|
||||
{
|
||||
$aArgs = func_get_args();
|
||||
|
||||
if (2 < count($aArgs))
|
||||
{
|
||||
$nParameter = $aArgs[0];
|
||||
$sType = $aArgs[1];
|
||||
|
||||
if (XAJAX_FORM_VALUES == $sType)
|
||||
{
|
||||
$sFormID = $aArgs[2];
|
||||
$this->aParameters[$nParameter] =
|
||||
"xajax.getFormValues("
|
||||
. $this->sQuoteCharacter
|
||||
. $sFormID
|
||||
. $this->sQuoteCharacter
|
||||
. ")";
|
||||
}
|
||||
else if (XAJAX_INPUT_VALUE == $sType)
|
||||
{
|
||||
$sInputID = $aArgs[2];
|
||||
$this->aParameters[$nParameter] =
|
||||
"xajax.$("
|
||||
. $this->sQuoteCharacter
|
||||
. $sInputID
|
||||
. $this->sQuoteCharacter
|
||||
. ").value";
|
||||
}
|
||||
else if (XAJAX_CHECKED_VALUE == $sType)
|
||||
{
|
||||
$sCheckedID = $aArgs[2];
|
||||
$this->aParameters[$nParameter] =
|
||||
"xajax.$("
|
||||
. $this->sQuoteCharacter
|
||||
. $sCheckedID
|
||||
. $this->sQuoteCharacter
|
||||
. ").checked";
|
||||
}
|
||||
else if (XAJAX_ELEMENT_INNERHTML == $sType)
|
||||
{
|
||||
$sElementID = $aArgs[2];
|
||||
$this->aParameters[$nParameter] =
|
||||
"xajax.$("
|
||||
. $this->sQuoteCharacter
|
||||
. $sElementID
|
||||
. $this->sQuoteCharacter
|
||||
. ").innerHTML";
|
||||
}
|
||||
else if (XAJAX_QUOTED_VALUE == $sType)
|
||||
{
|
||||
$sValue = $aArgs[2];
|
||||
$this->aParameters[$nParameter] =
|
||||
$this->sQuoteCharacter
|
||||
. $sValue
|
||||
. $this->sQuoteCharacter;
|
||||
}
|
||||
else if (XAJAX_JS_VALUE == $sType)
|
||||
{
|
||||
$sValue = $aArgs[2];
|
||||
$this->aParameters[$nParameter] = $sValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getScript
|
||||
|
||||
Returns a string representation of the script output (javascript) from
|
||||
this request object. See also: <xajaxRequest::printScript>
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
ob_start();
|
||||
$this->printScript();
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printScript
|
||||
|
||||
Generates a block of javascript code that can be used to invoke
|
||||
the specified xajax request.
|
||||
*/
|
||||
public function printScript()
|
||||
{
|
||||
echo $this->sName;
|
||||
echo '(';
|
||||
|
||||
$sSeparator = '';
|
||||
|
||||
foreach ($this->aParameters as $sParameter)
|
||||
{
|
||||
echo $sSeparator;
|
||||
echo $sParameter;
|
||||
$sSeparator = ', ';
|
||||
}
|
||||
|
||||
echo ')';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: xajaxCustomRequest
|
||||
|
||||
This class extends the <xajaxRequest> class such that simple javascript
|
||||
can be put in place of a xajax request to the server. The primary purpose
|
||||
of this class is to provide simple scripting services to the <xajaxControl>
|
||||
based objects, like <clsInput>, <clsTable> and <clsButton>.
|
||||
*/
|
||||
class xajaxCustomRequest extends xajaxRequest
|
||||
{
|
||||
/*
|
||||
Array: aVariables;
|
||||
*/
|
||||
var $aVariables;
|
||||
|
||||
/*
|
||||
String: sScript;
|
||||
*/
|
||||
var $sScript;
|
||||
|
||||
/*
|
||||
Function: xajaxCustomRequest
|
||||
|
||||
Constructs and initializes an instance of the object.
|
||||
|
||||
Parameters:
|
||||
|
||||
sScript - (string): The javascript (template) that will be printed
|
||||
upon request.
|
||||
aVariables - (associative array, optional): An array of variable name,
|
||||
value pairs that will be passed to <xajaxCustomRequest->setVariable>
|
||||
*/
|
||||
function xajaxCustomRequest($sScript)
|
||||
{
|
||||
$this->aVariables = array();
|
||||
$this->sScript = $sScript;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearVariables
|
||||
|
||||
Clears the array of variables that will be used to modify the script before
|
||||
it is printed and sent to the client.
|
||||
*/
|
||||
function clearVariables()
|
||||
{
|
||||
$this->aVariables = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setVariable
|
||||
|
||||
Sets a value that will be used to modify the script before it is sent to
|
||||
the browser. The <xajaxCustomRequest> object will perform a string
|
||||
replace operation on each of the values set with this function.
|
||||
|
||||
Parameters:
|
||||
$sName - (string): Variable name
|
||||
$sValue - (string): Value
|
||||
|
||||
*/
|
||||
function setVariable($sName, $sValue)
|
||||
{
|
||||
$this->aVariables[$sName] = $sValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printScript
|
||||
*/
|
||||
function printScript()
|
||||
{
|
||||
$sScript = $this->sScript;
|
||||
foreach ($this->aVariables as $sKey => $sValue)
|
||||
$sScript = str_replace($sKey, $sValue, $sScript);
|
||||
echo $sScript;
|
||||
}
|
||||
}
|
||||
2076
resources/xajax/xajax_core/xajaxResponse.inc.php
Normal file
2076
resources/xajax/xajax_core/xajaxResponse.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
262
resources/xajax/xajax_core/xajaxResponseManager.inc.php
Normal file
262
resources/xajax/xajax_core/xajaxResponseManager.inc.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxResponseManager.inc.php
|
||||
|
||||
Contains the xajaxResponseManager class
|
||||
|
||||
Title: xajaxResponseManager class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxResponseManager.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxResponseManager
|
||||
|
||||
This class stores and tracks the response that will be returned after
|
||||
processing a request. The response manager represents a single point
|
||||
of contact for working with <xajaxResponse> objects as well as
|
||||
<xajaxCustomResponse> objects.
|
||||
*/
|
||||
final class xajaxResponseManager
|
||||
{
|
||||
/*
|
||||
Object: objResponse
|
||||
|
||||
The current response object that will be sent back to the browser
|
||||
once the request processing phase is complete.
|
||||
*/
|
||||
private $objResponse;
|
||||
|
||||
/*
|
||||
String: sCharacterEncoding
|
||||
*/
|
||||
private $sCharacterEncoding;
|
||||
|
||||
/*
|
||||
Boolean: bOutputEntities
|
||||
*/
|
||||
private $bOutputEntities;
|
||||
|
||||
/*
|
||||
Array: aDebugMessages
|
||||
*/
|
||||
private $aDebugMessages;
|
||||
|
||||
/*
|
||||
Function: xajaxResponseManager
|
||||
|
||||
Construct and initialize the one and only xajaxResponseManager object.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->objResponse = NULL;
|
||||
$this->aDebugMessages = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getInstance
|
||||
|
||||
Implementation of the singleton pattern: provide a single instance of the <xajaxResponseManager>
|
||||
to all who request it.
|
||||
*/
|
||||
public static function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new xajaxResponseManager();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Called by the xajax object when configuration options are set in the main script. Option
|
||||
values are passed to each of the main xajax components and stored locally as needed. The
|
||||
<xajaxResponseManager> will track the characterEncoding and outputEntities settings.
|
||||
|
||||
Parameters:
|
||||
$sName - (string): Setting name
|
||||
$mValue - (mixed): Value
|
||||
*/
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
if ('characterEncoding' == $sName)
|
||||
{
|
||||
$this->sCharacterEncoding = $mValue;
|
||||
|
||||
if (isset($this->objResponse))
|
||||
$this->objResponse->setCharacterEncoding($this->sCharacterEncoding);
|
||||
}
|
||||
else if ('contentType' == $sName)
|
||||
{
|
||||
if (isset($this->objResponse))
|
||||
$this->objResponse->setContentType($mValue);
|
||||
}
|
||||
else if ('outputEntities' == $sName)
|
||||
{
|
||||
if (true === $mValue || false === $mValue)
|
||||
{
|
||||
$this->bOutputEntities = $mValue;
|
||||
|
||||
if (isset($this->objResponse))
|
||||
$this->objResponse->setOutputEntities($this->bOutputEntities);
|
||||
}
|
||||
}
|
||||
$this->aSettings[$sName] = $mValue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Function: getConfiguration
|
||||
|
||||
Get the current value of a configuration setting that was previously set
|
||||
via <xajax->configure> or <xajax->configureMany>
|
||||
|
||||
Parameters:
|
||||
|
||||
$sName - (string): The name of the configuration setting
|
||||
|
||||
Returns:
|
||||
|
||||
$mValue : (mixed): The value of the setting if set, null otherwise.
|
||||
*/
|
||||
|
||||
public function getConfiguration($sName)
|
||||
{
|
||||
if (isset($this->aSettings[$sName]))
|
||||
return $this->aSettings[$sName];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clear
|
||||
|
||||
Clear the current response. A new response will need to be appended
|
||||
before the request processing is complete.
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->objResponse = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: append
|
||||
|
||||
Used, primarily internally, to append one response object onto the end of another. You can
|
||||
append one xajaxResponse to the end of another, or append a xajaxCustomResponse onto the end of
|
||||
another xajaxCustomResponse. However, you cannot append a standard response object onto the end
|
||||
of a custom response and likewise, you cannot append a custom response onto the end of a standard
|
||||
response.
|
||||
|
||||
Parameters:
|
||||
|
||||
$mResponse - (object): The new response object to be added to the current response object.
|
||||
|
||||
If no prior response has been appended, this response becomes the main response object to which other
|
||||
response objects will be appended.
|
||||
*/
|
||||
public function append($mResponse)
|
||||
{
|
||||
if ( $mResponse instanceof xajaxResponse ) {
|
||||
if (NULL == $this->objResponse) {
|
||||
$this->objResponse = $mResponse;
|
||||
} else if ( $this->objResponse instanceof xajaxResponse ) {
|
||||
if ($this->objResponse != $mResponse)
|
||||
$this->objResponse->appendResponse($mResponse);
|
||||
} else {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
$this->debug(
|
||||
$objLanguageManager->getText('XJXRM:MXRTERR')
|
||||
. get_class($this->objResponse)
|
||||
. ')'
|
||||
);
|
||||
}
|
||||
} else if ( $mResponse instanceof xajaxCustomResponse ) {
|
||||
if (NULL == $this->objResponse) {
|
||||
$this->objResponse = $mResponse;
|
||||
} else if ( $this->objResponse instanceof xajaxCustomResponse ) {
|
||||
if ($this->objResponse != $mResponse)
|
||||
$this->objResponse->appendResponse($mResponse);
|
||||
} else {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
$this->debug(
|
||||
$objLanguageManager->getText('XJXRM:MXRTERR')
|
||||
. get_class($this->objResponse)
|
||||
. ')'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
$this->debug($objLanguageManager->getText('XJXRM:IRERR'));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: debug
|
||||
|
||||
Appends a debug message on the end of the debug message queue. Debug messages
|
||||
will be sent to the client with the normal response (if the response object supports
|
||||
the sending of debug messages, see: <xajaxResponse>)
|
||||
|
||||
Parameters:
|
||||
|
||||
$sMessage - (string): The text of the debug message to be sent.
|
||||
*/
|
||||
public function debug($sMessage)
|
||||
{
|
||||
$this->aDebugMessages[] = $sMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: send
|
||||
|
||||
Prints the response object to the output stream, thus sending the response to the client.
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
if (NULL != $this->objResponse) {
|
||||
foreach ($this->aDebugMessages as $sMessage)
|
||||
$this->objResponse->debug($sMessage);
|
||||
$this->aDebugMessages = array();
|
||||
$this->objResponse->printOutput();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getCharacterEncoding
|
||||
|
||||
Called automatically by new response objects as they are constructed to obtain the
|
||||
current character encoding setting. As the character encoding is changed, the <xajaxResponseManager>
|
||||
will automatically notify the current response object since it would have been constructed
|
||||
prior to the setting change, see <xajaxResponseManager::configure>.
|
||||
*/
|
||||
public function getCharacterEncoding()
|
||||
{
|
||||
return $this->sCharacterEncoding;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getOutputEntities
|
||||
|
||||
Called automatically by new response objects as they are constructed to obtain the
|
||||
current output entities setting. As the output entities setting is changed, the
|
||||
<xajaxResponseManager> will automatically notify the current response object since it would
|
||||
have been constructed prior to the setting change, see <xajaxResponseManager::configure>.
|
||||
*/
|
||||
public function getOutputEntities()
|
||||
{
|
||||
return $this->bOutputEntities;
|
||||
}
|
||||
}
|
||||
88
resources/xajax/xajax_core/xajax_lang_de.inc.php
Normal file
88
resources/xajax/xajax_core/xajax_lang_de.inc.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajax_lang_de.inc.php
|
||||
|
||||
Contains the debug and error messages output by xajax translated to German.
|
||||
|
||||
Title: xajax class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
|
||||
Translations provided by: (Thank you!)
|
||||
- mic <info@joomx.com>
|
||||
- q_no
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_lang_de.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
@copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
//SkipAIO
|
||||
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
$objLanguageManager->register('de', array(
|
||||
'LOGHDR:01' => '** xajax Fehler Protokoll - ',
|
||||
'LOGHDR:02' => " **\n",
|
||||
'LOGHDR:03' => "\n\n\n",
|
||||
'LOGERR:01' => "** Protokolliere Fehler **\n\nxajax konnte den Fehler nicht in die Protokolldatei schreiben:\n",
|
||||
'LOGMSG:01' => "** PHP Fehlermeldungen: **",
|
||||
'CMPRSJS:RDERR:01' => 'Die unkomprimierte JavaScript-Datei konnte nicht gefunden werden im Verzeichnis: <b>',
|
||||
'CMPRSJS:RDERR:02' => '</b>. Fehler ',
|
||||
'CMPRSJS:WTERR:01' => 'Die komprimierte xajax JavaScript-Datei konnte nicht in das Verzeichnis <b>',
|
||||
'CMPRSJS:WTERR:02' => '</b> geschrieben werden. Fehler ',
|
||||
'CMPRSPHP:WTERR:01' => 'Die komprimierte xajax Datei <b>',
|
||||
'CMPRSPHP:WTERR:02' => '</b> konnte nicht geschrieben werden. Fehler ',
|
||||
'CMPRSAIO:WTERR:01' => 'Die komprimierte xajax Datei <b>',
|
||||
'CMPRSAIO:WTERR:02' => '/xajaxAIO.inc.php</b> konnte nicht geschrieben werden. Fehler ',
|
||||
'DTCTURI:01' => 'xajax Fehler: xajax konnte die Request URI nicht automatisch identifizieren.',
|
||||
'DTCTURI:02' => 'Bitte setzen sie die Request URI explizit wenn sie die xajax Klasse instanziieren.',
|
||||
'ARGMGR:ERR:01' => 'Fehlerhaftes Objekt erhalten: ',
|
||||
'ARGMGR:ERR:02' => ' <==> ',
|
||||
'ARGMGR:ERR:03' => 'Die erhaltenen xajax Daten konnte nicht aus UTF8 konvertiert werden.',
|
||||
'XJXCTL:IAERR:01' => 'Ungültiges Attribut [',
|
||||
'XJXCTL:IAERR:02' => '] für Element [',
|
||||
'XJXCTL:IAERR:03' => '].',
|
||||
'XJXCTL:IRERR:01' => 'Ungültiges Request-Objekt übergeben an xajaxControl::setEvent',
|
||||
'XJXCTL:IEERR:01' => 'Ungültiges Attribut (event name) [',
|
||||
'XJXCTL:IEERR:02' => '] für Element [',
|
||||
'XJXCTL:IEERR:03' => '].',
|
||||
'XJXCTL:MAERR:01' => 'Erforderliches Attribut fehlt [',
|
||||
'XJXCTL:MAERR:02' => '] für Element [',
|
||||
'XJXCTL:MAERR:03' => '].',
|
||||
'XJXCTL:IETERR:01' => "Ungültiges End-Tag; Sollte 'forbidden' oder 'optional' sein.\n",
|
||||
'XJXCTL:ICERR:01' => "Ungültige Klasse für html control angegeben.; Sollte %inline, %block oder %flow sein.\n",
|
||||
'XJXCTL:ICLERR:01' => 'Ungültige Klasse (control) an addChild übergeben; Sollte abgeleitet sein von xajaxControl.',
|
||||
'XJXCTL:ICLERR:02' => 'Ungültige Klasse (control) an addChild übergeben [',
|
||||
'XJXCTL:ICLERR:03' => '] für Element [',
|
||||
'XJXCTL:ICLERR:04' => "].\n",
|
||||
'XJXCTL:ICHERR:01' => 'Ungültiger Parameter übergeben für xajaxControl::addChildren; Array aus xajaxControl Objekten erwartet.',
|
||||
'XJXCTL:MRAERR:01' => 'Erforderliches Attribut fehlt [',
|
||||
'XJXCTL:MRAERR:02' => '] für Element [',
|
||||
'XJXCTL:MRAERR:03' => '].',
|
||||
'XJXPLG:GNERR:01' => 'Response plugin sollte die Funktion getName überschreiben.',
|
||||
'XJXPLG:PERR:01' => 'Response plugin sollte die process Funktion überschreiben.',
|
||||
'XJXPM:IPLGERR:01' => 'Versuch ungültiges Plugin zu registrieren: : ',
|
||||
'XJXPM:IPLGERR:02' => ' Ableitung von xajaxRequestPlugin oder xajaxResponsePlugin erwartet.',
|
||||
'XJXPM:MRMERR:01' => 'Konnte die Registrierungsmethode nicht finden für: : ',
|
||||
'XJXRSP:EDERR:01' => 'Die Angabe der Zeichensatzkodierung in der xajaxResponse ist veraltet. Die neue Funktion lautet: $xajax->configure("characterEncoding", ...);',
|
||||
'XJXRSP:MPERR:01' => 'Ungültiger oder fehlender Pluginname festgestellt im Aufruf von xajaxResponse::plugin',
|
||||
'XJXRSP:CPERR:01' => "Der Parameter \$sType in addCreate ist veraltet. Die neue Funktion lautet addCreateInput()",
|
||||
'XJXRSP:LCERR:01' => "Das xajax response Objeckt konnte die Befehler nich verarbeiten, da kein gültiges Array übergeben wurde.",
|
||||
'XJXRSP:AKERR:01' => 'Ungültiger Tag-Name im Array.',
|
||||
'XJXRSP:IEAERR:01' => 'Ungeeignet kodiertes Array.',
|
||||
'XJXRSP:NEAERR:01' => 'Nicht kodiertes Array festgestellt.',
|
||||
'XJXRSP:MBEERR:01' => 'Die Ausgabe vonn xajax response konnte nicht in htmlentities umgewandelt werden, da die Funktion mb_convert_encoding nicht verfügbar ist.',
|
||||
'XJXRSP:MXRTERR' => 'Fehler: Kann keine verschiedenen Typen in einer einzelnen Antwort verarbeiten.',
|
||||
'XJXRSP:MXCTERR' => 'Fehler: Kann keine verschiedenen Content-Types in einer einzelnen Antwort verarbeiten.',
|
||||
'XJXRSP:MXCEERR' => 'Fehler: Kann keine verschiedenen Zeichensatzkodierungen in einer einzelnen Antwort verarbeiten.',
|
||||
'XJXRSP:MXOEERR' => 'Fehler: Kann keine output entities (true/false) in ener einzelnen Antwort verarbeiten.',
|
||||
'XJXRM:IRERR' => 'Ungültige Antwort erhalten während der Ausführung der Anfrage.',
|
||||
'XJXRM:MXRTERR' => 'Fehler: Kann kkeine verschiedenen reponse types benutzen während der Ausführung einer Anfrage: '
|
||||
));
|
||||
|
||||
//EndSkipAIO
|
||||
79
resources/xajax/xajax_core/xajax_lang_nl.inc.php
Normal file
79
resources/xajax/xajax_core/xajax_lang_nl.inc.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajax_lang_nl.inc.php
|
||||
|
||||
Contains the debug and error messages output by xajax translated to Dutch.
|
||||
|
||||
Title: xajax class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
|
||||
Translations provided by: (Thank you!)
|
||||
- Jeffrey <walkingsoul@gmail.com>
|
||||
*/
|
||||
|
||||
//SkipAIO
|
||||
|
||||
$objLanguageManager = xajaxLanguageManager::getInstance();
|
||||
$objLanguageManager->register('nl', array(
|
||||
'LOGHDR:01' => '** xajax Foutmelding logboek - ',
|
||||
'LOGHDR:02' => " **\n",
|
||||
'LOGHDR:03' => "\n\n\n",
|
||||
'LOGERR:01' => "** Logboek fouten **\n\nxajax was niet in staat om te schrijven naar het logboek:\n",
|
||||
'LOGMSG:01' => "** PHP Foutmeldingen: **",
|
||||
'CMPRSJS:RDERR:01' => 'Het xajax ongecomprimeerde Javascript bestand kon niet worden gevonden in de: <b>',
|
||||
'CMPRSJS:RDERR:02' => '</b>. map. ',
|
||||
'CMPRSJS:WTERR:01' => 'Het xajax gecomprimeerde Javascript bestand kon niet worden geschreven in de: <b>',
|
||||
'CMPRSJS:WTERR:02' => '</b> map. Fout ',
|
||||
'CMPRSPHP:WTERR:01' => 'Naar het xajax gecomprimeerde bestand <b>',
|
||||
'CMPRSPHP:WTERR:02' => '</b> kon niet worden geschreven. Fout ',
|
||||
'CMPRSAIO:WTERR:01' => 'Naar het xajax gecomprimeerde bestand <b>',
|
||||
'CMPRSAIO:WTERR:02' => '/xajaxAIO.inc.php</b> kon niet worden geschreven. Fout ',
|
||||
'DTCTURI:01' => 'xajax Fout: xajax kon de Request URI niet automatisch identificeren.',
|
||||
'DTCTURI:02' => 'Alstublieft, specificeer de Request URI expliciet bij het initiëren van het xajax object.',
|
||||
'ARGMGR:ERR:01' => 'Misvormd object argument ontvangen: ',
|
||||
'ARGMGR:ERR:02' => ' <==> ',
|
||||
'ARGMGR:ERR:03' => 'De binnenkomende xajax data kon niet wordt geconverteerd van UTF-8.',
|
||||
'XJXCTL:IAERR:01' => 'Ongeldig attribuut [',
|
||||
'XJXCTL:IAERR:02' => '] voor element [',
|
||||
'XJXCTL:IAERR:03' => '].',
|
||||
'XJXCTL:IRERR:01' => 'Ongeldige object aanvraag doorgegeven aan xajaxControl::setEvent',
|
||||
'XJXCTL:IEERR:01' => 'Ongeldig attribuut (event name) [',
|
||||
'XJXCTL:IEERR:02' => '] voor element [',
|
||||
'XJXCTL:IEERR:03' => '].',
|
||||
'XJXCTL:MAERR:01' => 'Ontbrekend attribuut [',
|
||||
'XJXCTL:MAERR:02' => '] voor element [',
|
||||
'XJXCTL:MAERR:03' => '].',
|
||||
'XJXCTL:IETERR:01' => "Ongeldige eind-tag; zou 'forbidden' of 'optional' moeten zijn..\n",
|
||||
'XJXCTL:ICERR:01' => "Ongeldige klasse gespecificeerd voor html control.; zou %inline, %block of %flow moeten zijn.\n",
|
||||
'XJXCTL:ICLERR:01' => 'Ongeldige (control) doorgegeven aan addChild; Zou moeten worden afgeleid van xajaxControl.',
|
||||
'XJXCTL:ICLERR:02' => 'Ongeldige (control) doorgegeven aan addChild [',
|
||||
'XJXCTL:ICLERR:03' => '] voor element [',
|
||||
'XJXCTL:ICLERR:04' => "].\n",
|
||||
'XJXCTL:ICHERR:01' => 'Ongeldige parameter doorgegeven aan xajaxControl::addChildren; Array moet bestaan uit xajaxControl objecten.',
|
||||
'XJXCTL:MRAERR:01' => 'Ontbrekend attribuut [',
|
||||
'XJXCTL:MRAERR:02' => '] voor element [',
|
||||
'XJXCTL:MRAERR:03' => '].',
|
||||
'XJXPLG:GNERR:01' => 'Retourneer plugin zou de getName functie moeten overschrijven.',
|
||||
'XJXPLG:PERR:01' => 'Retourneer plugin zou de proces functie moeten overschrijven.',
|
||||
'XJXPM:IPLGERR:01' => 'Poging om ongeldige plugin te registreren: : ',
|
||||
'XJXPM:IPLGERR:02' => ' afleiding moet komen van xajaxRequestPlugin of xajaxResponsePlugin.',
|
||||
'XJXPM:MRMERR:01' => 'Localisatie van registratie methode faalde voor het volgende: : ',
|
||||
'XJXRSP:EDERR:01' => 'Doorgeven van karakter decodering naar de xajaxResponse constructie is verouderd. De nieuwe functie luidt: $xajax->configure("characterEncoding", ...);',
|
||||
'XJXRSP:MPERR:01' => 'Ongeldige of ontbrekende plugin naam gedetecteerd in een aanvraag naar xajaxResponse::plugin',
|
||||
'XJXRSP:CPERR:01' => "De parameter \$sType in addCreate is verouderd.. De nieuwe functie luidt addCreateInput()",
|
||||
'XJXRSP:LCERR:01' => "Het xajax antwoord object kon de commando's niet laden, gezien de meegegeven data geen geldige array is.",
|
||||
'XJXRSP:AKERR:01' => 'Ongeldige ge-encodeerde tag naam in array',
|
||||
'XJXRSP:IEAERR:01' => 'Ungeeignet kodiertes Array.',
|
||||
'XJXRSP:NEAERR:01' => 'Niet gecodeerde array gedetecteerd.',
|
||||
'XJXRSP:MBEERR:01' => 'De xajax output kon niet worden geconverteerd naar HTML entities, gezien mb_convert_encoding niet beschikbaar is.',
|
||||
'XJXRSP:MXRTERR' => 'Fout: Kann keine verschiedenen Typen in einer einzelnen Antwort verarbeiten.',
|
||||
'XJXRSP:MXCTERR' => 'Fout: Kan geen meerdere typen verwisselen in een enkele teruggave.',
|
||||
'XJXRSP:MXCEERR' => 'Fout: Kan geen meerdere karakter decoderingen verwerken in een enkele teruggave.',
|
||||
'XJXRSP:MXOEERR' => 'Fout: kan geen output entities (true/false) in een enkele teruggave verwerken.',
|
||||
'XJXRM:IRERR' => 'Een ongeldig antwoord is geretourneerd tijdens het verwerken van deze aanvraag.',
|
||||
'XJXRM:MXRTERR' => 'Fout: Kan geen meerdere typen verwisselen tijdens het verwerken van een enkele aanvraag: '
|
||||
));
|
||||
|
||||
//EndSkipAIO
|
||||
Reference in New Issue
Block a user