/usr/share/php/xajax/xajax_core/plugin_layer/support/xajaxEvent.inc.php is in php-xajax 0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 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-2009 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.
*/
class xajaxEvent
{
/*
String: sName
The name of the event.
*/
var $sName;
/*
Array: aConfiguration
Configuration / call options to be used when initiating a xajax request
to trigger this event.
*/
var $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.
*/
var $aHandlers;
/*
Function: xajaxEvent
Construct and initialize this <xajaxEvent> object.
*/
function xajaxEvent($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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
function fire($aArgs)
{
$objResponseManager =& xajaxResponseManager::getInstance();
foreach (array_keys($this->aHandlers) as $sKey)
$this->aHandlers[$sKey]->call($aArgs);
}
}
|