/usr/share/php/xajax/xajax_core/xajaxPluginManager.inc.php is in php-xajax 0.5-1ubuntu1.
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | <?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-2009 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
*/
class xajaxPluginManager
{
/*
Array: aRequestPlugins
*/
var $aRequestPlugins;
/*
Array: aResponsePlugins
*/
var $aResponsePlugins;
/*
Array: aConfigurable
*/
var $aConfigurable;
/*
Array: aRegistrars
*/
var $aRegistrars;
/*
Array: aProcessors
*/
var $aProcessors;
/*
Array: aClientScriptGenerators
*/
var $aClientScriptGenerators;
/*
Function: xajaxPluginManager
Construct and initialize the one and only xajax plugin manager.
*/
function xajaxPluginManager()
{
$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.
*/
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
*/
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.
*/
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
*/
function registerPlugin(&$objPlugin, $nPriority=1000)
{
if (is_a($objPlugin, '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 (is_a($objPlugin, '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.
*/
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.
*/
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.
*/
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) :
*/
function register($aArgs)
{
$aKeys = array_keys($this->aRegistrars);
sort($aKeys);
foreach ($aKeys as $sKey)
{
$objPlugin =& $this->aRegistrars[$sKey];
$mResult =& $objPlugin->register($aArgs);
if (is_a($mResult, '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.
*/
function generateClientScript()
{
$aKeys = array_keys($this->aClientScriptGenerators);
sort($aKeys);
foreach ($aKeys as $sKey)
$this->aClientScriptGenerators[$sKey]->generateClientScript();
}
/*
Function: getPlugin
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.
*/
function &getPlugin($sName)
{
$aKeys = array_keys($this->aResponsePlugins);
sort($aKeys);
foreach ($aKeys as $sKey)
if (is_a($this->aResponsePlugins[$sKey], $sName))
return $this->aResponsePlugins[$sKey];
$bFailure = false;
return $bFailure;
}
}
|