/usr/share/php/xajax/xajax_core/plugin_layer/xajaxDefaultIncludePlugin.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 345 346 347 348 349 350 351 352 | <?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-2009 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.
*/
class xajaxIncludeClientScriptPlugin extends xajaxRequestPlugin
{
var $sJsURI;
var $aJsFiles;
var $sDefer;
var $sRequestURI;
var $sStatusMessages;
var $sWaitCursor;
var $sVersion;
var $sDefaultMode;
var $sDefaultMethod;
var $bDebug;
var $bVerboseDebug;
var $nScriptLoadTimeout;
var $bUseUncompressedScripts;
var $bDeferScriptGeneration;
var $sLanguage;
var $nResponseQueueSize;
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;
}
/*
Function: configure
*/
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;
}
}
/*
Function: generateClientScript
*/
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.
*/
function getJavascriptConfig()
{
ob_start();
$this->printJavascriptConfig();
return ob_get_clean();
}
/*
Function: printJavascriptConfig
See <xajaxIncludeClientScriptPlugin::getJavascriptConfig>
*/
function printJavascriptConfig()
{
$sCrLf = "\n";
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.legacy = false;';
echo $sCrLf;
echo 'xajax.config.defaultMode = "';
echo $this->sDefaultMode;
echo '";';
echo $sCrLf;
echo 'xajax.config.defaultMethod = "';
echo $this->sDefaultMethod;
echo '";';
if (false === (null === $this->nResponseQueueSize))
{
echo $sCrLf;
echo 'xajax.config.responseQueueSize = ';
echo $this->nResponseQueueSize;
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.
*/
function getJavascriptInclude()
{
ob_start();
$this->printJavascriptInclude();
return ob_get_clean();
}
/*
Function: printJavascriptInclude
See <xajaxIncludeClientScriptPlugin::getJavascriptInclude>
*/
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.
*/
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);
|