Initial commit: Kimai TMS
Kimai time management system (PHP 5.6 / MySQL) with custom extensions: - Budget tracking (ki_budget) - Change request form (ki_changerequest) - Invoice generation (ki_invoice) - Expense tracking (ki_expenses) - Flexi time (ki_flexitime) - Export, admin panel, timesheets, tasks, summary Database: ~900K time entries, 2,000+ users, 439 projects. Config: includes/autoconf.php — localhost/kimai/kimai
This commit is contained in:
54
libraries/xajax/copyright.inc.php
Normal file
54
libraries/xajax/copyright.inc.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
File: copyright.inc.php
|
||||
|
||||
This file contains detailed information regarding the xajax project,
|
||||
current version, copyrights, licnese and documentation.
|
||||
|
||||
You do not need to include this file in your project for xajax to
|
||||
function properly.
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Current Version
|
||||
|
||||
xajax version 0.5 (beta 4)
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Copyright
|
||||
|
||||
- copyright (c) 2005-2007 by Jared White & J. Max Wilson
|
||||
- portions copyright (c) 2006-2007 by Joseph Woolley
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
xajax is an open source PHP class library for easily creating powerful
|
||||
PHP-driven, web-based Ajax Applications. Using xajax, you can asynchronously
|
||||
call PHP functions and update the content of your your webpage without
|
||||
reloading the page.
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: License
|
||||
|
||||
xajax is released under the terms of the BSD license
|
||||
http://www.xajaxproject.org/bsd_license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: copyright.inc.php 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Online documentation
|
||||
|
||||
Online documentation for this class is available on the xajax wiki at:
|
||||
http://wiki.xajaxproject.org/Documentation:xajax.inc.php
|
||||
*/
|
||||
|
||||
283
libraries/xajax/xajax_controls/content.inc.php
Normal file
283
libraries/xajax/xajax_controls/content.inc.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
/*
|
||||
File: content.inc.php
|
||||
|
||||
HTML Control Library - Content Level Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: content.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains class declarations for the following HTML tags:
|
||||
|
||||
- literal
|
||||
- br, hr
|
||||
- sub, sup, q, em, strong, cite, dfn, code, samp, kbd, var, abbr, acronym, tt, i, b, big, small, ins, del
|
||||
- h1 ... h6, address, p, blockquote, pre
|
||||
|
||||
The following tags are deprecated as of HTML 4.01 and therefore they are not supported.
|
||||
|
||||
- font, strike, s, u, center
|
||||
*/
|
||||
|
||||
class clsLiteral extends xajaxControl
|
||||
{
|
||||
function clsLiteral($sText)
|
||||
{
|
||||
xajaxControl::xajaxControl('CDATA');
|
||||
|
||||
$this->sClass = '%inline';
|
||||
$this->sText = $sText;
|
||||
}
|
||||
|
||||
function printHTML($sIndent='')
|
||||
{
|
||||
echo $this->sText;
|
||||
}
|
||||
}
|
||||
|
||||
class clsBr extends xajaxControl
|
||||
{
|
||||
function clsBr($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('br', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsHr extends xajaxControl
|
||||
{
|
||||
function clsHr($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('hr', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsInlineContainer extends xajaxControlContainer
|
||||
{
|
||||
function clsInlineContainer($sTag, $aConfiguration)
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
$this->sEndTag = 'required';
|
||||
}
|
||||
}
|
||||
|
||||
class clsSub extends clsInlineContainer
|
||||
{
|
||||
function clsSub($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('sub', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsSup extends xajaxControlContainer
|
||||
{
|
||||
function clsSup($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('sup', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsEm extends clsInlineContainer
|
||||
{
|
||||
function clsEm($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('em', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsStrong extends clsInlineContainer
|
||||
{
|
||||
function clsStrong($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('strong', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsCite extends clsInlineContainer
|
||||
{
|
||||
function clsCite($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('cite', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsDfn extends clsInlineContainer
|
||||
{
|
||||
function clsDfn($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('dfn', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsCode extends clsInlineContainer
|
||||
{
|
||||
function clsCode($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('code', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsSamp extends clsInlineContainer
|
||||
{
|
||||
function clsSamp($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('samp', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsKbd extends clsInlineContainer
|
||||
{
|
||||
function clsKbd($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('kbd', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsVar extends clsInlineContainer
|
||||
{
|
||||
function clsVar($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('var', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsAbbr extends clsInlineContainer
|
||||
{
|
||||
function clsAbbr($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('abbr', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsAcronym extends clsInlineContainer
|
||||
{
|
||||
function clsAcronym($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('acronym', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsTt extends clsInlineContainer
|
||||
{
|
||||
function clsTt($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('tt', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsItalic extends clsInlineContainer
|
||||
{
|
||||
function clsItalic($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('i', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsBold extends clsInlineContainer
|
||||
{
|
||||
function clsBold($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('b', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsBig extends clsInlineContainer
|
||||
{
|
||||
function clsBig($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('big', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class clsSmall extends clsInlineContainer
|
||||
{
|
||||
function clsSmall($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('small', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsIns extends clsInlineContainer
|
||||
{
|
||||
function clsIns($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('ins', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsDel extends clsInlineContainer
|
||||
{
|
||||
function clsDel($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('del', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsHeadline extends xajaxControlContainer
|
||||
{
|
||||
function clsHeadline($sType, $aConfiguration=array())
|
||||
{
|
||||
if (0 < strpos($sType, '123456'))
|
||||
trigger_error('Invalid type for headline control; should be 1,2,3,4,5 or 6.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR
|
||||
);
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('h' . $sType, $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
}
|
||||
}
|
||||
|
||||
class clsAddress extends clsInlineContainer
|
||||
{
|
||||
function clsAddress($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('address', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsParagraph extends clsInlineContainer
|
||||
{
|
||||
function clsParagraph($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('p', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsBlockquote extends clsInlineContainer
|
||||
{
|
||||
function clsBlockquote($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('blockquote', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsPre extends clsInlineContainer
|
||||
{
|
||||
function clsPre($aConfiguration=array())
|
||||
{
|
||||
clsInlineContainer::clsInlineContainer('pre', $aConfiguration);
|
||||
}
|
||||
}
|
||||
323
libraries/xajax/xajax_controls/document.inc.php
Normal file
323
libraries/xajax/xajax_controls/document.inc.php
Normal file
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
/*
|
||||
File: document.inc.php
|
||||
|
||||
HTML Control Library - Document Level Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: document.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains the class declarations for the following HTML Controls:
|
||||
|
||||
- document, doctype, html, head, body
|
||||
- meta, link, script, style
|
||||
- title, base
|
||||
- noscript
|
||||
- frameset, frame, iframe, noframes
|
||||
|
||||
The following controls are deprecated as of HTML 4.01, so they will not be supported:
|
||||
|
||||
- basefont
|
||||
*/
|
||||
|
||||
class clsDocument extends xajaxControlContainer
|
||||
{
|
||||
function clsDocument($aConfiguration=array())
|
||||
{
|
||||
if (isset($aConfiguration['attributes']))
|
||||
trigger_error(
|
||||
'clsDocument objects cannot have attributes.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR);
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('DOCUMENT', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function printHTML()
|
||||
{
|
||||
$tStart = microtime();
|
||||
$this->_printChildren();
|
||||
$tStop = microtime();
|
||||
echo '<' . '!--';
|
||||
echo ' page generation took ';
|
||||
$nTime = $tStop - $tStart;
|
||||
$nTime *= 1000;
|
||||
echo $nTime;
|
||||
echo ' --' . '>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class clsDoctype extends xajaxControlContainer
|
||||
{
|
||||
var $sText;
|
||||
|
||||
var $sFormat;
|
||||
var $sVersion;
|
||||
var $sValidation;
|
||||
var $sEncoding;
|
||||
|
||||
function clsDocType($sFormat=null, $sVersion=null, $sValidation=null, $sEncoding='UTF-8')
|
||||
{
|
||||
if (null === $sFormat && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT'))
|
||||
trigger_error('You must specify a doctype format.', E_USER_ERROR);
|
||||
if (null === $sVersion && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VERSION'))
|
||||
trigger_error('You must specify a doctype version.', E_USER_ERROR);
|
||||
if (null === $sValidation && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION'))
|
||||
trigger_error('You must specify a doctype validation.', E_USER_ERROR);
|
||||
|
||||
if (null === $sFormat)
|
||||
$sFormat = XAJAX_HTML_CONTROL_DOCTYPE_FORMAT;
|
||||
if (null === $sVersion)
|
||||
$sVersion = XAJAX_HTML_CONTROL_DOCTYPE_VERSION;
|
||||
if (null === $sValidation)
|
||||
$sValidation = XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION;
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('DOCTYPE', array());
|
||||
|
||||
$this->sText = '<'.'!DOCTYPE html PUBLIC "-//W3C//DTD ';
|
||||
$this->sText .= $sFormat;
|
||||
$this->sText .= ' ';
|
||||
$this->sText .= $sVersion;
|
||||
if ('TRANSITIONAL' == $sValidation)
|
||||
$this->sText .= ' Transitional';
|
||||
else if ('FRAMESET' == $sValidation)
|
||||
$this->sText .= ' Frameset';
|
||||
$this->sText .= '//EN" ';
|
||||
|
||||
if ('HTML' == $sFormat) {
|
||||
if ('4.0' == $sVersion) {
|
||||
if ('STRICT' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/html40/strict.dtd"';
|
||||
else if ('TRANSITIONAL' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/html40/loose.dtd"';
|
||||
} else if ('4.01' == $sVersion) {
|
||||
if ('STRICT' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/html401/strict.dtd"';
|
||||
else if ('TRANSITIONAL' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/html401/loose.dtd"';
|
||||
else if ('FRAMESET' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/html4/frameset.dtd"';
|
||||
}
|
||||
} else if ('XHTML' == $sFormat) {
|
||||
if ('1.0' == $sVersion) {
|
||||
if ('STRICT' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"';
|
||||
else if ('TRANSITIONAL' == $sValidation)
|
||||
$this->sText .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"';
|
||||
} else if ('1.1' == $sVersion) {
|
||||
$this->sText .= '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"';
|
||||
}
|
||||
} else
|
||||
trigger_error('Unsupported DOCTYPE tag.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR
|
||||
);
|
||||
|
||||
$this->sText .= '>';
|
||||
|
||||
$this->sFormat = $sFormat;
|
||||
$this->sVersion = $sVersion;
|
||||
$this->sValidation = $sValidation;
|
||||
$this->sEncoding = $sEncoding;
|
||||
}
|
||||
|
||||
function printHTML($sIndent='')
|
||||
{
|
||||
header('content-type: text/html; charset=' . $this->sEncoding);
|
||||
|
||||
if ('XHTML' == $this->sFormat)
|
||||
print '<' . '?' . 'xml version="1.0" encoding="' . $this->sEncoding . '" ' . '?' . ">\n";
|
||||
|
||||
print $this->sText;
|
||||
|
||||
print "\n";
|
||||
|
||||
xajaxControlContainer::_printChildren($sIndent);
|
||||
}
|
||||
}
|
||||
|
||||
class clsHtml extends xajaxControlContainer
|
||||
{
|
||||
function clsHtml($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('html', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsHead extends xajaxControlContainer
|
||||
{
|
||||
var $objXajax;
|
||||
|
||||
function clsHead($aConfiguration=array())
|
||||
{
|
||||
$this->objXajax = null;
|
||||
if (isset($aConfiguration['xajax']))
|
||||
$this->setXajax($aConfiguration['xajax']);
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('head', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
|
||||
function setXajax(&$objXajax)
|
||||
{
|
||||
$this->objXajax =& $objXajax;
|
||||
}
|
||||
|
||||
function _printChildren($sIndent='')
|
||||
{
|
||||
if (null != $this->objXajax)
|
||||
$this->objXajax->printJavascript();
|
||||
|
||||
xajaxControlContainer::_printChildren($sIndent);
|
||||
}
|
||||
}
|
||||
|
||||
class clsBody extends xajaxControlContainer
|
||||
{
|
||||
function clsBody($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('body', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsScript extends xajaxControlContainer
|
||||
{
|
||||
function clsScript($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('script', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsStyle extends xajaxControlContainer
|
||||
{
|
||||
function clsStyle($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('style', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsLink extends xajaxControl
|
||||
{
|
||||
function clsLink($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('link', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsMeta extends xajaxControl
|
||||
{
|
||||
function clsMeta($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('meta', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsTitle extends xajaxControlContainer
|
||||
{
|
||||
function clsTitle($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('title', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function setEvent($sEvent, &$objRequest)
|
||||
{
|
||||
trigger_error(
|
||||
'clsTitle objects do not support events.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
class clsBase extends xajaxControl
|
||||
{
|
||||
function clsBase($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('base', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsNoscript extends xajaxControlContainer
|
||||
{
|
||||
function clsNoscript($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('noscript', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
}
|
||||
}
|
||||
|
||||
class clsIframe extends xajaxControlContainer
|
||||
{
|
||||
function clsIframe($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('iframe', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsFrameset extends xajaxControlContainer
|
||||
{
|
||||
function clsFrameset($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('frameset', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsFrame extends xajaxControl
|
||||
{
|
||||
function clsFrame($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('frame', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsNoframes extends xajaxControlContainer
|
||||
{
|
||||
function clsNoframes($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('noframes', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
}
|
||||
}
|
||||
314
libraries/xajax/xajax_controls/form.inc.php
Normal file
314
libraries/xajax/xajax_controls/form.inc.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/*
|
||||
File: form.inc.php
|
||||
|
||||
HTML Control Library - Form Level Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: form.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains the class declarations for the following HTML Controls:
|
||||
|
||||
- form
|
||||
- input, textarea, select, optgroup, option
|
||||
- label
|
||||
- fieldset, legend
|
||||
|
||||
The following tags are deprecated as of HTML 4.01, therefore, they will not
|
||||
be supported:
|
||||
|
||||
- isindex
|
||||
*/
|
||||
|
||||
class clsForm extends xajaxControlContainer
|
||||
{
|
||||
function clsForm($aConfiguration=array())
|
||||
{
|
||||
if (false == isset($aConfiguration['attributes']))
|
||||
$aConfiguration['attributes'] = array();
|
||||
if (false == isset($aConfiguration['attributes']['method']))
|
||||
$aConfiguration['attributes']['method'] = 'POST';
|
||||
if (false == isset($aConfiguration['attributes']['action']))
|
||||
$aConfiguration['attributes']['action'] = '#';
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('form', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsInput extends xajaxControl
|
||||
{
|
||||
function clsInput($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('input', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsInputWithLabel extends clsInput
|
||||
{
|
||||
var $objLabel;
|
||||
var $sWhere;
|
||||
var $objBreak;
|
||||
|
||||
function clsInputWithLabel($sLabel, $sWhere, $aConfiguration=array())
|
||||
{
|
||||
clsInput::clsInput($aConfiguration);
|
||||
|
||||
$this->objLabel =& new clsLabel(array(
|
||||
'child' => new clsLiteral($sLabel)
|
||||
));
|
||||
$this->objLabel->setControl($this);
|
||||
|
||||
$this->sWhere = $sWhere;
|
||||
|
||||
$this->objBreak =& new clsBr();
|
||||
}
|
||||
|
||||
function printHTML($sIndent='')
|
||||
{
|
||||
if ('left' == $this->sWhere || 'above' == $this->sWhere)
|
||||
$this->objLabel->printHTML($sIndent);
|
||||
if ('above' == $this->sWhere)
|
||||
$this->objBreak->printHTML($sIndent);
|
||||
|
||||
clsInput::printHTML($sIndent);
|
||||
|
||||
if ('below' == $this->sWhere)
|
||||
$this->objBreak->printHTML($sIndent);
|
||||
if ('right' == $this->sWhere || 'below' == $this->sWhere)
|
||||
$this->objLabel->printHTML($sIndent);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsSelect
|
||||
|
||||
A <xajaxControlContainer> derived class that assists in the construction
|
||||
of an HTML select control.
|
||||
|
||||
This control can only accept <clsOption> controls as children.
|
||||
*/
|
||||
class clsSelect extends xajaxControlContainer
|
||||
{
|
||||
/*
|
||||
Function: clsSelect
|
||||
|
||||
Construct and initialize an instance of the class. See <xajaxControlContainer>
|
||||
for details regarding the aConfiguration parameter.
|
||||
*/
|
||||
function clsSelect($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('select', $aConfiguration);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addOption
|
||||
|
||||
Used to add a single option to the options list.
|
||||
|
||||
sValue - (string): The value that is returned as the form value
|
||||
when this option is the selected option.
|
||||
sText - (string): The text that is displayed in the select box when
|
||||
this option is the selected option.
|
||||
*/
|
||||
function addOption($sValue, $sText)
|
||||
{
|
||||
$optionNew =& new clsOption();
|
||||
$optionNew->setValue($sValue);
|
||||
$optionNew->setText($sText);
|
||||
$this->addChild($optionNew);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addOptions
|
||||
|
||||
Used to add a list of options.
|
||||
|
||||
aOptions - (associative array): A list of key/value pairs that will
|
||||
be passed to <clsSelect->addOption>.
|
||||
*/
|
||||
function addOptions($aOptions, $aFields=array())
|
||||
{
|
||||
if (0 == count($aFields))
|
||||
foreach ($aOptions as $sValue => $sText)
|
||||
$this->addOption($sValue, $sText);
|
||||
else if (1 < count($aFields))
|
||||
foreach ($aOptions as $aOption)
|
||||
$this->addOption($aOption[$aFields[0]], $aOption[$aFields[1]]);
|
||||
else
|
||||
trigger_error('Invalid list of fields passed to clsSelect::addOptions; should be array of two strings.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsOptionGroup
|
||||
|
||||
A <xajaxControlContainer> derived class that can be used around a list of <clsOption>
|
||||
objects to help the user find items in a select list.
|
||||
*/
|
||||
class clsOptionGroup extends xajaxControlContainer
|
||||
{
|
||||
function clsOptionGroup($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('optgroup', $aConfiguration);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addOption
|
||||
|
||||
Used to add a single option to the options list.
|
||||
|
||||
sValue - (string): The value that is returned as the form value
|
||||
when this option is the selected option.
|
||||
sText - (string): The text that is displayed in the select box when
|
||||
this option is the selected option.
|
||||
*/
|
||||
function addOption($sValue, $sText)
|
||||
{
|
||||
$optionNew =& new clsOption();
|
||||
$optionNew->setValue($sValue);
|
||||
$optionNew->setText($sText);
|
||||
$this->addChild($optionNew);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addOptions
|
||||
|
||||
Used to add a list of options.
|
||||
|
||||
aOptions - (associative array): A list of key/value pairs that will
|
||||
be passed to <clsSelect->addOption>.
|
||||
*/
|
||||
function addOptions($aOptions, $aFields=array())
|
||||
{
|
||||
if (0 == count($aFields))
|
||||
foreach ($aOptions as $sValue => $sText)
|
||||
$this->addOption($sValue, $sText);
|
||||
else if (1 < count($aFields))
|
||||
foreach ($aOptions as $aOption)
|
||||
$this->addOption($aOption[$aFields[0]], $aOption[$aFields[1]]);
|
||||
else
|
||||
trigger_error('Invalid list of fields passed to clsOptionGroup::addOptions; should be array of two strings.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsOption
|
||||
|
||||
A <xajaxControlContainer> derived class that assists with the construction
|
||||
of HTML option tags that will be assigned to an HTML select tag.
|
||||
|
||||
This control can only accept <clsLiteral> objects as children.
|
||||
*/
|
||||
class clsOption extends xajaxControlContainer
|
||||
{
|
||||
/*
|
||||
Function: clsOption
|
||||
|
||||
Constructs and initializes an instance of this class. See <xajaxControlContainer>
|
||||
for more information regarding the aConfiguration parameter.
|
||||
*/
|
||||
function clsOption($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('option', $aConfiguration);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setValue
|
||||
|
||||
Used to set the value associated with this option. The value is sent as the
|
||||
value of the select control when this is the selected option.
|
||||
*/
|
||||
function setValue($sValue)
|
||||
{
|
||||
$this->setAttribute('value', $sValue);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setText
|
||||
|
||||
Sets the text to be shown in the select control when this is the
|
||||
selected option.
|
||||
*/
|
||||
function setText($sText)
|
||||
{
|
||||
$this->clearChildren();
|
||||
$this->addChild(new clsLiteral($sText));
|
||||
}
|
||||
}
|
||||
|
||||
class clsTextArea extends xajaxControlContainer
|
||||
{
|
||||
function clsTextArea($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('textarea', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsLabel extends xajaxControlContainer
|
||||
{
|
||||
var $objFor;
|
||||
|
||||
function clsLabel($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('label', $aConfiguration);
|
||||
}
|
||||
|
||||
function setControl(&$objControl)
|
||||
{
|
||||
if (false == is_a($objControl, 'xajaxControl'))
|
||||
trigger_error(
|
||||
'Invalid control passed to clsLabel::setControl(); should be xajaxControl.'
|
||||
. $this->backtrace(),
|
||||
E_USER_ERROR);
|
||||
|
||||
$this->objFor =& $objControl;
|
||||
}
|
||||
|
||||
function printHTML($sIndent='')
|
||||
{
|
||||
$this->aAttributes['for'] = $this->objFor->aAttributes['id'];
|
||||
|
||||
xajaxControlContainer::printHTML($sIndent);
|
||||
}
|
||||
}
|
||||
|
||||
class clsFieldset extends xajaxControlContainer
|
||||
{
|
||||
function clsFieldset($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('fieldset', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsLegend extends xajaxControlContainer
|
||||
{
|
||||
function clsLegend($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('legend', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
}
|
||||
}
|
||||
578
libraries/xajax/xajax_controls/group.inc.php
Normal file
578
libraries/xajax/xajax_controls/group.inc.php
Normal file
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
/*
|
||||
File: group.inc.php
|
||||
|
||||
HTML Control Library - Group Level Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: group.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains the class declarations for the following HTML Controls:
|
||||
|
||||
- ol, ul, li
|
||||
- dl, dt, dd
|
||||
- table, caption, colgroup, col, thead, tfoot, tbody, tr, td, th
|
||||
|
||||
The following tags are deprecated as of HTML 4.01, therefore, they will not
|
||||
be supported:
|
||||
|
||||
- dir, menu
|
||||
*/
|
||||
|
||||
class clsList extends xajaxControlContainer
|
||||
{
|
||||
function clsList($sTag, $aConfiguration=array())
|
||||
{
|
||||
$this->clearEvent_AddItem();
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function addItem($mItem, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddItem) {
|
||||
$objItem =& call_user_func($this->eventAddItem, $mItem, $mConfiguration);
|
||||
$this->addChild($objItem);
|
||||
} else {
|
||||
$objItem =& $this->_onAddItem($mItem, $mConfiguration);
|
||||
$this->addChild($objItem);
|
||||
}
|
||||
}
|
||||
|
||||
function addItems($aItems, $mConfiguration=null)
|
||||
{
|
||||
foreach ($aItems as $mItem)
|
||||
$this->addItem($mItem, $mConfiguration);
|
||||
}
|
||||
|
||||
function clearEvent_AddItem()
|
||||
{
|
||||
$this->eventAddItem = null;
|
||||
}
|
||||
|
||||
function setEvent_AddItem($mFunction)
|
||||
{
|
||||
$this->eventAddItem = $mFunction;
|
||||
}
|
||||
|
||||
function &_onAddItem($mItem, $mConfiguration)
|
||||
{
|
||||
$objItem =& new clsLI(array(
|
||||
'child' => new clsLiteral($mItem)
|
||||
));
|
||||
return $objItem;
|
||||
}
|
||||
}
|
||||
|
||||
class clsUL extends clsList
|
||||
{
|
||||
function clsUL($aConfiguration=array())
|
||||
{
|
||||
clsList::clsList('ul', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsOL extends clsList
|
||||
{
|
||||
function clsOL($aConfiguration=array())
|
||||
{
|
||||
clsList::clsList('ol', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
class clsLI extends xajaxControlContainer
|
||||
{
|
||||
function clsLI($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('li', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsDl extends xajaxControlContainer
|
||||
{
|
||||
function clsDl($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('dl', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsDt extends xajaxControlContainer
|
||||
{
|
||||
function clsDt($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('dt', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsDd extends xajaxControlContainer
|
||||
{
|
||||
function clsDd($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('dd', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsTableRowContainer extends xajaxControlContainer
|
||||
{
|
||||
var $eventAddRow;
|
||||
var $eventAddRowCell;
|
||||
|
||||
function clsTableRowContainer($sTag, $aConfiguration=array())
|
||||
{
|
||||
$this->clearEvent_AddRow();
|
||||
$this->clearEvent_AddRowCell();
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function addRow($aCells, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddRow) {
|
||||
$objRow =& call_user_func($this->eventAddRow, $aCells, $mConfiguration);
|
||||
$this->addChild($objRow);
|
||||
} else {
|
||||
$objRow =& $this->_onAddRow($aCells, $mConfiguration);
|
||||
$this->addChild($objRow);
|
||||
}
|
||||
}
|
||||
|
||||
function addRows($aRows, $mConfiguration=null)
|
||||
{
|
||||
foreach ($aRows as $aCells)
|
||||
$this->addRow($aCells, $mConfiguration);
|
||||
}
|
||||
|
||||
function clearEvent_AddRow()
|
||||
{
|
||||
$this->eventAddRow = null;
|
||||
}
|
||||
function clearEvent_AddRowCell()
|
||||
{
|
||||
$this->eventAddRowCell = null;
|
||||
}
|
||||
|
||||
function setEvent_AddRow($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddRow;
|
||||
$this->eventAddRow = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddRowCell($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddRowCell;
|
||||
$this->eventAddRowCell = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
|
||||
function &_onAddRow($aCells, $mConfiguration=null)
|
||||
{
|
||||
$objTableRow =& new clsTr();
|
||||
if (null != $this->eventAddRowCell)
|
||||
$objTableRow->setEvent_AddCell($this->eventAddRowCell);
|
||||
$objTableRow->addCells($aCells, $mConfiguration);
|
||||
return $objTableRow;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTable
|
||||
|
||||
A <xajaxControlContainer> derived class that aids in the construction of HTML
|
||||
tables. Inherently, <xajaxControl> and <xajaxControlContainer> derived classes
|
||||
support <xajaxRequest> based events using the <xajaxControl->setEvent> method.
|
||||
*/
|
||||
class clsTable extends xajaxControlContainer
|
||||
{
|
||||
var $eventAddHeader;
|
||||
var $eventAddHeaderRow;
|
||||
var $eventAddHeaderRowCell;
|
||||
var $eventAddBody;
|
||||
var $eventAddBodyRow;
|
||||
var $eventAddBodyRowCell;
|
||||
var $eventAddFooter;
|
||||
var $eventAddFooterRow;
|
||||
var $eventAddFooterRowCell;
|
||||
|
||||
/*
|
||||
Function: clsTable
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTable($aConfiguration=array())
|
||||
{
|
||||
$this->clearEvent_AddHeader();
|
||||
$this->clearEvent_AddHeaderRow();
|
||||
$this->clearEvent_AddHeaderRowCell();
|
||||
$this->clearEvent_AddBody();
|
||||
$this->clearEvent_AddBodyRow();
|
||||
$this->clearEvent_AddBodyRowCell();
|
||||
$this->clearEvent_AddFooter();
|
||||
$this->clearEvent_AddFooterRow();
|
||||
$this->clearEvent_AddFooterRowCell();
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('table', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function addHeader($aRows, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddHeader) {
|
||||
$objHeader =& call_user_func($this->eventAddHeader, $aRows, $mConfiguration);
|
||||
$this->addChild($objHeader);
|
||||
} else {
|
||||
$objHeader =& $this->_onAddHeader($aRows, $mConfiguration);
|
||||
$this->addChild($objHeader);
|
||||
}
|
||||
}
|
||||
function addBody($aRows, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddBody) {
|
||||
$objBody =& call_user_func($this->eventAddBody, $aRows, $mConfiguration);
|
||||
$this->addChild($objBody);
|
||||
} else {
|
||||
$objBody =& $this->_onAddBody($aRows, $mConfiguration);
|
||||
$this->addChild($objBody);
|
||||
}
|
||||
}
|
||||
function addFooter($aRows, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddFooter) {
|
||||
$objFooter =& call_user_func($this->eventAddFooter, $aRows, $mConfiguration);
|
||||
$this->addChild($objFooter);
|
||||
} else {
|
||||
$objFooter =& $this->_onAddFooter($aRows, $mConfiguration);
|
||||
$this->addChild($objFooter);
|
||||
}
|
||||
}
|
||||
|
||||
function addBodies($aBodies, $mConfiguration=null)
|
||||
{
|
||||
foreach ($aBodies as $aRows)
|
||||
$this->addBody($aRows, $mConfiguration);
|
||||
}
|
||||
|
||||
function clearEvent_AddHeader()
|
||||
{
|
||||
$this->eventAddHeader = null;
|
||||
}
|
||||
function clearEvent_AddHeaderRow()
|
||||
{
|
||||
$this->eventAddHeaderRow = null;
|
||||
}
|
||||
function clearEvent_AddHeaderRowCell()
|
||||
{
|
||||
$this->eventAddHeaderRowCell = null;
|
||||
}
|
||||
function clearEvent_AddBody()
|
||||
{
|
||||
$this->eventAddBody = null;
|
||||
}
|
||||
function clearEvent_AddBodyRow()
|
||||
{
|
||||
$this->eventAddBodyRow = null;
|
||||
}
|
||||
function clearEvent_AddBodyRowCell()
|
||||
{
|
||||
$this->eventAddBodyRowCell = null;
|
||||
}
|
||||
function clearEvent_AddFooter()
|
||||
{
|
||||
$this->eventAddFooter = null;
|
||||
}
|
||||
function clearEvent_AddFooterRow()
|
||||
{
|
||||
$this->eventAddFooterRow = null;
|
||||
}
|
||||
function clearEvent_AddFooterRowCell()
|
||||
{
|
||||
$this->eventAddFooterRowCell = null;
|
||||
}
|
||||
|
||||
function setEvent_AddHeader($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddHeader;
|
||||
$this->eventAddHeader = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddHeaderRow($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddHeaderRow;
|
||||
$this->eventAddHeaderRow = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddHeaderRowCell($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddHeaderRowCell;
|
||||
$this->eventAddHeaderRowCell = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddBody($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddBody;
|
||||
$this->eventAddBody = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddBodyRow($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddBodyRow;
|
||||
$this->eventAddBodyRow = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddBodyRowCell($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddBodyRowCell;
|
||||
$this->eventAddBodyRowCell = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddFooter($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddFooter;
|
||||
$this->eventAddFooter = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddFooterRow($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddFooterRow;
|
||||
$this->eventAddFooterRow = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
function setEvent_AddFooterRowCell($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddFooterRowCell;
|
||||
$this->eventAddFooterRowCell = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
|
||||
function &_onAddHeader($aRows, $mConfiguration)
|
||||
{
|
||||
$objTableHeader =& new clsThead();
|
||||
if (null != $this->eventAddHeaderRow)
|
||||
$objTableHeader->setEvent_AddRow($this->eventAddHeaderRow);
|
||||
if (null != $this->eventAddHeaderRowCell)
|
||||
$objTableHeader->setEvent_AddRowCell($this->eventAddHeaderRowCell);
|
||||
$objTableHeader->addRows($aRows, $mConfiguration);
|
||||
return $objTableHeader;
|
||||
}
|
||||
function &_onAddBody($aRows, $mConfiguration)
|
||||
{
|
||||
$objTableBody =& new clsTbody();
|
||||
if (null != $this->eventAddBodyRow)
|
||||
$objTableBody->setEvent_AddRow($this->eventAddBodyRow);
|
||||
if (null != $this->eventAddBodyRowCell)
|
||||
$objTableBody->setEvent_AddRowCell($this->eventAddBodyRowCell);
|
||||
$objTableBody->addRows($aRows, $mConfiguration);
|
||||
return $objTableBody;
|
||||
}
|
||||
function &_onAddFooter($aRows, $mConfiguration)
|
||||
{
|
||||
$objTableFooter =& new clsTfoot();
|
||||
if (null != $this->eventAddFooterRow)
|
||||
$objTableFooter->setEvent_AddRow($this->eventAddFooterRow);
|
||||
if (null != $this->eventAddFooterRowCell)
|
||||
$objTableFooter->setEvent_AddRowCell($this->eventAddFooterRowCell);
|
||||
$objTableFooter->addRows($aRows, $mConfiguration);
|
||||
return $objTableFooter;
|
||||
}
|
||||
}
|
||||
|
||||
class clsCaption extends xajaxControlContainer
|
||||
{
|
||||
function clsCaption($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('caption', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsColgroup extends xajaxControlContainer
|
||||
{
|
||||
function clsColgroup($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('colgroup', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'optional';
|
||||
}
|
||||
}
|
||||
|
||||
class clsCol extends xajaxControl
|
||||
{
|
||||
function clsCol($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('col');
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsThead
|
||||
*/
|
||||
class clsThead extends clsTableRowContainer
|
||||
{
|
||||
/*
|
||||
Function: clsThead
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsThead($aConfiguration=array())
|
||||
{
|
||||
clsTableRowContainer::clsTableRowContainer('thead', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTbody
|
||||
*/
|
||||
class clsTbody extends clsTableRowContainer
|
||||
{
|
||||
/*
|
||||
Function: clsTbody
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTbody($aConfiguration=array())
|
||||
{
|
||||
clsTableRowContainer::clsTableRowContainer('tbody', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTfoot
|
||||
*/
|
||||
class clsTfoot extends clsTableRowContainer
|
||||
{
|
||||
/*
|
||||
Function: clsTfoot
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTfoot($aConfiguration=array())
|
||||
{
|
||||
clsTableRowContainer::clsTableRowContainer('tfoot', $aConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTr
|
||||
*/
|
||||
class clsTr extends xajaxControlContainer
|
||||
{
|
||||
var $eventAddCell;
|
||||
|
||||
/*
|
||||
Function: clsTr
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTr($aConfiguration=array())
|
||||
{
|
||||
$this->clearEvent_AddCell();
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('tr', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
|
||||
function addCell($mCell, $mConfiguration=null)
|
||||
{
|
||||
if (null != $this->eventAddCell) {
|
||||
$objCell =& call_user_func($this->eventAddCell, $mCell, $mConfiguration);
|
||||
$this->addChild($objCell);
|
||||
} else {
|
||||
$objCell =& $this->_onAddCell($mCell, $mConfiguration);
|
||||
$this->addChild($objCell);
|
||||
}
|
||||
}
|
||||
|
||||
function addCells($aCells, $mConfiguration=null)
|
||||
{
|
||||
foreach ($aCells as $mCell)
|
||||
$this->addCell($mCell, $mConfiguration);
|
||||
}
|
||||
|
||||
function clearEvent_AddCell()
|
||||
{
|
||||
$this->eventAddCell = null;
|
||||
}
|
||||
|
||||
function setEvent_AddCell($mFunction)
|
||||
{
|
||||
$mPrevious = $this->eventAddCell;
|
||||
$this->eventAddCell = $mFunction;
|
||||
return $mPrevious;
|
||||
}
|
||||
|
||||
function &_onAddCell($mCell, $mConfiguration=null)
|
||||
{
|
||||
return new clsTd(array(
|
||||
'child' => new clsLiteral($mCell)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTd
|
||||
*/
|
||||
class clsTd extends xajaxControlContainer
|
||||
{
|
||||
/*
|
||||
Function: clsTd
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTd($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('td', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTh
|
||||
*/
|
||||
class clsTh extends xajaxControlContainer
|
||||
{
|
||||
/*
|
||||
Function: clsTh
|
||||
|
||||
Constructs and initializes an instance of the class.
|
||||
*/
|
||||
function clsTh($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('th', $aConfiguration);
|
||||
|
||||
$this->sClass = '%flow';
|
||||
}
|
||||
}
|
||||
117
libraries/xajax/xajax_controls/misc.inc.php
Normal file
117
libraries/xajax/xajax_controls/misc.inc.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/*
|
||||
File: misc.inc.php
|
||||
|
||||
HTML Control Library - Miscellaneous Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: misc.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains the class declarations for the following HTML Controls:
|
||||
|
||||
(whatever does not fit elsewhere)
|
||||
|
||||
- object, param
|
||||
- a, img, button
|
||||
- area, map
|
||||
|
||||
The following tags are deprecated as of HTML 4.01, therefore, they will not be
|
||||
supported:
|
||||
|
||||
- applet, embed
|
||||
*/
|
||||
|
||||
class clsObject extends xajaxControlContainer
|
||||
{
|
||||
function clsObject($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('object', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
$this->sEndTag = 'required';
|
||||
}
|
||||
}
|
||||
|
||||
class clsParam extends xajaxControl
|
||||
{
|
||||
function clsParam($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('param', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsAnchor extends xajaxControlContainer
|
||||
{
|
||||
function clsAnchor($aConfiguration=array())
|
||||
{
|
||||
if (false == isset($aConfiguration['attributes']))
|
||||
$aConfiguration['attributes'] = array();
|
||||
if (false == isset($aConfiguration['attributes']['href']))
|
||||
$aConfiguration['attributes']['href'] = '#';
|
||||
|
||||
xajaxControlContainer::xajaxControlContainer('a', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
$this->sEndTag = 'required';
|
||||
}
|
||||
|
||||
function setEvent($sEvent, &$objRequest, $aParameters=array(), $sBeforeRequest='if (false == ', $sAfterRequest=') return false; ')
|
||||
{
|
||||
xajaxControl::setEvent($sEvent, $objRequest, $aParameters, $sBeforeRequest, $sAfterRequest);
|
||||
}
|
||||
}
|
||||
|
||||
class clsImg extends xajaxControl
|
||||
{
|
||||
function clsImg($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('img', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
}
|
||||
}
|
||||
|
||||
class clsButton extends xajaxControlContainer
|
||||
{
|
||||
function clsButton($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('button', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
}
|
||||
}
|
||||
|
||||
class clsArea extends xajaxControl
|
||||
{
|
||||
function clsArea($aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl('area', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsMap extends xajaxControlContainer
|
||||
{
|
||||
function clsMap($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('map', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
46
libraries/xajax/xajax_controls/structure.inc.php
Normal file
46
libraries/xajax/xajax_controls/structure.inc.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
File: structure.inc.php
|
||||
|
||||
HTML Control Library - Structure Tags
|
||||
|
||||
Title: xajax HTML control class library
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: structure.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Section: Description
|
||||
|
||||
This file contains the class declarations for the following HTML Controls:
|
||||
|
||||
- div, span
|
||||
*/
|
||||
|
||||
class clsDiv extends xajaxControlContainer
|
||||
{
|
||||
function clsDiv($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('div', $aConfiguration);
|
||||
|
||||
$this->sClass = '%block';
|
||||
}
|
||||
}
|
||||
|
||||
class clsSpan extends xajaxControlContainer
|
||||
{
|
||||
function clsSpan($aConfiguration=array())
|
||||
{
|
||||
xajaxControlContainer::xajaxControlContainer('span', $aConfiguration);
|
||||
|
||||
$this->sClass = '%inline';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,893 @@
|
||||
<?php
|
||||
|
||||
$aAttributes = array(
|
||||
'%bodycolors' => array(
|
||||
'bgcolor',
|
||||
'text',
|
||||
'link',
|
||||
'vlink',
|
||||
'alink'
|
||||
),
|
||||
'%coreattrs' => array(
|
||||
'id',
|
||||
'class',
|
||||
'style',
|
||||
'title'
|
||||
),
|
||||
'%i18n' => array(
|
||||
'lang',
|
||||
'dir'
|
||||
),
|
||||
'%events' => array(
|
||||
'onclick',
|
||||
'ondblclick',
|
||||
'onmousedown',
|
||||
'onmouseup',
|
||||
'onmouseover',
|
||||
'onmousemove',
|
||||
'onmouseout',
|
||||
'onkeypress',
|
||||
'onkeydown',
|
||||
'onkeyup'
|
||||
),
|
||||
'%attrs' => array(
|
||||
'%coreattrs',
|
||||
'%i18n',
|
||||
'%events'
|
||||
),
|
||||
'%align' => array(
|
||||
'left',
|
||||
'center',
|
||||
'right',
|
||||
'justify'
|
||||
),
|
||||
'%cellhalign' => array(
|
||||
'align'
|
||||
),
|
||||
'%cellvalign' => array(
|
||||
'valign'
|
||||
),
|
||||
'TT' => array('%attrs'),
|
||||
'I' => array('%attrs'),
|
||||
'B' => array('%attrs'),
|
||||
'U' => array('%attrs'),
|
||||
'S' => array('%attrs'),
|
||||
'STRIKE' => array('%attrs'),
|
||||
'BIG' => array('%attrs'),
|
||||
'SMALL' => array('%attrs'),
|
||||
'EM' => array('%attrs'),
|
||||
'STRONG' => array('%attrs'),
|
||||
'DFN' => array('%attrs'),
|
||||
'CODE' => array('%attrs'),
|
||||
'SAMP' => array('%attrs'),
|
||||
'KBD' => array('%attrs'),
|
||||
'VAR' => array('%attrs'),
|
||||
'CITE' => array('%attrs'),
|
||||
'ABBR' => array('%attrs'),
|
||||
'ACRONYM' => array('%attrs'),
|
||||
'SUB' => array('%attrs'),
|
||||
'SUP' => array('%attrs'),
|
||||
'SPAN' => array(
|
||||
'%attrs'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'BDO' => array(
|
||||
'%coreattrs',
|
||||
'lang',
|
||||
'dir'
|
||||
),
|
||||
'BASEFONT' => array(
|
||||
'id',
|
||||
'size',
|
||||
'color',
|
||||
'face'
|
||||
),
|
||||
'FONT' => array(
|
||||
'%coreattrs',
|
||||
'%i18n',
|
||||
'size',
|
||||
'color',
|
||||
'face'
|
||||
),
|
||||
'BR' => array(
|
||||
'%coreattrs',
|
||||
'clear'
|
||||
),
|
||||
'BODY' => array(
|
||||
'%attrs',
|
||||
'onload',
|
||||
'onunload',
|
||||
'background',
|
||||
'%bodycolors'
|
||||
),
|
||||
'ADDRESS' => array('%attrs'),
|
||||
'DIV' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'CENTER' => array('%attrs'),
|
||||
'A' => array(
|
||||
'%attrs',
|
||||
'charset',
|
||||
'type',
|
||||
'name',
|
||||
'href',
|
||||
'hreflang',
|
||||
'target',
|
||||
'rel',
|
||||
'rev',
|
||||
'accesskey',
|
||||
'shape',
|
||||
'coords',
|
||||
'tabindex',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
),
|
||||
'MAP' => array(
|
||||
'%attrs',
|
||||
'name'
|
||||
),
|
||||
'AREA' => array(
|
||||
'%attrs',
|
||||
'shape',
|
||||
'coords',
|
||||
'href',
|
||||
'target',
|
||||
'nohref',
|
||||
'alt',
|
||||
'tabindex',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
),
|
||||
'LINK' => array(
|
||||
'%attrs',
|
||||
'charset',
|
||||
'href',
|
||||
'hreflang',
|
||||
'type',
|
||||
'rel',
|
||||
'rev',
|
||||
'media',
|
||||
'target'
|
||||
),
|
||||
'IMG' => array(
|
||||
'%attrs',
|
||||
'src',
|
||||
'alt',
|
||||
'longdesc',
|
||||
'name',
|
||||
'height',
|
||||
'width',
|
||||
'usemap',
|
||||
'ismap',
|
||||
'align',
|
||||
'border',
|
||||
'hspace',
|
||||
'vspace'
|
||||
),
|
||||
'OBJECT' => array(
|
||||
'%attrs',
|
||||
'declare',
|
||||
'classid',
|
||||
'codebase',
|
||||
'data',
|
||||
'type',
|
||||
'codetype',
|
||||
'archive',
|
||||
'standby',
|
||||
'height',
|
||||
'width',
|
||||
'usemap',
|
||||
'name',
|
||||
'tabindex',
|
||||
'align',
|
||||
'border',
|
||||
'hspace',
|
||||
'vspace'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'PARAM' => array(
|
||||
'id',
|
||||
'name',
|
||||
'value',
|
||||
'valuetype',
|
||||
'type'
|
||||
),
|
||||
'APPLET' => array(
|
||||
'%coreattrs',
|
||||
'codebase',
|
||||
'archive',
|
||||
'code',
|
||||
'object',
|
||||
'alt',
|
||||
'name',
|
||||
'width',
|
||||
'height',
|
||||
'align',
|
||||
'hspace',
|
||||
'vspace'
|
||||
),
|
||||
'HR' => array(
|
||||
'%attrs',
|
||||
'align',
|
||||
'noshade',
|
||||
'size',
|
||||
'width'
|
||||
),
|
||||
'P' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H1' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H2' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H3' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H4' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H5' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'H6' => array(
|
||||
'%attrs',
|
||||
'%align'
|
||||
),
|
||||
'PRE' => array(
|
||||
'%attrs',
|
||||
'width'
|
||||
),
|
||||
'Q' => array(
|
||||
'%attrs',
|
||||
'cite'
|
||||
),
|
||||
'BLOCKQUOTE' => array(
|
||||
'%attrs',
|
||||
'cite'
|
||||
),
|
||||
'INS' => array(
|
||||
'%attrs',
|
||||
'cite',
|
||||
'datetime'
|
||||
),
|
||||
'DEL' => array(
|
||||
'%attrs',
|
||||
'cite',
|
||||
'datetime'
|
||||
),
|
||||
'DL' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'DT' => array('%attrs'),
|
||||
'DD' => array('%attrs'),
|
||||
'OL' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'compact',
|
||||
'start'
|
||||
),
|
||||
'UL' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'compact'
|
||||
),
|
||||
'DIR' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'MENU' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'LI' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'value'
|
||||
),
|
||||
'FORM' => array(
|
||||
'%attrs',
|
||||
'action',
|
||||
'method',
|
||||
'enctype',
|
||||
'accept',
|
||||
'name',
|
||||
'onsubmit',
|
||||
'onreset',
|
||||
'target',
|
||||
'accept-charset'
|
||||
),
|
||||
'LABEL' => array(
|
||||
'%attrs',
|
||||
'for',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
),
|
||||
'INPUT' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'name',
|
||||
'value',
|
||||
'checked',
|
||||
'disabled',
|
||||
'readonly',
|
||||
'size',
|
||||
'maxlength',
|
||||
'src',
|
||||
'alt',
|
||||
'usemap',
|
||||
'ismap',
|
||||
'tabindex',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur',
|
||||
'onselect',
|
||||
'onchange',
|
||||
'accept',
|
||||
'align'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'SELECT' => array(
|
||||
'%attrs',
|
||||
'name',
|
||||
'size',
|
||||
'multiple',
|
||||
'disabled',
|
||||
'tabindex',
|
||||
'onfocus',
|
||||
'onblur',
|
||||
'onchange'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'OPTGROUP' => array(
|
||||
'%attrs',
|
||||
'disabled',
|
||||
'label'
|
||||
),
|
||||
'OPTION' => array(
|
||||
'%attrs',
|
||||
'selected',
|
||||
'disabled',
|
||||
'label',
|
||||
'value'
|
||||
),
|
||||
'TEXTAREA' => array(
|
||||
'%attrs',
|
||||
'name',
|
||||
'rows',
|
||||
'cols',
|
||||
'disabled',
|
||||
'readonly',
|
||||
'tabindex',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur',
|
||||
'onselect',
|
||||
'onchange'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'FIELDSET' => array('%attrs'),
|
||||
'LEGEND' => array(
|
||||
'%attrs',
|
||||
'accesskey',
|
||||
'align'
|
||||
),
|
||||
'BUTTON' => array(
|
||||
'%attrs',
|
||||
'name',
|
||||
'value',
|
||||
'type',
|
||||
'disabled',
|
||||
'tabindex',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
// ,
|
||||
// '%reserved'
|
||||
),
|
||||
'TABLE' => array(
|
||||
'%attrs',
|
||||
'summary',
|
||||
'width',
|
||||
'border',
|
||||
'frame',
|
||||
'rules',
|
||||
'cellspacing',
|
||||
'cellpadding',
|
||||
'align',
|
||||
'bgcolor',
|
||||
// '%reserved',
|
||||
'datapagesize'
|
||||
),
|
||||
'CAPTION' => array('%attrs', 'align'),
|
||||
'COLGROUP' => array(
|
||||
'%attrs',
|
||||
'span',
|
||||
'width',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'COL' => array(
|
||||
'%attrs',
|
||||
'span',
|
||||
'width',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'THEAD' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'TBODY' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'TFOOT' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'TR' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'bgcolor'
|
||||
),
|
||||
'TH' => array(
|
||||
'%attrs',
|
||||
'abbr',
|
||||
'axis',
|
||||
'headers',
|
||||
'scope',
|
||||
'rowspan',
|
||||
'colspan',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'nowrap',
|
||||
'bgcolor',
|
||||
'width',
|
||||
'height'
|
||||
),
|
||||
'TD' => array(
|
||||
'%attrs',
|
||||
'abbr',
|
||||
'axis',
|
||||
'headers',
|
||||
'scope',
|
||||
'rowspan',
|
||||
'colspan',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'nowrap',
|
||||
'bgcolor',
|
||||
'width',
|
||||
'height'
|
||||
),
|
||||
'IFRAME' => array(
|
||||
'%coreattrs',
|
||||
'longdesc',
|
||||
'name',
|
||||
'src',
|
||||
'frameborder',
|
||||
'marginwidth',
|
||||
'marginheight',
|
||||
'scrolling',
|
||||
'align',
|
||||
'height',
|
||||
'width'
|
||||
),
|
||||
'NOFRAMES' => array('%attrs'),
|
||||
'HEAD' => array(
|
||||
'%i18n',
|
||||
'profile'
|
||||
),
|
||||
'TITLE' => array('%i18n'),
|
||||
'BASE' => array(
|
||||
'href',
|
||||
'target'
|
||||
),
|
||||
'META' => array(
|
||||
'%i18n',
|
||||
'http-equiv',
|
||||
'name',
|
||||
'content',
|
||||
'scheme'
|
||||
),
|
||||
'STYLE' => array(
|
||||
'%i18n',
|
||||
'type',
|
||||
'media',
|
||||
'title'
|
||||
),
|
||||
'SCRIPT' => array(
|
||||
'charset',
|
||||
'type',
|
||||
'language',
|
||||
'src',
|
||||
'defer',
|
||||
'event',
|
||||
'for'
|
||||
),
|
||||
'NOSCRIPT' => array('%attrs'),
|
||||
'HTML' => array('%i18n') // , '%version')
|
||||
);
|
||||
|
||||
$aTags = array(
|
||||
'%heading' => array(
|
||||
'H1',
|
||||
'H2',
|
||||
'H3',
|
||||
'H4',
|
||||
'H5',
|
||||
'H6'
|
||||
),
|
||||
'%list' => array(
|
||||
'UL',
|
||||
'OL',
|
||||
'DIR',
|
||||
'MENU'
|
||||
),
|
||||
'%preformatted' => array('PRE'),
|
||||
'%fontstyle' => array(
|
||||
'TT',
|
||||
'I',
|
||||
'B',
|
||||
'U',
|
||||
'S',
|
||||
'STRIKE',
|
||||
'BIG',
|
||||
'SMALL'
|
||||
),
|
||||
'%phrase' => array(
|
||||
'EM',
|
||||
'STRONG',
|
||||
'DFN',
|
||||
'CODE',
|
||||
'SAMP',
|
||||
'KBD',
|
||||
'VAR',
|
||||
'CITE',
|
||||
'ABBR',
|
||||
'ACRONYM'
|
||||
),
|
||||
'%special' => array(
|
||||
'A',
|
||||
'IMG',
|
||||
'APPLET',
|
||||
'OBJECT',
|
||||
'FONT',
|
||||
'BASEFONT',
|
||||
'BR',
|
||||
'SCRIPT',
|
||||
'MAP',
|
||||
'Q',
|
||||
'SUB',
|
||||
'SUP',
|
||||
'SPAN',
|
||||
'BDO',
|
||||
'IFRAME'
|
||||
),
|
||||
'%formctrl' => array(
|
||||
'INPUT',
|
||||
'SELECT',
|
||||
'TEXTAREA',
|
||||
'LABEL',
|
||||
'BUTTON'
|
||||
),
|
||||
'%inline' => array(
|
||||
'CDATA',
|
||||
'%fontstyle',
|
||||
'%phrase',
|
||||
'%special',
|
||||
'%formctrl'
|
||||
),
|
||||
'%block' => array(
|
||||
'P',
|
||||
'%heading',
|
||||
'%list',
|
||||
'%preformatted',
|
||||
'DL',
|
||||
'DIV',
|
||||
'CENTER',
|
||||
'NOSCRIPT',
|
||||
'NOFRAMES',
|
||||
'BLOCKQUOTE',
|
||||
'INS',
|
||||
'DEL',
|
||||
'FORM',
|
||||
'ISINDEX',
|
||||
'HR',
|
||||
'TABLE',
|
||||
'FIELDSET',
|
||||
'ADDRESS'
|
||||
),
|
||||
'%flow' => array(
|
||||
'%block',
|
||||
'%inline'
|
||||
),
|
||||
|
||||
'TT' => array('%inline'), // fontstyle
|
||||
'I' => array('%inline'),
|
||||
'B' => array('%inline'),
|
||||
'U' => array('%inline'),
|
||||
'S' => array('%inline'),
|
||||
'STRIKE' => array('%inline'),
|
||||
'BIG' => array('%inline'),
|
||||
'SMALL' => array('%inline'),
|
||||
|
||||
'EM' => array('%inline'), // phrase
|
||||
'STRONG' => array('%inline'),
|
||||
'DFN' => array('%inline'),
|
||||
'CODE' => array('%inline'),
|
||||
'SAMP' => array('%inline'),
|
||||
'KBD' => array('%inline'),
|
||||
'VAR' => array('%inline'),
|
||||
'CITE' => array('%inline'),
|
||||
'ABBR' => array('%inline'),
|
||||
'ACRONYM' => array('%inline'),
|
||||
|
||||
'SUB' => array('%inline'),
|
||||
'SUP' => array('%inline'),
|
||||
'SPAN' => array('%inline'),
|
||||
'BDO' => array('%inline'),
|
||||
'BASEFONT' => array(),
|
||||
'FONT' => array('%inline'),
|
||||
'BR' => array(),
|
||||
'BODY' => array(
|
||||
'%flow',
|
||||
'INS',
|
||||
'DEL'
|
||||
),
|
||||
'ADDRESS' => array(
|
||||
'%inline',
|
||||
'P'
|
||||
),
|
||||
'DIV' => array('%flow'),
|
||||
'CENTER' => array('%flow'),
|
||||
'A' => array('%inline'),
|
||||
'MAP' => array(
|
||||
'%block',
|
||||
'AREA'
|
||||
),
|
||||
'AREA' => array(),
|
||||
'LINK' => array(),
|
||||
'IMG' => array(),
|
||||
'OBJECT' => array(
|
||||
'PARAM',
|
||||
'%flow'
|
||||
),
|
||||
'PARAM' => array(),
|
||||
'HR' => array(),
|
||||
'P' => array('%inline'),
|
||||
'H1' => array('%inline'),
|
||||
'H2' => array('%inline'),
|
||||
'H3' => array('%inline'),
|
||||
'H4' => array('%inline'),
|
||||
'H5' => array('%inline'),
|
||||
'H6' => array('%inline'),
|
||||
'PRE' => array('%inline'),
|
||||
'Q' => array('%inline'),
|
||||
'BLOCKQUOTE' => array('%flow'),
|
||||
'INS' => array('%flow'),
|
||||
'DEL' => array('%flow'),
|
||||
'DL' => array(
|
||||
'DT',
|
||||
'DD'
|
||||
),
|
||||
'DT' => array('%inline'),
|
||||
'DD' => array('%flow'),
|
||||
'OL' => array('LI'),
|
||||
'UL' => array('LI'),
|
||||
'DIR' => array('LI'),
|
||||
'MENU' => array('LI'),
|
||||
'LI' => array('%flow'),
|
||||
'FORM' => array('%flow'),
|
||||
'LABEL' => array('%inline'),
|
||||
'INPUT' => array(),
|
||||
'SELECT' => array(
|
||||
'OPTGROUP',
|
||||
'OPTION'
|
||||
),
|
||||
'OPTGROUP' => array('OPTION'),
|
||||
'OPTION' => array('CDATA'),
|
||||
'TEXTAREA' => array('CDATA'),
|
||||
'FIELDSET' => array(
|
||||
'CDATA',
|
||||
'LEGEND',
|
||||
'%flow'
|
||||
),
|
||||
'LEGEND' => array('%inline'),
|
||||
'BUTTON' => array('%flow'),
|
||||
'TABLE' => array(
|
||||
'CAPTION',
|
||||
'COL',
|
||||
'COLGROUP',
|
||||
'THEAD',
|
||||
'TFOOT',
|
||||
'TBODY'
|
||||
),
|
||||
'CAPTION' => array('%inline'),
|
||||
'THEAD' => array('TR'),
|
||||
'TFOOT' => array('TR'),
|
||||
'TBODY' => array('TR'),
|
||||
'COLGROUP' => array('COL'),
|
||||
'COL' => array(),
|
||||
'TR' => array(
|
||||
'TH',
|
||||
'TD'
|
||||
),
|
||||
'TH' => array('%flow'),
|
||||
'TD' => array('%flow'),
|
||||
'IFRAME' => array('%flow'),
|
||||
'NOFRAMES' => array('%flow'),
|
||||
'HEAD' => array(
|
||||
'TITLE',
|
||||
'BASE',
|
||||
'SCRIPT',
|
||||
'STYLE',
|
||||
'META',
|
||||
'LINK',
|
||||
'OBJECT'
|
||||
),
|
||||
'TITLE' => array('CDATA'),
|
||||
'META' => array(),
|
||||
'STYLE' => array('CDATA'),
|
||||
'SCRIPT' => array('CDATA'),
|
||||
'NOSCRIPT' => array('%flow'),
|
||||
'BASE' => array(),
|
||||
'HTML' => array(
|
||||
'HEAD',
|
||||
'BODY'
|
||||
),
|
||||
'DOCUMENT' => array(
|
||||
'DOCTYPE',
|
||||
'HTML'
|
||||
)
|
||||
);
|
||||
|
||||
$aExclusions = array(
|
||||
'A' => array('A'),
|
||||
'PRE' => array(
|
||||
'IMG',
|
||||
'OBJECT',
|
||||
'APPLET',
|
||||
'BIG',
|
||||
'SMALL',
|
||||
'SUB',
|
||||
'SUP',
|
||||
'FONT',
|
||||
'BASEFONT'
|
||||
),
|
||||
'DIR' => array('%block'),
|
||||
'MENU' => array('%block'),
|
||||
'FORM' => array('FORM'),
|
||||
'LABEL' => array('LABEL'),
|
||||
'BUTTON' => array(
|
||||
'A',
|
||||
'%formctrl',
|
||||
'FORM',
|
||||
'ISINDEX',
|
||||
'FIELDSET',
|
||||
'IFRAME'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$aRequiredAttributes = array(
|
||||
'style' => array('type'),
|
||||
'script' => array('type'),
|
||||
'meta' => array('content'),
|
||||
'optgroup' => array('label'),
|
||||
'textarea' => array('rows', 'cols'),
|
||||
'img' => array('src', 'alt')
|
||||
);
|
||||
|
||||
|
||||
class clsValidator
|
||||
{
|
||||
var $aTags;
|
||||
var $aAttributes;
|
||||
var $aRequiredAttributes;
|
||||
|
||||
function clsValidator()
|
||||
{
|
||||
global $aTags;
|
||||
global $aAttributes;
|
||||
global $aRequiredAttributes;
|
||||
|
||||
$this->aTags = array();
|
||||
$this->aAttributes = array();
|
||||
$this->aRequiredAttributes = array();
|
||||
|
||||
foreach (array_keys($aTags) as $sTag)
|
||||
{
|
||||
$this->aTags[$sTag] = array();
|
||||
$this->_expand($this->aTags[$sTag], $aTags[$sTag], $aTags);
|
||||
}
|
||||
|
||||
foreach (array_keys($aAttributes) as $sAttribute)
|
||||
{
|
||||
$this->aAttributes[$sAttribute] = array();
|
||||
$this->_expand($this->aAttributes[$sAttribute], $aAttributes[$sAttribute], $aAttributes);
|
||||
}
|
||||
|
||||
foreach (array_keys($aRequiredAttributes) as $sElement)
|
||||
{
|
||||
$this->aRequiredAttributes[$sElement] = array();
|
||||
$this->_expand($this->aRequiredAttributes[$sElement], $aRequiredAttributes[$sElement], $aRequiredAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new clsValidator();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function _expand(&$aDestination, &$aSource, &$aDictionary)
|
||||
{
|
||||
foreach ($aSource as $sChild)
|
||||
{
|
||||
if ('%' == substr($sChild, 0, 1)) {
|
||||
$this->_expand($aDestination, $aDictionary[$sChild], $aDictionary);
|
||||
} else
|
||||
$aDestination[] = $sChild;
|
||||
}
|
||||
}
|
||||
|
||||
function elementValid($sElement)
|
||||
{
|
||||
return isset($this->aTags[strtoupper($sElement)]);
|
||||
}
|
||||
|
||||
function attributeValid($sElement, $sAttribute)
|
||||
{
|
||||
if (false == isset($this->aAttributes[strtoupper($sElement)]))
|
||||
return false;
|
||||
return in_array(strtolower($sAttribute), $this->aAttributes[strtoupper($sElement)]);
|
||||
}
|
||||
|
||||
function childValid($sParent, $sElement)
|
||||
{
|
||||
if (false == isset($this->aTags[strtoupper($sParent)]))
|
||||
return false;
|
||||
return in_array(strtoupper($sElement), $this->aTags[strtoupper($sParent)]);
|
||||
}
|
||||
|
||||
// verify that required attributes have been specified
|
||||
function checkRequiredAttributes($sElement, &$aAttributes, &$sMissing)
|
||||
{
|
||||
if (isset($this->aRequiredAttributes[strtolower($sElement)]))
|
||||
foreach ($this->aRequiredAttributes[strtolower($sElement)] as $sRequiredAttribute)
|
||||
if (false == isset($aAttributes[$sRequiredAttribute]))
|
||||
{
|
||||
$sMissing = $sRequiredAttribute;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,923 @@
|
||||
<?php
|
||||
|
||||
$aAttributes = array(
|
||||
'%coreattrs' => array(
|
||||
'id',
|
||||
'class',
|
||||
'style',
|
||||
'title'
|
||||
),
|
||||
'%i18n' => array(
|
||||
'lang',
|
||||
'xml:lang',
|
||||
'dir'
|
||||
),
|
||||
'%events' => array(
|
||||
'onclick',
|
||||
'ondblclick',
|
||||
'onmousedown',
|
||||
'onmouseup',
|
||||
'onmouseover',
|
||||
'onmousemove',
|
||||
'onmouseout',
|
||||
'onkeypress',
|
||||
'onkeydown',
|
||||
'onkeyup'
|
||||
),
|
||||
'%focus' => array(
|
||||
'accesskey',
|
||||
'tabindex',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
),
|
||||
'%attrs' => array(
|
||||
'%coreattrs',
|
||||
'%i18n',
|
||||
'%events'
|
||||
),
|
||||
'%TextAlign' => array('align'),
|
||||
'html' => array(
|
||||
'%i18n',
|
||||
'id',
|
||||
'xmlns'
|
||||
),
|
||||
'head' => array(
|
||||
'%i18n',
|
||||
'id',
|
||||
'profile'
|
||||
),
|
||||
'title' => array(
|
||||
'%i18n',
|
||||
'id'
|
||||
),
|
||||
'base' => array(
|
||||
'id',
|
||||
'href',
|
||||
'target'
|
||||
),
|
||||
'meta' => array(
|
||||
'%i18n',
|
||||
'id',
|
||||
'http-equiv',
|
||||
'name',
|
||||
'content',
|
||||
'scheme'
|
||||
),
|
||||
'link' => array(
|
||||
'%attrs',
|
||||
'charset',
|
||||
'href',
|
||||
'hreflang',
|
||||
'type',
|
||||
'rel',
|
||||
'rev',
|
||||
'media',
|
||||
'target'
|
||||
),
|
||||
'style' => array(
|
||||
'%i18n',
|
||||
'id',
|
||||
'type',
|
||||
'media',
|
||||
'title',
|
||||
'xml:space'
|
||||
),
|
||||
'script' => array(
|
||||
'id',
|
||||
'charset',
|
||||
'type',
|
||||
'language',
|
||||
'src',
|
||||
'defer',
|
||||
'xml:space'
|
||||
),
|
||||
'noscript' => array('%attrs'),
|
||||
'iframe' => array(
|
||||
'%coreattrs',
|
||||
'longdesc',
|
||||
'name',
|
||||
'src',
|
||||
'frameborder',
|
||||
'marginwidth',
|
||||
'marginheight',
|
||||
'scrolling',
|
||||
'align',
|
||||
'height',
|
||||
'width'
|
||||
),
|
||||
'noframes' => array('%attrs'),
|
||||
'body' => array(
|
||||
'%attrs',
|
||||
'onload',
|
||||
'onunload',
|
||||
'background',
|
||||
'bgcolor',
|
||||
'text',
|
||||
'link',
|
||||
'vlink',
|
||||
'alink'
|
||||
),
|
||||
'div' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'p' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h1' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h2' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h3' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h4' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h5' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'h6' => array(
|
||||
'%attrs',
|
||||
'%TextAlign'
|
||||
),
|
||||
'ul' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'compact'
|
||||
),
|
||||
'ol' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'compact',
|
||||
'start'
|
||||
),
|
||||
'menu' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'dir' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'li' => array(
|
||||
'%attrs',
|
||||
'type',
|
||||
'value'
|
||||
),
|
||||
'dl' => array(
|
||||
'%attrs',
|
||||
'compact'
|
||||
),
|
||||
'dt' => array('%attrs'),
|
||||
'dd' => array('%attrs'),
|
||||
'address' => array(
|
||||
'%attrs'
|
||||
),
|
||||
'hr' => array(
|
||||
'%attrs',
|
||||
'align',
|
||||
'noshade',
|
||||
'size',
|
||||
'width'
|
||||
),
|
||||
'pre' => array(
|
||||
'%attrs',
|
||||
'width',
|
||||
'xml:space'
|
||||
),
|
||||
'blockquote' => array(
|
||||
'%attrs',
|
||||
'cite'
|
||||
),
|
||||
'center' => array('%attrs'),
|
||||
'ins' => array(
|
||||
'%attrs',
|
||||
'cite',
|
||||
'datetime'
|
||||
),
|
||||
'del' => array(
|
||||
'%attrs',
|
||||
'cite',
|
||||
'datetime'
|
||||
),
|
||||
'a' => array(
|
||||
'%attrs',
|
||||
'%focus',
|
||||
'charset',
|
||||
'type',
|
||||
'name',
|
||||
'href',
|
||||
'hreflang',
|
||||
'rel',
|
||||
'rev',
|
||||
'shape',
|
||||
'coords',
|
||||
'target'
|
||||
),
|
||||
'span' => array('%attrs'),
|
||||
'bdo' => array(
|
||||
'%coreattrs',
|
||||
'%events',
|
||||
'lang',
|
||||
'xml:lang',
|
||||
'dir'
|
||||
),
|
||||
'br' => array(
|
||||
'%coreattrs',
|
||||
'clear'
|
||||
),
|
||||
'em' => array('%attrs'),
|
||||
'strong' => array('%attrs'),
|
||||
'dfn' => array('%attrs'),
|
||||
'code' => array('%attrs'),
|
||||
'samp' => array('%attrs'),
|
||||
'kbd' => array('%attrs'),
|
||||
'var' => array('%attrs'),
|
||||
'cite' => array('%attrs'),
|
||||
'abbr' => array('%attrs'),
|
||||
'acronym' => array('%attrs'),
|
||||
'q' => array('%attrs','cite'),
|
||||
'sub' => array('%attrs'),
|
||||
'sup' => array('%attrs'),
|
||||
'tt' => array('%attrs'),
|
||||
'i' => array('%attrs'),
|
||||
'b' => array('%attrs'),
|
||||
'big' => array('%attrs'),
|
||||
'small' => array('%attrs'),
|
||||
'u' => array('%attrs'),
|
||||
's' => array('%attrs'),
|
||||
'strike' => array('%attrs'),
|
||||
'basefont' => array(
|
||||
'id',
|
||||
'size',
|
||||
'color',
|
||||
'face'
|
||||
),
|
||||
'font' => array(
|
||||
'%coreattrs',
|
||||
'%i18n',
|
||||
'size',
|
||||
'color',
|
||||
'face'
|
||||
),
|
||||
'object' => array(
|
||||
'%attrs',
|
||||
'declare',
|
||||
'classid',
|
||||
'codebase',
|
||||
'data',
|
||||
'type',
|
||||
'codetype',
|
||||
'archive',
|
||||
'standby',
|
||||
'height',
|
||||
'width',
|
||||
'usemap',
|
||||
'name',
|
||||
'tabindex',
|
||||
'align',
|
||||
'border',
|
||||
'hspace',
|
||||
'vspace'
|
||||
),
|
||||
'param' => array(
|
||||
'id',
|
||||
'name',
|
||||
'value',
|
||||
'valuetype',
|
||||
'type'
|
||||
),
|
||||
'applet' => array(
|
||||
'%coreattrs',
|
||||
'codebase',
|
||||
'archive',
|
||||
'code',
|
||||
'object',
|
||||
'alt',
|
||||
'name',
|
||||
'width',
|
||||
'height',
|
||||
'align',
|
||||
'hspace',
|
||||
'vspace'
|
||||
),
|
||||
'img' => array(
|
||||
'%attrs',
|
||||
'src',
|
||||
'alt',
|
||||
'name',
|
||||
'longdesc',
|
||||
'height',
|
||||
'width',
|
||||
'usemap',
|
||||
'ismap',
|
||||
'align',
|
||||
'border',
|
||||
'hspace',
|
||||
'vspace'
|
||||
),
|
||||
'map' => array(
|
||||
'%i18n',
|
||||
'%events',
|
||||
'id',
|
||||
'class',
|
||||
'style',
|
||||
'title',
|
||||
'name'
|
||||
),
|
||||
'area' => array(
|
||||
'%attrs',
|
||||
'%focus',
|
||||
'shape',
|
||||
'coords',
|
||||
'href',
|
||||
'nohref',
|
||||
'alt',
|
||||
'target'
|
||||
),
|
||||
'form' => array(
|
||||
'%attrs',
|
||||
'action',
|
||||
'method',
|
||||
'name',
|
||||
'enctype',
|
||||
'onsubmit',
|
||||
'onreset',
|
||||
'accept',
|
||||
'accept-charset',
|
||||
'target'
|
||||
),
|
||||
'label' => array(
|
||||
'%attrs',
|
||||
'for',
|
||||
'accesskey',
|
||||
'onfocus',
|
||||
'onblur'
|
||||
),
|
||||
'input' => array(
|
||||
'%attrs',
|
||||
'%focus',
|
||||
'type',
|
||||
'name',
|
||||
'value',
|
||||
'checked',
|
||||
'disabled',
|
||||
'readonly',
|
||||
'size',
|
||||
'maxlength',
|
||||
'src',
|
||||
'alt',
|
||||
'usemap',
|
||||
'onselect',
|
||||
'onchange',
|
||||
'accept',
|
||||
'align'
|
||||
),
|
||||
'select' => array(
|
||||
'%attrs',
|
||||
'name',
|
||||
'size',
|
||||
'multiple',
|
||||
'disabled',
|
||||
'tabindex',
|
||||
'onfocus',
|
||||
'onblur',
|
||||
'onchange'
|
||||
),
|
||||
'optgroup' => array(
|
||||
'%attrs',
|
||||
'disabled',
|
||||
'label'
|
||||
),
|
||||
'option' => array(
|
||||
'%attrs',
|
||||
'selected',
|
||||
'disabled',
|
||||
'label',
|
||||
'value'
|
||||
),
|
||||
'textarea' => array(
|
||||
'%attrs',
|
||||
'%focus',
|
||||
'name',
|
||||
'rows',
|
||||
'cols',
|
||||
'disabled',
|
||||
'readonly',
|
||||
'onselect',
|
||||
'onchange'
|
||||
),
|
||||
'fieldset' => array('%attrs'),
|
||||
'legend' => array(
|
||||
'%attrs',
|
||||
'accesskey',
|
||||
'align'
|
||||
),
|
||||
'button' => array(
|
||||
'%attrs',
|
||||
'%focus',
|
||||
'name',
|
||||
'value',
|
||||
'type',
|
||||
'disabled'
|
||||
),
|
||||
'isindex' => array(
|
||||
'%coreattrs',
|
||||
'%i18n',
|
||||
'prompt'
|
||||
),
|
||||
'table' => array(
|
||||
'%attrs',
|
||||
'summary',
|
||||
'width',
|
||||
'border',
|
||||
'frame',
|
||||
'rules',
|
||||
'cellspacing',
|
||||
'cellpadding',
|
||||
'align',
|
||||
'bgcolor'
|
||||
),
|
||||
'caption' => array(
|
||||
'%attrs',
|
||||
'align'
|
||||
),
|
||||
'colgroup' => array(
|
||||
'%attrs',
|
||||
'span',
|
||||
'width',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'col' => array(
|
||||
'%attrs',
|
||||
'span',
|
||||
'width',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'thead' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'tfoot' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'tbody' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign'
|
||||
),
|
||||
'tr' => array(
|
||||
'%attrs',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'bgcolor'
|
||||
),
|
||||
'th' => array(
|
||||
'%attrs',
|
||||
'abbr',
|
||||
'axis',
|
||||
'headers',
|
||||
'scope',
|
||||
'rowspan',
|
||||
'colspan',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'nowrap',
|
||||
'bgcolor',
|
||||
'width',
|
||||
'height'
|
||||
),
|
||||
'td' => array(
|
||||
'%attrs',
|
||||
'abbr',
|
||||
'axis',
|
||||
'headers',
|
||||
'scope',
|
||||
'rowspan',
|
||||
'colspan',
|
||||
'%cellhalign',
|
||||
'%cellvalign',
|
||||
'nowrap',
|
||||
'bgcolor',
|
||||
'width',
|
||||
'height'
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$aTags = array(
|
||||
'%special.extra' => array(
|
||||
'object',
|
||||
'applet',
|
||||
'img',
|
||||
'map',
|
||||
'iframe'
|
||||
),
|
||||
'%special.basic' => array(
|
||||
'br',
|
||||
'span',
|
||||
'bdo'
|
||||
),
|
||||
'%special' => array(
|
||||
'%special.basic',
|
||||
'%special.extra'
|
||||
),
|
||||
'%fontstyle.extra' => array(
|
||||
'big',
|
||||
'small',
|
||||
'font',
|
||||
'basefont'
|
||||
),
|
||||
'%fontstyle.basic' => array(
|
||||
'tt',
|
||||
'i',
|
||||
'b',
|
||||
'u',
|
||||
's',
|
||||
'strike'
|
||||
),
|
||||
'%fontstyle' => array(
|
||||
'%fontstyle.basic',
|
||||
'%fontstyle.extra'
|
||||
),
|
||||
'%phrase.extra' => array(
|
||||
'sub',
|
||||
'sup'
|
||||
),
|
||||
'%phrase.basic' => array(
|
||||
'em',
|
||||
'strong',
|
||||
'dfn',
|
||||
'code',
|
||||
'q',
|
||||
'samp',
|
||||
'kbd',
|
||||
'var',
|
||||
'cite',
|
||||
'abbr',
|
||||
'acronym'
|
||||
),
|
||||
'%phrase' => array(
|
||||
'%phrase.basic',
|
||||
'%phrase.extra'
|
||||
),
|
||||
'%inline.forms' => array(
|
||||
'input',
|
||||
'select',
|
||||
'textarea',
|
||||
'label',
|
||||
'button'
|
||||
),
|
||||
'%misc.inline' => array(
|
||||
'ins',
|
||||
'del',
|
||||
'script'
|
||||
),
|
||||
'%misc' => array(
|
||||
'noscript',
|
||||
'%misc.inline'
|
||||
),
|
||||
'%inline' => array(
|
||||
'a',
|
||||
'%special',
|
||||
'%fontstyle',
|
||||
'%phrase',
|
||||
'%inline.forms'
|
||||
),
|
||||
'%Inline' => array(
|
||||
'cdata',
|
||||
'%inline',
|
||||
'%misc.inline'
|
||||
),
|
||||
'%heading' => array(
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6'
|
||||
),
|
||||
'%lists' => array(
|
||||
'ul',
|
||||
'ol',
|
||||
'dl',
|
||||
'menu',
|
||||
'dir'
|
||||
),
|
||||
'%blocktext' => array(
|
||||
'pre',
|
||||
'hr',
|
||||
'blockquote',
|
||||
'address',
|
||||
'center',
|
||||
'noframes'
|
||||
),
|
||||
'%block' => array(
|
||||
'p',
|
||||
'%heading',
|
||||
'div',
|
||||
'%lists',
|
||||
'%blocktext',
|
||||
'isindex',
|
||||
'fieldset',
|
||||
'table'
|
||||
),
|
||||
'%Flow' => array(
|
||||
'cdata',
|
||||
'%block',
|
||||
'form',
|
||||
'%inline',
|
||||
'%misc'
|
||||
),
|
||||
'%a.content' => array(
|
||||
'cdata',
|
||||
'%special',
|
||||
'%fontstyle',
|
||||
'%phrase',
|
||||
'%inline.forms',
|
||||
'%misc.inline'
|
||||
),
|
||||
'%pre.content' => array(
|
||||
'cdata',
|
||||
'a',
|
||||
'%special.basic',
|
||||
'%fontstyle.basic',
|
||||
'%phrase.basic',
|
||||
'%inline.forms',
|
||||
'%misc.inline'
|
||||
),
|
||||
'%form.content' => array(
|
||||
'cdata',
|
||||
'%block',
|
||||
'%inline',
|
||||
'%misc'
|
||||
),
|
||||
'%button.content' => array(
|
||||
'cdata',
|
||||
'p',
|
||||
'%heading',
|
||||
'div',
|
||||
'%lists',
|
||||
'%blocktext',
|
||||
'table',
|
||||
'br',
|
||||
'span',
|
||||
'bdo',
|
||||
'object',
|
||||
'applet',
|
||||
'img',
|
||||
'map',
|
||||
'%fontstyle',
|
||||
'%phrase',
|
||||
'%misc'
|
||||
),
|
||||
'%head.misc' => array(
|
||||
'script',
|
||||
'style',
|
||||
'meta',
|
||||
'link',
|
||||
'object'
|
||||
),
|
||||
'html' => array(
|
||||
'head',
|
||||
'body'
|
||||
),
|
||||
'head' => array(
|
||||
'%head.misc',
|
||||
'title',
|
||||
'base'
|
||||
),
|
||||
'title' => array('cdata'),
|
||||
'base' => array(),
|
||||
'meta' => array(),
|
||||
'link' => array(),
|
||||
'style' => array('cdata'),
|
||||
'script' => array('cdata'),
|
||||
'noscript' => array('%Flow'),
|
||||
'iframe' => array('%Flow'),
|
||||
'noframes' => array('%Flow'),
|
||||
'body' => array('%Flow'),
|
||||
'div' => array('%Flow'),
|
||||
'p' => array('%Inline'),
|
||||
'h1' => array('%Inline'),
|
||||
'h2' => array('%Inline'),
|
||||
'h3' => array('%Inline'),
|
||||
'h4' => array('%Inline'),
|
||||
'h5' => array('%Inline'),
|
||||
'h6' => array('%Inline'),
|
||||
'ul' => array('li'),
|
||||
'ol' => array('li'),
|
||||
'menu' => array('li'),
|
||||
'dir' => array('li'),
|
||||
'li' => array('%Flow'),
|
||||
'dl' => array(
|
||||
'dt',
|
||||
'dd'
|
||||
),
|
||||
'dt' => array('%Inline'),
|
||||
'dd' => array('%Flow'),
|
||||
'address' => array('cdata', '%inline', '%misc.inline', 'p'),
|
||||
'hr' => array(),
|
||||
'pre' => array('%pre.content'),
|
||||
'blockquote' => array('%Flow'),
|
||||
'center' => array('%Flow'),
|
||||
'ins' => array('%Flow'),
|
||||
'del' => array('%Flow'),
|
||||
'a' => array('%a.content'),
|
||||
'span' => array('%Inline'),
|
||||
'bdo' => array('%Inline'),
|
||||
'br' => array(),
|
||||
'em' => array('%Inline'),
|
||||
'strong' => array('%Inline'),
|
||||
'dfn' => array('%Inline'),
|
||||
'code' => array('%Inline'),
|
||||
'samp' => array('%Inline'),
|
||||
'kbd' => array('%Inline'),
|
||||
'var' => array('%Inline'),
|
||||
'cite' => array('%Inline'),
|
||||
'abbr' => array('%Inline'),
|
||||
'acronym' => array('%Inline'),
|
||||
'q' => array('%Inline'),
|
||||
'sub' => array('%Inline'),
|
||||
'sup' => array('%Inline'),
|
||||
'tt' => array('%Inline'),
|
||||
'i' => array('%Inline'),
|
||||
'b' => array('%Inline'),
|
||||
'big' => array('%Inline'),
|
||||
'small' => array('%Inline'),
|
||||
'u' => array('%Inline'),
|
||||
's' => array('%Inline'),
|
||||
'strike' => array('%Inline'),
|
||||
'basefont' => array(),
|
||||
'font' => array('%Inline'),
|
||||
'object' => array(
|
||||
'cdata',
|
||||
'param',
|
||||
'%block',
|
||||
'form',
|
||||
'%inline',
|
||||
'%misc'
|
||||
),
|
||||
'param' => array(),
|
||||
'applet' => array(
|
||||
'cdata',
|
||||
'param',
|
||||
'%block',
|
||||
'form',
|
||||
'%inline',
|
||||
'%misc'
|
||||
),
|
||||
'img' => array(),
|
||||
'map' => array(
|
||||
'%block',
|
||||
'form',
|
||||
'%misc',
|
||||
'area'
|
||||
),
|
||||
'area' => array(),
|
||||
'form' => array('%form.content'),
|
||||
'label' => array('%Inline'),
|
||||
'input' => array(),
|
||||
'select' => array('optgroup','option'),
|
||||
'optgroup' => array('option'),
|
||||
'option' => array('cdata'),
|
||||
'textarea' => array('cdata'),
|
||||
'fieldset' => array('cdata','legend','%block','form','%inline','%misc'),
|
||||
'legend' => array('%Inline'),
|
||||
'button' => array('%button.content'),
|
||||
'isindex' => array(),
|
||||
'table' => array('caption','col','colgroup','thead','tfoot','tbody','tr'),
|
||||
'caption' => array('%Inline'),
|
||||
'thead' => array('tr'),
|
||||
'tfoot' => array('tr'),
|
||||
'tbody' => array('tr'),
|
||||
'colgroup' => array('col'),
|
||||
'col' => array(),
|
||||
'tr' => array('th','td'),
|
||||
'th' => array('%Flow'),
|
||||
'td' => array('%Flow'),
|
||||
'document' => array(
|
||||
'doctype',
|
||||
'html'
|
||||
),
|
||||
'doctype' => array(
|
||||
'cdata'
|
||||
)
|
||||
);
|
||||
|
||||
$aRequiredAttributes = array(
|
||||
'html' => array(
|
||||
'xmlns',
|
||||
'xml:lang',
|
||||
'lang'
|
||||
),
|
||||
'style' => array('type'),
|
||||
'script' => array('type'),
|
||||
'meta' => array('content'),
|
||||
'optgroup' => array('label'),
|
||||
'textarea' => array('rows', 'cols'),
|
||||
'img' => array('src', 'alt')
|
||||
);
|
||||
|
||||
class clsValidator
|
||||
{
|
||||
var $aTags;
|
||||
var $aAttributes;
|
||||
var $aRequiredAttributes;
|
||||
|
||||
function clsValidator()
|
||||
{
|
||||
global $aTags;
|
||||
global $aAttributes;
|
||||
global $aRequiredAttributes;
|
||||
|
||||
$this->aTags = array();
|
||||
$this->aAttributes = array();
|
||||
$this->aRequiredAttributes = array();
|
||||
|
||||
foreach (array_keys($aTags) as $sTag)
|
||||
{
|
||||
$this->aTags[$sTag] = array();
|
||||
$this->_expand($this->aTags[$sTag], $aTags[$sTag], $aTags);
|
||||
}
|
||||
|
||||
foreach (array_keys($aAttributes) as $sAttribute)
|
||||
{
|
||||
$this->aAttributes[$sAttribute] = array();
|
||||
$this->_expand($this->aAttributes[$sAttribute], $aAttributes[$sAttribute], $aAttributes);
|
||||
}
|
||||
|
||||
foreach (array_keys($aRequiredAttributes) as $sElement)
|
||||
{
|
||||
$this->aRequiredAttributes[$sElement] = array();
|
||||
$this->_expand($this->aRequiredAttributes[$sElement], $aRequiredAttributes[$sElement], $aRequiredAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new clsValidator();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function _expand(&$aDestination, &$aSource, &$aDictionary)
|
||||
{
|
||||
foreach ($aSource as $sChild)
|
||||
{
|
||||
if ('%' == substr($sChild, 0, 1))
|
||||
$this->_expand($aDestination, $aDictionary[$sChild], $aDictionary);
|
||||
else
|
||||
$aDestination[] = $sChild;
|
||||
}
|
||||
}
|
||||
|
||||
function elementValid($sElement)
|
||||
{
|
||||
return isset($this->aTags[strtolower($sElement)]);
|
||||
}
|
||||
|
||||
function attributeValid($sElement, $sAttribute)
|
||||
{
|
||||
if (false == isset($this->aAttributes[strtolower($sElement)]))
|
||||
return false;
|
||||
return in_array(strtolower($sAttribute), $this->aAttributes[strtolower($sElement)]);
|
||||
}
|
||||
|
||||
function childValid($sParent, $sElement)
|
||||
{
|
||||
if (false == isset($this->aTags[strtolower($sParent)]))
|
||||
return false;
|
||||
return in_array(strtolower($sElement), $this->aTags[strtolower($sParent)]);
|
||||
}
|
||||
|
||||
// verify that required attributes have been specified
|
||||
function checkRequiredAttributes($sElement, &$aAttributes, &$sMissing)
|
||||
{
|
||||
if (isset($this->aRequiredAttributes[strtolower($sElement)]))
|
||||
foreach ($this->aRequiredAttributes[strtolower($sElement)] as $sRequiredAttribute)
|
||||
if (false == isset($aAttributes[$sRequiredAttribute]))
|
||||
{
|
||||
$sMissing = $sRequiredAttribute;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
73
libraries/xajax/xajax_core/legacy.inc.php
Normal file
73
libraries/xajax/xajax_core/legacy.inc.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class legacyXajaxResponse extends xajaxResponse {
|
||||
function outputEntitiesOn() { $this->setOutputEntities(true); }
|
||||
function outputEntitiesOff() { $this->setOutputEntities(false); }
|
||||
function addConfirmCommands() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'confirmCommands'), $temp); }
|
||||
function addAssign() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'assign'), $temp); }
|
||||
function addAppend() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'append'), $temp); }
|
||||
function addPrepend() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'prepend'), $temp); }
|
||||
function addReplace() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'replace'), $temp); }
|
||||
function addClear() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'clear'), $temp); }
|
||||
function addAlert() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'alert'), $temp); }
|
||||
function addRedirect() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'redirect'), $temp); }
|
||||
function addScript() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'script'), $temp); }
|
||||
function addScriptCall() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'call'), $temp); }
|
||||
function addRemove() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'remove'), $temp); }
|
||||
function addCreate() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'create'), $temp); }
|
||||
function addInsert() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'insert'), $temp); }
|
||||
function addInsertAfter() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'insertAfter'), $temp); }
|
||||
function addCreateInput() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'createInput'), $temp); }
|
||||
function addInsertInput() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'insertInput'), $temp); }
|
||||
function addInsertInputAfter() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'insertInputAfter'), $temp); }
|
||||
function addRemoveHandler() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'removeHandler'), $temp); }
|
||||
function addIncludeScript() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'includeScript'), $temp); }
|
||||
function addIncludeCSS() { $temp=func_get_args(); return call_user_func_array(array(&$this, 'includeCSS'), $temp); }
|
||||
function &getXML() { return $this; }
|
||||
}
|
||||
|
||||
class legacyXajax extends xajax {
|
||||
function legacyXajax($sRequestURI='', $sWrapperPrefix='xajax_', $sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bDebug=false)
|
||||
{
|
||||
parent::xajax();
|
||||
$this->configure('requestURI', $sRequestURI);
|
||||
$this->configure('wrapperPrefix', $sWrapperPrefix);
|
||||
$this->configure('characterEncoding', $sEncoding);
|
||||
$this->configure('debug', $bDebug);
|
||||
}
|
||||
function registerExternalFunction($mFunction, $sInclude)
|
||||
{
|
||||
$xuf =& new xajaxUserFunction($mFunction, $sInclude);
|
||||
$this->register(XAJAX_FUNCTION, $xuf);
|
||||
}
|
||||
function registerCatchAllFunction($mFunction)
|
||||
{
|
||||
if (is_array($mFunction)) array_shift($mFunction);
|
||||
$this->register(XAJAX_PROCESSING_EVENT, XAJAX_PROCESSING_EVENT_INVALID, $mFunction);
|
||||
}
|
||||
function registerPreFunction($mFunction)
|
||||
{
|
||||
if (is_array($mFunction)) array_shift($mFunction);
|
||||
$this->register(XAJAX_PROCESSING_EVENT, XAJAX_PROCESSING_EVENT_BEFORE, $mFunction);
|
||||
}
|
||||
function canProcessRequests() { return $this->canProcessRequest(); }
|
||||
function processRequests() { return $this->processRequest(); }
|
||||
function setCallableObject(&$oObject) { return $this->register(XAJAX_CALLABLE_OBJECT, $oObject); }
|
||||
function debugOn() { return $this->configure('debug',true); }
|
||||
function debugOff() { return $this->configure('debug',false); }
|
||||
function statusMessagesOn() { return $this->configure('statusMessages',true); }
|
||||
function statusMessagesOff() { return $this->configure('statusMessages',false); }
|
||||
function waitCursorOn() { return $this->configure('waitCursor',true); }
|
||||
function waitCursorOff() { return $this->configure('waitCursor',false); }
|
||||
function exitAllowedOn() { return $this->configure('exitAllowed',true); }
|
||||
function exitAllowedOff() { return $this->configure('exitAllowed',false); }
|
||||
function errorHandlerOn() { return $this->configure('errorHandler',true); }
|
||||
function errorHandlerOff() { return $this->configure('errorHandler',false); }
|
||||
function cleanBufferOn() { return $this->configure('cleanBuffer',true); }
|
||||
function cleanBufferOff() { return $this->configure('cleanBuffer',false); }
|
||||
function decodeUTF8InputOn() { return $this->configure('decodeUTF8Input',true); }
|
||||
function decodeUTF8InputOff() { return $this->configure('decodeUTF8Input',false); }
|
||||
function outputEntitiesOn() { return $this->configure('outputEntities',true); }
|
||||
function outputEntitiesOff() { return $this->configure('outputEntities',false); }
|
||||
function allowBlankResponseOn() { return $this->configure('allowBlankResponse',true); }
|
||||
function allowBlankResponseOff() { return $this->configure('allowBlankResponse',false); }
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
class xajaxCallableObject
|
||||
{
|
||||
/*
|
||||
Object: obj
|
||||
|
||||
A reference to the callable object.
|
||||
*/
|
||||
var $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.
|
||||
*/
|
||||
var $aConfiguration;
|
||||
|
||||
/*
|
||||
Function: xajaxCallableObject
|
||||
|
||||
Constructs and initializes the <xajaxCallableObject>
|
||||
|
||||
obj - (object): The object to reference.
|
||||
*/
|
||||
function xajaxCallableObject(&$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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function generateRequests($sXajaxPrefix)
|
||||
{
|
||||
$aRequests = array();
|
||||
|
||||
$sClass = get_class($this->obj);
|
||||
|
||||
foreach (get_class_methods($this->obj) as $sMethodName)
|
||||
{
|
||||
$bInclude = true;
|
||||
// exclude magic __call method
|
||||
if ("__call" == $sMethodName)
|
||||
$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.
|
||||
*/
|
||||
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 method
|
||||
if ("__call" == $sMethodName)
|
||||
$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.
|
||||
*/
|
||||
function isClass($sClass)
|
||||
{
|
||||
return is_a($this->obj, $sClass);
|
||||
}
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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-2006 by 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
var $sAlias;
|
||||
|
||||
/*
|
||||
Object: uf
|
||||
|
||||
A string or array which defines the function to be registered.
|
||||
*/
|
||||
var $uf;
|
||||
|
||||
/*
|
||||
String: sInclude
|
||||
|
||||
The path and file name of the include file that contains the function.
|
||||
*/
|
||||
var $sInclude;
|
||||
|
||||
/*
|
||||
Array: aConfiguration
|
||||
|
||||
An associative array containing call options that will be sent to the
|
||||
browser curing client script generation.
|
||||
*/
|
||||
var $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 - (string, optional): The path and file name of the include file
|
||||
that contains the class or function to be called.
|
||||
|
||||
$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);
|
||||
*/
|
||||
function xajaxUserFunction($uf, $sInclude=NULL, $aConfiguration=array())
|
||||
{
|
||||
$this->sAlias = '';
|
||||
$this->uf =& $uf;
|
||||
$this->sInclude = $sInclude;
|
||||
$this->aConfiguration = array();
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function configure($sName, $sValue)
|
||||
{
|
||||
if ('alias' == $sName)
|
||||
$this->sAlias = $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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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,218 @@
|
||||
<?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-2006 by 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
|
||||
*/
|
||||
class xajaxCallableObjectPlugin extends xajaxRequestPlugin
|
||||
{
|
||||
/*
|
||||
Array: aCallableObjects
|
||||
*/
|
||||
var $aCallableObjects;
|
||||
|
||||
/*
|
||||
String: sXajaxPrefix
|
||||
*/
|
||||
var $sXajaxPrefix;
|
||||
|
||||
/*
|
||||
String: sDefer
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
var $bDeferScriptGeneration;
|
||||
|
||||
/*
|
||||
String: sRequestedClass
|
||||
*/
|
||||
var $sRequestedClass;
|
||||
|
||||
/*
|
||||
String: sRequestedMethod
|
||||
*/
|
||||
var $sRequestedMethod;
|
||||
|
||||
/*
|
||||
Function: xajaxCallableObjectPlugin
|
||||
*/
|
||||
function xajaxCallableObjectPlugin()
|
||||
{
|
||||
$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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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 === is_a($xco, '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
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if (false === $this->bDeferScriptGeneration || 'deferred' === $this->bDeferScriptGeneration)
|
||||
{
|
||||
if (0 < count($this->aCallableObjects))
|
||||
{
|
||||
$sCrLf = "\n";
|
||||
|
||||
print $sCrLf;
|
||||
print '<';
|
||||
print 'script type="text/javascript" ';
|
||||
print $this->sDefer;
|
||||
print 'charset="UTF-8">';
|
||||
print $sCrLf;
|
||||
print '/* <';
|
||||
print '![CDATA[ */';
|
||||
print $sCrLf;
|
||||
|
||||
foreach(array_keys($this->aCallableObjects) as $sKey)
|
||||
$this->aCallableObjects[$sKey]->generateClientScript($this->sXajaxPrefix);
|
||||
|
||||
print '/* ]]> */';
|
||||
print $sCrLf;
|
||||
print '<';
|
||||
print '/script>';
|
||||
print $sCrLf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: canProcessRequest
|
||||
*/
|
||||
function canProcessRequest()
|
||||
{
|
||||
if (NULL == $this->sRequestedClass)
|
||||
return false;
|
||||
if (NULL == $this->sRequestedMethod)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processRequest
|
||||
*/
|
||||
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,338 @@
|
||||
<?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-2006 by 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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";
|
||||
|
||||
print $sCrLf;
|
||||
print '<';
|
||||
print 'script type="text/javascript" ';
|
||||
print $this->sDefer;
|
||||
print 'charset="UTF-8">';
|
||||
print $sCrLf;
|
||||
print '/* <';
|
||||
print '![CDATA[ */';
|
||||
print $sCrLf;
|
||||
print 'try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.requestURI = "';
|
||||
print $this->sRequestURI;
|
||||
print '";';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.statusMessages = ';
|
||||
print $this->sStatusMessages;
|
||||
print ';';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.waitCursor = ';
|
||||
print $this->sWaitCursor;
|
||||
print ';';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.version = "';
|
||||
print $this->sVersion;
|
||||
print '";';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.legacy = false;';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.defaultMode = "';
|
||||
print $this->sDefaultMode;
|
||||
print '";';
|
||||
print $sCrLf;
|
||||
print 'xajax.config.defaultMethod = "';
|
||||
print $this->sDefaultMethod;
|
||||
print '";';
|
||||
print $sCrLf;
|
||||
print '/* ]]> */';
|
||||
print $sCrLf;
|
||||
print '<';
|
||||
print '/script>';
|
||||
print $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) {
|
||||
print '<';
|
||||
print 'script type="text/javascript" src="';
|
||||
print $sJsURI;
|
||||
print $aJsFile[0];
|
||||
print '" ';
|
||||
print $this->sDefer;
|
||||
print 'charset="UTF-8"><';
|
||||
print '/script>';
|
||||
print $sCrLf;
|
||||
}
|
||||
|
||||
if (0 < $this->nScriptLoadTimeout) {
|
||||
foreach ($aJsFiles as $aJsFile) {
|
||||
print '<';
|
||||
print 'script type="text/javascript" ';
|
||||
print $this->sDefer;
|
||||
print 'charset="UTF-8">';
|
||||
print $sCrLf;
|
||||
print '/* <';
|
||||
print '![CDATA[ */';
|
||||
print $sCrLf;
|
||||
print 'window.setTimeout(';
|
||||
print $sCrLf;
|
||||
print ' function() {';
|
||||
print $sCrLf;
|
||||
print ' var scriptExists = false;';
|
||||
print $sCrLf;
|
||||
print ' try { if (';
|
||||
print $aJsFile[1];
|
||||
print '.isLoaded) scriptExists = true; }';
|
||||
print $sCrLf;
|
||||
print ' catch (e) {}';
|
||||
print $sCrLf;
|
||||
print ' if (!scriptExists) {';
|
||||
print $sCrLf;
|
||||
print ' alert("Error: the ';
|
||||
print $aJsFile[1];
|
||||
print ' Javascript component could not be included. Perhaps the URL is incorrect?\nURL: ';
|
||||
print $sJsURI;
|
||||
print $aJsFile[0];
|
||||
print '");';
|
||||
print $sCrLf;
|
||||
print ' }';
|
||||
print $sCrLf;
|
||||
print ' }, ';
|
||||
print $this->nScriptLoadTimeout;
|
||||
print ');';
|
||||
print $sCrLf;
|
||||
print '/* ]]> */';
|
||||
print $sCrLf;
|
||||
print '<';
|
||||
print '/script>';
|
||||
print $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);
|
||||
228
libraries/xajax/xajax_core/plugin_layer/xajaxEventPlugin.inc.php
Normal file
228
libraries/xajax/xajax_core/plugin_layer/xajaxEventPlugin.inc.php
Normal file
@@ -0,0 +1,228 @@
|
||||
<?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-2006 by 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 === is_a($xuf, '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,230 @@
|
||||
<?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-2006 by 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 === is_a($xuf, 'xajaxUserFunction'))
|
||||
$xuf =& new xajaxUserFunction($xuf);
|
||||
|
||||
if (2 < count($aArgs))
|
||||
if (is_array($aArgs[2]))
|
||||
foreach ($aArgs[2] as $sName => $sValue)
|
||||
$xuf->configure($sName, $sValue);
|
||||
|
||||
$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,265 @@
|
||||
<?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-2006 by 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);
|
||||
1370
libraries/xajax/xajax_core/xajax.inc.php
Normal file
1370
libraries/xajax/xajax_core/xajax.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
450
libraries/xajax/xajax_core/xajaxArgumentManager.inc.php
Normal file
450
libraries/xajax/xajax_core/xajaxArgumentManager.inc.php
Normal file
@@ -0,0 +1,450 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
class xajaxArgumentManager
|
||||
{
|
||||
/*
|
||||
Array: aArgs
|
||||
|
||||
An array of arguments received via the GET or POST parameter
|
||||
xjxargs.
|
||||
*/
|
||||
var $aArgs;
|
||||
|
||||
/*
|
||||
Boolean: bDecodeUTF8Input
|
||||
|
||||
A configuration option used to indicate whether input data should be
|
||||
UTF8 decoded automatically.
|
||||
*/
|
||||
var $bDecodeUTF8Input;
|
||||
|
||||
/*
|
||||
String: sCharacterEncoding
|
||||
|
||||
The character encoding in which the input data will be received.
|
||||
*/
|
||||
var $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
|
||||
*/
|
||||
var $nMethod;
|
||||
|
||||
/*
|
||||
Array: aSequence
|
||||
|
||||
Stores the decoding sequence table.
|
||||
*/
|
||||
var $aSequence;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function argumentStripSlashes(&$sArg)
|
||||
{
|
||||
if (false == is_string($sArg))
|
||||
return;
|
||||
|
||||
$sArg = stripslashes($sArg);
|
||||
}
|
||||
|
||||
function argumentDecodeXML(&$sArg)
|
||||
{
|
||||
if (false == is_string($sArg))
|
||||
return;
|
||||
|
||||
if (0 == strlen($sArg))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
$nStackDepth = 0;
|
||||
$aStack = array();
|
||||
$aArg = array();
|
||||
|
||||
$nCurrent = 0;
|
||||
$nLast = 0;
|
||||
$aExpecting = array();
|
||||
$nFound = 0;
|
||||
list($aExpecting, $nFound) = $this->aSequence['start'];
|
||||
|
||||
$nLength = strlen($sArg);
|
||||
|
||||
$sKey = '';
|
||||
$mValue = '';
|
||||
|
||||
|
||||
while ($nCurrent < $nLength)
|
||||
{
|
||||
$bFound = false;
|
||||
|
||||
foreach ($aExpecting as $sExpecting => $nExpectedLength)
|
||||
{
|
||||
if ($sArg[$nCurrent] == $sExpecting[0])
|
||||
if ($sExpecting == substr($sArg, $nCurrent, $nExpectedLength))
|
||||
{
|
||||
list($aExpecting, $nFound) = $this->aSequence[$sExpecting];
|
||||
|
||||
switch ($nFound)
|
||||
{
|
||||
case 3: // k
|
||||
$sKey = '';
|
||||
break;
|
||||
case 4: // /k
|
||||
$sKey = str_replace(
|
||||
array('<'.'![CDATA[', ']]>'),
|
||||
'',
|
||||
substr($sArg, $nLast, $nCurrent - $nLast)
|
||||
);
|
||||
break;
|
||||
case 5: // v
|
||||
$mValue = '';
|
||||
break;
|
||||
case 6: // /v
|
||||
if ($nLast < $nCurrent)
|
||||
{
|
||||
$mValue = str_replace(
|
||||
array('<'.'![CDATA[', ']]>'),
|
||||
'',
|
||||
substr($sArg, $nLast, $nCurrent - $nLast)
|
||||
);
|
||||
|
||||
$cType = substr($mValue, 0, 1);
|
||||
$sValue = substr($mValue, 1);
|
||||
switch ($cType) {
|
||||
case 'S': $mValue = false === $sValue ? '' : $sValue; break;
|
||||
case 'B': $mValue = $this->convertStringToBool($sValue); break;
|
||||
case 'N': $mValue = floatval($sValue); break;
|
||||
case '*': $mValue = null; break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7: // /e
|
||||
$aArg[$sKey] = $mValue;
|
||||
break;
|
||||
case 1: // xjxobj
|
||||
++$nStackDepth;
|
||||
array_push($aStack, $aArg);
|
||||
$aArg = array();
|
||||
array_push($aStack, $sKey);
|
||||
$sKey = '';
|
||||
break;
|
||||
case 8: // /xjxobj
|
||||
if (1 < $nStackDepth) {
|
||||
$mValue = $aArg;
|
||||
$sKey = array_pop($aStack);
|
||||
$aArg = array_pop($aStack);
|
||||
--$nStackDepth;
|
||||
} else {
|
||||
$sArg = $aArg;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$nCurrent += $nExpectedLength;
|
||||
$nLast = $nCurrent;
|
||||
$bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (false == $bFound)
|
||||
{
|
||||
if (0 == $nCurrent)
|
||||
{
|
||||
$sArg = str_replace(
|
||||
array('<'.'![CDATA[', ']]>'),
|
||||
'',
|
||||
$sArg
|
||||
);
|
||||
|
||||
$cType = substr($sArg, 0, 1);
|
||||
$sValue = substr($sArg, 1);
|
||||
switch ($cType) {
|
||||
case 'S': $sArg = false === $sValue ? '' : $sValue; break;
|
||||
case 'B': $sArg = $this->convertStringToBool($sValue); break;
|
||||
case 'N': $sArg = floatval($sValue); break;
|
||||
case '*': $sArg = null; break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// for larger arg data, performance may suffer using concatenation
|
||||
// $sText .= $sArg[$nCurrent];
|
||||
$nCurrent++;
|
||||
}
|
||||
}
|
||||
|
||||
$objLanguageManager =& xajaxLanguageManager::getInstance();
|
||||
|
||||
trigger_error(
|
||||
$objLanguageManager->getText('ARGMGR:ERR:01')
|
||||
. $sExpected
|
||||
. $objLanguageManager->getText('ARGMGR:ERR:02')
|
||||
. $sChunk
|
||||
, E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
function xajaxArgumentManager()
|
||||
{
|
||||
$this->aArgs = array();
|
||||
|
||||
$this->bDecodeUTF8Input = false;
|
||||
$this->sCharacterEncoding = 'UTF-8';
|
||||
$this->nMethod = XAJAX_METHOD_UNKNOWN;
|
||||
|
||||
$this->aSequence = array(
|
||||
'<'.'k'.'>' => array(array(
|
||||
'<'.'/k'.'>' => 4
|
||||
), 3),
|
||||
'<'.'/k'.'>' => array(array(
|
||||
'<'.'v'.'>' => 3,
|
||||
'<'.'/e'.'>' => 4
|
||||
), 4),
|
||||
'<'.'v'.'>' => array(array(
|
||||
'<'.'xjxobj'.'>' => 8,
|
||||
'<'.'/v'.'>' => 4
|
||||
), 5),
|
||||
'<'.'/v'.'>' => array(array(
|
||||
'<'.'/e'.'>' => 4,
|
||||
'<'.'k'.'>' => 3
|
||||
), 6),
|
||||
'<'.'e'.'>' => array(array(
|
||||
'<'.'k'.'>' => 3,
|
||||
'<'.'v'.'>' => 3,
|
||||
'<'.'/e'.'>' => 4
|
||||
), 2),
|
||||
'<'.'/e'.'>' => array(array(
|
||||
'<'.'e'.'>' => 3,
|
||||
'<'.'/xjxobj'.'>' => 9
|
||||
), 7),
|
||||
'<'.'xjxobj'.'>' => array(array(
|
||||
'<'.'e'.'>' => 3,
|
||||
'<'.'/xjxobj'.'>' => 9
|
||||
), 1),
|
||||
'<'.'/xjxobj'.'>' => array(array(
|
||||
'<'.'/v'.'>' => 4
|
||||
), 8),
|
||||
'start' => array(array(
|
||||
'<'.'xjxobj'.'>' => 8
|
||||
), 9)
|
||||
);
|
||||
|
||||
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, 'argumentDecodeXML'));
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getInstance
|
||||
|
||||
Returns:
|
||||
|
||||
object - A reference to an instance of this class. This function is
|
||||
used to implement the singleton pattern.
|
||||
*/
|
||||
function &getInstance()
|
||||
{
|
||||
static $obj;
|
||||
if (!$obj) {
|
||||
$obj = new xajaxArgumentManager();
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Accepts configuration settings from the main <xajax> object.
|
||||
|
||||
The <xajaxArgumentManager> tracks the following configuration settings:
|
||||
<decodeUTF8Input> - (boolean): See <xajaxArgumentManager->bDecodeUTF8Input>
|
||||
<characterEncoding> - (string): See <xajaxArgumentManager->sCharacterEncoding>
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function getRequestMethod()
|
||||
{
|
||||
return $this->nMethod;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: process
|
||||
|
||||
Returns the array of arguments that were extracted and parsed from
|
||||
the GET or POST data.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
362
libraries/xajax/xajax_core/xajaxCall.inc.php
Normal file
362
libraries/xajax/xajax_core/xajaxCall.inc.php
Normal file
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxCall.inc.php
|
||||
|
||||
Contains the xajaxCall class
|
||||
|
||||
Title: xajaxCall class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxCall.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxCall
|
||||
|
||||
Create a piece of javascript code that will invoke the <xajax.call>
|
||||
function.
|
||||
|
||||
This class is deprecated and will be removed in future versions; please use
|
||||
<xajaxRequest> instead.
|
||||
*/
|
||||
class xajaxCall {
|
||||
|
||||
/**#@+
|
||||
* @access protected
|
||||
*/
|
||||
|
||||
/*
|
||||
String: sFunction
|
||||
|
||||
Required: The name of the xajax enabled function to call
|
||||
*/
|
||||
var $sFunction;
|
||||
|
||||
/*
|
||||
String: sReturnValue
|
||||
|
||||
Required: The value to return once the <xajax.call> has
|
||||
returned. (for asynchronous calls, this is immediate)
|
||||
*/
|
||||
var $sReturnValue;
|
||||
|
||||
/*
|
||||
Array: aParameters
|
||||
|
||||
The associative array that will be used to store the parameters for this
|
||||
call.
|
||||
- key: The textual representation of the parameter.
|
||||
- value: A boolean value indicating whether or not to use quotes around
|
||||
this parameter.
|
||||
*/
|
||||
var $aParameters;
|
||||
|
||||
/*
|
||||
String: sMode
|
||||
|
||||
The mode to use for the call
|
||||
- 'synchronous'
|
||||
- 'asynchronous'
|
||||
*/
|
||||
var $sMode;
|
||||
|
||||
/*
|
||||
String: sRequestType
|
||||
|
||||
The request type that will be used for the call
|
||||
- 'GET'
|
||||
- 'POST'
|
||||
*/
|
||||
var $sRequestType;
|
||||
|
||||
/*
|
||||
String: sResponseProcessor
|
||||
|
||||
The name of the javascript function that will be invoked
|
||||
to handle the response.
|
||||
*/
|
||||
var $sResponseProcessor;
|
||||
|
||||
/*
|
||||
String: sRequestURI
|
||||
|
||||
The URI for where this request will be sent.
|
||||
*/
|
||||
var $sRequestURI;
|
||||
|
||||
/*
|
||||
String: sContentType
|
||||
|
||||
The content type to use for the request.
|
||||
*/
|
||||
var $sContentType;
|
||||
|
||||
/*
|
||||
Constructor: xajaxCall
|
||||
|
||||
Initializes the xajaxCall object.
|
||||
|
||||
sFunction - (string): The name of the xajax enabled function
|
||||
that will be invoked when this javascript code is executed
|
||||
on the browser. This function name should match a PHP
|
||||
function from your script.
|
||||
*/
|
||||
function xajaxCall($sFunction = '') {
|
||||
$this->sFunction = $sFunction;
|
||||
$this->aParameters = array();
|
||||
$this->sMode = '';
|
||||
$this->sRequestType = '';
|
||||
$this->sResponseProcessor = '';
|
||||
$this->sRequestURI = '';
|
||||
$this->sContentType = '';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setFunction
|
||||
|
||||
Override the function name set in the constructor.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setFunction($sFunction) {
|
||||
$this->sFunction = $sFunction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearParameters
|
||||
|
||||
Clear the list of parameters being accumulated for this
|
||||
call.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function clearParameters() {
|
||||
$this->aParameters = array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addParameter
|
||||
|
||||
Adds a parameter to the list that will be specified for the
|
||||
request generated by this <xajaxCall> object.
|
||||
|
||||
sParameter - (string): The parameter value or name.
|
||||
bUseQuotes - (boolean): Whether or not to put quotes around this value.
|
||||
|
||||
If you specify the name of a javascript variable, or provide a javascript
|
||||
function call as a parameter, do not use quotes around the value.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function addParameter($sParameter, $bUseQuotes = true) {
|
||||
$this->aParameters[] = array($sParameter, $bUseQuotes);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: addFormValuesParameter
|
||||
|
||||
Add a parameter value that is the result of calling <xajax.getFormValues>
|
||||
for the specified form.
|
||||
|
||||
sFormID - (string): The id of the form for which you wish to return
|
||||
the input values.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function addFormValuesParameter($sFormID) {
|
||||
$this->aParameters[] = array('xajax.getFormValues("'.$sFormID.'")');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setMode
|
||||
|
||||
Sets the mode that will be specified for this <xajax.call>
|
||||
|
||||
- 'synchronous'
|
||||
- 'asynchronous'
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setMode($sMode) {
|
||||
$this->sMode = $sMode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setRequestType
|
||||
|
||||
Sets the request type which will be specified for the
|
||||
generated <xajax.call>.
|
||||
|
||||
- 'GET'
|
||||
- 'POST'
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setRequestType($sRequestType) {
|
||||
$this->sRequestType = $sRequestType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setResponseProcessor
|
||||
|
||||
Sets the name of the javascript function that will be used
|
||||
to process this response. This is an advanced function, use
|
||||
with caution.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setResponseProcessor($sResponseProcessor) {
|
||||
$this->sResponseProcessor = $sResponseProcessor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setRequestURI
|
||||
|
||||
Override the default URI with the specified one.
|
||||
|
||||
sRequestURI - (string): The URI that the generated request will be sent
|
||||
to.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setRequestURI($sRequestURI) {
|
||||
$this->sRequestURI = $sRequestURI;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setContentType
|
||||
|
||||
Sets the content type that will be used by the generated request.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setContentType($sContentType) {
|
||||
$this->sContentType = $sContentType;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: setReturnValue
|
||||
|
||||
Sets the value that will be returned after the generated call.
|
||||
Set to an empty string if no return value is desired.
|
||||
|
||||
Returns:
|
||||
|
||||
object - The <xajaxCall> object.
|
||||
*/
|
||||
function setReturnValue($sReturnValue) {
|
||||
$this->sReturnValue = $sReturnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generate
|
||||
|
||||
Construct a <xajax.call> statement in javascript that can be used
|
||||
to make a xajax request with the parameters and settings previously
|
||||
configured for this <xajaxCall> object.
|
||||
|
||||
The output from this function can be used as an event handler in your
|
||||
javascript code.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The javascript statement that will invoked the <xajax.call>
|
||||
function on the browser, causing a xajax request to be sent to
|
||||
the server.
|
||||
*/
|
||||
function generate() {
|
||||
$output = 'xajax.call("';
|
||||
$output .= $this->sFunction;
|
||||
$output .= '", {';
|
||||
$separator = '';
|
||||
if (0 < count($this->aParameters)) {
|
||||
$output .= 'parameters: [';
|
||||
foreach ($this->aParameters as $aParameter) {
|
||||
$output .= $separator;
|
||||
$bUseQuotes = $aParameter[1];
|
||||
if ($bUseQuotes)
|
||||
$output .= '"';
|
||||
$output .= $aParameter[0];
|
||||
if ($bUseQuotes)
|
||||
$output .= '"';
|
||||
$separator = ',';
|
||||
}
|
||||
$output .= ']';
|
||||
}
|
||||
if (0 < strlen($this->sMode)) {
|
||||
$output .= $separator;
|
||||
$output .= 'mode:"';
|
||||
$output .= $this->sMode;
|
||||
$output .= '"';
|
||||
$separator = ',';
|
||||
}
|
||||
if (0 < strlen($this->sRequestType)) {
|
||||
$output .= $separator;
|
||||
$output .= 'requestType:"';
|
||||
$output .= $this->sRequestType;
|
||||
$output .= '"';
|
||||
$separator = ',';
|
||||
}
|
||||
if (0 < strlen($this->sResponseProcessor)) {
|
||||
$output .= $separator;
|
||||
$output .= 'responseProcessor:';
|
||||
$output .= $this->sResponseProcessor;
|
||||
$separator = ',';
|
||||
}
|
||||
if (0 < strlen($this->sRequestURI)) {
|
||||
$output .= $separator;
|
||||
$output .= 'requestURI:"';
|
||||
$output .= $this->sRequestURI;
|
||||
$output .= '"';
|
||||
$separator = ',';
|
||||
}
|
||||
if (0 < strlen($this->sContentType)) {
|
||||
$output .= $separator;
|
||||
$output .= 'contentType:"';
|
||||
$output .= $this->sContentType;
|
||||
$output .= '"';
|
||||
$separator = ',';
|
||||
}
|
||||
$output .= '}); ';
|
||||
if (0 < strlen($this->sReturnValue)) {
|
||||
$output .= 'return ';
|
||||
$output .= $this->sReturnValue;
|
||||
} else {
|
||||
$output .= 'return false;';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
146
libraries/xajax/xajax_core/xajaxCompress.inc.php
Normal file
146
libraries/xajax/xajax_core/xajaxCompress.inc.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Function: xajaxCompressFile
|
||||
|
||||
<xajax> will call this function internally to compress the javascript code for
|
||||
more efficient delivery.
|
||||
|
||||
$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;
|
||||
}
|
||||
668
libraries/xajax/xajax_core/xajaxControl.inc.php
Normal file
668
libraries/xajax/xajax_core/xajaxControl.inc.php
Normal file
@@ -0,0 +1,668 @@
|
||||
<?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-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
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');
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
var $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
|
||||
*/
|
||||
var $sEndTag;
|
||||
|
||||
/*
|
||||
Array: aAttributes
|
||||
|
||||
An associative array of attributes that will be used in the generation
|
||||
of the HMTL code for this control.
|
||||
*/
|
||||
var $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>.
|
||||
*/
|
||||
var $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.
|
||||
*/
|
||||
var $sClass;
|
||||
|
||||
/*
|
||||
Function: xajaxControl
|
||||
|
||||
$aConfiguration - (array): An associative array that contains a variety
|
||||
of configuration options for this <xajaxControl> object.
|
||||
|
||||
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.
|
||||
*/
|
||||
function xajaxControl($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
|
||||
*/
|
||||
function getClass()
|
||||
{
|
||||
return $this->sClass;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearAttributes
|
||||
|
||||
Removes all attributes assigned to this control.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
|
||||
sName - (string): The name of the attribute to be returned.
|
||||
|
||||
Returns:
|
||||
|
||||
mixed - The value associated with the attribute, or null.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
|
||||
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
|
||||
*/
|
||||
function setEvent($sEvent, &$objRequest, $aParameters=array(), $sBeforeRequest='', $sAfterRequest='; return false;')
|
||||
{
|
||||
//SkipDebug
|
||||
if (false == is_a($objRequest, '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
|
||||
|
||||
$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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
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}' ";
|
||||
}
|
||||
|
||||
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}' ";
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
var $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.
|
||||
*/
|
||||
var $sChildClass;
|
||||
|
||||
/*
|
||||
Function: xajaxControlContainer
|
||||
|
||||
Called to construct and configure this control.
|
||||
|
||||
aConfiguration - (array): See <xajaxControl->xajaxControl> for more
|
||||
information.
|
||||
*/
|
||||
function xajaxControlContainer($sTag, $aConfiguration=array())
|
||||
{
|
||||
xajaxControl::xajaxControl($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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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>.
|
||||
*/
|
||||
function addChild(&$objControl)
|
||||
{
|
||||
//SkipDebug
|
||||
if (false == is_a($objControl, '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;
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
function _printChildren($sIndent='')
|
||||
{
|
||||
if (false == is_a($this, '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);
|
||||
}
|
||||
}
|
||||
}
|
||||
183
libraries/xajax/xajax_core/xajaxLanguageManager.inc.php
Normal file
183
libraries/xajax/xajax_core/xajaxLanguageManager.inc.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
class xajaxLanguageManager
|
||||
{
|
||||
/*
|
||||
Array: aMessages
|
||||
|
||||
An array of the currently registered languages.
|
||||
*/
|
||||
var $aMessages;
|
||||
|
||||
/*
|
||||
String: sLanguage
|
||||
|
||||
The currently configured language.
|
||||
*/
|
||||
var $sLanguage;
|
||||
|
||||
/*
|
||||
Function: xajaxLanguageManager
|
||||
|
||||
Construct and initialize the one and only xajax language manager object.
|
||||
*/
|
||||
function xajaxLanguageManager()
|
||||
{
|
||||
$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.
|
||||
*/
|
||||
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:
|
||||
|
||||
- language (string, default 'en'): The currently selected language.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('language' == $sName) {
|
||||
if ($mValue !== $this->sLanguage) {
|
||||
$sFolder = dirname(__FILE__);
|
||||
require $sFolder . '/xajax_lang_' . $mValue . '.inc.php';
|
||||
$this->sLanguage = $mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: register
|
||||
|
||||
Called to register an array of alternate language messages.
|
||||
|
||||
sLanguage - (string) the character code which represents the language being registered.
|
||||
aMessages - (array) the array of translated debug and error messages
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
185
libraries/xajax/xajax_core/xajaxPlugin.inc.php
Normal file
185
libraries/xajax/xajax_core/xajaxPlugin.inc.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?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-2006 by 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>.
|
||||
*/
|
||||
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.
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
320
libraries/xajax/xajax_core/xajaxPluginManager.inc.php
Normal file
320
libraries/xajax/xajax_core/xajaxPluginManager.inc.php
Normal file
@@ -0,0 +1,320 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
function loadPlugins($aFolders)
|
||||
{
|
||||
foreach ($aFolders as $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.
|
||||
|
||||
nPriorityNumber - (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.
|
||||
|
||||
objPlugin - (object): A reference to an instance of a plugin.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
344
libraries/xajax/xajax_core/xajaxRequest.inc.php
Normal file
344
libraries/xajax/xajax_core/xajaxRequest.inc.php
Normal file
@@ -0,0 +1,344 @@
|
||||
<?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-2006 by 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.
|
||||
|
||||
Constant: XAJAX_INPUT_VALUE
|
||||
Specifies that the parameter will contain the value of an input control.
|
||||
|
||||
Constant: XAJAX_CHECKED_VALUE
|
||||
Specifies that the parameter will consist of a boolean value of a checkbox.
|
||||
|
||||
Constant: XAJAX_ELEMENT_INNERHTML
|
||||
Specifies that the parameter value will be the innerHTML value of the element.
|
||||
|
||||
Constant: XAJAX_QUOTED_VALUE
|
||||
Specifies that the parameter will be a quoted value (string).
|
||||
|
||||
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_FORM_VALUES')) define ('XAJAX_FORM_VALUES', 'get form values');
|
||||
if (!defined ('XAJAX_INPUT_VALUE')) define ('XAJAX_INPUT_VALUE', 'get input value');
|
||||
if (!defined ('XAJAX_CHECKED_VALUE')) define ('XAJAX_CHECKED_VALUE', 'get checked value');
|
||||
if (!defined ('XAJAX_ELEMENT_INNERHTML')) define ('XAJAX_ELEMENT_INNERHTML', 'get element innerHTML');
|
||||
if (!defined ('XAJAX_QUOTED_VALUE')) define ('XAJAX_QUOTED_VALUE', 'quoted value');
|
||||
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.
|
||||
*/
|
||||
var $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>
|
||||
*/
|
||||
var $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>
|
||||
*/
|
||||
var $aParameters;
|
||||
|
||||
/*
|
||||
Function: xajaxRequest
|
||||
|
||||
Construct and initialize this request.
|
||||
|
||||
sName - (string): The name of this request.
|
||||
*/
|
||||
function xajaxRequest($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.
|
||||
*/
|
||||
function useSingleQuote()
|
||||
{
|
||||
$this->sQuoteCharacter = "'";
|
||||
}
|
||||
|
||||
/*
|
||||
Function: useDoubleQuote
|
||||
|
||||
Call this to instruct the request to use double quotes while generating
|
||||
the javascript.
|
||||
*/
|
||||
function useDoubleQuote()
|
||||
{
|
||||
$this->sQuoteCharacter = '"';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clearParameters
|
||||
|
||||
Clears the parameter list associated with this request.
|
||||
*/
|
||||
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 <xajaxRequest->setParameter> for details.
|
||||
*/
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
TODO: finish documenting the options.
|
||||
*/
|
||||
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>
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function printScript()
|
||||
{
|
||||
$sOutput = $this->sName;
|
||||
$sOutput .= "(";
|
||||
|
||||
$sSeparator = "";
|
||||
|
||||
foreach ($this->aParameters as $sParameter)
|
||||
{
|
||||
$sOutput .= $sSeparator;
|
||||
$sOutput .= $sParameter;
|
||||
$sSeparator = ", ";
|
||||
}
|
||||
|
||||
$sOutput .= ")";
|
||||
|
||||
print $sOutput;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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.
|
||||
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
1772
libraries/xajax/xajax_core/xajaxResponse.inc.php
Normal file
1772
libraries/xajax/xajax_core/xajaxResponse.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
222
libraries/xajax/xajax_core/xajaxResponseManager.inc.php
Normal file
222
libraries/xajax/xajax_core/xajaxResponseManager.inc.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?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-2006 by 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.
|
||||
*/
|
||||
class xajaxResponseManager
|
||||
{
|
||||
/*
|
||||
Object: objResponse
|
||||
|
||||
The current response object that will be sent back to the browser
|
||||
once the request processing phase is complete.
|
||||
*/
|
||||
var $objResponse;
|
||||
|
||||
/*
|
||||
String: sCharacterEncoding
|
||||
*/
|
||||
var $sCharacterEncoding;
|
||||
|
||||
/*
|
||||
Boolean: bOutputEntities
|
||||
*/
|
||||
var $bOutputEntities;
|
||||
|
||||
/*
|
||||
Array: aDebugMessages
|
||||
*/
|
||||
var $aDebugMessages;
|
||||
|
||||
/*
|
||||
Function: xajaxResponseManager
|
||||
|
||||
Construct and initialize the one and only xajaxResponseManager object.
|
||||
*/
|
||||
function xajaxResponseManager()
|
||||
{
|
||||
$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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('characterEncoding' == $sName)
|
||||
{
|
||||
$this->sCharacterEncoding = $mValue;
|
||||
|
||||
if (isset($this->objResponse))
|
||||
$this->objResponse->setCharacterEncoding($this->sCharacterEncoding);
|
||||
}
|
||||
else if ('outputEntities' == $sName)
|
||||
{
|
||||
if (true === $mValue || false === $mValue)
|
||||
{
|
||||
$this->bOutputEntities = $mValue;
|
||||
|
||||
if (isset($this->objResponse))
|
||||
$this->objResponse->setOutputEntities($this->bOutputEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: clear
|
||||
|
||||
Clear the current response. A new response will need to be appended
|
||||
before the request processing is complete.
|
||||
*/
|
||||
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.
|
||||
|
||||
$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.
|
||||
*/
|
||||
function append($mResponse)
|
||||
{
|
||||
if (is_a($mResponse, 'xajaxResponse')) {
|
||||
if (NULL == $this->objResponse) {
|
||||
$this->objResponse = $mResponse;
|
||||
} else if (is_a($this->objResponse, 'xajaxResponse')) {
|
||||
if ($this->objResponse != $mResponse)
|
||||
$this->objResponse->absorb($mResponse);
|
||||
} else {
|
||||
$objLanguageManager =& xajaxLanguageManager::getInstance();
|
||||
$this->debug(
|
||||
$objLanguageManager->getText('XJXRM:MXRTERR')
|
||||
. get_class($this->objResponse)
|
||||
. ')'
|
||||
);
|
||||
}
|
||||
} else if (is_a($mResponse, 'xajaxCustomResponse')) {
|
||||
if (NULL == $this->objResponse) {
|
||||
$this->objResponse = $mResponse;
|
||||
} else if (is_a($this->objResponse, 'xajaxCustomResponse')) {
|
||||
if ($this->objResponse != $mResponse)
|
||||
$this->objResponse->absorb($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>)
|
||||
|
||||
$sMessage - (string): The text of the debug message to be sent.
|
||||
*/
|
||||
function debug($sMessage)
|
||||
{
|
||||
$this->aDebugMessages[] = $sMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: send
|
||||
|
||||
Prints the response object to the output stream, thus sending the response to the client.
|
||||
*/
|
||||
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>.
|
||||
*/
|
||||
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>.
|
||||
*/
|
||||
function getOutputEntities()
|
||||
{
|
||||
return $this->bOutputEntities;
|
||||
}
|
||||
}
|
||||
87
libraries/xajax/xajax_core/xajax_lang_de.inc.php
Normal file
87
libraries/xajax/xajax_core/xajax_lang_de.inc.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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-2006 by 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
|
||||
86
libraries/xajax/xajax_core/xajax_lang_nl.inc.php
Normal file
86
libraries/xajax/xajax_core/xajax_lang_nl.inc.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajax_lang_de.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>
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_lang_de.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by 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 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
|
||||
409
libraries/xajax/xajax_js/xajax_core.js
Normal file
409
libraries/xajax/xajax_js/xajax_core.js
Normal file
@@ -0,0 +1,409 @@
|
||||
|
||||
try{if('undefined'==typeof xajax.config)xajax.config={};}catch(e){xajax={};xajax.config={};}
|
||||
xajax.config.setDefault=function(option,defaultValue){if('undefined'==typeof xajax.config[option])
|
||||
xajax.config[option]=defaultValue;}
|
||||
xajax.config.setDefault('commonHeaders',{'If-Modified-Since':'Sat, 1 Jan 2000 00:00:00 GMT'
|
||||
});xajax.config.setDefault('postHeaders',{});xajax.config.setDefault('getHeaders',{});xajax.config.setDefault('waitCursor',false);xajax.config.setDefault('statusMessages',false);xajax.config.setDefault('baseDocument',document);xajax.config.setDefault('requestURI',xajax.config.baseDocument.URL);xajax.config.setDefault('defaultMode','asynchronous');xajax.config.setDefault('defaultHttpVersion','HTTP/1.1');xajax.config.setDefault('defaultContentType','application/x-www-form-urlencoded');xajax.config.setDefault('defaultResponseDelayTime',1000);xajax.config.setDefault('defaultExpirationTime',10000);xajax.config.setDefault('defaultMethod','POST');xajax.config.setDefault('defaultRetry',5);xajax.config.setDefault('defaultReturnValue',false);xajax.config.setDefault('maxObjectDepth',20);xajax.config.setDefault('maxObjectSize',2000);xajax.config.status={update:function(){return{onRequest:function(){window.status='Sending Request...';},
|
||||
onWaiting:function(){window.status='Waiting for Response...';},
|
||||
onProcessing:function(){window.status='Processing...';},
|
||||
onComplete:function(){window.status='Done.';}
|
||||
}
|
||||
},
|
||||
dontUpdate:function(){return{onRequest:function(){},
|
||||
onWaiting:function(){},
|
||||
onProcessing:function(){},
|
||||
onComplete:function(){}
|
||||
}
|
||||
}
|
||||
}
|
||||
xajax.config.cursor={update:function(){return{onWaiting:function(){if(xajax.config.baseDocument.body)
|
||||
xajax.config.baseDocument.body.style.cursor='wait';},
|
||||
onComplete:function(){xajax.config.baseDocument.body.style.cursor='auto';}
|
||||
}
|
||||
},
|
||||
dontUpdate:function(){return{onWaiting:function(){},
|
||||
onComplete:function(){}
|
||||
}
|
||||
}
|
||||
}
|
||||
xajax.tools={}
|
||||
xajax.tools.$=function(sId){if(!sId)
|
||||
return null;var oDoc=xajax.config.baseDocument;var obj=oDoc.getElementById(sId);if(obj)
|
||||
return obj;if(oDoc.all)
|
||||
return oDoc.all[sId];return obj;}
|
||||
xajax.tools.arrayContainsValue=function(array,valueToCheck){var i=0;var l=array.length;while(i < l){if(array[i]==valueToCheck)
|
||||
return true;++i;}
|
||||
return false;}
|
||||
xajax.tools.doubleQuotes=function(haystack){return haystack.replace(new RegExp("'",'g'),'"');}
|
||||
xajax.tools.singleQuotes=function(haystack){return haystack.replace(new RegExp('"','g'),"'");}
|
||||
xajax.tools._escape=function(data){if('undefined'==typeof data)
|
||||
return data;if('string'!=typeof data)
|
||||
return data;var needCDATA=false;if(encodeURIComponent(data)!=data){needCDATA=true;var segments=data.split('<![CDATA[');var segLen=segments.length;data=[];for(var i=0;i < segLen;++i){var segment=segments[i];var fragments=segment.split(']]>');var fragLen=fragments.length;segment='';for(var j=0;j < fragLen;++j){if(0!=j)
|
||||
segment+=']]]]><![CDATA[>';segment+=fragments[j];}
|
||||
if(0!=i)
|
||||
data.push('<![]]><![CDATA[CDATA[');data.push(segment);}
|
||||
data=data.join('');}
|
||||
if(needCDATA)
|
||||
data='<![CDATA['+data+']]>';return data;}
|
||||
xajax.tools._objectToXML=function(obj,guard){var aXml=[];aXml.push('<xjxobj>');for(var key in obj){++guard.size;if(guard.maxSize < guard.size)
|
||||
return aXml.join('');if('undefined'!=typeof obj[key]){if('constructor'==key)
|
||||
continue;if('function'==typeof obj[key])
|
||||
continue;aXml.push('<e><k>');var val=xajax.tools._escape(key);aXml.push(val);aXml.push('</k><v>');if('object'==typeof obj[key]){++guard.depth;if(guard.maxDepth > guard.depth){try{aXml.push(xajax.tools._objectToXML(obj[key],guard));}catch(e){}
|
||||
}
|
||||
--guard.depth;}else{var val=xajax.tools._escape(obj[key]);if('undefined'==typeof val||null==val){aXml.push('*');}else{var sType=typeof val;if('string'==sType)
|
||||
aXml.push('S');else if('boolean'==sType)
|
||||
aXml.push('B');else if('number'==sType)
|
||||
aXml.push('N');aXml.push(val);}
|
||||
}
|
||||
aXml.push('</v></e>');}
|
||||
}
|
||||
aXml.push('</xjxobj>');return aXml.join('');}
|
||||
xajax.tools._enforceDataType=function(value){value=new String(value);var type=value.substr(0,1);value=value.substr(1);if('*'==type)
|
||||
value=null;else if('N'==type)
|
||||
value=value-0;else if('B'==type)
|
||||
value=!!value;return value;}
|
||||
xajax.tools._nodeToObject=function(node){if(null==node)
|
||||
return '';if('undefined'!=typeof node.nodeName){if('#cdata-section'==node.nodeName||'#text'==node.nodeName){var data='';do if(node.data)data+=node.data;while(node=node.nextSibling);return xajax.tools._enforceDataType(data);}else if('xjxobj'==node.nodeName){var key=null;var value=null;var data=new Array;var child=node.firstChild;while(child){if('e'==child.nodeName){var grandChild=child.firstChild;while(grandChild){if('k'==grandChild.nodeName)
|
||||
key=xajax.tools._enforceDataType(grandChild.firstChild.data);else('v'==grandChild.nodeName)
|
||||
value=xajax.tools._nodeToObject(grandChild.firstChild);grandChild=grandChild.nextSibling;}
|
||||
if(null!=key){data[key]=value;key=value=null;}
|
||||
}
|
||||
child=child.nextSibling;}
|
||||
return data;}
|
||||
}
|
||||
throw{code:10001,data:node.nodeName};}
|
||||
xajax.tools.getRequestObject=function(){if('undefined'!=typeof XMLHttpRequest){xajax.tools.getRequestObject=function(){return new XMLHttpRequest();}
|
||||
}else if('undefined'!=typeof ActiveXObject){xajax.tools.getRequestObject=function(){try{return new ActiveXObject('Msxml2.XMLHTTP.4.0');}catch(e){xajax.tools.getRequestObject=function(){try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e2){xajax.tools.getRequestObject=function(){return new ActiveXObject('Microsoft.XMLHTTP');}
|
||||
return xajax.tools.getRequestObject();}
|
||||
}
|
||||
return xajax.tools.getRequestObject();}
|
||||
}
|
||||
}else if(window.createRequest){xajax.tools.getRequestObject=function(){return window.createRequest();}
|
||||
}else{xajax.tools.getRequestObject=function(){throw{code:10002};}
|
||||
}
|
||||
return xajax.tools.getRequestObject();}
|
||||
xajax.tools.getBrowserHTML=function(sValue){var oDoc=xajax.config.baseDocument;if(!oDoc.body)
|
||||
return '';var elWorkspace=xajax.$('xajax_temp_workspace');if(!elWorkspace){elWorkspace=oDoc.createElement('div');elWorkspace.setAttribute('id','xajax_temp_workspace');elWorkspace.style.display='none';elWorkspace.style.visibility='hidden';oDoc.body.appendChild(elWorkspace);}
|
||||
elWorkspace.innerHTML=sValue;var browserHTML=elWorkspace.innerHTML;elWorkspace.innerHTML='';return browserHTML;}
|
||||
xajax.tools.willChange=function(element,attribute,newData){if('string'==typeof element)
|
||||
element=xajax.$(element);if(element){var oldData;eval('oldData=element.'+attribute);return(newData!=oldData);}
|
||||
return false;}
|
||||
xajax.tools.getFormValues=function(parent){var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true)
|
||||
submitDisabledElements=true;var prefix='';if(arguments.length > 2)
|
||||
prefix=arguments[2];if('string'==typeof parent)
|
||||
parent=xajax.$(parent);var aFormValues={};if(parent)
|
||||
if(parent.childNodes)
|
||||
xajax.tools._getFormValues(aFormValues,parent.childNodes,submitDisabledElements,prefix);return aFormValues;}
|
||||
xajax.tools._getFormValues=function(aFormValues,children,submitDisabledElements,prefix){var iLen=children.length;for(var i=0;i < iLen;++i){var child=children[i];if('undefined'!=typeof child.childNodes)
|
||||
xajax.tools._getFormValues(aFormValues,child.childNodes,submitDisabledElements,prefix);xajax.tools._getFormValue(aFormValues,child,submitDisabledElements,prefix);}
|
||||
}
|
||||
xajax.tools._getFormValue=function(aFormValues,child,submitDisabledElements,prefix){if(!child.name)
|
||||
return;if(child.disabled)
|
||||
if(true==child.disabled)
|
||||
if(false==submitDisabledElements)
|
||||
return;if(prefix!=child.name.substring(0,prefix.length))
|
||||
return;if(child.type)
|
||||
if(child.type=='radio'||child.type=='checkbox')
|
||||
if(false==child.checked)
|
||||
return;var name=child.name;var values=[];if('select-multiple'==child.type){var jLen=child.length;for(var j=0;j < jLen;++j){var option=child.options[j];if(true==option.selected)
|
||||
values.push(option.value);}
|
||||
}else{values=child.value;}
|
||||
var keyBegin=name.indexOf('[');if(0 <=keyBegin){var n=name;var k=n.substr(0,n.indexOf('['));var a=n.substr(n.indexOf('['));if(typeof aFormValues[k]=='undefined')
|
||||
aFormValues[k]={};var p=aFormValues;while(a.length!=0){var sa=a.substr(0,a.indexOf(']')+1);var lk=k;var lp=p;a=a.substr(a.indexOf(']')+1);p=p[k];k=sa.substr(1,sa.length-2);if(k==''){if('select-multiple'==child.type){k=lk;p=lp;}else{var i=0;for(afoo in p)i++;k=i;}
|
||||
}
|
||||
if(typeof p[k]=='undefined'){p[k]={};}
|
||||
}
|
||||
p[k]=values;}else{aFormValues[name]=values;}
|
||||
}
|
||||
xajax.tools.stripOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(0==sEventName.indexOf('on'))
|
||||
sEventName=sEventName.replace(/on/,'');return sEventName;}
|
||||
xajax.tools.addOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(0!=sEventName.indexOf('on'))
|
||||
sEventName='on'+sEventName;return sEventName;}
|
||||
xajax.tools.xml={};xajax.tools.xml.parseAttributes=function(child,obj){var iLen=child.attributes.length;for(var i=0;i < iLen;++i){var attr=child.attributes[i];obj[attr.name]=attr.value;}
|
||||
}
|
||||
xajax.tools.xml.parseChildren=function(child,obj){obj.data='';if(0 < child.childNodes.length){if(1 < child.childNodes.length){var grandChild=child.firstChild;do{if('#cdata-section'==grandChild.nodeName||'#text'==grandChild.nodeName){obj.data+=grandChild.data;}
|
||||
}while(grandChild=grandChild.nextSibling);}else{var grandChild=child.firstChild;if('xjxobj'==grandChild.nodeName){obj.data=xajax.tools._nodeToObject(grandChild);return;}else if('#cdata-section'==grandChild.nodeName||'#text'==grandChild.nodeName){obj.data=grandChild.data;}
|
||||
}
|
||||
}else if('undefined'!=typeof child.data){obj.data=child.data;}
|
||||
obj.data=xajax.tools._enforceDataType(obj.data);}
|
||||
xajax.tools.xml.processFragment=function(xmlNode,seq,oRequest){var xx=xajax;var xt=xx.tools;while(xmlNode){if('cmd'==xmlNode.nodeName){var obj={};obj.fullName='*unknown*';obj.sequence=seq;obj.request=oRequest;obj.context=oRequest.context;xt.xml.parseAttributes(xmlNode,obj);xt.xml.parseChildren(xmlNode,obj);xt.queue.push(xx.response,obj);}else if('xjxrv'==xmlNode.nodeName){oRequest.returnValue=xt._nodeToObject(xmlNode.firstChild);}else if('debugmsg'==xmlNode.nodeName){}else
|
||||
throw{code:10004,data:xmlNode.nodeName}
|
||||
++seq;xmlNode=xmlNode.nextSibling;}
|
||||
}
|
||||
xajax.tools.queue={}
|
||||
xajax.tools.queue.create=function(size){return{start:0,
|
||||
size:size,
|
||||
end:0,
|
||||
commands:[],
|
||||
timeout:null
|
||||
}
|
||||
}
|
||||
xajax.tools.queue.retry=function(obj,count){var retries=obj.retries;if(retries){--retries;if(1 > retries)
|
||||
return false;}else retries=count;obj.retries=retries;return true;}
|
||||
xajax.tools.queue.rewind=function(theQ){if(0 < theQ.start)
|
||||
--theQ.start;else
|
||||
theQ.start=theQ.size;}
|
||||
xajax.tools.queue.setWakeup=function(theQ,when){if(null!=theQ.timeout){clearTimeout(theQ.timeout);theQ.timeout=null;}
|
||||
theQ.timout=setTimeout(function(){xajax.tools.queue.process(theQ);},when);}
|
||||
xajax.tools.queue.process=function(theQ){if(null!=theQ.timeout){clearTimeout(theQ.timeout);theQ.timeout=null;}
|
||||
var obj=xajax.tools.queue.pop(theQ);while(null!=obj){try{if(false==xajax.executeCommand(obj))
|
||||
return false;}catch(e){}
|
||||
delete obj;obj=xajax.tools.queue.pop(theQ);}
|
||||
return true;}
|
||||
xajax.tools.queue.push=function(theQ,obj){var next=theQ.end+1;if(next > theQ.size)
|
||||
next=0;if(next!=theQ.start){theQ.commands[theQ.end]=obj;theQ.end=next;}else
|
||||
throw{code:10003}
|
||||
}
|
||||
xajax.tools.queue.pushFront=function(theQ,obj){xajax.tools.queue.rewind(theQ);theQ.commands[theQ.start]=obj;}
|
||||
xajax.tools.queue.pop=function(theQ){var next=theQ.start;if(next==theQ.end)
|
||||
return null;next++;if(next > theQ.size)
|
||||
next=0;var obj=theQ.commands[theQ.start];delete theQ.commands[theQ.start];theQ.start=next;return obj;}
|
||||
xajax.responseProcessor={};xajax.responseProcessor.xml=function(oRequest){var xx=xajax;var xt=xx.tools;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;if(xt.arrayContainsValue(xx.responseSuccessCodes,oRequest.request.status)){xcb.execute([gcb,lcb],'onSuccess',oRequest);var seq=0;if(oRequest.request.responseXML){var responseXML=oRequest.request.responseXML;if(responseXML.documentElement){oRequest.status.onProcessing();var child=responseXML.documentElement.firstChild;xt.xml.processFragment(child,seq,oRequest);}
|
||||
}
|
||||
var obj={};obj.fullName='Response Complete';obj.sequence=seq;obj.request=oRequest;obj.context=oRequest.context;obj.cmd='rcmplt';xt.queue.push(xx.response,obj);if(null==xx.response.timeout)
|
||||
xt.queue.process(xx.response);}else if(xt.arrayContainsValue(xx.responseRedirectCodes,oRequest.request.status)){xcb.execute([gcb,lcb],'onRedirect',oRequest);window.location=oRequest.request.getResponseHeader('location');xx.completeResponse(oRequest);}else if(xt.arrayContainsValue(xx.responseErrorsForAlert,oRequest.request.status)){xcb.execute([gcb,lcb],'onFailure',oRequest);xx.completeResponse(oRequest);}
|
||||
return oRequest.returnValue;}
|
||||
xajax.js={}
|
||||
xajax.js.includeScriptOnce=function(command){command.fullName='includeScriptOnce';var fileName=command.data;var oDoc=xajax.config.baseDocument;var loadedScripts=oDoc.getElementsByTagName('script');var iLen=loadedScripts.length;for(var i=0;i < iLen;++i){var script=loadedScripts[i];if(script.src){if(0 <=script.src.indexOf(fileName))
|
||||
return true;}
|
||||
}
|
||||
return xajax.js.includeScript({data:fileName});}
|
||||
xajax.js.includeScript=function(command){command.fullName='includeScript';var fileName=command.data;var oDoc=xajax.config.baseDocument;var objHead=oDoc.getElementsByTagName('head');var objScript=oDoc.createElement('script');objScript.type='text/javascript';objScript.src=fileName;if('function'==command.onload){objScript.onload.command.onload;}
|
||||
objHead[0].appendChild(objScript);return true;}
|
||||
xajax.js.removeScript=function(command){command.fullName='removeScript';var fileName=command.data;var unload=command.unld;var oDoc=xajax.config.baseDocument;var loadedScripts=oDoc.getElementsByTagName('script');var iLen=loadedScripts.length;for(var i=0;i < iLen;++i){var script=loadedScripts[i];if(script.src){if(0 <=script.src.indexOf(fileName)){if('undefined'!=typeof unload){var args={};args.data=unload;args.context=window;xajax.js.execute(args);}
|
||||
var parent=script.parentNode;parent.removeChild(script);}
|
||||
}
|
||||
}
|
||||
return true;}
|
||||
xajax.js.sleep=function(command){command.fullName='sleep';if(xajax.tools.queue.retry(command,command.prop)){xajax.tools.queue.setWakeup(xajax.response,100);return false;}
|
||||
return true;}
|
||||
xajax.js.confirmCommands=function(command){command.fullName='confirmCommands';var msg=command.data;var numberOfCommands=command.id;if(false==confirm(msg)){while(0 < numberOfCommands){xajax.tools.queue.pop(xajax.response);--numberOfCommands;}
|
||||
}
|
||||
return true;}
|
||||
xajax.js.execute=function(args){args.fullName='execute Javascript';var returnValue=true;args.context.xajaxDelegateCall=function(){eval(args.data);}
|
||||
args.context.xajaxDelegateCall();return returnValue;}
|
||||
xajax.js.waitFor=function(args){args.fullName='waitFor';var bResult=false;var cmdToEval='bResult = (';cmdToEval+=args.data;cmdToEval+=');';try{args.context.xajaxDelegateCall=function(){eval(cmdToEval);}
|
||||
args.context.xajaxDelegateCall();}catch(e){}
|
||||
if(false==bResult){if(xajax.tools.queue.retry(args,args.prop)){xajax.tools.queue.setWakeup(xajax.response,100);return false;}
|
||||
}
|
||||
return true;}
|
||||
xajax.js.call=function(args){args.fullName='call js function';var parameters=args.data;var scr=new Array();scr.push(args.func);scr.push('(');if('undefined'!=typeof parameters){if('object'==typeof parameters){var iLen=parameters.length;if(0 < iLen){scr.push('parameters[0]');for(var i=1;i < iLen;++i)
|
||||
scr.push(', parameters['+i+']');}
|
||||
}
|
||||
}
|
||||
scr.push(');');args.context.xajaxDelegateCall=function(){eval(scr.join(''));}
|
||||
args.context.xajaxDelegateCall();return true;}
|
||||
xajax.js.setFunction=function(args){args.fullName='setFunction';var code=new Array();code.push(args.func);code.push(' = function(');if('object'==typeof args.prop){var separator='';for(var m in args.prop){code.push(separator);code.push(args.prop[m]);separator=',';}
|
||||
}else code.push(args.prop);code.push(') { ');code.push(args.data);code.push(' }');args.context.xajaxDelegateCall=function(){eval(code.join(''));}
|
||||
args.context.xajaxDelegateCall();return true;}
|
||||
xajax.js.wrapFunction=function(args){args.fullName='wrapFunction';var code=new Array();code.push(args.func);code.push(' = xajax.js.makeWrapper(');code.push(args.func);code.push(', args.prop, args.data, args.type, args.context);');args.context.xajaxDelegateCall=function(){eval(code.join(''));}
|
||||
args.context.xajaxDelegateCall();return true;}
|
||||
xajax.js.makeWrapper=function(origFun,args,codeBlocks,returnVariable,context){var originalCall='';if(0 < returnVariable.length){originalCall+=returnVariable;originalCall+=' = ';}
|
||||
var originalCall='origFun(';originalCall+=args;originalCall+='); ';var code='wrapper = function(';code+=args;code+=') { ';if(0 < returnVariable.length){code+=' var ';code+=returnVariable;code+=' = null;';}
|
||||
var separator='';var bLen=codeBlocks.length;for(var b=0;b < bLen;++b){code+=separator;code+=codeBlocks[b];separator=originalCall;}
|
||||
if(0 < returnVariable.length){code+=' return ';code+=returnVariable;code+=';';}
|
||||
code+=' } ';var wrapper=null;context.xajaxDelegateCall=function(){eval(code);}
|
||||
context.xajaxDelegateCall();return wrapper;}
|
||||
xajax.dom={}
|
||||
xajax.dom.assign=function(element,property,data){if('string'==typeof element)
|
||||
element=xajax.$(element);switch(property){case 'innerHTML':
|
||||
element.innerHTML=data;break;case 'outerHTML':
|
||||
if('undefined'==typeof element.outerHTML){var r=xajax.config.baseDocument.createRange();r.setStartBefore(element);var df=r.createContextualFragment(data);element.parentNode.replaceChild(df,element);}else element.outerHTML=data;break;default:
|
||||
if(xajax.tools.willChange(element,property,data))
|
||||
eval('element.'+property+' = data;');break;}
|
||||
return true;}
|
||||
xajax.dom.append=function(element,property,data){if('string'==typeof element)
|
||||
element=xajax.$(element);eval('element.'+property+' += data;');return true;}
|
||||
xajax.dom.prepend=function(element,property,data){if('string'==typeof element)
|
||||
element=xajax.$(element);eval('element.'+property+' = data + element.'+property);return true;}
|
||||
xajax.dom.replace=function(element,sAttribute,aData){var sSearch=aData['s'];var sReplace=aData['r'];if(sAttribute=='innerHTML')
|
||||
sSearch=xajax.tools.getBrowserHTML(sSearch);if('string'==typeof element)
|
||||
element=xajax.$(element);eval('var txt = element.'+sAttribute);var bFunction=false;if('function'==typeof txt){txt=txt.join('');bFunction=true;}
|
||||
var start=txt.indexOf(sSearch);if(start >-1){var newTxt=[];while(start >-1){var end=start+sSearch.length;newTxt.push(txt.substr(0,start));newTxt.push(sReplace);txt=txt.substr(end,txt.length-end);start=txt.indexOf(sSearch);}
|
||||
newTxt.push(txt);newTxt=newTxt.join('');if(bFunction){eval('element.'+sAttribute+'=newTxt;');}else if(xajax.tools.willChange(element,sAttribute,newTxt)){eval('element.'+sAttribute+'=newTxt;');}
|
||||
}
|
||||
return true;}
|
||||
xajax.dom.remove=function(element){if('string'==typeof element)
|
||||
element=xajax.$(element);if(element&&element.parentNode&&element.parentNode.removeChild)
|
||||
element.parentNode.removeChild(element);return true;}
|
||||
xajax.dom.create=function(objParent,sTag,sId){if('string'==typeof objParent)
|
||||
objParent=xajax.$(objParent);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);if(objParent)
|
||||
objParent.appendChild(target);return true;}
|
||||
xajax.dom.insert=function(objSibling,sTag,sId){if('string'==typeof objSibling)
|
||||
objSibling=xajax.$(objSibling);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);objSibling.parentNode.insertBefore(target,objSibling);return true;}
|
||||
xajax.dom.insertAfter=function(objSibling,sTag,sId){if('string'==typeof objSibling)
|
||||
objSibling=xajax.$(objSibling);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);objSibling.parentNode.insertBefore(target,objSibling.nextSibling);return true;}
|
||||
xajax.dom.contextAssign=function(args){args.fullName='context assign';var code=[];code.push('this.');code.push(args.prop);code.push(' = data;');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
|
||||
args.context.xajaxDelegateCall(args.data);return true;}
|
||||
xajax.dom.contextAppend=function(args){args.fullName='context append';var code=[];code.push('this.');code.push(args.prop);code.push(' += data;');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
|
||||
args.context.xajaxDelegateCall(args.data);return true;}
|
||||
xajax.dom.contextPrepend=function(args){args.fullName='context prepend';var code=[];code.push('this.');code.push(args.prop);code.push(' = data + this.');code.push(args.prop);code.push(';');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
|
||||
args.context.xajaxDelegateCall(args.data);return true;}
|
||||
xajax.css={}
|
||||
xajax.css.add=function(filename){var oDoc=xajax.config.baseDocument;var oHeads=oDoc.getElementsByTagName('head');var oHead=oHeads[0];var oLinks=oHead.getElementsByTagName('link');var found=false;var iLen=oLinks.length;for(var i=0;i < iLen&&false==found;++i)
|
||||
if(0 < oLinks[i].href.indexOf(filename))
|
||||
found=true;if(false==found){var oCSS=oDoc.createElement('link');oCSS.rel='stylesheet';oCSS.type='text/css';oCSS.href=filename;oHead.appendChild(oCSS);}
|
||||
return true;}
|
||||
xajax.css.remove=function(filename){var oDoc=xajax.config.baseDocument;var oHeads=oDoc.getElementsByTagName('head');var oHead=oHeads[0];var oLinks=oHead.getElementsByTagName('link');var i=0;while(i < oLinks.length)
|
||||
if(0 <=oLinks[i].href.indexOf(filename))
|
||||
oHead.removeChild(oLinks[i]);else++i;return true;}
|
||||
xajax.css.waitForCSS=function(args){var oDocSS=xajax.config.baseDocument.styleSheets;var ssEnabled=[];var iLen=oDocSS.length;for(var i=0;i < iLen;++i){ssEnabled[i]=0;try{ssEnabled[i]=oDocSS[i].cssRules.length;}catch(e){try{ssEnabled[i]=oDocSS[i].rules.length;}catch(e){}
|
||||
}
|
||||
}
|
||||
var ssLoaded=true;var iLen=ssEnabled.length;for(var i=0;i < iLen;++i)
|
||||
if(0==ssEnabled[i])
|
||||
ssLoaded=false;if(false==ssLoaded){if(xajax.tools.queue.retry(args,args.prop)){xajax.tools.queue.setWakeup(xajax.response,10);return false;}
|
||||
}
|
||||
return true;}
|
||||
xajax.forms={}
|
||||
xajax.forms.getInput=function(type,name,id){if('undefined'==typeof window.addEventListener){xajax.forms.getInput=function(type,name,id){return xajax.config.baseDocument.createElement('<input type="'+type+'" name="'+name+'" id="'+id+'">');}
|
||||
}else{xajax.forms.getInput=function(type,name,id){var oDoc=xajax.config.baseDocument;var Obj=oDoc.createElement('input');Obj.setAttribute('type',type);Obj.setAttribute('name',name);Obj.setAttribute('id',id);return Obj;}
|
||||
}
|
||||
return xajax.forms.getInput(type,name,id);}
|
||||
xajax.forms.createInput=function(command){command.fullName='createInput';var objParent=command.id;var sType=args.type;var sName=args.data;var sId=args.prop;if('string'==typeof objParent)
|
||||
objParent=xajax.$(objParent);var target=xajax.forms.getInput(sType,sName,sId);if(objParent&&target)
|
||||
objParent.appendChild(target);return true;}
|
||||
xajax.forms.insertInput=function(command){command.fullName='insertInput';var objSibling=command.id;var sType=command.type;var sName=command.data;var sId=command.prop;if('string'==typeof objSibling)
|
||||
objSibling=xajax.$(objSibling);var target=xajax.forms.getInput(sType,sName,sId);if(target&&objSibling&&objSibling.parentNode)
|
||||
objSibling.parentNode.insertBefore(target,objSibling);return true;}
|
||||
xajax.forms.insertInputAfter=function(command){command.fullName='insertInputAfter';var objSibling=command.id;var sType=command.type;var sName=command.data;var sId=command.prop;if('string'==typeof objSibling)
|
||||
objSibling=xajax.$(objSibling);var target=xajax.forms.getInput(sType,sName,sId);if(target&&objSibling&&objSibling.parentNode)
|
||||
objSibling.parentNode.insertBefore(target,objSibling.nextSibling);return true;}
|
||||
xajax.events={}
|
||||
xajax.events.setEvent=function(command){command.fullName='addEvent';var element=command.id;var sEvent=command.prop;var code=command.data;if('string'==typeof element)
|
||||
element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);code=xajax.tools.doubleQuotes(code);eval('element.'+sEvent+' = function() { '+code+'; }');return true;}
|
||||
xajax.events.addHandler=function(element,sEvent,fun){if(window.addEventListener){xajax.events.addHandler=function(command){command.fullName='addHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
|
||||
element=xajax.$(element);sEvent=xajax.tools.stripOnPrefix(sEvent);eval('element.addEventListener("'+sEvent+'", '+fun+', false);');return true;}
|
||||
}else{xajax.events.addHandler=function(command){command.fullName='addHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
|
||||
element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);eval('element.attachEvent("'+sEvent+'", '+fun+', false);');return true;}
|
||||
}
|
||||
return xajax.events.addHandler(element,sEvent,fun);}
|
||||
xajax.events.removeHandler=function(element,sEvent,fun){if(window.removeEventListener){xajax.events.removeHandler=function(command){command.fullName='removeHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
|
||||
element=xajax.$(element);sEvent=xajax.tools.stripOnPrefix(sEvent);eval('element.removeEventListener("'+sEvent+'", '+fun+', false);');return true;}
|
||||
}else{xajax.events.removeHandler=function(command){command.fullName='removeHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
|
||||
element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);eval('element.detachEvent("'+sEvent+'", '+fun+', false);');return true;}
|
||||
}
|
||||
return xajax.events.removeHandler(element,sEvent,fun);}
|
||||
xajax.callback={}
|
||||
xajax.callback.create=function(){var xx=xajax;var xc=xx.config;var xcb=xx.callback;var oCB={}
|
||||
oCB.timers={};oCB.timers.onResponseDelay=xcb.setupTimer(
|
||||
(arguments.length > 0)
|
||||
? arguments[0]
|
||||
:xc.defaultResponseDelayTime);oCB.timers.onExpiration=xcb.setupTimer(
|
||||
(arguments.length > 1)
|
||||
? arguments[1]
|
||||
:xc.defaultExpirationTime);oCB.onRequest=null;oCB.onResponseDelay=null;oCB.onExpiration=null;oCB.beforeResponseProcessing=null;oCB.onFailure=null;oCB.onRedirect=null;oCB.onSuccess=null;oCB.onComplete=null;return oCB;}
|
||||
xajax.callback.setupTimer=function(iDelay){return{timer:null,delay:iDelay};}
|
||||
xajax.callback.clearTimer=function(oCallback,sFunction){if('undefined'!=typeof oCallback.timers){if('undefined'!=typeof oCallback.timers[sFunction]){clearTimeout(oCallback.timers[sFunction].timer);}
|
||||
}else if('object'==typeof oCallback){var iLen=oCallback.length;for(var i=0;i < iLen;++i)
|
||||
xajax.callback.clearTimer(oCallback[i],sFunction);}
|
||||
}
|
||||
xajax.callback.execute=function(oCallback,sFunction,args){if('undefined'!=typeof oCallback[sFunction]){var func=oCallback[sFunction];if('function'==typeof func){if('undefined'!=typeof oCallback.timers[sFunction]){oCallback.timers[sFunction].timer=setTimeout(function(){func(args);},oCallback.timers[sFunction].delay);}
|
||||
else{func(args);}
|
||||
}
|
||||
}else if('object'==typeof oCallback){var iLen=oCallback.length;for(var i=0;i < iLen;++i)
|
||||
xajax.callback.execute(oCallback[i],sFunction,args);}
|
||||
}
|
||||
xajax.callback.global=xajax.callback.create();xajax.response=xajax.tools.queue.create(1000);xajax.responseSuccessCodes=['0','200'];xajax.responseErrorsForAlert=['400','401','402','403','404','500','501','502','503'];xajax.responseRedirectCodes=['301','302','307'];if('undefined'==typeof xajax.command)
|
||||
xajax.command={};xajax.command.create=function(sequence,request,context){var newCmd={};newCmd.cmd='*';newCmd.fullName='* unknown command name *';newCmd.sequence=sequence;newCmd.request=request;newCmd.context=context;return newCmd;}
|
||||
if('undefined'==typeof xajax.command.handler)
|
||||
xajax.command.handler={};if('undefined'==typeof xajax.command.handler.handlers)
|
||||
xajax.command.handler.handlers=[];xajax.command.handler.register=function(shortName,func){xajax.command.handler.handlers[shortName]=func;}
|
||||
xajax.command.handler.unregister=function(shortName){var func=xajax.command.handler.handlers[shortName];delete xajax.command.handler.handlers[shortName];return func;}
|
||||
xajax.command.handler.isRegistered=function(command){var shortName=command.cmd;if(xajax.command.handler.handlers[shortName])
|
||||
return true;return false;}
|
||||
xajax.command.handler.call=function(command){var shortName=command.cmd;return xajax.command.handler.handlers[shortName](command);}
|
||||
xajax.command.handler.register('rcmplt',function(args){xajax.completeResponse(args.request);return true;});xajax.command.handler.register('css',function(args){args.fullName='includeCSS';return xajax.css.add(args.data);});xajax.command.handler.register('rcss',function(args){args.fullName='removeCSS';return xajax.css.remove(args.data);});xajax.command.handler.register('wcss',function(args){args.fullName='waitForCSS';return xajax.css.waitForCSS(args);});xajax.command.handler.register('as',function(args){args.fullName='assign/clear';try{return xajax.dom.assign(args.target,args.prop,args.data);}catch(e){}
|
||||
return true;});xajax.command.handler.register('ap',function(args){args.fullName='append';return xajax.dom.append(args.target,args.prop,args.data);});xajax.command.handler.register('pp',function(args){args.fullName='prepend';return xajax.dom.prepend(args.target,args.prop,args.data);});xajax.command.handler.register('rp',function(args){args.fullName='replace';return xajax.dom.replace(args.id,args.prop,args.data);});xajax.command.handler.register('rm',function(args){args.fullName='remove';return xajax.dom.remove(args.id);});xajax.command.handler.register('ce',function(args){args.fullName='create';return xajax.dom.create(args.id,args.data,args.prop);});xajax.command.handler.register('ie',function(args){args.fullName='insert';return xajax.dom.insert(args.id,args.data,args.prop);});xajax.command.handler.register('ia',function(args){args.fullName='insertAfter';return xajax.dom.insertAfter(args.id,args.data,args.prop);});xajax.command.handler.register('c:as',xajax.dom.contextAssign);xajax.command.handler.register('c:ap',xajax.dom.contextAppend);xajax.command.handler.register('c:pp',xajax.dom.contextPrepend);xajax.command.handler.register('s',xajax.js.sleep);xajax.command.handler.register('ino',xajax.js.includeScriptOnce);xajax.command.handler.register('in',xajax.js.includeScript);xajax.command.handler.register('rjs',xajax.js.removeScript);xajax.command.handler.register('wf',xajax.js.waitFor);xajax.command.handler.register('js',xajax.js.execute);xajax.command.handler.register('jc',xajax.js.call);xajax.command.handler.register('sf',xajax.js.setFunction);xajax.command.handler.register('wpf',xajax.js.wrapFunction);xajax.command.handler.register('al',function(args){args.fullName='alert';alert(args.data);return true;});xajax.command.handler.register('cc',xajax.js.confirmCommands);xajax.command.handler.register('ci',xajax.forms.createInput);xajax.command.handler.register('ii',xajax.forms.insertInput);xajax.command.handler.register('iia',xajax.forms.insertInputAfter);xajax.command.handler.register('ev',xajax.events.setEvent);xajax.command.handler.register('ah',xajax.events.addHandler);xajax.command.handler.register('rh',xajax.events.removeHandler);xajax.command.handler.register('dbg',function(args){args.fullName='debug message';return true;});xajax.initializeRequest=function(oRequest){var xx=xajax;var xc=xx.config;oRequest.append=function(opt,def){if('undefined'!=typeof this[opt]){for(var itmName in def)
|
||||
if('undefined'==typeof this[opt][itmName])
|
||||
this[opt][itmName]=def[itmName];}else this[opt]=def;}
|
||||
oRequest.append('commonHeaders',xc.commonHeaders);oRequest.append('postHeaders',xc.postHeaders);oRequest.append('getHeaders',xc.getHeaders);oRequest.set=function(option,defaultValue){if('undefined'==typeof this[option])
|
||||
this[option]=defaultValue;}
|
||||
oRequest.set('statusMessages',xc.statusMessages);oRequest.set('waitCursor',xc.waitCursor);oRequest.set('mode',xc.defaultMode);oRequest.set('method',xc.defaultMethod);oRequest.set('URI',xc.requestURI);oRequest.set('httpVersion',xc.defaultHttpVersion);oRequest.set('contentType',xc.defaultContentType);oRequest.set('retry',xc.defaultRetry);oRequest.set('returnValue',xc.defaultReturnValue);oRequest.set('maxObjectDepth',xc.maxObjectDepth);oRequest.set('maxObjectSize',xc.maxObjectSize);oRequest.set('context',window);var xcb=xx.callback;var gcb=xcb.global;var lcb=xcb.create();lcb.take=function(frm,opt){if('undefined'!=typeof frm[opt]){lcb[opt]=frm[opt];lcb.hasEvents=true;}
|
||||
delete frm[opt];}
|
||||
lcb.take(oRequest,'onRequest');lcb.take(oRequest,'onResponseDelay');lcb.take(oRequest,'onExpiration');lcb.take(oRequest,'beforeResponseProcessing');lcb.take(oRequest,'onFailure');lcb.take(oRequest,'onRedirect');lcb.take(oRequest,'onSuccess');lcb.take(oRequest,'onComplete');if('undefined'!=typeof oRequest.callback){if(lcb.hasEvents)
|
||||
oRequest.callback=[oRequest.callback,lcb];}else
|
||||
oRequest.callback=lcb;oRequest.status=(oRequest.statusMessages)
|
||||
? xc.status.update()
|
||||
:xc.status.dontUpdate();oRequest.cursor=(oRequest.waitCursor)
|
||||
? xc.cursor.update()
|
||||
:xc.cursor.dontUpdate();oRequest.method=oRequest.method.toUpperCase();if('GET'!=oRequest.method)
|
||||
oRequest.method='POST';oRequest.requestRetry=oRequest.retry;oRequest.append('postHeaders',{'content-type':oRequest.contentType
|
||||
});delete oRequest['append'];delete oRequest['set'];delete oRequest['take'];if('undefined'==typeof oRequest.URI)
|
||||
throw{code:10005}
|
||||
}
|
||||
xajax.processParameters=function(oRequest){var xx=xajax;var xt=xx.tools;var rd=[];var separator='';for(var sCommand in oRequest.functionName){if('constructor'!=sCommand){rd.push(separator);rd.push(sCommand);rd.push('=');rd.push(encodeURIComponent(oRequest.functionName[sCommand]));separator='&';}
|
||||
}
|
||||
var dNow=new Date();rd.push('&xjxr=');rd.push(dNow.getTime());delete dNow;if(oRequest.parameters){var i=0;var iLen=oRequest.parameters.length;while(i < iLen){var oVal=oRequest.parameters[i];if('object'==typeof oVal&&null!=oVal){try{var oGuard={};oGuard.depth=0;oGuard.maxDepth=oRequest.maxObjectDepth;oGuard.size=0;oGuard.maxSize=oRequest.maxObjectSize;oVal=xt._objectToXML(oVal,oGuard);}catch(e){oVal='';}
|
||||
rd.push('&xjxargs[]=');oVal=encodeURIComponent(oVal);rd.push(oVal);++i;}else{rd.push('&xjxargs[]=');oVal=xt._escape(oVal);if('undefined'==typeof oVal||null==oVal){rd.push('*');}else{var sType=typeof oVal;if('string'==sType)
|
||||
rd.push('S');else if('boolean'==sType)
|
||||
rd.push('B');else if('number'==sType)
|
||||
rd.push('N');oVal=encodeURIComponent(oVal);rd.push(oVal);}
|
||||
++i;}
|
||||
}
|
||||
}
|
||||
oRequest.requestURI=oRequest.URI;if('GET'==oRequest.method){oRequest.requestURI+=oRequest.requestURI.indexOf('?')==-1 ? '?':'&';oRequest.requestURI+=rd.join('');rd=[];}
|
||||
oRequest.requestData=rd.join('');}
|
||||
xajax.prepareRequest=function(oRequest){var xx=xajax;var xt=xx.tools;oRequest.request=xt.getRequestObject();oRequest.setRequestHeaders=function(headers){if('object'==typeof headers){for(var optionName in headers)
|
||||
this.request.setRequestHeader(optionName,headers[optionName]);}
|
||||
}
|
||||
oRequest.setCommonRequestHeaders=function(){this.setRequestHeaders(this.commonHeaders);}
|
||||
oRequest.setPostRequestHeaders=function(){this.setRequestHeaders(this.postHeaders);}
|
||||
oRequest.setGetRequestHeaders=function(){this.setRequestHeaders(this.getHeaders);}
|
||||
if('asynchronous'==oRequest.mode){oRequest.request.onreadystatechange=function(){if(oRequest.request.readyState!=4)
|
||||
return;xajax.responseReceived(oRequest);}
|
||||
oRequest.finishRequest=function(){return this.returnValue;}
|
||||
}else{oRequest.finishRequest=function(){return xajax.responseReceived(oRequest);}
|
||||
}
|
||||
if('undefined'!=typeof oRequest.userName&&'undefined'!=typeof oRequest.password){oRequest.open=function(){this.request.open(
|
||||
this.method,
|
||||
this.requestURI,
|
||||
'asynchronous'==this.mode,
|
||||
oRequest.userName,
|
||||
oRequest.password);}
|
||||
}else{oRequest.open=function(){this.request.open(
|
||||
this.method,
|
||||
this.requestURI,
|
||||
'asynchronous'==this.mode);}
|
||||
}
|
||||
if('POST'==oRequest.method){oRequest.applyRequestHeaders=function(){this.setCommonRequestHeaders();try{this.setPostRequestHeaders();}catch(e){this.method='GET';this.requestURI+=this.requestURI.indexOf('?')==-1 ? '?':'&';this.requestURI+=this.requestData;this.requestData='';if(0==this.requestRetry)this.requestRetry=1;throw e;}
|
||||
}
|
||||
}else{oRequest.applyRequestHeaders=function(){this.setCommonRequestHeaders();this.setGetRequestHeaders();}
|
||||
}
|
||||
}
|
||||
xajax.request=function(){var numArgs=arguments.length;if(0==numArgs)
|
||||
return false;var oRequest={}
|
||||
if(1 < numArgs)
|
||||
oRequest=arguments[1];oRequest.functionName=arguments[0];var xx=xajax;xx.initializeRequest(oRequest);xx.processParameters(oRequest);while(0 < oRequest.requestRetry){try{--oRequest.requestRetry;xx.prepareRequest(oRequest);return xx.submitRequest(oRequest);}catch(e){xajax.callback.execute(
|
||||
[xajax.callback.global,oRequest.callback],
|
||||
'onFailure',oRequest);if(0==oRequest.requestRetry)
|
||||
throw e;}
|
||||
}
|
||||
}
|
||||
xajax.call=function(){var numArgs=arguments.length;if(0==numArgs)
|
||||
return false;var oRequest={}
|
||||
if(1 < numArgs)
|
||||
oRequest=arguments[1];oRequest.functionName={xjxfun:arguments[0]};var xx=xajax;xx.initializeRequest(oRequest);xx.processParameters(oRequest);while(0 < oRequest.requestRetry){try{--oRequest.requestRetry;xx.prepareRequest(oRequest);return xx.submitRequest(oRequest);}catch(e){xajax.callback.execute(
|
||||
[xajax.callback.global,oRequest.callback],
|
||||
'onFailure',oRequest);if(0==oRequest.requestRetry)
|
||||
throw e;}
|
||||
}
|
||||
}
|
||||
xajax.submitRequest=function(oRequest){oRequest.status.onRequest();var xcb=xajax.callback;var gcb=xcb.global;var lcb=oRequest.callback;xcb.execute([gcb,lcb],'onResponseDelay',oRequest);xcb.execute([gcb,lcb],'onExpiration',oRequest);xcb.execute([gcb,lcb],'onRequest',oRequest);oRequest.open();oRequest.applyRequestHeaders();oRequest.cursor.onWaiting();oRequest.status.onWaiting();xajax._internalSend(oRequest);return oRequest.finishRequest();}
|
||||
xajax._internalSend=function(oRequest){oRequest.request.send(oRequest.requestData);}
|
||||
xajax.abortRequest=function(oRequest){oRequest.aborted=true;oRequest.request.abort();xajax.completeResponse(oRequest);}
|
||||
xajax.responseReceived=function(oRequest){var xx=xajax;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;if(oRequest.aborted)
|
||||
return;xcb.clearTimer([gcb,lcb],'onExpiration');xcb.clearTimer([gcb,lcb],'onResponseDelay');xcb.execute([gcb,lcb],'beforeResponseProcessing',oRequest);var fProc=xx.getResponseProcessor(oRequest);if('undefined'==typeof fProc){xcb.execute([gcb,lcb],'onFailure',oRequest);xx.completeResponse(oRequest);return;}
|
||||
return fProc(oRequest);}
|
||||
xajax.getResponseProcessor=function(oRequest){var fProc;if('undefined'==typeof oRequest.responseProcessor){var cTyp=oRequest.request.getResponseHeader('content-type');if(cTyp){if(0 <=cTyp.indexOf('text/xml')){fProc=xajax.responseProcessor.xml;}
|
||||
}
|
||||
}else fProc=oRequest.responseProcessor;return fProc;}
|
||||
xajax.executeCommand=function(command){if(xajax.command.handler.isRegistered(command)){if(command.id)
|
||||
command.target=xajax.$(command.id);if(false==xajax.command.handler.call(command)){xajax.tools.queue.pushFront(xajax.response,command);return false;}
|
||||
}
|
||||
return true;}
|
||||
xajax.completeResponse=function(oRequest){xajax.callback.execute(
|
||||
[xajax.callback.global,oRequest.callback],
|
||||
'onComplete',oRequest);oRequest.cursor.onComplete();oRequest.status.onComplete();delete oRequest['functionName'];delete oRequest['requestURI'];delete oRequest['requestData'];delete oRequest['requestRetry'];delete oRequest['request'];delete oRequest['set'];delete oRequest['open'];delete oRequest['setRequestHeaders'];delete oRequest['setCommonRequestHeaders'];delete oRequest['setPostRequestHeaders'];delete oRequest['setGetRequestHeaders'];delete oRequest['applyRequestHeaders'];delete oRequest['finishRequest'];delete oRequest['status'];delete oRequest['cursor'];}
|
||||
xajax.$=xajax.tools.$;xajax.getFormValues=xajax.tools.getFormValues;xajax.isLoaded=true;xjx={}
|
||||
xjx.$=xajax.tools.$;xjx.getFormValues=xajax.tools.getFormValues;xjx.call=xajax.call;xjx.request=xajax.request;
|
||||
3372
libraries/xajax/xajax_js/xajax_core_uncompressed.js
Normal file
3372
libraries/xajax/xajax_js/xajax_core_uncompressed.js
Normal file
File diff suppressed because it is too large
Load Diff
856
libraries/xajax/xajax_js/xajax_debug.js
Normal file
856
libraries/xajax/xajax_js/xajax_debug.js
Normal file
@@ -0,0 +1,856 @@
|
||||
/*
|
||||
File: xajax_debug.js
|
||||
|
||||
This optional file contains the debugging module for use with xajax. If
|
||||
you include this module after the standard <xajax_core.js> module, you
|
||||
will receive debugging messages, including errors, that occur during
|
||||
the processing of your xajax requests.
|
||||
|
||||
Title: xajax debugging module
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_debug_uncompressed.js 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajax.debug
|
||||
|
||||
This object contains the variables and functions used to display process state
|
||||
messages and to trap error conditions and report them to the user via
|
||||
a secondary browser window or alert messages as necessary.
|
||||
*/
|
||||
try {
|
||||
if ('undefined' == typeof xajax.debug)
|
||||
xajax.debug = {}
|
||||
} catch (e) {
|
||||
alert('An internal error has occurred: the xajax_core has not been loaded prior to xajax_debug.');
|
||||
}
|
||||
|
||||
/*
|
||||
String: workId
|
||||
|
||||
Stores a 'unique' identifier for this session so that an existing debugging
|
||||
window can be detected, else one will be created.
|
||||
*/
|
||||
xajax.debug.workId = 'xajaxWork'+ new Date().getTime();
|
||||
|
||||
/*
|
||||
String: windowSource
|
||||
|
||||
The default URL that is given to the debugging window upon creation.
|
||||
*/
|
||||
xajax.debug.windowSource = 'about:blank';
|
||||
|
||||
/*
|
||||
String: windowID
|
||||
|
||||
A 'unique' name used to identify the debugging window that is attached
|
||||
to this xajax session.
|
||||
*/
|
||||
xajax.debug.windowID = 'xajax_debug_'+xajax.debug.workId;
|
||||
|
||||
/*
|
||||
String: windowStyle
|
||||
|
||||
The parameters that will be used to create the debugging window.
|
||||
*/
|
||||
if ('undefined' == typeof xajax.debug.windowStyle)
|
||||
xajax.debug.windowStyle =
|
||||
'width=800,' +
|
||||
'height=600,' +
|
||||
'scrollbars=yes,' +
|
||||
'resizable=yes,' +
|
||||
'status=yes';
|
||||
|
||||
/*
|
||||
String: windowTemplate
|
||||
|
||||
The HTML template and CSS style information used to populate the
|
||||
debugging window upon creation.
|
||||
*/
|
||||
if ('undefined' == typeof xajax.debug.windowTemplate)
|
||||
xajax.debug.windowTemplate =
|
||||
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' +
|
||||
'<html><head>' +
|
||||
'<title>xajax debug output</title>' +
|
||||
'<style type="text/css">' +
|
||||
'/* <![CDATA[ */' +
|
||||
'.debugEntry { margin: 3px; padding: 3px; border-top: 1px solid #999999; } ' +
|
||||
'.debugDate { font-weight: bold; margin: 2px; } ' +
|
||||
'.debugText { margin: 2px; } ' +
|
||||
'.warningText { margin: 2px; font-weight: bold; } ' +
|
||||
'.errorText { margin: 2px; font-weight: bold; color: #ff7777; }' +
|
||||
'/* ]]> */' +
|
||||
'</style>' +
|
||||
'</head><body>' +
|
||||
'<h2>xajax debug output</h2>' +
|
||||
'<div id="debugTag"></div>' +
|
||||
'</body></html>';
|
||||
|
||||
/*
|
||||
Object: window
|
||||
|
||||
A reference to the debugging window, once constructed, where messages will
|
||||
be displayed throughout the request process. This is constructed internally
|
||||
as needed.
|
||||
*/
|
||||
|
||||
/*
|
||||
Array: text
|
||||
*/
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'WARNING: ';
|
||||
xajax.debug.text[101] = 'ERROR: ';
|
||||
xajax.debug.text[102] = 'XAJAX DEBUG MESSAGE:\n';
|
||||
xajax.debug.text[103] = '...\n[LONG RESPONSE]\n...';
|
||||
xajax.debug.text[104] = 'SENDING REQUEST';
|
||||
xajax.debug.text[105] = 'SENT [';
|
||||
xajax.debug.text[106] = ' bytes]';
|
||||
xajax.debug.text[107] = 'CALLING: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'INITIALIZING REQUEST';
|
||||
xajax.debug.text[110] = 'PROCESSING PARAMETERS [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'NO PARAMETERS TO PROCESS';
|
||||
xajax.debug.text[113] = 'PREPARING REQUEST';
|
||||
xajax.debug.text[114] = 'STARTING XAJAX CALL (deprecated: use xajax.request instead)';
|
||||
xajax.debug.text[115] = 'STARTING XAJAX REQUEST';
|
||||
xajax.debug.text[116] = 'No response processor is available to process the response from the server.\n';
|
||||
xajax.debug.text[117] = '.\nCheck for error messages from the server.';
|
||||
xajax.debug.text[118] = 'RECEIVED [status: ';
|
||||
xajax.debug.text[119] = ', size: ';
|
||||
xajax.debug.text[120] = ' bytes, time: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'The server returned the following HTTP status: ';
|
||||
xajax.debug.text[123] = '\nRECEIVED:\n';
|
||||
xajax.debug.text[124] = 'The server returned a redirect to:<br />';
|
||||
xajax.debug.text[125] = 'DONE [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INITIALIZING REQUEST OBJECT';
|
||||
|
||||
/*
|
||||
Array: exceptions
|
||||
*/
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Invalid response XML: The response contains an unknown tag: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest is not available, xajax is disabled.';
|
||||
xajax.debug.exceptions[10003] = 'Queue overflow: Cannot push object onto queue because it is full.';
|
||||
xajax.debug.exceptions[10004] = 'Invalid response XML: The response contains an unexpected tag or text: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Invalid request URI: Invalid or missing URI; autodetection failed; please specify a one explicitly.';
|
||||
xajax.debug.exceptions[10006] = 'Invalid response command: Malformed response command received.';
|
||||
xajax.debug.exceptions[10007] = 'Invalid response command: Command [{data}] is not a known command.';
|
||||
xajax.debug.exceptions[10008] = 'Element with ID [{data}] not found in the document.';
|
||||
xajax.debug.exceptions[10009] = 'Invalid request: Missing function name parameter.';
|
||||
xajax.debug.exceptions[10010] = 'Invalid request: Missing function object parameter.';
|
||||
|
||||
/*
|
||||
Function: getExceptionText
|
||||
*/
|
||||
xajax.debug.getExceptionText = function(e) {
|
||||
if ('undefined' != typeof e.code) {
|
||||
if ('undefined' != typeof xajax.debug.exceptions[e.code]) {
|
||||
var msg = xajax.debug.exceptions[e.code];
|
||||
if ('undefined' != typeof e.data) {
|
||||
msg.replace('{data}', e.data);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
} else if ('undefined' != typeof e.name) {
|
||||
var msg = e.name;
|
||||
if ('undefined' != typeof e.message) {
|
||||
msg += ': ';
|
||||
msg += e.message;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
return 'An unknown error has occurred.';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: writeMessage
|
||||
|
||||
Output a debug message to the debug window if available or send to an
|
||||
alert box. If the debug window has not been created, attempt to
|
||||
create it.
|
||||
|
||||
text - (string): The text to output.
|
||||
|
||||
prefix - (string): The prefix to use; this is prepended onto the
|
||||
message; it should indicate the type of message (warning, error)
|
||||
|
||||
cls - (stirng): The className that will be applied to the message;
|
||||
invoking a style from the CSS provided in
|
||||
<xajax.debug.windowTemplate>. Should be one of the following:
|
||||
- warningText
|
||||
- errorText
|
||||
*/
|
||||
xajax.debug.writeMessage = function(text, prefix, cls) {
|
||||
try {
|
||||
var xd = xajax.debug;
|
||||
if ('undefined' == typeof xd.window || true == xd.window.closed) {
|
||||
xd.window = window.open(xd.windowSource, xd.windowID, xd.windowStyle);
|
||||
if ("about:blank" == xd.windowSource)
|
||||
xd.window.document.write(xd.windowTemplate);
|
||||
}
|
||||
var xdw = xd.window;
|
||||
var xdwd = xdw.document;
|
||||
if ('undefined' == typeof prefix)
|
||||
prefix = '';
|
||||
if ('undefined' == typeof cls)
|
||||
cls = 'debugText';
|
||||
|
||||
text = xajax.debug.prepareDebugText(text);
|
||||
|
||||
var debugTag = xdwd.getElementById('debugTag');
|
||||
var debugEntry = xdwd.createElement('div');
|
||||
var debugDate = xdwd.createElement('span');
|
||||
var debugText = xdwd.createElement('pre');
|
||||
|
||||
debugDate.innerHTML = new Date().toString();
|
||||
debugText.innerHTML = prefix + text;
|
||||
|
||||
debugEntry.appendChild(debugDate);
|
||||
debugEntry.appendChild(debugText);
|
||||
debugTag.insertBefore(debugEntry, debugTag.firstChild);
|
||||
// don't allow 'style' issues to hinder the debug output
|
||||
try {
|
||||
debugEntry.className = 'debugEntry';
|
||||
debugDate.className = 'debugDate';
|
||||
debugText.className = cls;
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {
|
||||
if (text.length > 1000) text = text.substr(0,1000) + xajax.debug.text[102];
|
||||
alert(xajax.debug.text[102] + text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: prepareDebugText
|
||||
|
||||
Convert special characters to their HTML equivellents so they
|
||||
will show up in the <xajax.debug.window>.
|
||||
*/
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
try {
|
||||
text = text.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br />');
|
||||
return text;
|
||||
} catch (e) {
|
||||
xajax.debug.stringReplace = function(haystack, needle, newNeedle) {
|
||||
var segments = haystack.split(needle);
|
||||
haystack = '';
|
||||
for (var i = 0; i < segments.length; ++i) {
|
||||
if (0 != i)
|
||||
haystack += newNeedle;
|
||||
haystack += segments[i];
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
text = xajax.debug.stringReplace(text, '&', '&');
|
||||
text = xajax.debug.stringReplace(text, '<', '<');
|
||||
text = xajax.debug.stringReplace(text, '>', '>');
|
||||
text = xajax.debug.stringReplace(text, '\n', '<br />');
|
||||
return text;
|
||||
}
|
||||
xajax.debug.prepareDebugText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: executeCommand
|
||||
|
||||
Catch any exceptions that are thrown by a response command handler
|
||||
and display a message in the debugger.
|
||||
|
||||
This is a wrapper function which surrounds the standard
|
||||
<xajax.executeCommand> function.
|
||||
*/
|
||||
xajax.debug.executeCommand = xajax.executeCommand;
|
||||
xajax.executeCommand = function(args) {
|
||||
try {
|
||||
if ('undefined' == typeof args.cmd)
|
||||
throw { code: 10006 };
|
||||
if (false == xajax.command.handler.isRegistered(args))
|
||||
throw { code: 10007, data: args.cmd };
|
||||
return xajax.debug.executeCommand(args);
|
||||
} catch(e) {
|
||||
var msg = 'ExecuteCommand (';
|
||||
if ('undefined' != typeof args.sequence) {
|
||||
msg += '#';
|
||||
msg += args.sequence;
|
||||
msg += ', ';
|
||||
}
|
||||
if ('undefined' != typeof args.cmdFullName) {
|
||||
msg += '"';
|
||||
msg += args.cmdFullName;
|
||||
msg += '"';
|
||||
}
|
||||
msg += '):\n';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: parseAttributes
|
||||
|
||||
Catch any exception thrown during the parsing of response
|
||||
command attributes and display an appropriate debug message.
|
||||
|
||||
This is a wrapper around the standard <xajax.parseAttributes>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.parseAttributes = xajax.parseAttributes;
|
||||
xajax.parseAttributes = function(child, obj) {
|
||||
try {
|
||||
xajax.debug.parseAttributes(child, obj);
|
||||
} catch(e) {
|
||||
var msg = 'ParseAttributes:\n';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
}
|
||||
|
||||
xajax.debug.commandHandler = xajax.command.handler.unregister('dbg');
|
||||
xajax.command.handler.register('dbg', function(args) {
|
||||
args.cmdFullName = 'debug message';
|
||||
xajax.debug.writeMessage(args.data, xajax.debug.text[100], 'warningText');
|
||||
return xajax.debug.commandHandler(args);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
Function: $
|
||||
|
||||
Catch any exceptions thrown while attempting to locate an
|
||||
HTML element by it's unique name.
|
||||
|
||||
This is a wrapper around the standard <xajax.tools.$> function.
|
||||
*/
|
||||
xajax.debug.$ = xajax.tools.$;
|
||||
xajax.tools.$ = function(sId) {
|
||||
try {
|
||||
var returnValue = xajax.debug.$(sId);
|
||||
if ('object' != typeof returnValue)
|
||||
throw { code: 10008 };
|
||||
}
|
||||
catch (e) {
|
||||
var msg = '$:';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[100], 'warningText');
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _objectToXML
|
||||
|
||||
Generate a message indicating that a javascript object is
|
||||
being converted to xml. Indicate the max depth and size. Then
|
||||
display the size of the object upon completion. Catch any
|
||||
exceptions thrown during the conversion process.
|
||||
|
||||
This is a wrapper around the standard <xajax.tools._objectToXML>
|
||||
function.
|
||||
*/
|
||||
xajax.debug._objectToXML = xajax.tools._objectToXML;
|
||||
xajax.tools._objectToXML = function(obj, guard) {
|
||||
try {
|
||||
if (0 == guard.size) {
|
||||
var msg = 'OBJECT TO XML: maxDepth = ';
|
||||
msg += guard.maxDepth;
|
||||
msg += ', maxSize = ';
|
||||
msg += guard.maxSize;
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
var r = xajax.debug._objectToXML(obj, guard);
|
||||
if (0 == guard.depth) {
|
||||
var msg = 'OBJECT TO XML: size = ';
|
||||
msg += guard.size;
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
return r;
|
||||
} catch(e) {
|
||||
var msg = 'ObjectToXML: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _internalSend
|
||||
|
||||
Generate a message indicating that the xajax request is
|
||||
about the be sent to the server.
|
||||
|
||||
This is a wrapper around the standard <xajax._internalSend>
|
||||
function.
|
||||
*/
|
||||
xajax.debug._internalSend = xajax._internalSend;
|
||||
xajax._internalSend = function(oRequest) {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[104]);
|
||||
xajax.debug.writeMessage(
|
||||
xajax.debug.text[105] +
|
||||
oRequest.requestData.length +
|
||||
xajax.debug.text[106]
|
||||
);
|
||||
oRequest.beginDate = new Date();
|
||||
xajax.debug._internalSend(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'InternalSend: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: submitRequest
|
||||
|
||||
Generate a message indicating that a request is ready to be
|
||||
submitted; providing the URL and the function being invoked.
|
||||
|
||||
Catch any exceptions thrown and display a message.
|
||||
|
||||
This is a wrapper around the standard <xajax.submitRequest>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.submitRequest = xajax.submitRequest;
|
||||
xajax.submitRequest = function(oRequest) {
|
||||
var msg = oRequest.method;
|
||||
msg += ': ';
|
||||
text = decodeURIComponent(oRequest.requestData);
|
||||
text = text.replace(new RegExp('&xjx', 'g'), '\n&xjx');
|
||||
text = text.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
|
||||
text = text.replace(new RegExp('<e>', 'g'), '\n<e>');
|
||||
text = text.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
|
||||
msg += text;
|
||||
xajax.debug.writeMessage(msg);
|
||||
msg = xajax.debug.text[107];
|
||||
var separator = '\n';
|
||||
for (var mbr in oRequest.functionName) {
|
||||
msg += separator;
|
||||
msg += mbr;
|
||||
msg += ': ';
|
||||
msg += oRequest.functionName[mbr];
|
||||
separator = '\n';
|
||||
}
|
||||
msg += separator;
|
||||
msg += xajax.debug.text[108];
|
||||
msg += separator;
|
||||
msg += oRequest.URI;
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
try {
|
||||
return xajax.debug.submitRequest(oRequest);
|
||||
} catch (e) {
|
||||
xajax.debug.writeMessage(e.message);
|
||||
if (0 < oRequest.retry)
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: initializeRequest
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being initialized.
|
||||
|
||||
This is a wrapper around the standard <xajax.initializeRequest>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.initializeRequest = xajax.initializeRequest;
|
||||
xajax.initializeRequest = function(oRequest) {
|
||||
try {
|
||||
var msg = xajax.debug.text[109];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return xajax.debug.initializeRequest(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'InitializeRequest: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processParameters
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being populated with the parameters provided.
|
||||
|
||||
This is a wrapper around the standard <xajax.processParameters>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.processParameters = xajax.processParameters;
|
||||
xajax.processParameters = function(oRequest) {
|
||||
try {
|
||||
if ('undefined' != typeof oRequest.parameters) {
|
||||
var msg = xajax.debug.text[110];
|
||||
msg += oRequest.parameters.length;
|
||||
msg += xajax.debug.text[111];
|
||||
xajax.debug.writeMessage(msg);
|
||||
} else {
|
||||
var msg = xajax.debug.text[112];
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
return xajax.debug.processParameters(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'ProcessParameters: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: prepareRequest
|
||||
|
||||
Generate a message indicating that the request is being
|
||||
prepared. This may occur more than once for a request
|
||||
if it errors and a retry is attempted.
|
||||
|
||||
This is a wrapper around the standard <xajax.prepareRequest>
|
||||
*/
|
||||
xajax.debug.prepareRequest = xajax.prepareRequest;
|
||||
xajax.prepareRequest = function(oRequest) {
|
||||
try {
|
||||
var msg = xajax.debug.text[113];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return xajax.debug.prepareRequest(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'PrepareRequest: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: call
|
||||
|
||||
Validates that a function name was provided, generates a message
|
||||
indicating that a xajax call is starting and sets a flag in the
|
||||
request object indicating that debugging is enabled for this call.
|
||||
|
||||
This is a wrapper around the standard <xajax.call> function.
|
||||
*/
|
||||
xajax.debug.call = xajax.call;
|
||||
xajax.call = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[114]);
|
||||
|
||||
var numArgs = arguments.length;
|
||||
|
||||
if (0 == numArgs)
|
||||
throw { code: 10009 };
|
||||
|
||||
var functionName = arguments[0];
|
||||
var oOptions = {}
|
||||
if (1 < numArgs)
|
||||
oOptions = arguments[1];
|
||||
|
||||
oOptions.debugging = true;
|
||||
|
||||
return xajax.debug.call(functionName, oOptions);
|
||||
} catch (e) {
|
||||
var msg = 'Call: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: request
|
||||
|
||||
Validates that a function name was provided, generates a message
|
||||
indicating that a xajax request is starting and sets a flag in the
|
||||
request object indicating that debugging is enabled for this request.
|
||||
|
||||
This is a wrapper around the standard <xajax.request> function.
|
||||
*/
|
||||
xajax.debug.request = xajax.request;
|
||||
xajax.request = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[115]);
|
||||
|
||||
var numArgs = arguments.length;
|
||||
|
||||
if (0 == numArgs)
|
||||
throw { code: 10010 };
|
||||
|
||||
var oFunction = arguments[0];
|
||||
var oOptions = {}
|
||||
if (1 < numArgs)
|
||||
oOptions = arguments[1];
|
||||
|
||||
oOptions.debugging = true;
|
||||
|
||||
return xajax.debug.request(oFunction, oOptions);
|
||||
} catch (e) {
|
||||
var msg = 'Request: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getResponseProcessor
|
||||
|
||||
Generate an error message when no reponse processor is available
|
||||
to process the type of response returned from the server.
|
||||
|
||||
This is a wrapper around the standard <xajax.getResponseProcessor>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.getResponseProcessor = xajax.getResponseProcessor;
|
||||
xajax.getResponseProcessor = function(oRequest) {
|
||||
try {
|
||||
var fProc = xajax.debug.getResponseProcessor(oRequest);
|
||||
|
||||
if ('undefined' == typeof fProc) {
|
||||
var msg = xajax.debug.text[116];
|
||||
try {
|
||||
var contentType = oRequest.request.getResponseHeader('content-type');
|
||||
msg += "Content-Type: ";
|
||||
msg += contentType;
|
||||
if ('text/html' == contentType) {
|
||||
msg += xajax.debug.text[117];
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
|
||||
return fProc;
|
||||
} catch (e) {
|
||||
var msg = 'GetResponseProcessor: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: responseReceived
|
||||
|
||||
Generate a message indicating that a response has been received
|
||||
from the server; provide some statistical data regarding the
|
||||
response and the response time.
|
||||
|
||||
Catch any exceptions that are thrown during the processing of
|
||||
the response and generate a message.
|
||||
|
||||
This is a wrapper around the standard <xajax.responseReceived>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.responseReceived = xajax.responseReceived;
|
||||
xajax.responseReceived = function(oRequest) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xd = xx.debug;
|
||||
|
||||
var oRet;
|
||||
|
||||
try {
|
||||
var status = oRequest.request.status;
|
||||
if (xt.arrayContainsValue(xx.responseSuccessCodes, status)) {
|
||||
var packet = oRequest.request.responseText;
|
||||
packet = packet.replace(new RegExp('<cmd', 'g'), '\n<cmd');
|
||||
packet = packet.replace(new RegExp('<xjx>', 'g'), '\n<xjx>');
|
||||
packet = packet.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
|
||||
packet = packet.replace(new RegExp('<e>', 'g'), '\n<e>');
|
||||
packet = packet.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
|
||||
packet = packet.replace(new RegExp('</xjx>', 'g'), '\n</xjx>');
|
||||
oRequest.midDate = new Date();
|
||||
var msg = xajax.debug.text[118];
|
||||
msg += oRequest.request.status;
|
||||
msg += xajax.debug.text[119];
|
||||
msg += packet.length;
|
||||
msg += xajax.debug.text[120];
|
||||
msg += (oRequest.midDate - oRequest.beginDate);
|
||||
msg += xajax.debug.text[121];
|
||||
msg += packet;
|
||||
xd.writeMessage(msg);
|
||||
} else if (xt.arrayContainsValue(xx.responseErrorsForAlert, status)) {
|
||||
var msg = xajax.debug.text[122];
|
||||
msg += status;
|
||||
msg += xajax.debug.text[123];
|
||||
msg += oRequest.request.responseText;
|
||||
xd.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
} else if (xt.arrayContainsValue(xx.responseRedirectCodes, status)) {
|
||||
var msg = xajax.debug.text[124];
|
||||
msg += oRequest.request.getResponseHeader('location');
|
||||
xd.writeMessage(msg);
|
||||
}
|
||||
oRet = xd.responseReceived(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'ResponseReceived: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xd.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
|
||||
return oRet;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: completeRequest
|
||||
|
||||
Generate a message indicating that the request has completed
|
||||
and provide some statistics regarding the request and response.
|
||||
|
||||
This is a wrapper around the standard <xajax.completeResponse>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.completeResponse = xajax.completeResponse;
|
||||
xajax.completeResponse = function(oRequest) {
|
||||
try {
|
||||
var returnValue = xajax.debug.completeResponse(oRequest);
|
||||
oRequest.endDate = new Date();
|
||||
var msg = xajax.debug.text[125];
|
||||
msg += (oRequest.endDate - oRequest.beginDate);
|
||||
msg += xajax.debug.text[126];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return returnValue;
|
||||
} catch (e) {
|
||||
var msg = 'CompleteResponse: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getRequestObject
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being initialized.
|
||||
|
||||
Catch any exceptions that are thrown during the process or
|
||||
initializing a new request object.
|
||||
|
||||
This is a wrapper around the standard <xajax.getRequestObject>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.getRequestObject = xajax.tools.getRequestObject;
|
||||
xajax.tools.getRequestObject = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[127]);
|
||||
return xajax.debug.getRequestObject();
|
||||
} catch (e) {
|
||||
var msg = 'GetRequestObject: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: assign
|
||||
|
||||
Catch any exceptions thrown during the assignment and
|
||||
display an error message.
|
||||
|
||||
This is a wrapper around the standard <xajax.dom.assign>
|
||||
function.
|
||||
*/
|
||||
if (xajax.dom.assign) {
|
||||
xajax.debug.assign = xajax.dom.assign;
|
||||
xajax.dom.assign = function(element, id, property, data) {
|
||||
try {
|
||||
return xajax.debug.assign(element, id, property, data);
|
||||
} catch (e) {
|
||||
var msg = 'xajax.dom.assign: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
msg += 'Eval: element.';
|
||||
msg += property;
|
||||
msg += ' = data;\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: xajax.tools.queue.retry
|
||||
*/
|
||||
if (xajax.tools) {
|
||||
if (xajax.tools.queue) {
|
||||
if (xajax.tools.queue.retry) {
|
||||
if ('undefined' == typeof xajax.debug.tools)
|
||||
xajax.debug.tools = {};
|
||||
if ('undefined' == typeof xajax.debug.tools.queue)
|
||||
xajax.debug.tools.queue = {};
|
||||
xajax.debug.tools.queue.retry = xajax.tools.queue.retry;
|
||||
xajax.tools.queue.retry = function(obj, count) {
|
||||
if (xajax.debug.tools.queue.retry(obj, count))
|
||||
return true;
|
||||
// no 'exceeded' message for sleep command
|
||||
if (obj.cmd && 's' == obj.cmd)
|
||||
return false;
|
||||
xajax.debug.writeMessage('Retry count exceeded.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Boolean: isLoaded
|
||||
|
||||
true - indicates that the debugging module is loaded
|
||||
*/
|
||||
xajax.debug.isLoaded = true;
|
||||
|
||||
/*
|
||||
Section: Redefine shortcuts.
|
||||
|
||||
Must redefine these shortcuts so they point to the new debug (wrapper) versions:
|
||||
- <xjx.$>
|
||||
- <xjx.getFormValues>
|
||||
- <xjx.call>
|
||||
|
||||
Must redefine these shortcuts as well:
|
||||
- <xajax.$>
|
||||
- <xajax.getFormValues>
|
||||
*/
|
||||
xjx = {}
|
||||
|
||||
xjx.$ = xajax.tools.$;
|
||||
xjx.getFormValues = xajax.tools.getFormValues;
|
||||
xjx.call = xajax.call;
|
||||
xjx.request = xajax.request;
|
||||
|
||||
xajax.$ = xajax.tools.$;
|
||||
xajax.getFormValues = xajax.tools.getFormValues;
|
||||
856
libraries/xajax/xajax_js/xajax_debug_uncompressed.js
Normal file
856
libraries/xajax/xajax_js/xajax_debug_uncompressed.js
Normal file
@@ -0,0 +1,856 @@
|
||||
/*
|
||||
File: xajax_debug.js
|
||||
|
||||
This optional file contains the debugging module for use with xajax. If
|
||||
you include this module after the standard <xajax_core.js> module, you
|
||||
will receive debugging messages, including errors, that occur during
|
||||
the processing of your xajax requests.
|
||||
|
||||
Title: xajax debugging module
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_debug_uncompressed.js 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajax.debug
|
||||
|
||||
This object contains the variables and functions used to display process state
|
||||
messages and to trap error conditions and report them to the user via
|
||||
a secondary browser window or alert messages as necessary.
|
||||
*/
|
||||
try {
|
||||
if ('undefined' == typeof xajax.debug)
|
||||
xajax.debug = {}
|
||||
} catch (e) {
|
||||
alert('An internal error has occurred: the xajax_core has not been loaded prior to xajax_debug.');
|
||||
}
|
||||
|
||||
/*
|
||||
String: workId
|
||||
|
||||
Stores a 'unique' identifier for this session so that an existing debugging
|
||||
window can be detected, else one will be created.
|
||||
*/
|
||||
xajax.debug.workId = 'xajaxWork'+ new Date().getTime();
|
||||
|
||||
/*
|
||||
String: windowSource
|
||||
|
||||
The default URL that is given to the debugging window upon creation.
|
||||
*/
|
||||
xajax.debug.windowSource = 'about:blank';
|
||||
|
||||
/*
|
||||
String: windowID
|
||||
|
||||
A 'unique' name used to identify the debugging window that is attached
|
||||
to this xajax session.
|
||||
*/
|
||||
xajax.debug.windowID = 'xajax_debug_'+xajax.debug.workId;
|
||||
|
||||
/*
|
||||
String: windowStyle
|
||||
|
||||
The parameters that will be used to create the debugging window.
|
||||
*/
|
||||
if ('undefined' == typeof xajax.debug.windowStyle)
|
||||
xajax.debug.windowStyle =
|
||||
'width=800,' +
|
||||
'height=600,' +
|
||||
'scrollbars=yes,' +
|
||||
'resizable=yes,' +
|
||||
'status=yes';
|
||||
|
||||
/*
|
||||
String: windowTemplate
|
||||
|
||||
The HTML template and CSS style information used to populate the
|
||||
debugging window upon creation.
|
||||
*/
|
||||
if ('undefined' == typeof xajax.debug.windowTemplate)
|
||||
xajax.debug.windowTemplate =
|
||||
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' +
|
||||
'<html><head>' +
|
||||
'<title>xajax debug output</title>' +
|
||||
'<style type="text/css">' +
|
||||
'/* <![CDATA[ */' +
|
||||
'.debugEntry { margin: 3px; padding: 3px; border-top: 1px solid #999999; } ' +
|
||||
'.debugDate { font-weight: bold; margin: 2px; } ' +
|
||||
'.debugText { margin: 2px; } ' +
|
||||
'.warningText { margin: 2px; font-weight: bold; } ' +
|
||||
'.errorText { margin: 2px; font-weight: bold; color: #ff7777; }' +
|
||||
'/* ]]> */' +
|
||||
'</style>' +
|
||||
'</head><body>' +
|
||||
'<h2>xajax debug output</h2>' +
|
||||
'<div id="debugTag"></div>' +
|
||||
'</body></html>';
|
||||
|
||||
/*
|
||||
Object: window
|
||||
|
||||
A reference to the debugging window, once constructed, where messages will
|
||||
be displayed throughout the request process. This is constructed internally
|
||||
as needed.
|
||||
*/
|
||||
|
||||
/*
|
||||
Array: text
|
||||
*/
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'WARNING: ';
|
||||
xajax.debug.text[101] = 'ERROR: ';
|
||||
xajax.debug.text[102] = 'XAJAX DEBUG MESSAGE:\n';
|
||||
xajax.debug.text[103] = '...\n[LONG RESPONSE]\n...';
|
||||
xajax.debug.text[104] = 'SENDING REQUEST';
|
||||
xajax.debug.text[105] = 'SENT [';
|
||||
xajax.debug.text[106] = ' bytes]';
|
||||
xajax.debug.text[107] = 'CALLING: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'INITIALIZING REQUEST';
|
||||
xajax.debug.text[110] = 'PROCESSING PARAMETERS [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'NO PARAMETERS TO PROCESS';
|
||||
xajax.debug.text[113] = 'PREPARING REQUEST';
|
||||
xajax.debug.text[114] = 'STARTING XAJAX CALL (deprecated: use xajax.request instead)';
|
||||
xajax.debug.text[115] = 'STARTING XAJAX REQUEST';
|
||||
xajax.debug.text[116] = 'No response processor is available to process the response from the server.\n';
|
||||
xajax.debug.text[117] = '.\nCheck for error messages from the server.';
|
||||
xajax.debug.text[118] = 'RECEIVED [status: ';
|
||||
xajax.debug.text[119] = ', size: ';
|
||||
xajax.debug.text[120] = ' bytes, time: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'The server returned the following HTTP status: ';
|
||||
xajax.debug.text[123] = '\nRECEIVED:\n';
|
||||
xajax.debug.text[124] = 'The server returned a redirect to:<br />';
|
||||
xajax.debug.text[125] = 'DONE [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INITIALIZING REQUEST OBJECT';
|
||||
|
||||
/*
|
||||
Array: exceptions
|
||||
*/
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Invalid response XML: The response contains an unknown tag: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest is not available, xajax is disabled.';
|
||||
xajax.debug.exceptions[10003] = 'Queue overflow: Cannot push object onto queue because it is full.';
|
||||
xajax.debug.exceptions[10004] = 'Invalid response XML: The response contains an unexpected tag or text: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Invalid request URI: Invalid or missing URI; autodetection failed; please specify a one explicitly.';
|
||||
xajax.debug.exceptions[10006] = 'Invalid response command: Malformed response command received.';
|
||||
xajax.debug.exceptions[10007] = 'Invalid response command: Command [{data}] is not a known command.';
|
||||
xajax.debug.exceptions[10008] = 'Element with ID [{data}] not found in the document.';
|
||||
xajax.debug.exceptions[10009] = 'Invalid request: Missing function name parameter.';
|
||||
xajax.debug.exceptions[10010] = 'Invalid request: Missing function object parameter.';
|
||||
|
||||
/*
|
||||
Function: getExceptionText
|
||||
*/
|
||||
xajax.debug.getExceptionText = function(e) {
|
||||
if ('undefined' != typeof e.code) {
|
||||
if ('undefined' != typeof xajax.debug.exceptions[e.code]) {
|
||||
var msg = xajax.debug.exceptions[e.code];
|
||||
if ('undefined' != typeof e.data) {
|
||||
msg.replace('{data}', e.data);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
} else if ('undefined' != typeof e.name) {
|
||||
var msg = e.name;
|
||||
if ('undefined' != typeof e.message) {
|
||||
msg += ': ';
|
||||
msg += e.message;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
return 'An unknown error has occurred.';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: writeMessage
|
||||
|
||||
Output a debug message to the debug window if available or send to an
|
||||
alert box. If the debug window has not been created, attempt to
|
||||
create it.
|
||||
|
||||
text - (string): The text to output.
|
||||
|
||||
prefix - (string): The prefix to use; this is prepended onto the
|
||||
message; it should indicate the type of message (warning, error)
|
||||
|
||||
cls - (stirng): The className that will be applied to the message;
|
||||
invoking a style from the CSS provided in
|
||||
<xajax.debug.windowTemplate>. Should be one of the following:
|
||||
- warningText
|
||||
- errorText
|
||||
*/
|
||||
xajax.debug.writeMessage = function(text, prefix, cls) {
|
||||
try {
|
||||
var xd = xajax.debug;
|
||||
if ('undefined' == typeof xd.window || true == xd.window.closed) {
|
||||
xd.window = window.open(xd.windowSource, xd.windowID, xd.windowStyle);
|
||||
if ("about:blank" == xd.windowSource)
|
||||
xd.window.document.write(xd.windowTemplate);
|
||||
}
|
||||
var xdw = xd.window;
|
||||
var xdwd = xdw.document;
|
||||
if ('undefined' == typeof prefix)
|
||||
prefix = '';
|
||||
if ('undefined' == typeof cls)
|
||||
cls = 'debugText';
|
||||
|
||||
text = xajax.debug.prepareDebugText(text);
|
||||
|
||||
var debugTag = xdwd.getElementById('debugTag');
|
||||
var debugEntry = xdwd.createElement('div');
|
||||
var debugDate = xdwd.createElement('span');
|
||||
var debugText = xdwd.createElement('pre');
|
||||
|
||||
debugDate.innerHTML = new Date().toString();
|
||||
debugText.innerHTML = prefix + text;
|
||||
|
||||
debugEntry.appendChild(debugDate);
|
||||
debugEntry.appendChild(debugText);
|
||||
debugTag.insertBefore(debugEntry, debugTag.firstChild);
|
||||
// don't allow 'style' issues to hinder the debug output
|
||||
try {
|
||||
debugEntry.className = 'debugEntry';
|
||||
debugDate.className = 'debugDate';
|
||||
debugText.className = cls;
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {
|
||||
if (text.length > 1000) text = text.substr(0,1000) + xajax.debug.text[102];
|
||||
alert(xajax.debug.text[102] + text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: prepareDebugText
|
||||
|
||||
Convert special characters to their HTML equivellents so they
|
||||
will show up in the <xajax.debug.window>.
|
||||
*/
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
try {
|
||||
text = text.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br />');
|
||||
return text;
|
||||
} catch (e) {
|
||||
xajax.debug.stringReplace = function(haystack, needle, newNeedle) {
|
||||
var segments = haystack.split(needle);
|
||||
haystack = '';
|
||||
for (var i = 0; i < segments.length; ++i) {
|
||||
if (0 != i)
|
||||
haystack += newNeedle;
|
||||
haystack += segments[i];
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
text = xajax.debug.stringReplace(text, '&', '&');
|
||||
text = xajax.debug.stringReplace(text, '<', '<');
|
||||
text = xajax.debug.stringReplace(text, '>', '>');
|
||||
text = xajax.debug.stringReplace(text, '\n', '<br />');
|
||||
return text;
|
||||
}
|
||||
xajax.debug.prepareDebugText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: executeCommand
|
||||
|
||||
Catch any exceptions that are thrown by a response command handler
|
||||
and display a message in the debugger.
|
||||
|
||||
This is a wrapper function which surrounds the standard
|
||||
<xajax.executeCommand> function.
|
||||
*/
|
||||
xajax.debug.executeCommand = xajax.executeCommand;
|
||||
xajax.executeCommand = function(args) {
|
||||
try {
|
||||
if ('undefined' == typeof args.cmd)
|
||||
throw { code: 10006 };
|
||||
if (false == xajax.command.handler.isRegistered(args))
|
||||
throw { code: 10007, data: args.cmd };
|
||||
return xajax.debug.executeCommand(args);
|
||||
} catch(e) {
|
||||
var msg = 'ExecuteCommand (';
|
||||
if ('undefined' != typeof args.sequence) {
|
||||
msg += '#';
|
||||
msg += args.sequence;
|
||||
msg += ', ';
|
||||
}
|
||||
if ('undefined' != typeof args.cmdFullName) {
|
||||
msg += '"';
|
||||
msg += args.cmdFullName;
|
||||
msg += '"';
|
||||
}
|
||||
msg += '):\n';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: parseAttributes
|
||||
|
||||
Catch any exception thrown during the parsing of response
|
||||
command attributes and display an appropriate debug message.
|
||||
|
||||
This is a wrapper around the standard <xajax.parseAttributes>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.parseAttributes = xajax.parseAttributes;
|
||||
xajax.parseAttributes = function(child, obj) {
|
||||
try {
|
||||
xajax.debug.parseAttributes(child, obj);
|
||||
} catch(e) {
|
||||
var msg = 'ParseAttributes:\n';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
}
|
||||
|
||||
xajax.debug.commandHandler = xajax.command.handler.unregister('dbg');
|
||||
xajax.command.handler.register('dbg', function(args) {
|
||||
args.cmdFullName = 'debug message';
|
||||
xajax.debug.writeMessage(args.data, xajax.debug.text[100], 'warningText');
|
||||
return xajax.debug.commandHandler(args);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
Function: $
|
||||
|
||||
Catch any exceptions thrown while attempting to locate an
|
||||
HTML element by it's unique name.
|
||||
|
||||
This is a wrapper around the standard <xajax.tools.$> function.
|
||||
*/
|
||||
xajax.debug.$ = xajax.tools.$;
|
||||
xajax.tools.$ = function(sId) {
|
||||
try {
|
||||
var returnValue = xajax.debug.$(sId);
|
||||
if ('object' != typeof returnValue)
|
||||
throw { code: 10008 };
|
||||
}
|
||||
catch (e) {
|
||||
var msg = '$:';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[100], 'warningText');
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _objectToXML
|
||||
|
||||
Generate a message indicating that a javascript object is
|
||||
being converted to xml. Indicate the max depth and size. Then
|
||||
display the size of the object upon completion. Catch any
|
||||
exceptions thrown during the conversion process.
|
||||
|
||||
This is a wrapper around the standard <xajax.tools._objectToXML>
|
||||
function.
|
||||
*/
|
||||
xajax.debug._objectToXML = xajax.tools._objectToXML;
|
||||
xajax.tools._objectToXML = function(obj, guard) {
|
||||
try {
|
||||
if (0 == guard.size) {
|
||||
var msg = 'OBJECT TO XML: maxDepth = ';
|
||||
msg += guard.maxDepth;
|
||||
msg += ', maxSize = ';
|
||||
msg += guard.maxSize;
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
var r = xajax.debug._objectToXML(obj, guard);
|
||||
if (0 == guard.depth) {
|
||||
var msg = 'OBJECT TO XML: size = ';
|
||||
msg += guard.size;
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
return r;
|
||||
} catch(e) {
|
||||
var msg = 'ObjectToXML: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: _internalSend
|
||||
|
||||
Generate a message indicating that the xajax request is
|
||||
about the be sent to the server.
|
||||
|
||||
This is a wrapper around the standard <xajax._internalSend>
|
||||
function.
|
||||
*/
|
||||
xajax.debug._internalSend = xajax._internalSend;
|
||||
xajax._internalSend = function(oRequest) {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[104]);
|
||||
xajax.debug.writeMessage(
|
||||
xajax.debug.text[105] +
|
||||
oRequest.requestData.length +
|
||||
xajax.debug.text[106]
|
||||
);
|
||||
oRequest.beginDate = new Date();
|
||||
xajax.debug._internalSend(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'InternalSend: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: submitRequest
|
||||
|
||||
Generate a message indicating that a request is ready to be
|
||||
submitted; providing the URL and the function being invoked.
|
||||
|
||||
Catch any exceptions thrown and display a message.
|
||||
|
||||
This is a wrapper around the standard <xajax.submitRequest>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.submitRequest = xajax.submitRequest;
|
||||
xajax.submitRequest = function(oRequest) {
|
||||
var msg = oRequest.method;
|
||||
msg += ': ';
|
||||
text = decodeURIComponent(oRequest.requestData);
|
||||
text = text.replace(new RegExp('&xjx', 'g'), '\n&xjx');
|
||||
text = text.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
|
||||
text = text.replace(new RegExp('<e>', 'g'), '\n<e>');
|
||||
text = text.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
|
||||
msg += text;
|
||||
xajax.debug.writeMessage(msg);
|
||||
msg = xajax.debug.text[107];
|
||||
var separator = '\n';
|
||||
for (var mbr in oRequest.functionName) {
|
||||
msg += separator;
|
||||
msg += mbr;
|
||||
msg += ': ';
|
||||
msg += oRequest.functionName[mbr];
|
||||
separator = '\n';
|
||||
}
|
||||
msg += separator;
|
||||
msg += xajax.debug.text[108];
|
||||
msg += separator;
|
||||
msg += oRequest.URI;
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
try {
|
||||
return xajax.debug.submitRequest(oRequest);
|
||||
} catch (e) {
|
||||
xajax.debug.writeMessage(e.message);
|
||||
if (0 < oRequest.retry)
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: initializeRequest
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being initialized.
|
||||
|
||||
This is a wrapper around the standard <xajax.initializeRequest>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.initializeRequest = xajax.initializeRequest;
|
||||
xajax.initializeRequest = function(oRequest) {
|
||||
try {
|
||||
var msg = xajax.debug.text[109];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return xajax.debug.initializeRequest(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'InitializeRequest: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: processParameters
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being populated with the parameters provided.
|
||||
|
||||
This is a wrapper around the standard <xajax.processParameters>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.processParameters = xajax.processParameters;
|
||||
xajax.processParameters = function(oRequest) {
|
||||
try {
|
||||
if ('undefined' != typeof oRequest.parameters) {
|
||||
var msg = xajax.debug.text[110];
|
||||
msg += oRequest.parameters.length;
|
||||
msg += xajax.debug.text[111];
|
||||
xajax.debug.writeMessage(msg);
|
||||
} else {
|
||||
var msg = xajax.debug.text[112];
|
||||
xajax.debug.writeMessage(msg);
|
||||
}
|
||||
return xajax.debug.processParameters(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'ProcessParameters: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: prepareRequest
|
||||
|
||||
Generate a message indicating that the request is being
|
||||
prepared. This may occur more than once for a request
|
||||
if it errors and a retry is attempted.
|
||||
|
||||
This is a wrapper around the standard <xajax.prepareRequest>
|
||||
*/
|
||||
xajax.debug.prepareRequest = xajax.prepareRequest;
|
||||
xajax.prepareRequest = function(oRequest) {
|
||||
try {
|
||||
var msg = xajax.debug.text[113];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return xajax.debug.prepareRequest(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'PrepareRequest: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: call
|
||||
|
||||
Validates that a function name was provided, generates a message
|
||||
indicating that a xajax call is starting and sets a flag in the
|
||||
request object indicating that debugging is enabled for this call.
|
||||
|
||||
This is a wrapper around the standard <xajax.call> function.
|
||||
*/
|
||||
xajax.debug.call = xajax.call;
|
||||
xajax.call = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[114]);
|
||||
|
||||
var numArgs = arguments.length;
|
||||
|
||||
if (0 == numArgs)
|
||||
throw { code: 10009 };
|
||||
|
||||
var functionName = arguments[0];
|
||||
var oOptions = {}
|
||||
if (1 < numArgs)
|
||||
oOptions = arguments[1];
|
||||
|
||||
oOptions.debugging = true;
|
||||
|
||||
return xajax.debug.call(functionName, oOptions);
|
||||
} catch (e) {
|
||||
var msg = 'Call: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: request
|
||||
|
||||
Validates that a function name was provided, generates a message
|
||||
indicating that a xajax request is starting and sets a flag in the
|
||||
request object indicating that debugging is enabled for this request.
|
||||
|
||||
This is a wrapper around the standard <xajax.request> function.
|
||||
*/
|
||||
xajax.debug.request = xajax.request;
|
||||
xajax.request = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[115]);
|
||||
|
||||
var numArgs = arguments.length;
|
||||
|
||||
if (0 == numArgs)
|
||||
throw { code: 10010 };
|
||||
|
||||
var oFunction = arguments[0];
|
||||
var oOptions = {}
|
||||
if (1 < numArgs)
|
||||
oOptions = arguments[1];
|
||||
|
||||
oOptions.debugging = true;
|
||||
|
||||
return xajax.debug.request(oFunction, oOptions);
|
||||
} catch (e) {
|
||||
var msg = 'Request: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getResponseProcessor
|
||||
|
||||
Generate an error message when no reponse processor is available
|
||||
to process the type of response returned from the server.
|
||||
|
||||
This is a wrapper around the standard <xajax.getResponseProcessor>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.getResponseProcessor = xajax.getResponseProcessor;
|
||||
xajax.getResponseProcessor = function(oRequest) {
|
||||
try {
|
||||
var fProc = xajax.debug.getResponseProcessor(oRequest);
|
||||
|
||||
if ('undefined' == typeof fProc) {
|
||||
var msg = xajax.debug.text[116];
|
||||
try {
|
||||
var contentType = oRequest.request.getResponseHeader('content-type');
|
||||
msg += "Content-Type: ";
|
||||
msg += contentType;
|
||||
if ('text/html' == contentType) {
|
||||
msg += xajax.debug.text[117];
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
|
||||
return fProc;
|
||||
} catch (e) {
|
||||
var msg = 'GetResponseProcessor: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: responseReceived
|
||||
|
||||
Generate a message indicating that a response has been received
|
||||
from the server; provide some statistical data regarding the
|
||||
response and the response time.
|
||||
|
||||
Catch any exceptions that are thrown during the processing of
|
||||
the response and generate a message.
|
||||
|
||||
This is a wrapper around the standard <xajax.responseReceived>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.responseReceived = xajax.responseReceived;
|
||||
xajax.responseReceived = function(oRequest) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xd = xx.debug;
|
||||
|
||||
var oRet;
|
||||
|
||||
try {
|
||||
var status = oRequest.request.status;
|
||||
if (xt.arrayContainsValue(xx.responseSuccessCodes, status)) {
|
||||
var packet = oRequest.request.responseText;
|
||||
packet = packet.replace(new RegExp('<cmd', 'g'), '\n<cmd');
|
||||
packet = packet.replace(new RegExp('<xjx>', 'g'), '\n<xjx>');
|
||||
packet = packet.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
|
||||
packet = packet.replace(new RegExp('<e>', 'g'), '\n<e>');
|
||||
packet = packet.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
|
||||
packet = packet.replace(new RegExp('</xjx>', 'g'), '\n</xjx>');
|
||||
oRequest.midDate = new Date();
|
||||
var msg = xajax.debug.text[118];
|
||||
msg += oRequest.request.status;
|
||||
msg += xajax.debug.text[119];
|
||||
msg += packet.length;
|
||||
msg += xajax.debug.text[120];
|
||||
msg += (oRequest.midDate - oRequest.beginDate);
|
||||
msg += xajax.debug.text[121];
|
||||
msg += packet;
|
||||
xd.writeMessage(msg);
|
||||
} else if (xt.arrayContainsValue(xx.responseErrorsForAlert, status)) {
|
||||
var msg = xajax.debug.text[122];
|
||||
msg += status;
|
||||
msg += xajax.debug.text[123];
|
||||
msg += oRequest.request.responseText;
|
||||
xd.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
} else if (xt.arrayContainsValue(xx.responseRedirectCodes, status)) {
|
||||
var msg = xajax.debug.text[124];
|
||||
msg += oRequest.request.getResponseHeader('location');
|
||||
xd.writeMessage(msg);
|
||||
}
|
||||
oRet = xd.responseReceived(oRequest);
|
||||
} catch (e) {
|
||||
var msg = 'ResponseReceived: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xd.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
|
||||
return oRet;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: completeRequest
|
||||
|
||||
Generate a message indicating that the request has completed
|
||||
and provide some statistics regarding the request and response.
|
||||
|
||||
This is a wrapper around the standard <xajax.completeResponse>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.completeResponse = xajax.completeResponse;
|
||||
xajax.completeResponse = function(oRequest) {
|
||||
try {
|
||||
var returnValue = xajax.debug.completeResponse(oRequest);
|
||||
oRequest.endDate = new Date();
|
||||
var msg = xajax.debug.text[125];
|
||||
msg += (oRequest.endDate - oRequest.beginDate);
|
||||
msg += xajax.debug.text[126];
|
||||
xajax.debug.writeMessage(msg);
|
||||
return returnValue;
|
||||
} catch (e) {
|
||||
var msg = 'CompleteResponse: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getRequestObject
|
||||
|
||||
Generate a message indicating that the request object is
|
||||
being initialized.
|
||||
|
||||
Catch any exceptions that are thrown during the process or
|
||||
initializing a new request object.
|
||||
|
||||
This is a wrapper around the standard <xajax.getRequestObject>
|
||||
function.
|
||||
*/
|
||||
xajax.debug.getRequestObject = xajax.tools.getRequestObject;
|
||||
xajax.tools.getRequestObject = function() {
|
||||
try {
|
||||
xajax.debug.writeMessage(xajax.debug.text[127]);
|
||||
return xajax.debug.getRequestObject();
|
||||
} catch (e) {
|
||||
var msg = 'GetRequestObject: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: assign
|
||||
|
||||
Catch any exceptions thrown during the assignment and
|
||||
display an error message.
|
||||
|
||||
This is a wrapper around the standard <xajax.dom.assign>
|
||||
function.
|
||||
*/
|
||||
if (xajax.dom.assign) {
|
||||
xajax.debug.assign = xajax.dom.assign;
|
||||
xajax.dom.assign = function(element, id, property, data) {
|
||||
try {
|
||||
return xajax.debug.assign(element, id, property, data);
|
||||
} catch (e) {
|
||||
var msg = 'xajax.dom.assign: ';
|
||||
msg += xajax.debug.getExceptionText(e);
|
||||
msg += '\n';
|
||||
msg += 'Eval: element.';
|
||||
msg += property;
|
||||
msg += ' = data;\n';
|
||||
xajax.debug.writeMessage(msg, xajax.debug.text[101], 'errorText');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: xajax.tools.queue.retry
|
||||
*/
|
||||
if (xajax.tools) {
|
||||
if (xajax.tools.queue) {
|
||||
if (xajax.tools.queue.retry) {
|
||||
if ('undefined' == typeof xajax.debug.tools)
|
||||
xajax.debug.tools = {};
|
||||
if ('undefined' == typeof xajax.debug.tools.queue)
|
||||
xajax.debug.tools.queue = {};
|
||||
xajax.debug.tools.queue.retry = xajax.tools.queue.retry;
|
||||
xajax.tools.queue.retry = function(obj, count) {
|
||||
if (xajax.debug.tools.queue.retry(obj, count))
|
||||
return true;
|
||||
// no 'exceeded' message for sleep command
|
||||
if (obj.cmd && 's' == obj.cmd)
|
||||
return false;
|
||||
xajax.debug.writeMessage('Retry count exceeded.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Boolean: isLoaded
|
||||
|
||||
true - indicates that the debugging module is loaded
|
||||
*/
|
||||
xajax.debug.isLoaded = true;
|
||||
|
||||
/*
|
||||
Section: Redefine shortcuts.
|
||||
|
||||
Must redefine these shortcuts so they point to the new debug (wrapper) versions:
|
||||
- <xjx.$>
|
||||
- <xjx.getFormValues>
|
||||
- <xjx.call>
|
||||
|
||||
Must redefine these shortcuts as well:
|
||||
- <xajax.$>
|
||||
- <xajax.getFormValues>
|
||||
*/
|
||||
xjx = {}
|
||||
|
||||
xjx.$ = xajax.tools.$;
|
||||
xjx.getFormValues = xajax.tools.getFormValues;
|
||||
xjx.call = xajax.call;
|
||||
xjx.request = xajax.request;
|
||||
|
||||
xajax.$ = xajax.tools.$;
|
||||
xajax.getFormValues = xajax.tools.getFormValues;
|
||||
10
libraries/xajax/xajax_js/xajax_lang_de.js
Normal file
10
libraries/xajax/xajax_js/xajax_lang_de.js
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
if('undefined'!=typeof xajax.debug){xajax.debug.text=[];xajax.debug.text[100]='WARNUNG: ';xajax.debug.text[101]='FEHLER: ';xajax.debug.text[102]='XAJAX FEHLERSUCHE NACHRICHT:\n';xajax.debug.text[103]='...\n[UMGFANGREICHE ANTWORT]\n...';xajax.debug.text[104]='SENDE ANFRAGE';xajax.debug.text[105]='GESENDET [';xajax.debug.text[106]=' bytes]';xajax.debug.text[107]='RUFE AUF: ';xajax.debug.text[108]='URI: ';xajax.debug.text[109]='BEGINNE ANFRAGE';xajax.debug.text[110]='PARAMETER IN BEARBEITUNG [';xajax.debug.text[111]=']';xajax.debug.text[112]='KEINE PARAMETER ZU VERARBEITEN';xajax.debug.text[113]='BEREITE REQUEST VOR';xajax.debug.text[114]='BEGINNE XAJAX CALL (veraltet: verwendet stattdessen xajax.request)';xajax.debug.text[115]='BEGINNE XAJAX ANFRAGE';xajax.debug.text[116]='Die vom Server erhaltenen Daten konnten nicht verarbeitet werden.\n';xajax.debug.text[117]='.\nPrüfe auf Fehlermeldungen des Servers.';xajax.debug.text[118]='ERHALTEN [status: ';xajax.debug.text[119]=', Größe: ';xajax.debug.text[120]=' bytes, Zeit: ';xajax.debug.text[121]='ms]:\n';xajax.debug.text[122]='Der Server hat folgenden HTTP-Status zurück gesendet: ';xajax.debug.text[123]='\nERHALTEN:\n';xajax.debug.text[124]='Der Server lieferte einen Redirect nach:<br />';xajax.debug.text[125]='ERLEDIGT [';xajax.debug.text[126]='ms]';xajax.debug.text[127]='INITIALISIERE REQUEST OBJEKT';xajax.debug.exceptions=[];xajax.debug.exceptions[10001]='Ungültige XML-Antwort: die Antwort enthält ein ungültiges Tag: {data}.';xajax.debug.exceptions[10002]='GetRequestObject: XMLHttpRequest ist nicht verfügbar, XajaX ist nicht verfügbar.';xajax.debug.exceptions[10003]='Warteschleife-Überlauf: kann Objekt nicht an Warteschleife übergeben da diese voll ist.';xajax.debug.exceptions[10004]='Ungültige XML-Antwort: die Antwort enthält einen unerwarteten Tag oder Text: {data}.';xajax.debug.exceptions[10005]='Ungültige Request-URI: Ungültige oder Fehlende URI; Autoerkennung fehlgeschlagen; bitte nur eine einzige URI angeben.';xajax.debug.exceptions[10006]='Ungültiges Antwort-Befehl: Unvollständiges Objekt zurück erhalten.';xajax.debug.exceptions[10007]='Ungültiges Antwort-Befehl: Befehl [{data}] ist nicht bekannt.';xajax.debug.exceptions[10008]='Es konnte kein Element mit der ID [{data}] konnte im Dokument gefunden werden.';xajax.debug.exceptions[10009]='Ungültige Anfrage: Fehlender Funktionsparameter - name.';xajax.debug.exceptions[10010]='Ungültige Anfrage: Fehlender Funktionsparameter - object.';}
|
||||
if('undefined'!=typeof xajax.config){if('undefined'!=typeof xajax.config.status){xajax.config.status.update=function(){return{onRequest:function(){window.status="Sende Anfrage...";},
|
||||
onWaiting:function(){window.status="Warten auf Antwort...";},
|
||||
onProcessing:function(){window.status="Verarbeitung...";},
|
||||
onComplete:function(){window.status="Abgeschlossen.";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
libraries/xajax/xajax_js/xajax_lang_de_uncompressed.js
Normal file
84
libraries/xajax/xajax_js/xajax_lang_de_uncompressed.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* translation for: xajax v.x.x
|
||||
* @version: 1.0.0
|
||||
* @author: mic <info@joomx.com>
|
||||
* @copyright xajax project
|
||||
* @license GNU/GPL
|
||||
* @package xajax x.x.x
|
||||
* @since v.x.x.x
|
||||
* save as UTF-8
|
||||
*/
|
||||
|
||||
if ('undefined' != typeof xajax.debug) {
|
||||
/*
|
||||
Array: text
|
||||
*/
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'WARNUNG: ';
|
||||
xajax.debug.text[101] = 'FEHLER: ';
|
||||
xajax.debug.text[102] = 'XAJAX FEHLERSUCHE NACHRICHT:\n';
|
||||
xajax.debug.text[103] = '...\n[UMGFANGREICHE ANTWORT]\n...';
|
||||
xajax.debug.text[104] = 'SENDE ANFRAGE';
|
||||
xajax.debug.text[105] = 'GESENDET [';
|
||||
xajax.debug.text[106] = ' bytes]';
|
||||
xajax.debug.text[107] = 'RUFE AUF: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'BEGINNE ANFRAGE';
|
||||
xajax.debug.text[110] = 'PARAMETER IN BEARBEITUNG [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'KEINE PARAMETER ZU VERARBEITEN';
|
||||
xajax.debug.text[113] = 'BEREITE REQUEST VOR';
|
||||
xajax.debug.text[114] = 'BEGINNE XAJAX CALL (veraltet: verwendet stattdessen xajax.request)';
|
||||
xajax.debug.text[115] = 'BEGINNE XAJAX ANFRAGE';
|
||||
xajax.debug.text[116] = 'Die vom Server erhaltenen Daten konnten nicht verarbeitet werden.\n';
|
||||
xajax.debug.text[117] = '.\nPrüfe auf Fehlermeldungen des Servers.';
|
||||
xajax.debug.text[118] = 'ERHALTEN [status: ';
|
||||
xajax.debug.text[119] = ', Größe: ';
|
||||
xajax.debug.text[120] = ' bytes, Zeit: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'Der Server hat folgenden HTTP-Status zurück gesendet: ';
|
||||
xajax.debug.text[123] = '\nERHALTEN:\n';
|
||||
xajax.debug.text[124] = 'Der Server lieferte einen Redirect nach:<br />';
|
||||
xajax.debug.text[125] = 'ERLEDIGT [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INITIALISIERE REQUEST OBJEKT';
|
||||
|
||||
/*
|
||||
Array: exceptions
|
||||
*/
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Ungültige XML-Antwort: die Antwort enthält ein ungültiges Tag: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest ist nicht verfügbar, XajaX ist nicht verfügbar.';
|
||||
xajax.debug.exceptions[10003] = 'Warteschleife-Überlauf: kann Objekt nicht an Warteschleife übergeben da diese voll ist.';
|
||||
xajax.debug.exceptions[10004] = 'Ungültige XML-Antwort: die Antwort enthält einen unerwarteten Tag oder Text: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Ungültige Request-URI: Ungültige oder Fehlende URI; Autoerkennung fehlgeschlagen; bitte nur eine einzige URI angeben.';
|
||||
xajax.debug.exceptions[10006] = 'Ungültiges Antwort-Befehl: Unvollständiges Objekt zurück erhalten.';
|
||||
xajax.debug.exceptions[10007] = 'Ungültiges Antwort-Befehl: Befehl [{data}] ist nicht bekannt.';
|
||||
xajax.debug.exceptions[10008] = 'Es konnte kein Element mit der ID [{data}] konnte im Dokument gefunden werden.';
|
||||
xajax.debug.exceptions[10009] = 'Ungültige Anfrage: Fehlender Funktionsparameter - name.';
|
||||
xajax.debug.exceptions[10010] = 'Ungültige Anfrage: Fehlender Funktionsparameter - object.';
|
||||
}
|
||||
|
||||
if ('undefined' != typeof xajax.config) {
|
||||
if ('undefined' != typeof xajax.config.status) {
|
||||
/*
|
||||
Object: update
|
||||
*/
|
||||
xajax.config.status.update = function() {
|
||||
return {
|
||||
onRequest: function() {
|
||||
window.status = 'Sending Request...';
|
||||
},
|
||||
onWaiting: function() {
|
||||
window.status = 'Waiting for Response...';
|
||||
},
|
||||
onProcessing: function() {
|
||||
window.status = 'Processing...';
|
||||
},
|
||||
onComplete: function() {
|
||||
window.status = 'Done.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
libraries/xajax/xajax_js/xajax_lang_es_uncompressed.js
Normal file
81
libraries/xajax/xajax_js/xajax_lang_es_uncompressed.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* translation for: xajax v.x.x
|
||||
* @version: 1.0.0
|
||||
* @author: mic <info@joomx.com>
|
||||
* @copyright xajax project
|
||||
* @license GNU/GPL
|
||||
* @package xajax x.x.x
|
||||
* @since v.x.x.x
|
||||
* save as UTF-8
|
||||
*/
|
||||
|
||||
if ('undefined' != typeof xajax.debug) {
|
||||
/*
|
||||
Array: text
|
||||
*/
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'ALERTA: ';
|
||||
xajax.debug.text[101] = 'ERROR: ';
|
||||
xajax.debug.text[102] = 'MENSAJE XAJAX DEBUG:\n';
|
||||
xajax.debug.text[103] = '...\n[RESPUESTA LARGA]\n...';
|
||||
xajax.debug.text[104] = 'ENVIANDO PETICION';
|
||||
xajax.debug.text[105] = 'ENVIADO [';
|
||||
xajax.debug.text[106] = ' bytes]';
|
||||
xajax.debug.text[107] = 'LLAMADA: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'INICIALIZANDO PETICION';
|
||||
xajax.debug.text[110] = 'PROCESANDO PARAMETROS [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'NO HAY PARAMETROS A PROCESAR';
|
||||
xajax.debug.text[113] = 'PREPARANDO PETICION';
|
||||
xajax.debug.text[114] = 'INICIANDO XAJAX CALL (En desuso: use xajax.request)';
|
||||
xajax.debug.text[115] = 'INICIANDO XAJAX REQUEST';
|
||||
xajax.debug.text[116] = 'Ning<6E>n procesador de respuesta esta disponible para tratar la respuesta del servidor.\n';
|
||||
xajax.debug.text[117] = '.\nRevisa mensajes de error del servidor.';
|
||||
xajax.debug.text[118] = 'RECIBIDO [status: ';
|
||||
xajax.debug.text[119] = ', size: ';
|
||||
xajax.debug.text[120] = ' bytes, time: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'El servidor retorno el siguiente estado HTTP: ';
|
||||
xajax.debug.text[123] = '\nRECIBIDO:\n';
|
||||
xajax.debug.text[124] = 'El servidor retorno una redireccion a:<br />';
|
||||
xajax.debug.text[125] = 'HECHO [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INICIALIZANDO PETICION OBJETO';
|
||||
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Invalid response XML: La respuesta contiene una etiqueta desconocida: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest no disponible, xajax esta deshabilitado.';
|
||||
xajax.debug.exceptions[10003] = 'Queue overflow: No se puede colocar objeto en cola porque esta llena.';
|
||||
xajax.debug.exceptions[10004] = 'Invalid response XML: La respuesta contiene una etiqueta o texto inesperado: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Invalid request URI: URI invalida o perdida; autodeteccion fallida; por favor especifica una explicitamente.';
|
||||
xajax.debug.exceptions[10006] = 'Invalid response command: Orden de respuesta mal formado recibido.';
|
||||
xajax.debug.exceptions[10007] = 'Invalid response command: Comando [{data}] no es un comando conocido.';
|
||||
xajax.debug.exceptions[10008] = 'Elemento con ID [{data}] no encontrado en el documento.';
|
||||
xajax.debug.exceptions[10009] = 'Invalid request: Nombre parametro de funcion perdido.';
|
||||
xajax.debug.exceptions[10010] = 'Invalid request: Objeto parametro de funcion perdido.';
|
||||
}
|
||||
|
||||
if ('undefined' != typeof xajax.config) {
|
||||
if ('undefined' != typeof xajax.config.status) {
|
||||
/*
|
||||
Object: update
|
||||
*/
|
||||
xajax.config.status.update = function() {
|
||||
return {
|
||||
onRequest: function() {
|
||||
window.status = 'Enviando Peticion...';
|
||||
},
|
||||
onWaiting: function() {
|
||||
window.status = 'Esperando Respuesta...';
|
||||
},
|
||||
onProcessing: function() {
|
||||
window.status = 'Procesando...';
|
||||
},
|
||||
onComplete: function() {
|
||||
window.status = 'Hecho.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
65
libraries/xajax/xajax_js/xajax_lang_fr_uncompressed.js
Normal file
65
libraries/xajax/xajax_js/xajax_lang_fr_uncompressed.js
Normal file
@@ -0,0 +1,65 @@
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'ATTENTION : ';
|
||||
xajax.debug.text[101] = 'ERREUR : ';
|
||||
xajax.debug.text[102] = 'MESSAGE DE DEBUG XAJAX :\n';
|
||||
xajax.debug.text[103] = '...\n[R<>PONSE LONGUE]\n...';
|
||||
xajax.debug.text[104] = 'ENVOI DE LA REQU<51>TE';
|
||||
xajax.debug.text[105] = 'ENVOY<4F> [';
|
||||
xajax.debug.text[106] = ' octets]';
|
||||
xajax.debug.text[107] = 'APPEL : ';
|
||||
xajax.debug.text[108] = 'URI : ';
|
||||
xajax.debug.text[109] = 'INITIALISATION DE LA REQU<51>TE';
|
||||
xajax.debug.text[110] = 'TRAITEMENT DES PARAM<41>TRES [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'AUCUN PARAM<41>TRE <20> TRAITER';
|
||||
xajax.debug.text[113] = 'PR<50>PARATION DE LA REQU<51>TE';
|
||||
xajax.debug.text[114] = 'D<>BUT DE L\'APPEL XAJAX (d<>pr<70>ci<63>: utilisez plut<75>t xajax.request)';
|
||||
xajax.debug.text[115] = 'D<>BUT DE LA REQU<51>TE';
|
||||
xajax.debug.text[116] = 'Aucun traitement disponible pour traiter la r<>ponse du serveur.\n';
|
||||
xajax.debug.text[117] = '.\nV<6E>rifie s\'il existe des messages d\'erreur du serveur.';
|
||||
xajax.debug.text[118] = 'RE<52>US [statut : ';
|
||||
xajax.debug.text[119] = ', taille: ';
|
||||
xajax.debug.text[120] = ' octets, temps: ';
|
||||
xajax.debug.text[121] = 'ms] :\n';
|
||||
xajax.debug.text[122] = 'Le serveur a retourn<72> la statut HTTP suivant : ';
|
||||
xajax.debug.text[123] = '\nRE<52>US :\n';
|
||||
xajax.debug.text[124] = 'Le serveur a indiqu<71> une redirection vers :<br />';
|
||||
xajax.debug.text[125] = 'FAIT [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INITIALISATION DE L\'OBJET REQU<51>TE';
|
||||
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'R<>ponse XML non valide : La r<>ponse contient une balise inconnue : {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject : XMLHttpRequest n\'est pas disponible, xajax est d<>sactiv<69>.';
|
||||
xajax.debug.exceptions[10003] = 'File pleine : Ne peut ajouter un objet <20> la file car elle est pleine.';
|
||||
xajax.debug.exceptions[10004] = 'R<>ponse XML non valide : La r<>ponse contient une balise ou un texte inattendu : {data}.';
|
||||
xajax.debug.exceptions[10005] = 'URI de la requ<71>te non valide : URI non valide ou manquante; auto-d<>tection <20>chou<6F>e; veuillez en sp<73>cifier une explicitement.';
|
||||
xajax.debug.exceptions[10006] = 'R<>ponse de commande invalide : Commande de r<>ponse re<72>ue mal form<72>e.';
|
||||
xajax.debug.exceptions[10007] = 'R<>ponse de commande invalide : Commande [{data}] est inconnue.';
|
||||
xajax.debug.exceptions[10008] = 'L\'<27>l<EFBFBD>ment d\'ID [{data}] est introuvable dans le document.';
|
||||
xajax.debug.exceptions[10009] = 'Requ<71>te invalide : Aucun nom de fonction indiqu<71> en param<61>tre.';
|
||||
xajax.debug.exceptions[10010] = 'Requ<71>te invalide : Aucun objet indiqu<71> en param<61>tre pour la fonction.';
|
||||
|
||||
if ('undefined' != typeof xajax.config) {
|
||||
if ('undefined' != typeof xajax.config.status) {
|
||||
/*
|
||||
Object: mise <20> jour
|
||||
*/
|
||||
xajax.config.status.update = function() {
|
||||
return {
|
||||
onRequest: function() {
|
||||
window.status = 'Envoi de la requ<71>te...';
|
||||
},
|
||||
onWaiting: function() {
|
||||
window.status = 'Attente de la r<>ponse...';
|
||||
},
|
||||
onProcessing: function() {
|
||||
window.status = 'En cours de traitement...';
|
||||
},
|
||||
onComplete: function() {
|
||||
window.status = 'Fait.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
libraries/xajax/xajax_js/xajax_lang_nl_uncompressed.js
Normal file
84
libraries/xajax/xajax_js/xajax_lang_nl_uncompressed.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* translation for: xajax v.x.x
|
||||
* @version: 1.0.0
|
||||
* @author: jeffrey <walkingsoul@gmail.com>
|
||||
* @copyright xajax project
|
||||
* @license GNU/GPL
|
||||
* @package xajax x.x.x
|
||||
* @since v.x.x.x
|
||||
* save as UTF-8
|
||||
*/
|
||||
|
||||
if ('undefined' != typeof xajax.debug) {
|
||||
/*
|
||||
Array: text
|
||||
*/
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'FOUTMELDING: ';
|
||||
xajax.debug.text[101] = 'FOUT: ';
|
||||
xajax.debug.text[102] = 'XAJAX FOUTMELDINGS BERICHT:\n';
|
||||
xajax.debug.text[103] = '...\n[LANG ANTWOORD]\n...';
|
||||
xajax.debug.text[104] = 'VERZENDING AANVRAAG';
|
||||
xajax.debug.text[105] = 'VERZONDEN [';
|
||||
xajax.debug.text[106] = ' bytes]';
|
||||
xajax.debug.text[107] = 'AANROEPING: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'INITIALISATIE AANVRAAG';
|
||||
xajax.debug.text[110] = 'VERWERKING PARAMETERS [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'GEEN PARAMETERS OM TE VERWERKEN';
|
||||
xajax.debug.text[113] = 'VOORBEREIDING AANVRAAG';
|
||||
xajax.debug.text[114] = 'BEGIN XAJAX AANVRAAG (verouderd: gebruik xajax.request)';
|
||||
xajax.debug.text[115] = 'BEGIN XAJAX AANVRAAG';
|
||||
xajax.debug.text[116] = 'Er is geen verwerkingsbestand gespecificeerd om de aanvraag te verwerken.\n';
|
||||
xajax.debug.text[117] = '.\nBekijk foutmeldingen van de server.';
|
||||
xajax.debug.text[118] = 'ONTVANGEN [status: ';
|
||||
xajax.debug.text[119] = ', omvang: ';
|
||||
xajax.debug.text[120] = ' bytes, Zeit: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'De server retourneert de volgende HTTP-status: ';
|
||||
xajax.debug.text[123] = '\nONTVANGEN:\n';
|
||||
xajax.debug.text[124] = 'De server retourneert een doorverwijzing naar:<br />';
|
||||
xajax.debug.text[125] = 'KLAAR [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'INITIALISATIE OBJECT AANVRAAG';
|
||||
|
||||
/*
|
||||
Array: exceptions
|
||||
*/
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Ongeldig XML-antwoord: het antwoord bevat een onbekende tag: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest is niet beschikbaar, XajaX is uitgeschakeld.';
|
||||
xajax.debug.exceptions[10003] = 'Wachtrij limiet overschreden: kan het object niet in de wachtrij plaatsen, omdat die vol is.';
|
||||
xajax.debug.exceptions[10004] = 'Ongeldig XML-antwoord: het antwoord bevat een onverwachte tag of tekst: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Ongeldige Request-URI: Ongeldige of ontbrekende URI; automatische detectie faalt; specificeer een URI expliciet.';
|
||||
xajax.debug.exceptions[10006] = 'Ongeldig antwoord bevel: misvormd antwoord bevel ontvangen.';
|
||||
xajax.debug.exceptions[10007] = 'Ongeldig antwoord bevel: Bevel [{data}] is niet bekend.';
|
||||
xajax.debug.exceptions[10008] = 'Element met het ID [{data}] kon niet in het document worden gevonden.';
|
||||
xajax.debug.exceptions[10009] = 'Ongeldige aanvraag: Missende functie parameter - naam.';
|
||||
xajax.debug.exceptions[10010] = 'Ongeldige aanvraag: Missende functie parameter - object.';
|
||||
}
|
||||
|
||||
if ('undefined' != typeof xajax.config) {
|
||||
if ('undefined' != typeof xajax.config.status) {
|
||||
/*
|
||||
Object: update
|
||||
*/
|
||||
xajax.config.status.update = function() {
|
||||
return {
|
||||
onRequest: function() {
|
||||
window.status = "Verzenden aanvraag...";
|
||||
},
|
||||
onWaiting: function() {
|
||||
window.status = "Wachten op antwoord...";
|
||||
},
|
||||
onProcessing: function() {
|
||||
window.status = "Verwerking...";
|
||||
},
|
||||
onComplete: function() {
|
||||
window.status = "Afgesloten.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
libraries/xajax/xajax_js/xajax_lang_tr_uncompressed.js
Normal file
81
libraries/xajax/xajax_js/xajax_lang_tr_uncompressed.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* translation for: xajax v.x.x
|
||||
* @version: 1.0.0
|
||||
* @author: mic <info@joomx.com>
|
||||
* @copyright xajax project
|
||||
* @license GNU/GPL
|
||||
* @package xajax x.x.x
|
||||
* @since v.x.x.x
|
||||
* save as UTF-8
|
||||
*/
|
||||
if ('undefined' != typeof xajax.debug) {
|
||||
|
||||
xajax.debug.text = [];
|
||||
xajax.debug.text[100] = 'IKAZ: ';
|
||||
xajax.debug.text[101] = 'HATA: ';
|
||||
xajax.debug.text[102] = 'XAJAX DEBUG (HATA AYIKLAMASI) MESAJI:\n';
|
||||
xajax.debug.text[103] = '...\n[UZUN YANIT]\n...';
|
||||
xajax.debug.text[104] = 'ISTEK GÖNDERILIYOR';
|
||||
xajax.debug.text[105] = 'GÖNDERILDI [';
|
||||
xajax.debug.text[106] = ' byte]';
|
||||
xajax.debug.text[107] = 'ÇAGIRILIYOR: ';
|
||||
xajax.debug.text[108] = 'URI: ';
|
||||
xajax.debug.text[109] = 'ISTEK BASLATILIYOR';
|
||||
xajax.debug.text[110] = 'PARAMETRELER ISLENIYOR [';
|
||||
xajax.debug.text[111] = ']';
|
||||
xajax.debug.text[112] = 'ISLENECEK PARAMETRE YOK';
|
||||
xajax.debug.text[113] = 'ISTEK HAZIRLANIYOR';
|
||||
xajax.debug.text[114] = 'XAJAX ÇAGRISI BASLATILIYOR (kullanimi tavsiye edilmiyor: yerine xajax.request kullanin)';
|
||||
xajax.debug.text[115] = 'XAJAX ISTEGI BASLATILIYOR';
|
||||
xajax.debug.text[116] = 'Sunucudan gelen cevabi isleyecek cevap islemcisi yok.\n';
|
||||
xajax.debug.text[117] = '.\nSunucudan gelen hata mesajlarini kontrol edin.';
|
||||
xajax.debug.text[118] = 'ALINDI [durum: ';
|
||||
xajax.debug.text[119] = ', boyut: ';
|
||||
xajax.debug.text[120] = ' byte, süre: ';
|
||||
xajax.debug.text[121] = 'ms]:\n';
|
||||
xajax.debug.text[122] = 'Sunucu asagidaki HTTP durumunu gönderdi: ';
|
||||
xajax.debug.text[123] = '\nALINDI:\n';
|
||||
xajax.debug.text[124] = 'Sunucu su adrese yönlendirme istegi gönderdi :<br />';
|
||||
xajax.debug.text[125] = 'TAMAMLANDI [';
|
||||
xajax.debug.text[126] = 'ms]';
|
||||
xajax.debug.text[127] = 'ISTEK NESNESI BASLATILIYOR';
|
||||
|
||||
/*
|
||||
Array: exceptions
|
||||
*/
|
||||
xajax.debug.exceptions = [];
|
||||
xajax.debug.exceptions[10001] = 'Geçersiz XML cevabi: Cevap bilinmeyen bir etiket tasiyor: {data}.';
|
||||
xajax.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest hazir degil, xajax nesnesi etkisizlestirildi.';
|
||||
xajax.debug.exceptions[10003] = 'Islem kuyrugu fazla yüklendi: Kuyruk dolu oldugu için nesne kuyruga eklenemiyor.';
|
||||
xajax.debug.exceptions[10004] = 'Geçersiz XML cevabi: Cevap bilinmeyen bir etiket veya metin tasiyor: {data}.';
|
||||
xajax.debug.exceptions[10005] = 'Geçersiz istek URI: Geçersiz veya kayip URI; otomatik tespit yapilamadi; lütfen açikça bir tane belirleyiniz.';
|
||||
xajax.debug.exceptions[10006] = 'Geçersiz cevap komutu: Bozulmus cevap komutu alindi.';
|
||||
xajax.debug.exceptions[10007] = 'Geçersiz cevap komutu: [{data}] komutu bilinmiyor.';
|
||||
xajax.debug.exceptions[10008] = '[{data}] ID li element dosya içinde bulunamadi.';
|
||||
xajax.debug.exceptions[10009] = 'Geçersiz istek: Fonksiyon isim parametresi eksik.';
|
||||
xajax.debug.exceptions[10010] = 'Geçersiz istek: Fonksiyon nesne parametresi eksik.';
|
||||
}
|
||||
|
||||
if ('undefined' != typeof xajax.config) {
|
||||
if ('undefined' != typeof xajax.config.status) {
|
||||
/*
|
||||
Object: update
|
||||
*/
|
||||
xajax.config.status.update = function() {
|
||||
return {
|
||||
onRequest: function() {
|
||||
window.status = 'İstek Gönderiliyor...';
|
||||
},
|
||||
onWaiting: function() {
|
||||
window.status = 'Cevap Bekleniyor...';
|
||||
},
|
||||
onProcessing: function() {
|
||||
window.status = 'İşlem Devam Ediyor...';
|
||||
},
|
||||
onComplete: function() {
|
||||
window.status = 'Tamamlandı.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
libraries/xajax/xajax_js/xajax_legacy.js
Normal file
13
libraries/xajax/xajax_js/xajax_legacy.js
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
try{if(undefined==xajax.legacy)
|
||||
xajax.legacy={}
|
||||
}catch(e){alert('An internal error has occurred: the xajax_core has not been loaded prior to xajax_legacy.');}
|
||||
xajax.legacy.call=xajax.call;xajax.call=function(sFunction,objParameters){var oOpt={}
|
||||
oOpt.parameters=objParameters;if(undefined!=xajax.loadingFunction){if(undefined==oOpt.callback)
|
||||
oOpt.callback={}
|
||||
oOpt.callback.onResponseDelay=xajax.loadingFunction;}
|
||||
if(undefined!=xajax.doneLoadingFunction){if(undefined==oOpt.callback)
|
||||
oOpt.callback={}
|
||||
oOpt.callback.onComplete=xajax.doneLoadingFunction;}
|
||||
return xajax.legacy.call(sFunction,oOpt);}
|
||||
xajax.legacy.isLoaded=true;
|
||||
60
libraries/xajax/xajax_js/xajax_legacy_uncompressed.js
Normal file
60
libraries/xajax/xajax_js/xajax_legacy_uncompressed.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
File: xajax_legacy.js
|
||||
|
||||
Provides support for legacy scripts that have not been updated to the
|
||||
latest syntax.
|
||||
|
||||
Title: xajax legacy support module
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_legacy_uncompressed.php 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajax.legacy
|
||||
*/
|
||||
try {
|
||||
if (undefined == xajax.legacy)
|
||||
xajax.legacy = {}
|
||||
} catch (e) {
|
||||
alert('An internal error has occurred: the xajax_core has not been loaded prior to xajax_legacy.');
|
||||
}
|
||||
|
||||
/*
|
||||
Function: call
|
||||
|
||||
Convert call parameters from the 0.2.x syntax to the new *improved*
|
||||
call format.
|
||||
|
||||
This is a wrapper function around the standard <xajax.call> function.
|
||||
*/
|
||||
xajax.legacy.call = xajax.call;
|
||||
xajax.call = function(sFunction, objParameters) {
|
||||
var oOpt = {}
|
||||
oOpt.parameters = objParameters;
|
||||
if (undefined != xajax.loadingFunction) {
|
||||
if (undefined == oOpt.callback)
|
||||
oOpt.callback = {}
|
||||
oOpt.callback.onResponseDelay = xajax.loadingFunction;
|
||||
}
|
||||
if (undefined != xajax.doneLoadingFunction) {
|
||||
if (undefined == oOpt.callback)
|
||||
oOpt.callback = {}
|
||||
oOpt.callback.onComplete = xajax.doneLoadingFunction;
|
||||
}
|
||||
return xajax.legacy.call(sFunction, oOpt);
|
||||
}
|
||||
|
||||
/*
|
||||
Boolean: isLoaded
|
||||
|
||||
true - Indicates that the <xajax.legacy> module is loaded.
|
||||
*/
|
||||
xajax.legacy.isLoaded = true;
|
||||
168
libraries/xajax/xajax_js/xajax_verbose.js
Normal file
168
libraries/xajax/xajax_js/xajax_verbose.js
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
File: xajax_verbose.js
|
||||
|
||||
The xajax verbose debugging module. This is an optional module, include in
|
||||
your project with care. :)
|
||||
|
||||
Title: xajax verbose debugging module
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_verbose_uncompressed 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
try {
|
||||
if (undefined == xajax)
|
||||
throw { name: 'SequenceError', message: 'Error: xajax was not detected, verbose module disabled.' }
|
||||
if (undefined == xajax.debug)
|
||||
throw { name: 'SequenceError', message: 'Error: xajax debugger was not detected, verbose module disabled.' }
|
||||
|
||||
/*
|
||||
Class: xajax.debug.verbose
|
||||
|
||||
Provide a high level of detail which can be used to debug hard to find
|
||||
problems.
|
||||
*/
|
||||
xajax.debug.verbose = {}
|
||||
|
||||
/*
|
||||
Function: expandObject
|
||||
|
||||
Generate a debug message expanding all the first level
|
||||
members found therein.
|
||||
|
||||
obj - (object): The object to be enumerated.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The textual representation of all the first
|
||||
level members.
|
||||
*/
|
||||
xajax.debug.verbose.expandObject = function(obj) {
|
||||
var rec = true;
|
||||
if (1 < arguments.length)
|
||||
rec = arguments[1];
|
||||
if ('function' == typeof (obj)) {
|
||||
return '[Function]';
|
||||
} else if ('object' == typeof (obj)) {
|
||||
if (true == rec) {
|
||||
var t = ' { ';
|
||||
var separator = '';
|
||||
for (var m in obj) {
|
||||
t += separator;
|
||||
t += m;
|
||||
t += ': ';
|
||||
try {
|
||||
t += xajax.debug.verbose.expandObject(obj[m], false);
|
||||
} catch (e) {
|
||||
t += '[n/a]';
|
||||
}
|
||||
separator = ', ';
|
||||
}
|
||||
t += ' } ';
|
||||
return t;
|
||||
} else return '[Object]';
|
||||
} else return '"' + obj + '"';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: makeFunction
|
||||
|
||||
Generate a wrapper function around the specified function.
|
||||
|
||||
obj - (object): The object that contains the function to be
|
||||
wrapped.
|
||||
name - (string): The name of the function to be wrapped.
|
||||
|
||||
Returns:
|
||||
|
||||
function - The wrapper function.
|
||||
*/
|
||||
xajax.debug.verbose.makeFunction = function(obj, name) {
|
||||
return function() {
|
||||
var fun = name;
|
||||
fun += '(';
|
||||
|
||||
var separator = '';
|
||||
var pLen = arguments.length;
|
||||
for (var p = 0; p < pLen; ++p) {
|
||||
fun += separator;
|
||||
fun += xajax.debug.verbose.expandObject(arguments[p]);
|
||||
separator = ',';
|
||||
}
|
||||
|
||||
fun += ');';
|
||||
|
||||
var msg = '--> ';
|
||||
msg += fun;
|
||||
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
var returnValue = true;
|
||||
var code = 'returnValue = obj(';
|
||||
separator = '';
|
||||
for (var p = 0; p < pLen; ++p) {
|
||||
code += separator;
|
||||
code += 'arguments[' + p + ']';
|
||||
separator = ',';
|
||||
}
|
||||
code += ');';
|
||||
|
||||
eval(code);
|
||||
|
||||
msg = '<-- ';
|
||||
msg += fun;
|
||||
msg += ' returns ';
|
||||
msg += xajax.debug.verbose.expandObject(returnValue);
|
||||
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: hook
|
||||
|
||||
Generate a wrapper function around each of the functions
|
||||
contained within the specified object.
|
||||
|
||||
x - (object): The object to be scanned.
|
||||
base - (string): The base reference to be prepended to the
|
||||
generated wrapper functions.
|
||||
*/
|
||||
xajax.debug.verbose.hook = function(x, base) {
|
||||
for (var m in x) {
|
||||
if ('function' == typeof (x[m])) {
|
||||
x[m] = xajax.debug.verbose.makeFunction(x[m], base + m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xajax.debug.verbose.hook(xajax, 'xajax.');
|
||||
xajax.debug.verbose.hook(xajax.callback, 'xajax.callback.');
|
||||
xajax.debug.verbose.hook(xajax.css, 'xajax.css.');
|
||||
xajax.debug.verbose.hook(xajax.dom, 'xajax.dom.');
|
||||
xajax.debug.verbose.hook(xajax.events, 'xajax.events.');
|
||||
xajax.debug.verbose.hook(xajax.forms, 'xajax.forms.');
|
||||
xajax.debug.verbose.hook(xajax.js, 'xajax.js.');
|
||||
xajax.debug.verbose.hook(xajax.tools, 'xajax.tools.');
|
||||
xajax.debug.verbose.hook(xajax.tools.queue, 'xajax.tools.queue.');
|
||||
xajax.debug.verbose.hook(xajax.command, 'xajax.command.');
|
||||
xajax.debug.verbose.hook(xajax.command.handler, 'xajax.command.handler.');
|
||||
|
||||
/*
|
||||
Boolean: isLoaded
|
||||
|
||||
true - indicates that the verbose debugging module is loaded.
|
||||
*/
|
||||
xajax.debug.verbose.isLoaded = true;
|
||||
} catch (e) {
|
||||
alert(e.name + ': ' + e.message);
|
||||
}
|
||||
168
libraries/xajax/xajax_js/xajax_verbose_uncompressed.js
Normal file
168
libraries/xajax/xajax_js/xajax_verbose_uncompressed.js
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
File: xajax_verbose.js
|
||||
|
||||
The xajax verbose debugging module. This is an optional module, include in
|
||||
your project with care. :)
|
||||
|
||||
Title: xajax verbose debugging module
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajax_verbose_uncompressed 327 2007-02-28 16:55:26Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
try {
|
||||
if (undefined == xajax)
|
||||
throw { name: 'SequenceError', message: 'Error: xajax was not detected, verbose module disabled.' }
|
||||
if (undefined == xajax.debug)
|
||||
throw { name: 'SequenceError', message: 'Error: xajax debugger was not detected, verbose module disabled.' }
|
||||
|
||||
/*
|
||||
Class: xajax.debug.verbose
|
||||
|
||||
Provide a high level of detail which can be used to debug hard to find
|
||||
problems.
|
||||
*/
|
||||
xajax.debug.verbose = {}
|
||||
|
||||
/*
|
||||
Function: expandObject
|
||||
|
||||
Generate a debug message expanding all the first level
|
||||
members found therein.
|
||||
|
||||
obj - (object): The object to be enumerated.
|
||||
|
||||
Returns:
|
||||
|
||||
string - The textual representation of all the first
|
||||
level members.
|
||||
*/
|
||||
xajax.debug.verbose.expandObject = function(obj) {
|
||||
var rec = true;
|
||||
if (1 < arguments.length)
|
||||
rec = arguments[1];
|
||||
if ('function' == typeof (obj)) {
|
||||
return '[Function]';
|
||||
} else if ('object' == typeof (obj)) {
|
||||
if (true == rec) {
|
||||
var t = ' { ';
|
||||
var separator = '';
|
||||
for (var m in obj) {
|
||||
t += separator;
|
||||
t += m;
|
||||
t += ': ';
|
||||
try {
|
||||
t += xajax.debug.verbose.expandObject(obj[m], false);
|
||||
} catch (e) {
|
||||
t += '[n/a]';
|
||||
}
|
||||
separator = ', ';
|
||||
}
|
||||
t += ' } ';
|
||||
return t;
|
||||
} else return '[Object]';
|
||||
} else return '"' + obj + '"';
|
||||
}
|
||||
|
||||
/*
|
||||
Function: makeFunction
|
||||
|
||||
Generate a wrapper function around the specified function.
|
||||
|
||||
obj - (object): The object that contains the function to be
|
||||
wrapped.
|
||||
name - (string): The name of the function to be wrapped.
|
||||
|
||||
Returns:
|
||||
|
||||
function - The wrapper function.
|
||||
*/
|
||||
xajax.debug.verbose.makeFunction = function(obj, name) {
|
||||
return function() {
|
||||
var fun = name;
|
||||
fun += '(';
|
||||
|
||||
var separator = '';
|
||||
var pLen = arguments.length;
|
||||
for (var p = 0; p < pLen; ++p) {
|
||||
fun += separator;
|
||||
fun += xajax.debug.verbose.expandObject(arguments[p]);
|
||||
separator = ',';
|
||||
}
|
||||
|
||||
fun += ');';
|
||||
|
||||
var msg = '--> ';
|
||||
msg += fun;
|
||||
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
var returnValue = true;
|
||||
var code = 'returnValue = obj(';
|
||||
separator = '';
|
||||
for (var p = 0; p < pLen; ++p) {
|
||||
code += separator;
|
||||
code += 'arguments[' + p + ']';
|
||||
separator = ',';
|
||||
}
|
||||
code += ');';
|
||||
|
||||
eval(code);
|
||||
|
||||
msg = '<-- ';
|
||||
msg += fun;
|
||||
msg += ' returns ';
|
||||
msg += xajax.debug.verbose.expandObject(returnValue);
|
||||
|
||||
xajax.debug.writeMessage(msg);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: hook
|
||||
|
||||
Generate a wrapper function around each of the functions
|
||||
contained within the specified object.
|
||||
|
||||
x - (object): The object to be scanned.
|
||||
base - (string): The base reference to be prepended to the
|
||||
generated wrapper functions.
|
||||
*/
|
||||
xajax.debug.verbose.hook = function(x, base) {
|
||||
for (var m in x) {
|
||||
if ('function' == typeof (x[m])) {
|
||||
x[m] = xajax.debug.verbose.makeFunction(x[m], base + m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xajax.debug.verbose.hook(xajax, 'xajax.');
|
||||
xajax.debug.verbose.hook(xajax.callback, 'xajax.callback.');
|
||||
xajax.debug.verbose.hook(xajax.css, 'xajax.css.');
|
||||
xajax.debug.verbose.hook(xajax.dom, 'xajax.dom.');
|
||||
xajax.debug.verbose.hook(xajax.events, 'xajax.events.');
|
||||
xajax.debug.verbose.hook(xajax.forms, 'xajax.forms.');
|
||||
xajax.debug.verbose.hook(xajax.js, 'xajax.js.');
|
||||
xajax.debug.verbose.hook(xajax.tools, 'xajax.tools.');
|
||||
xajax.debug.verbose.hook(xajax.tools.queue, 'xajax.tools.queue.');
|
||||
xajax.debug.verbose.hook(xajax.command, 'xajax.command.');
|
||||
xajax.debug.verbose.hook(xajax.command.handler, 'xajax.command.handler.');
|
||||
|
||||
/*
|
||||
Boolean: isLoaded
|
||||
|
||||
true - indicates that the verbose debugging module is loaded.
|
||||
*/
|
||||
xajax.debug.verbose.isLoaded = true;
|
||||
} catch (e) {
|
||||
alert(e.name + ': ' + e.message);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?
|
||||
|
||||
|
||||
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
|
||||
{
|
||||
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
|
||||
$sXajaxCore = $sBaseFolder . '/xajax_core';
|
||||
|
||||
if (false == class_exists('xajaxPlugin'))
|
||||
require $sXajaxCore . '/xajaxPlugin.inc.php';
|
||||
if (false == class_exists('xajaxPluginManager'))
|
||||
require $sXajaxCore . '/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
|
||||
//if (!defined ('XAJAX_UPLOAD_FUNCTION')) define ('XAJAX_UPLOAD_FUNCTION', 'upfunction');
|
||||
|
||||
//require_once dirname(__FILE__) . '/xajaxUploadFunction.inc.php';
|
||||
|
||||
class clsSession extends xajaxRequestPlugin
|
||||
{
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
private $sCallName = "Session";
|
||||
private $sXajaxPrefix = "xajax_";
|
||||
|
||||
|
||||
private $sSessionCheck = "";
|
||||
private $sSessionExpired = "";
|
||||
|
||||
public function clsSession()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function configure($sName, $mValue)
|
||||
{
|
||||
switch ($sName)
|
||||
{
|
||||
case 'sessionCheck':
|
||||
if (is_string($mValue) || is_array($mValue))
|
||||
{
|
||||
$this->sSessionCheck = $mValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sessionExpired':
|
||||
if (is_string($mValue) || is_array($mValue))
|
||||
{
|
||||
$this->sSessionExpired = $mValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsSession(), 10);
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
if ( false == class_exists( 'xajaxPlugin' ) || false == class_exists( 'xajaxPluginManager' ) )
|
||||
{
|
||||
$sBaseFolder = dirname( dirname( dirname( __FILE__ ) ) );
|
||||
$sXajaxCore = $sBaseFolder.'/xajax_core';
|
||||
|
||||
if ( false == class_exists( 'xajaxPlugin' ) )
|
||||
require $sXajaxCore.'/xajaxPlugin.inc.php';
|
||||
|
||||
if ( false == class_exists( 'xajaxPluginManager' ) )
|
||||
require $sXajaxCore.'/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
class clsSwfUpload
|
||||
extends xajaxResponsePlugin
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
private $sCallName = "SWFUpload";
|
||||
private $sDefer;
|
||||
private $sJavascriptURI;
|
||||
private $bInlineScript;
|
||||
private $SWFupload_FadeTimeOut = 1500;
|
||||
private $sRequestedFunction = NULL;
|
||||
|
||||
private $sXajaxPrefix = "xajax_";
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function clsSwfUpload()
|
||||
{
|
||||
$this->sDefer = '';
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = false;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function getName()
|
||||
{
|
||||
return get_class( $this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
public function configure( $sName, $mValue )
|
||||
{
|
||||
switch ( $sName )
|
||||
{
|
||||
case 'scriptDeferral':
|
||||
if ( true === $mValue || false === $mValue )
|
||||
{
|
||||
if ( $mValue )
|
||||
$this->sDefer = 'defer ';
|
||||
else
|
||||
$this->sDefer = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'javascript URI':
|
||||
$this->sJavascriptURI = $mValue;
|
||||
break;
|
||||
|
||||
case 'inlineScript':
|
||||
if ( true === $mValue || false === $mValue )
|
||||
$this->bInlineScript = $mValue;
|
||||
break;
|
||||
|
||||
case 'SWFupload_FadeTimeOut':
|
||||
if ( is_numeric( $mValue ) )
|
||||
$this->SWFupload_FadeTimeOut = $mValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function generateClientScript()
|
||||
{
|
||||
echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
echo "if (undefined == xajax.ext) xajax.ext = {};\n";
|
||||
echo "xajax.ext.SWFupload = {};";
|
||||
echo "xajax.ext.SWFupload.config = {};\n";
|
||||
echo "xajax.ext.SWFupload.config.javascript_URI='".$this->sJavascriptURI."xajax_plugins/request/swfupload/';\n";
|
||||
echo "xajax.ext.SWFupload.config.FadeTimeOut = '".$this->SWFupload_FadeTimeOut."';\n";
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
|
||||
if ( $this->bInlineScript )
|
||||
{
|
||||
echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
include( dirname( __FILE__ ).'xajax_plugins/request/swfupload/swfupload.js' );
|
||||
include( dirname( __FILE__ ).'xajax_plugins/request/swfupload/swfupload.xajax.js' );
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
}else
|
||||
{
|
||||
echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/request/swfupload/swfupload.js' ".$this->sDefer."charset='UTF-8'></script>\n";
|
||||
echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/request/swfupload/swfupload.xajax3.js' ".$this->sDefer."charset='UTF-8'></script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function transForm( $id, $config, $multi = false )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'SWFup_tfo',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array
|
||||
(
|
||||
"config" => $config,
|
||||
"multi" => $multi
|
||||
));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function transField( $id, $config, $multi = false )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'SWFup_tfi',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array
|
||||
(
|
||||
"config" => $config,
|
||||
"multi" => $multi
|
||||
));
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function destroyField( $id )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'SWFup_dfi',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array ());
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function destroyForm( $id )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'SWFup_dfo',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array ());
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
|
||||
$objPluginManager = &xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin( new clsSwfUpload(), 100 );
|
||||
?>
|
||||
99
libraries/xajax/xajax_plugins/request/swfupload/swfupload.js
Normal file
99
libraries/xajax/xajax_plugins/request/swfupload/swfupload.js
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
var SWFUpload=function(settings){this.initSWFUpload(settings);};SWFUpload.prototype.initSWFUpload=function(settings){try{this.customSettings={};this.settings=settings;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo();}catch(ex){delete SWFUpload.instances[this.movieName];throw ex;}
|
||||
};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.1.0 beta 1";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,
|
||||
FILE_EXCEEDS_SIZE_LIMIT:-110,
|
||||
ZERO_BYTE_FILE:-120,
|
||||
INVALID_FILETYPE:-130
|
||||
};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,
|
||||
MISSING_UPLOAD_URL:-210,
|
||||
IO_ERROR:-220,
|
||||
SECURITY_ERROR:-230,
|
||||
UPLOAD_LIMIT_EXCEEDED:-240,
|
||||
UPLOAD_FAILED:-250,
|
||||
SPECIFIED_FILE_ID_NOT_FOUND:-260,
|
||||
FILE_VALIDATION_FAILED:-270,
|
||||
FILE_CANCELLED:-280,
|
||||
UPLOAD_STOPPED:-290
|
||||
};SWFUpload.FILE_STATUS={QUEUED:-1,
|
||||
IN_PROGRESS:-2,
|
||||
ERROR:-3,
|
||||
COMPLETE:-4,
|
||||
CANCELLED:-5
|
||||
};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(settingName,defaultValue){this.settings[settingName]=(this.settings[settingName]==undefined)? defaultValue:this.settings[settingName];};this.ensureDefault("upload_url","");this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload_f9.swf");this.ensureDefault("flash_color","#FFFFFF");this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;delete this.ensureDefault;};SWFUpload.prototype.loadFlash=function(){var targetElement,container;if(document.getElementById(this.movieName)!==null){throw "ID "+this.movieName+" is already in use. The Flash Object could not be added";}
|
||||
targetElement=document.getElementsByTagName("body")[0];if(targetElement==undefined){throw "Could not find the 'body' element.";}
|
||||
container=document.createElement("div");container.style.width="1px";container.style.height="1px";targetElement.appendChild(container);container.innerHTML=this.getFlashHTML();};SWFUpload.prototype.getFlashHTML=function(){return ['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="1" height="1" style="-moz-user-focus: ignore;">',
|
||||
'<param name="movie" value="',this.settings.flash_url,'" />',
|
||||
'<param name="bgcolor" value="',this.settings.flash_color,'" />',
|
||||
'<param name="quality" value="high" />',
|
||||
'<param name="menu" value="false" />',
|
||||
'<param name="allowScriptAccess" value="always" />',
|
||||
'<param name="flashvars" value="'+this.getFlashVars()+'" />',
|
||||
'</object>'].join("");};SWFUpload.prototype.getFlashVars=function(){var paramString=this.buildParamString();return ["movieName=",encodeURIComponent(this.movieName),
|
||||
"&uploadURL=",encodeURIComponent(this.settings.upload_url),
|
||||
"&useQueryString=",encodeURIComponent(this.settings.use_query_string),
|
||||
"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),
|
||||
"&params=",encodeURIComponent(paramString),
|
||||
"&filePostName=",encodeURIComponent(this.settings.file_post_name),
|
||||
"&fileTypes=",encodeURIComponent(this.settings.file_types),
|
||||
"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),
|
||||
"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),
|
||||
"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),
|
||||
"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),
|
||||
"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled)].join("");};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName);}
|
||||
if(this.movieElement===null){throw "Could not find Flash element";}
|
||||
return this.movieElement;};SWFUpload.prototype.buildParamString=function(){var postParams=this.settings.post_params;var paramStringPairs=[];if(typeof(postParams)==="object"){for(var name in postParams){if(postParams.hasOwnProperty(name)){paramStringPairs.push(encodeURIComponent(name.toString())+"="+encodeURIComponent(postParams[name].toString()));}
|
||||
}
|
||||
}
|
||||
return paramStringPairs.join("&");};SWFUpload.prototype.displayDebugInfo=function(){this.debug(
|
||||
[
|
||||
"---SWFUpload Instance Info---\n",
|
||||
"Version: ",SWFUpload.version,"\n",
|
||||
"Movie Name: ",this.movieName,"\n",
|
||||
"Settings:\n",
|
||||
"\t","upload_url: ",this.settings.upload_url,"\n",
|
||||
"\t","use_query_string: ",this.settings.use_query_string.toString(),"\n",
|
||||
"\t","file_post_name: ",this.settings.file_post_name,"\n",
|
||||
"\t","post_params: ",this.settings.post_params.toString(),"\n",
|
||||
"\t","file_types: ",this.settings.file_types,"\n",
|
||||
"\t","file_types_description: ",this.settings.file_types_description,"\n",
|
||||
"\t","file_size_limit: ",this.settings.file_size_limit,"\n",
|
||||
"\t","file_upload_limit: ",this.settings.file_upload_limit,"\n",
|
||||
"\t","file_queue_limit: ",this.settings.file_queue_limit,"\n",
|
||||
"\t","flash_url: ",this.settings.flash_url,"\n",
|
||||
"\t","flash_color: ",this.settings.flash_color,"\n",
|
||||
"\t","debug: ",this.settings.debug.toString(),"\n",
|
||||
"\t","custom_settings: ",this.settings.custom_settings.toString(),"\n",
|
||||
"Event Handlers:\n",
|
||||
"\t","swfupload_loaded_handler assigned: ",(typeof(this.settings.swfupload_loaded_handler)==="function").toString(),"\n",
|
||||
"\t","file_dialog_start_handler assigned: ",(typeof(this.settings.file_dialog_start_handler)==="function").toString(),"\n",
|
||||
"\t","file_queued_handler assigned: ",(typeof(this.settings.file_queued_handler)==="function").toString(),"\n",
|
||||
"\t","file_queue_error_handler assigned: ",(typeof(this.settings.file_queue_error_handler)==="function").toString(),"\n",
|
||||
"\t","upload_start_handler assigned: ",(typeof(this.settings.upload_start_handler)==="function").toString(),"\n",
|
||||
"\t","upload_progress_handler assigned: ",(typeof(this.settings.upload_progress_handler)==="function").toString(),"\n",
|
||||
"\t","upload_error_handler assigned: ",(typeof(this.settings.upload_error_handler)==="function").toString(),"\n",
|
||||
"\t","upload_success_handler assigned: ",(typeof(this.settings.upload_success_handler)==="function").toString(),"\n",
|
||||
"\t","upload_complete_handler assigned: ",(typeof(this.settings.upload_complete_handler)==="function").toString(),"\n",
|
||||
"\t","debug_handler assigned: ",(typeof(this.settings.debug_handler)==="function").toString(),"\n"
|
||||
].join("")
|
||||
);};SWFUpload.prototype.addSetting=function(name,value,default_value){if(value==undefined){return(this.settings[name]=default_value);}else{return(this.settings[name]=value);}
|
||||
};SWFUpload.prototype.getSetting=function(name){if(this.settings[name]!=undefined){return this.settings[name];}
|
||||
return "";};SWFUpload.prototype.callFlash=function(functionName,withTimeout,argumentArray){withTimeout=!!withTimeout||false;argumentArray=argumentArray||[];var self=this;var callFunction=function(){var movieElement=self.getMovieElement();var returnValue;if(typeof(movieElement[functionName])==="function"){if(argumentArray.length===0){returnValue=movieElement[functionName]();}else if(argumentArray.length===1){returnValue=movieElement[functionName](argumentArray[0]);}else if(argumentArray.length===2){returnValue=movieElement[functionName](argumentArray[0],argumentArray[1]);}else if(argumentArray.length===3){returnValue=movieElement[functionName](argumentArray[0],argumentArray[1],argumentArray[2]);}else{throw "Too many arguments";}
|
||||
if(returnValue!=undefined&&typeof(returnValue.post)==="object"){returnValue=self.unescapeFilePostParams(returnValue);}
|
||||
return returnValue;}else{throw "Invalid function name";}
|
||||
};if(withTimeout){setTimeout(callFunction,0);}else{return callFunction();}
|
||||
};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile");};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles");};SWFUpload.prototype.startUpload=function(fileID){this.callFlash("StartUpload",false,[fileID]);};SWFUpload.prototype.cancelUpload=function(fileID){this.callFlash("CancelUpload",false,[fileID]);};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload");};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats");};SWFUpload.prototype.setStats=function(statsObject){this.callFlash("SetStats",false,[statsObject]);};SWFUpload.prototype.setCredentials=function(name,password){this.callFlash("SetCrednetials",false,[name,password]);};SWFUpload.prototype.getFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByIndex",false,[fileID]);}else{return this.callFlash("GetFile",false,[fileID]);}
|
||||
};SWFUpload.prototype.addFileParam=function(fileID,name,value){return this.callFlash("AddFileParam",false,[fileID,name,value]);};SWFUpload.prototype.removeFileParam=function(fileID,name){this.callFlash("RemoveFileParam",false,[fileID,name]);};SWFUpload.prototype.setUploadURL=function(url){this.settings.upload_url=url.toString();this.callFlash("SetUploadURL",false,[url]);};SWFUpload.prototype.setPostParams=function(paramsObject){this.settings.post_params=paramsObject;this.callFlash("SetPostParams",false,[paramsObject]);};SWFUpload.prototype.addPostParam=function(name,value){this.settings.post_params[name]=value;this.callFlash("SetPostParams",false,[this.settings.post_params]);};SWFUpload.prototype.removePostParam=function(name){delete this.settings.post_params[name];this.callFlash("SetPostParams",false,[this.settings.post_params]);};SWFUpload.prototype.setFileTypes=function(types,description){this.settings.file_types=types;this.settings.file_types_description=description;this.callFlash("SetFileTypes",false,[types,description]);};SWFUpload.prototype.setFileSizeLimit=function(fileSizeLimit){this.settings.file_size_limit=fileSizeLimit;this.callFlash("SetFileSizeLimit",false,[fileSizeLimit]);};SWFUpload.prototype.setFileUploadLimit=function(fileUploadLimit){this.settings.file_upload_limit=fileUploadLimit;this.callFlash("SetFileUploadLimit",false,[fileUploadLimit]);};SWFUpload.prototype.setFileQueueLimit=function(fileQueueLimit){this.settings.file_queue_limit=fileQueueLimit;this.callFlash("SetFileQueueLimit",false,[fileQueueLimit]);};SWFUpload.prototype.setFilePostName=function(filePostName){this.settings.file_post_name=filePostName;this.callFlash("SetFilePostName",false,[filePostName]);};SWFUpload.prototype.setUseQueryString=function(useQueryString){this.settings.use_query_string=useQueryString;this.callFlash("SetUseQueryString",false,[useQueryString]);};SWFUpload.prototype.setRequeueOnError=function(requeueOnError){this.settings.requeue_on_error=requeueOnError;this.callFlash("SetRequeueOnError",false,[requeueOnError]);};SWFUpload.prototype.setDebugEnabled=function(debugEnabled){this.settings.debug_enabled=debugEnabled;this.callFlash("SetDebugEnabled",false,[debugEnabled]);};SWFUpload.prototype.queueEvent=function(handlerName,argumentArray){if(argumentArray==undefined){argumentArray=[];}else if(!(argumentArray instanceof Array)){argumentArray=[argumentArray];}
|
||||
var self=this;if(typeof(this.settings[handlerName])==="function"){this.eventQueue.push(function(){this.settings[handlerName].apply(this,argumentArray);});setTimeout(function(){self.executeNextEvent();},0);}else if(this.settings[handlerName]!==null){throw "Event handler "+handlerName+" is unknown or is not a function";}
|
||||
};SWFUpload.prototype.executeNextEvent=function(){var f=this.eventQueue.shift();f.apply(this);};SWFUpload.prototype.unescapeFilePostParams=function(file){var reg=/[$]([0-9a-f]{4})/i;var unescapedPost={};var uk;for(var k in file.post){if(file.post.hasOwnProperty(k)){uk=k;var match;while((match=reg.exec(uk))!==null){uk=uk.replace(match[0],String.fromCharCode(parseInt("0x"+match[1],16)));}
|
||||
unescapedPost[uk]=file.post[k];}
|
||||
}
|
||||
file.post=unescapedPost;return file;};SWFUpload.prototype.flashReady=function(){var movieElement=this.getMovieElement();if(typeof(movieElement.StartUpload)!=="function"){throw "ExternalInterface methods failed to initialize.";}
|
||||
this.queueEvent("swfupload_loaded_handler");};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler");};SWFUpload.prototype.fileQueued=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("file_queued_handler",file);};SWFUpload.prototype.fileQueueError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("file_queue_error_handler",[file,errorCode,message]);};SWFUpload.prototype.fileDialogComplete=function(numFilesSelected,numFilesQueued){this.queueEvent("file_dialog_complete_handler",[numFilesSelected,numFilesQueued]);};SWFUpload.prototype.uploadStart=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("return_upload_start_handler",file);};SWFUpload.prototype.returnUploadStart=function(file){var returnValue;if(typeof(this.settings.upload_start_handler)==="function"){file=this.unescapeFilePostParams(file);returnValue=this.settings.upload_start_handler.call(this,file);}else if(this.settings.upload_start_handler!=undefined){throw "upload_start_handler must be a function";}
|
||||
if(returnValue===undefined){returnValue=true;}
|
||||
returnValue=!!returnValue;this.callFlash("ReturnUploadStart",false,[returnValue]);};SWFUpload.prototype.uploadProgress=function(file,bytesComplete,bytesTotal){file=this.unescapeFilePostParams(file);this.queueEvent("upload_progress_handler",[file,bytesComplete,bytesTotal]);};SWFUpload.prototype.uploadError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("upload_error_handler",[file,errorCode,message]);};SWFUpload.prototype.uploadSuccess=function(file,serverData){file=this.unescapeFilePostParams(file);this.queueEvent("upload_success_handler",[file,serverData]);};SWFUpload.prototype.uploadComplete=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("upload_complete_handler",file);};SWFUpload.prototype.debug=function(message){this.queueEvent("debug_handler",message);};SWFUpload.prototype.debugMessage=function(message){if(this.settings.debug){var exceptionMessage,exceptionValues=[];if(typeof(message)==="object"&&typeof(message.name)==="string"&&typeof(message.message)==="string"){for(var key in message){if(message.hasOwnProperty(key)){exceptionValues.push(key+": "+message[key]);}
|
||||
}
|
||||
exceptionMessage=exceptionValues.join("\n")||"";exceptionValues=exceptionMessage.split("\n");exceptionMessage="EXCEPTION: "+exceptionValues.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(exceptionMessage);}else{SWFUpload.Console.writeLine(message);}
|
||||
}
|
||||
};SWFUpload.Console={};SWFUpload.Console.writeLine=function(message){var console,documentForm;try{console=document.getElementById("SWFUpload_Console");if(!console){documentForm=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(documentForm);console=document.createElement("textarea");console.id="SWFUpload_Console";console.style.fontFamily="monospace";console.setAttribute("wrap","off");console.wrap="off";console.style.overflow="auto";console.style.width="700px";console.style.height="350px";console.style.margin="5px";documentForm.appendChild(console);}
|
||||
console.value+=message+"\n";console.scrollTop=console.scrollHeight-console.clientHeight;}catch(ex){alert("Exception: "+ex.name+" Message: "+ex.message);}
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
xajax.ext.SWFupload.swf=null;xajax.ext.SWFupload.forms={};xajax.ext.SWFupload.fields={};xajax.ext.SWFupload.queues={};xajax.ext.SWFupload.tools={};xajax.ext.SWFupload.settings={flash_url:xajax.ext.SWFupload.config.javascript_URI+"swfupload_f9.swf",
|
||||
file_size_limit:"0",
|
||||
file_types:"*.*",
|
||||
file_types_description:"All Files",
|
||||
file_upload_limit:0,
|
||||
file_queue_limit:0,
|
||||
debug:false,
|
||||
post_params:{'test':'x'}
|
||||
}
|
||||
if('undefined'==typeof xajax.ext.SWFupload.lang){xajax.ext.SWFupload.lang={};xajax.ext.SWFupload.lang.browseFiles='Browse Files';xajax.ext.SWFupload.lang.browseFile='Browse File';}
|
||||
xajax.ext.SWFupload.configure=function(config){if("object"==typeof config)return xajax.ext.SWFupload.tools.mergeObj(this.settings,config);return this.settings;}
|
||||
xajax.ext.SWFupload.addQueue=function(child,parent,config,multiple){var id=xajax.ext.SWFupload.tools.getId();this.queues[id]=new xajax.ext.SWFupload.tools.fileQueue(id,child,parent,config,multiple);return id;}
|
||||
xajax.ext.SWFupload.applyConfig=function(oQueue){var conf=oQueue.getConfig();var swf=xajax.ext.SWFupload.getInstance();if('undefined'!=typeof conf.file_types)
|
||||
swf.setFileTypes(conf.file_types,conf.file_types_description);if('undefined'!=typeof conf.file_size_limit)
|
||||
swf.setFileSizeLimit(conf.file_size_limit);if('object'==typeof conf.post_params){for(a in conf.post_params)
|
||||
swf.addPostParam(a,conf.post_params[a]);}
|
||||
swf.settings.file_queued_handler=function(oFile){oQueue.addFile(oFile)};;}
|
||||
xajax.ext.SWFupload.selectFile=function(oQueue){this.applyConfig(oQueue);if(oQueue.getConfig().file_queue_limit > 0&&oQueue.getConfig().file_queue_limit <=oQueue.queued)return;xajax.ext.SWFupload.getInstance().selectFile();}
|
||||
xajax.ext.SWFupload.selectFiles=function(oQueue){this.applyConfig(oQueue);if(oQueue.getConfig().file_queue_limit > 0&&oQueue.getConfig().file_queue_limit <=oQueue.queued)return;xajax.ext.SWFupload.getInstance().selectFiles();}
|
||||
xajax.ext.SWFupload.getInstance=function(){if(null==this.swf)this.swf=new SWFUpload(this.settings);return this.swf;}
|
||||
xajax.ext.SWFupload.removeFile=function(QueueId,FileId,finished){this.queues[QueueId].removeFile(FileId,finished);}
|
||||
xajax.ext.SWFupload.request={};xajax.ext.SWFupload.request.getFileFromQueue=function(oRequest){var instances={};var queued=0;if("string"==typeof oRequest.SWFform){if('object'!=typeof xajax.ext.SWFupload.forms[oRequest.SWFform]){return false;}
|
||||
for(a in xajax.ext.SWFupload.forms[oRequest.SWFform]){var field=xajax.ext.SWFupload.forms[oRequest.SWFform][a];if(0 < xajax.ext.SWFupload.queues[field].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[field].getFile();return true};}
|
||||
}else if("string"==typeof oRequest.SWFfield){if('string'!=typeof xajax.ext.SWFupload.fields[oRequest.SWFfield]){return false;}
|
||||
var qId=xajax.ext.SWFupload.fields[oRequest.SWFfield];if(0 < xajax.ext.SWFupload.queues[qId].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[qId].getFile();return true};}else{for(a in xajax.ext.SWFupload.queues){if(0 < xajax.ext.SWFupload.queues[a].queued){oRequest.currentFile=xajax.ext.SWFupload.queues[a].getFile();return true};}
|
||||
}
|
||||
return false;}
|
||||
xajax.ext.SWFupload.request.processParameters=function(oRequest){if("SWFupload"==oRequest.mode){oRequest.currentFile=false;xajax.ext.SWFupload.request.getFileFromQueue(oRequest);if(oRequest.currentFile)oRequest.method='GET';}
|
||||
return xajax.ext.SWFupload.bak.processParameters(oRequest);}
|
||||
xajax.ext.SWFupload.request.prepareRequest=function(oRequest){if("SWFupload"==oRequest.mode&&false!=oRequest.currentFile)return;return xajax.ext.SWFupload.bak.prepareRequest(oRequest);}
|
||||
xajax.ext.SWFupload.request.submitRequest=function(oRequest){if("SWFupload"==oRequest.mode&&false!=oRequest.currentFile){var swf=xajax.ext.SWFupload.getInstance();var fileQueue=xajax.ext.SWFupload.queues[oRequest.currentFile.QueueId];xajax.ext.SWFupload.applyConfig(fileQueue);swf.customSettings.currentFile=oRequest.currentFile;swf.setFilePostName(swf.customSettings.currentFile.name);swf.customSettings.oRequest=oRequest;swf.setUploadURL(oRequest.requestURI);swf.settings.upload_success_handler=function(oFile,response){var FileId=swf.customSettings.currentFile;if('function'==typeof this.old_upload_success_handler)this.old_upload_success_handler(oFile);var xx=xajax;var xt=xx.tools;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;var oRet=oRequest.returnValue;if(response){var cmd=(new DOMParser()).parseFromString(response,"text/xml");var seq=0;var child=cmd.documentElement.firstChild;xt.xml.processFragment(child,seq,oRequest);if(null==xx.response.timeout)
|
||||
xt.queue.process(xx.response);}
|
||||
}
|
||||
swf.settings.upload_complete_handler=function(oFile){var qFile=this.customSettings.currentFile;xajax.ext.SWFupload.removeFile(qFile.QueueId,qFile.id,true);if(!xajax.ext.SWFupload.request.getFileFromQueue(oRequest)){if('function'==typeof oRequest.onUploadComplete)oRequest.onUploadComplete();return;}
|
||||
swf.customSettings.currentFile=oRequest.currentFile;swf.setFilePostName(oRequest.currentFile.name);this.startUpload(oRequest.currentFile.id);}
|
||||
swf.settings.upload_start_handler=function(oFile){if('function'==typeof this.old_upload_start_handler)this.old_upload_start_handler(oFile);oRequest.startTime=new Date();}
|
||||
swf.settings.upload_progress_handler=function(oFile,bytesLoaded,bytesTotal){upload={};upload.received=bytesLoaded;upload.total=bytesTotal;upload.state="uploading";var reqTime=new Date();upload.lastbytes=oRequest.lastbytes;upload.now=reqTime.getTime()/1000;upload.start=oRequest.startTime.getTime()/1000;var step=upload.received/(upload.total/100);var progressbar=xajax.$('SWFup_progress_'+oFile.id);var w=Math.round(220*step/100);progressbar.style.width=w+'px';var progress=xajax.$("swf_queued_filesize_"+oFile.id);var elapsed=upload.now-upload.start;var rate=xajax.ext.SWFupload.tools.formatBytes(upload.received/elapsed).toString()+'/s';progress.innerHTML="<i>"+rate+"</i> "+xajax.ext.SWFupload.tools.formatBytes(upload.received)+"/"+xajax.ext.SWFupload.tools.formatBytes(upload.total);oRequest.lastbytes=upload.received;}
|
||||
swf.settings.upload_error_handler=function(file,errorCode,message){alert("Error Code: "+errorCode+", File name: "+file.name+", Message: "+message);};swf.startUpload(swf.customSettings.currentFile.id);return;}
|
||||
return xajax.ext.SWFupload.bak.submitRequest(oRequest);}
|
||||
xajax.ext.SWFupload.tools.queueFile=function(oFile,name,QueueId,QueueContainer){this.id=oFile.id;this.name=name;this.QueueId=QueueId;var container=document.createElement('div');container.id="SWFup_"+this.id;container.className="swf_queued_file";this.elm=container;var remove=document.createElement('div');remove.className="swf_queued_file_remove";remove.innerHTML=" ";var id=this.id;var QueueId=this.QueueId;remove.onclick=function(){xajax.ext.SWFupload.getInstance().cancelUpload(id);xajax.ext.SWFupload.removeFile(QueueId,id);}
|
||||
container.appendChild(remove);var label=document.createElement('div');label.className="swf_queued_filename";label.innerHTML=oFile.name;container.appendChild(label);var progress_container=document.createElement('div');progress_container.className="swf_queued_file_progress_container";container.appendChild(progress_container);var progress=document.createElement('div');progress.className="swf_queued_file_progress_bar";progress.style.width='1px';progress.id='SWFup_progress_'+oFile.id;progress_container.appendChild(progress);var fSize=document.createElement('div');fSize.className="swf_queued_filesize";fSize.id="swf_queued_filesize_"+this.id;fSize.innerHTML=xajax.ext.SWFupload.tools.formatBytes(oFile.size);container.appendChild(fSize);var fClear=document.createElement('div');fClear.style.clear='both';container.appendChild(fClear);QueueContainer.appendChild(container);this.container=container;this.oFile=oFile;this.destroy=function(){QueueContainer.removeChild(container);}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.fileQueue=function(id,child,parent,config,multiple){var swf=xajax.ext.SWFupload.getInstance();this.id=id;var config='object'==typeof config ? xajax.ext.SWFupload.tools.mergeObj(xajax.ext.SWFupload.settings,config):xajax.ext.SWFupload.settings;this.queued=0;this.files={};this.queue=null;this.getConfig=function(){return config;}
|
||||
xajax.forms.insertInput({id:child,
|
||||
type:"button",
|
||||
prop:"SWFup_Btn_"+this.id,
|
||||
data:"SWFup_Btn_"+this.id
|
||||
});parent.removeChild(child);var BtnSelect=xajax.$("SWFup_Btn_"+this.id);BtnSelect.name=this.id;var oQueue=this;if(true===multiple){BtnSelect.value=xajax.ext.SWFupload.lang.browseFiles;BtnSelect.onclick=function(){xajax.ext.SWFupload.selectFiles(oQueue);}
|
||||
}else{BtnSelect.value=xajax.ext.SWFupload.lang.browseFile;BtnSelect.onclick=function(){xajax.ext.SWFupload.selectFile(oQueue);}
|
||||
}
|
||||
var QueueContainer=document.createElement('div');QueueContainer.id='SWFqueue_'+this.id;parent.appendChild(QueueContainer);var fieldname=child.name;this.addFile=function(oFile){this.files[oFile.id]=new xajax.ext.SWFupload.tools.queueFile(oFile,fieldname,this.id,QueueContainer);this.queued++;if(this.queued==config.file_queue_limit)BtnSelect.disabled=true;}
|
||||
this.getFile=function(FileId){if("undefined"!=typeof FileId)return this.files[FileId];for(a in this.files)return this.files[a];return false;}
|
||||
this.removeFile=function(FileId,finished){this.queued--;if(this.queued <=config.file_queue_limit)BtnSelect.disabled=false;var filediv=xajax.$("SWFup_"+this.files[FileId].id);filediv.className=true===finished ? 'swf_queued_file_finished':'swf_queued_file_removed';setTimeout(function(){xajax.ext.SWFupload.tools.FadeOut(filediv,100);},xajax.ext.SWFupload.config.FadeTimeOut);this.files[FileId]=null;delete this.files[FileId];}
|
||||
this.destroy=function(){for(a in this.files){this.files[a].destroy();delete(this.files[a]);}
|
||||
this.queued=0;}
|
||||
}
|
||||
xajax.ext.SWFupload.tools._parseFields=function(children,parent,config,multiple){var result={};var iLen=children.length;for(var i=0;i < iLen;++i){var child=children[i];if('undefined'!=typeof child.childNodes)
|
||||
var res2=xajax.ext.SWFupload.tools._parseFields(child.childNodes,child,config,multiple);result=xajax.ext.SWFupload.tools.mergeObj(result,res2);if(child.name){if('file'==child.type){result[child.name]=xajax.ext.SWFupload.addQueue(child,parent,config,multiple);}
|
||||
}
|
||||
}
|
||||
return result;}
|
||||
xajax.ext.SWFupload.tools.transForm=function(form_id,config,multiple){var oForm=xajax.$(form_id);if(oForm)
|
||||
if(oForm.childNodes){var fields=xajax.ext.SWFupload.tools._parseFields(oForm.childNodes,oForm,config,multiple);xajax.ext.SWFupload.forms[form_id]=fields;}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.transField=function(field_id,config,multiple){try{var oField=xajax.$(field_id);if('undefined'!=typeof oField)return xajax.ext.SWFupload.fields[field_id]=xajax.ext.SWFupload.addQueue(oField,oField.parentNode,config,multiple);}catch(ex){}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.destroyForm=function(form_id){if("undefined"==typeof xajax.ext.SWFupload.forms[form_id])return;for(a in xajax.ext.SWFupload.forms[form_id]){var key=xajax.ext.SWFupload.forms[form_id][a];xajax.ext.SWFupload.queues[key].destroy();delete xajax.ext.SWFupload.queues[key];delete xajax.ext.SWFupload.forms[form_id];}
|
||||
return;}
|
||||
xajax.ext.SWFupload.tools.destroyField=function(field_id){if("undefined"==typeof xajax.ext.SWFupload.fields[field_id])return;var key=xajax.ext.SWFupload.fields[field_id];xajax.ext.SWFupload.queues[key].destroy();delete(xajax.ext.SWFupload.queues[key]);delete xajax.ext.SWFupload.fields[field_id];return true;}
|
||||
xajax.ext.SWFupload.tools.FadeOut=function(elm,opacity){var reduceOpacityBy=15;var rate=40;if(opacity > 0){opacity-=reduceOpacityBy;if(opacity < 0){opacity=0;}
|
||||
if(elm.filters){try{elm.filters.item("DXImageTransform.Microsoft.Alpha").opacity=opacity;}catch(e){elm.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+")";}
|
||||
}else{elm.style.opacity=opacity/100;}
|
||||
}
|
||||
if(opacity > 0){var oSelf=this;setTimeout(function(){xajax.ext.SWFupload.tools.FadeOut(elm,opacity);},rate);}else{var parent=elm.parentNode;parent.removeChild(elm);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.formatBytes=function(bytes){var ret={};if(bytes/1204 < 1024){return(Math.round(bytes/1024*100)/100).toString()+" kB";}else{return(Math.round(bytes/1024/1024*100)/100).toString()+" MB";}
|
||||
return ret;}
|
||||
xajax.ext.SWFupload.tools.mergeObj=function(){if('object'!=typeof arguments)return;var res={};var len=arguments.length;for(var i=0;i<len;i++){var obj=arguments[i];for(a in obj){res[a]=obj[a];}
|
||||
}
|
||||
return res;}
|
||||
xajax.ext.SWFupload.tools.getId=function(){var pid_str="";for(i=0;i<=3;i++){var pid=0;pid=Math.random();while(Math.ceil(pid).toString().length<8){pid*=10;}
|
||||
pid=Math.ceil(pid).toString();pid_str=pid_str+pid.toString();}
|
||||
return pid_str;}
|
||||
xajax.command.handler.register('SWFup_dfi',function(args){args.cmdFullName='ext.SWFupload.tools.destroyField';xajax.ext.SWFupload.tools.destroyField(args.id);return true;});xajax.command.handler.register('SWFup_dfo',function(args){args.cmdFullName='ext.SWFupload.tools.destroyForm';xajax.ext.SWFupload.tools.destroyForm(args.id);return true;});xajax.command.handler.register('SWFup_tfi',function(args){args.cmdFullName='ext.SWFupload.tools.transField';if("string"==typeof args.data.config.upload_success_handler){try{eval("var foo = "+args.data.config.upload_success_handler);args.data.config.upload_success_handler=foo;}catch(ex){delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transField(args.id,args.data.config,args.data.multi);return true;});xajax.command.handler.register('SWFup_tfo',function(args){try{args.cmdFullName='ext.SWFupload.tools.transForm';if("string"==typeof args.data.config.upload_success_handler){try{eval("var foo = "+args.data.config.upload_success_handler);args.data.config.upload_success_handler=foo;}catch(ex){delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transForm(args.id,args.data.config,args.data.multi);}catch(ex){}
|
||||
return true;});xajax.ext.SWFupload.bak={};xajax.ext.SWFupload.bak.prepareRequest=xajax.prepareRequest;xajax.ext.SWFupload.bak.submitRequest=xajax.submitRequest;xajax.ext.SWFupload.bak.responseProcessor=xajax.responseProcessor;xajax.ext.SWFupload.bak.processParameters=xajax.processParameters;xajax.prepareRequest=xajax.ext.SWFupload.request.prepareRequest;xajax.submitRequest=xajax.ext.SWFupload.request.submitRequest;xajax.processParameters=xajax.ext.SWFupload.request.processParameters;if(typeof DOMParser=="undefined"){DOMParser=function(){}
|
||||
DOMParser.prototype.parseFromString=function(str,contentType){if(typeof ActiveXObject!="undefined"){var d=new ActiveXObject("Microsoft.XMLDOM");d.loadXML(str);return d;}else if(typeof XMLHttpRequest!="undefined"){var req=new XMLHttpRequest;req.open("GET","data:"+(contentType||"application/xml")+
|
||||
";charset=utf-8,"+encodeURIComponent(str),false);if(req.overrideMimeType){req.overrideMimeType(contentType);}
|
||||
req.send(null);return req.responseXML;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
|
||||
//xjxSWFup = xajax.ext.SWFupload;
|
||||
|
||||
xajax.ext.SWFupload.swf = null;
|
||||
|
||||
xajax.ext.SWFupload.forms = {};
|
||||
xajax.ext.SWFupload.fields = {};
|
||||
xajax.ext.SWFupload.queues = {};
|
||||
xajax.ext.SWFupload.tools = {};
|
||||
|
||||
/* default upload settings */
|
||||
xajax.ext.SWFupload.settings = {
|
||||
flash_url : xajax.ext.SWFupload.config.javascript_URI+"swfupload_f9.swf",
|
||||
file_size_limit : "0",
|
||||
file_types : "*.*",
|
||||
file_types_description : "All Files",
|
||||
file_upload_limit : 0,
|
||||
file_queue_limit : 0,
|
||||
debug: false,
|
||||
post_params:{'test' : 'x'}
|
||||
}
|
||||
|
||||
if ('undefined' == typeof xajax.ext.SWFupload.lang)
|
||||
{
|
||||
xajax.ext.SWFupload.lang = {};
|
||||
xajax.ext.SWFupload.lang.browseFiles = 'Browse Files';
|
||||
xajax.ext.SWFupload.lang.browseFile = 'Browse File';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.init
|
||||
arguments: config [object]
|
||||
|
||||
Creates the SWFupload instance
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.configure = function (config)
|
||||
{
|
||||
if ("object" == typeof config) return xajax.ext.SWFupload.tools.mergeObj(this.settings,config);
|
||||
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.addQueue
|
||||
arguments: child [object], parent [object], config [objeect ,multiple [bool]
|
||||
|
||||
Creates a new a new file queue and stores the reference in this.queues
|
||||
*/
|
||||
xajax.ext.SWFupload.addQueue = function (child,parent,config,multiple)
|
||||
{
|
||||
var id = xajax.ext.SWFupload.tools.getId();
|
||||
this.queues[id] = new xajax.ext.SWFupload.tools.fileQueue(id,child,parent,config,multiple);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.applyConfig
|
||||
arguments: oQueue [object]
|
||||
|
||||
Applies the queue's config on the SWFupload instance
|
||||
*/
|
||||
xajax.ext.SWFupload.applyConfig = function(oQueue)
|
||||
{
|
||||
|
||||
var conf = oQueue.getConfig();
|
||||
var swf = xajax.ext.SWFupload.getInstance();
|
||||
|
||||
if ( 'undefined' != typeof conf.file_types )
|
||||
swf.setFileTypes(conf.file_types, conf.file_types_description);
|
||||
|
||||
if ( 'undefined' != typeof conf.file_size_limit )
|
||||
swf.setFileSizeLimit(conf.file_size_limit);
|
||||
|
||||
if ( 'object' == typeof conf.post_params)
|
||||
{
|
||||
for (a in conf.post_params)
|
||||
swf.addPostParam(a,conf.post_params[a]);
|
||||
}
|
||||
|
||||
swf.settings.file_queued_handler = function(oFile) {oQueue.addFile(oFile)};;
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.selectFile
|
||||
arguments: oQueue [object]
|
||||
|
||||
Onclick handler for selecting file
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.selectFile = function(oQueue)
|
||||
{
|
||||
this.applyConfig(oQueue);
|
||||
|
||||
if (oQueue.getConfig().file_queue_limit > 0 && oQueue.getConfig().file_queue_limit <= oQueue.queued) return;
|
||||
|
||||
xajax.ext.SWFupload.getInstance().selectFile();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.selectFiles
|
||||
arguments: oQueue [object]
|
||||
|
||||
Onclick handler for selecting files
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.selectFiles = function(oQueue)
|
||||
{
|
||||
this.applyConfig(oQueue);
|
||||
if (oQueue.getConfig().file_queue_limit > 0 && oQueue.getConfig().file_queue_limit <= oQueue.queued) return;
|
||||
xajax.ext.SWFupload.getInstance().selectFiles();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.getInstance
|
||||
arguments:
|
||||
|
||||
Return the SWFupload instace. If there's no instance available it creates a new one with default settings.
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.getInstance = function()
|
||||
{
|
||||
if (null == this.swf) this.swf = new SWFUpload(this.settings);
|
||||
|
||||
return this.swf;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.removeFile
|
||||
arguments: QueueId [integer] , FileId [integer]
|
||||
|
||||
Removes the file (FileID) from queue (QueueId)
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.removeFile = function(QueueId,FileId,finished)
|
||||
{
|
||||
this.queues[QueueId].removeFile(FileId,finished);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.SWFupload.request = {};
|
||||
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request.getFileFromQueue
|
||||
arguments: oRequest [object]
|
||||
|
||||
Returns the first file from first available queue.
|
||||
Returns false if no files were selected
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.getFileFromQueue = function(oRequest)
|
||||
{
|
||||
|
||||
var instances = {};
|
||||
var queued = 0;
|
||||
if ("string" == typeof oRequest.SWFform)
|
||||
{
|
||||
if ('object' != typeof xajax.ext.SWFupload.forms[oRequest.SWFform])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (a in xajax.ext.SWFupload.forms[oRequest.SWFform])
|
||||
{
|
||||
var field = xajax.ext.SWFupload.forms[oRequest.SWFform][a];
|
||||
if (0 < xajax.ext.SWFupload.queues[field].queued) { oRequest.currentFile = xajax.ext.SWFupload.queues[field].getFile();return true };
|
||||
}
|
||||
} else if ("string" == typeof oRequest.SWFfield)
|
||||
{
|
||||
if ('string' != typeof xajax.ext.SWFupload.fields[oRequest.SWFfield])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var qId = xajax.ext.SWFupload.fields[oRequest.SWFfield];
|
||||
if (0 < xajax.ext.SWFupload.queues[qId].queued) { oRequest.currentFile = xajax.ext.SWFupload.queues[qId].getFile();return true };
|
||||
} else
|
||||
{
|
||||
for (a in xajax.ext.SWFupload.queues)
|
||||
{
|
||||
if (0 < xajax.ext.SWFupload.queues[a].queued) { oRequest.currentFile = xajax.ext.SWFupload.queues[a].getFile();return true };
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.processParameters = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
Processes the parameters
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.processParameters = function(oRequest)
|
||||
{
|
||||
if ("SWFupload" == oRequest.mode)
|
||||
{
|
||||
oRequest.currentFile = false;
|
||||
xajax.ext.SWFupload.request.getFileFromQueue(oRequest);
|
||||
if (oRequest.currentFile) oRequest.method='GET';
|
||||
}
|
||||
return xajax.ext.SWFupload.bak.processParameters(oRequest);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.prepareRequest = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
doesn't to anything at all when a file for upload is selected
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.prepareRequest = function (oRequest)
|
||||
{
|
||||
if ("SWFupload" == oRequest.mode && false != oRequest.currentFile) return;
|
||||
return xajax.ext.SWFupload.bak.prepareRequest(oRequest);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.request. xajax.ext.SWFupload.request.submitRequest = function(oRequest)
|
||||
|
||||
arguments: oRequest [object]
|
||||
|
||||
Submits the request either via SWFupload or XHR
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.request.submitRequest = function(oRequest)
|
||||
{
|
||||
if ( "SWFupload" == oRequest.mode && false != oRequest.currentFile )
|
||||
{
|
||||
|
||||
var swf = xajax.ext.SWFupload.getInstance();
|
||||
|
||||
var fileQueue = xajax.ext.SWFupload.queues[oRequest.currentFile.QueueId];
|
||||
xajax.ext.SWFupload.applyConfig(fileQueue);
|
||||
|
||||
swf.customSettings.currentFile = oRequest.currentFile;
|
||||
swf.setFilePostName(swf.customSettings.currentFile.name);
|
||||
|
||||
swf.customSettings.oRequest = oRequest;
|
||||
swf.setUploadURL(oRequest.requestURI);
|
||||
|
||||
swf.settings.upload_success_handler = function ( oFile, response )
|
||||
{
|
||||
var FileId = swf.customSettings.currentFile;
|
||||
if ( 'function' == typeof this.old_upload_success_handler ) this.old_upload_success_handler( oFile );
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xcb = xx.callback;
|
||||
var gcb = xcb.global;
|
||||
var lcb = oRequest.callback;
|
||||
var oRet = oRequest.returnValue;
|
||||
if (response) {
|
||||
var cmd = (new DOMParser()).parseFromString(response, "text/xml");
|
||||
var seq=0;
|
||||
var child = cmd.documentElement.firstChild;
|
||||
xt.xml.processFragment(child, seq,oRequest);
|
||||
|
||||
if (null == xx.response.timeout)
|
||||
xt.queue.process(xx.response);
|
||||
}
|
||||
}
|
||||
|
||||
swf.settings.upload_complete_handler = function(oFile)
|
||||
{
|
||||
//if ('function' == typeof this.old_upload_complete_handler) this.old_upload_complete_handler(oFile);
|
||||
|
||||
var qFile = this.customSettings.currentFile;
|
||||
xajax.ext.SWFupload.removeFile(qFile.QueueId,qFile.id,true);
|
||||
|
||||
if ( !xajax.ext.SWFupload.request.getFileFromQueue(oRequest) )
|
||||
{
|
||||
if ('function' == typeof oRequest.onUploadComplete) oRequest.onUploadComplete();
|
||||
return;
|
||||
}
|
||||
swf.customSettings.currentFile = oRequest.currentFile;
|
||||
swf.setFilePostName(oRequest.currentFile.name);
|
||||
|
||||
this.startUpload(oRequest.currentFile.id);
|
||||
}
|
||||
|
||||
|
||||
swf.settings.upload_start_handler = function(oFile)
|
||||
{
|
||||
if ('function' == typeof this.old_upload_start_handler) this.old_upload_start_handler(oFile);
|
||||
oRequest.startTime = new Date();
|
||||
|
||||
}
|
||||
swf.settings.upload_progress_handler = function (oFile, bytesLoaded, bytesTotal)
|
||||
{
|
||||
|
||||
upload = {};
|
||||
upload.received=bytesLoaded;
|
||||
upload.total=bytesTotal;
|
||||
upload.state="uploading";
|
||||
var reqTime = new Date();
|
||||
|
||||
upload.lastbytes = oRequest.lastbytes;
|
||||
upload.now = reqTime.getTime() / 1000;
|
||||
upload.start = oRequest.startTime.getTime()/ 1000;
|
||||
|
||||
var step = upload.received / (upload.total / 100);
|
||||
var progressbar = xajax.$('SWFup_progress_'+oFile.id);
|
||||
var w = Math.round(220 * step / 100);
|
||||
progressbar.style.width=w+'px';
|
||||
|
||||
var progress = xajax.$("swf_queued_filesize_"+oFile.id);
|
||||
var elapsed = upload.now-upload.start;
|
||||
var rate = xajax.ext.SWFupload.tools.formatBytes(upload.received/ elapsed).toString() + '/s';
|
||||
progress.innerHTML = "<i>"+rate + "</i> "+xajax.ext.SWFupload.tools.formatBytes(upload.received)+"/"+xajax.ext.SWFupload.tools.formatBytes(upload.total);
|
||||
oRequest.lastbytes = upload.received;
|
||||
|
||||
}
|
||||
|
||||
swf.settings.upload_error_handler = function(file, errorCode, message)
|
||||
{
|
||||
alert("Error Code: "+errorCode+", File name: " + file.name + ", Message: " + message);
|
||||
};
|
||||
swf.startUpload(swf.customSettings.currentFile.id);
|
||||
return;
|
||||
}
|
||||
return xajax.ext.SWFupload.bak.submitRequest(oRequest);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.queueFile
|
||||
arguments: oFile,QueueId,QueueContainer
|
||||
|
||||
*/
|
||||
xajax.ext.SWFupload.tools.queueFile = function(oFile,name,QueueId,QueueContainer) {
|
||||
|
||||
this.id = oFile.id;
|
||||
this.name = name;
|
||||
this.QueueId = QueueId;
|
||||
|
||||
var container = document.createElement('div');
|
||||
container.id = "SWFup_"+this.id;
|
||||
container.className="swf_queued_file";
|
||||
|
||||
this.elm = container;
|
||||
|
||||
var remove = document.createElement('div');
|
||||
remove.className="swf_queued_file_remove";
|
||||
remove.innerHTML=" ";
|
||||
|
||||
var id = this.id;
|
||||
var QueueId = this.QueueId;
|
||||
remove.onclick= function () {
|
||||
xajax.ext.SWFupload.getInstance().cancelUpload(id);
|
||||
xajax.ext.SWFupload.removeFile(QueueId,id);
|
||||
}
|
||||
container.appendChild(remove);
|
||||
|
||||
var label = document.createElement('div');
|
||||
label.className="swf_queued_filename";
|
||||
label.innerHTML = oFile.name;
|
||||
container.appendChild(label);
|
||||
|
||||
var progress_container = document.createElement('div');
|
||||
progress_container.className="swf_queued_file_progress_container";
|
||||
container.appendChild(progress_container);
|
||||
|
||||
|
||||
var progress = document.createElement('div');
|
||||
progress.className="swf_queued_file_progress_bar";
|
||||
progress.style.width='1px';
|
||||
progress.id='SWFup_progress_'+oFile.id;
|
||||
progress_container.appendChild(progress);
|
||||
|
||||
|
||||
var fSize = document.createElement('div');
|
||||
fSize.className="swf_queued_filesize";
|
||||
fSize.id="swf_queued_filesize_"+this.id;
|
||||
fSize.innerHTML = xajax.ext.SWFupload.tools.formatBytes(oFile.size);
|
||||
container.appendChild(fSize);
|
||||
|
||||
var fClear= document.createElement('div');
|
||||
fClear.style.clear='both';
|
||||
container.appendChild(fClear);
|
||||
QueueContainer.appendChild(container);
|
||||
|
||||
this.container = container;
|
||||
this.oFile = oFile;
|
||||
|
||||
this.destroy = function()
|
||||
{
|
||||
QueueContainer.removeChild(container);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.fileQueue
|
||||
arguments: id [integer],child [object], parent [object], multiple [bool]
|
||||
|
||||
parses the form for fields
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.fileQueue = function (id,child,parent,config,multiple)
|
||||
{
|
||||
|
||||
var swf = xajax.ext.SWFupload.getInstance();
|
||||
|
||||
this.id = id;
|
||||
var config = 'object' == typeof config ? xajax.ext.SWFupload.tools.mergeObj(xajax.ext.SWFupload.settings,config) : xajax.ext.SWFupload.settings;
|
||||
this.queued = 0;
|
||||
this.files = {};
|
||||
this.queue = null;
|
||||
|
||||
this.getConfig = function() {return config;}
|
||||
|
||||
|
||||
xajax.forms.insertInput({
|
||||
id:child,
|
||||
type:"button",
|
||||
prop:"SWFup_Btn_"+this.id,
|
||||
data:"SWFup_Btn_"+this.id
|
||||
});
|
||||
parent.removeChild(child);
|
||||
var BtnSelect = xajax.$("SWFup_Btn_"+this.id);
|
||||
BtnSelect.name = this.id;
|
||||
|
||||
var oQueue = this;
|
||||
if (true === multiple)
|
||||
{
|
||||
BtnSelect.value = xajax.ext.SWFupload.lang.browseFiles;
|
||||
BtnSelect.onclick = function ()
|
||||
{
|
||||
xajax.ext.SWFupload.selectFiles(oQueue);
|
||||
}
|
||||
} else {
|
||||
BtnSelect.value = xajax.ext.SWFupload.lang.browseFile;
|
||||
BtnSelect.onclick = function ()
|
||||
{
|
||||
xajax.ext.SWFupload.selectFile(oQueue);
|
||||
}
|
||||
}
|
||||
|
||||
var QueueContainer = document.createElement('div');
|
||||
QueueContainer.id = 'SWFqueue_'+ this.id;
|
||||
parent.appendChild(QueueContainer);
|
||||
|
||||
var fieldname = child.name;
|
||||
this.addFile = function (oFile)
|
||||
{
|
||||
this.files[oFile.id] = new xajax.ext.SWFupload.tools.queueFile(oFile,fieldname,this.id,QueueContainer);
|
||||
this.queued++;
|
||||
if (this.queued == config.file_queue_limit) BtnSelect.disabled=true;
|
||||
}
|
||||
|
||||
this.getFile = function (FileId)
|
||||
{
|
||||
if ("undefined" != typeof FileId) return this.files[FileId];
|
||||
for (a in this.files) return this.files[a];
|
||||
return false;
|
||||
}
|
||||
|
||||
this.removeFile = function(FileId,finished)
|
||||
{
|
||||
this.queued--;
|
||||
if (this.queued <= config.file_queue_limit) BtnSelect.disabled=false;
|
||||
var filediv = xajax.$("SWFup_"+this.files[FileId].id);
|
||||
filediv.className = true === finished ? 'swf_queued_file_finished' : 'swf_queued_file_removed';
|
||||
setTimeout(function ()
|
||||
{
|
||||
xajax.ext.SWFupload.tools.FadeOut(filediv,100);
|
||||
}, xajax.ext.SWFupload.config.FadeTimeOut);
|
||||
|
||||
this.files[FileId] = null;
|
||||
delete this.files[FileId];
|
||||
}
|
||||
this.destroy = function() {
|
||||
for (a in this.files) {
|
||||
this.files[a].destroy();
|
||||
delete (this.files[a]);
|
||||
}
|
||||
this.queued=0;
|
||||
}
|
||||
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools._parseFields
|
||||
arguments: children [array],parent [object], config [object], multiple [bool]
|
||||
|
||||
parses the form for fields
|
||||
*/
|
||||
|
||||
|
||||
xajax.ext.SWFupload.tools._parseFields = function(children,parent,config,multiple)
|
||||
{
|
||||
var result={};
|
||||
var iLen = children.length;
|
||||
for (var i = 0; i < iLen; ++i)
|
||||
{
|
||||
var child = children[i];
|
||||
if ('undefined' != typeof child.childNodes)
|
||||
var res2 = xajax.ext.SWFupload.tools._parseFields(child.childNodes,child,config,multiple);
|
||||
result = xajax.ext.SWFupload.tools.mergeObj(result,res2);
|
||||
if (child.name)
|
||||
{
|
||||
if ('file' == child.type)
|
||||
{
|
||||
result[child.name] = xajax.ext.SWFupload.addQueue(child,parent,config,multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.transForm
|
||||
arguments: form_id [integer] ,config [object] ,multiple [bool]
|
||||
|
||||
transforms the all fields of the given form into fileQueue instances
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.transForm = function(form_id,config,multiple)
|
||||
{
|
||||
var oForm = xajax.$(form_id);
|
||||
if (oForm)
|
||||
if (oForm.childNodes) {
|
||||
var fields = xajax.ext.SWFupload.tools._parseFields(oForm.childNodes,oForm,config,multiple);
|
||||
xajax.ext.SWFupload.forms[form_id] = fields;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.transField
|
||||
arguments: field_id [integer] ,config [object] ,multiple [bool]
|
||||
|
||||
transforms the given field into a fileQueue instance
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.transField = function(field_id,config,multiple)
|
||||
{
|
||||
try {
|
||||
var oField = xajax.$(field_id);
|
||||
if ('undefined' != typeof oField) return xajax.ext.SWFupload.fields[field_id] = xajax.ext.SWFupload.addQueue(oField,oField.parentNode,config,multiple);
|
||||
|
||||
}catch(ex) {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.destroyForm
|
||||
arguments: form_id [integer]
|
||||
|
||||
destroys the given form
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.destroyForm = function(form_id)
|
||||
{
|
||||
if ("undefined" == typeof xajax.ext.SWFupload.forms[form_id]) return;
|
||||
for (a in xajax.ext.SWFupload.forms[form_id])
|
||||
{
|
||||
var key = xajax.ext.SWFupload.forms[form_id][a];
|
||||
xajax.ext.SWFupload.queues[key].destroy();
|
||||
delete xajax.ext.SWFupload.queues[key];
|
||||
delete xajax.ext.SWFupload.forms[form_id];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.destroyField
|
||||
arguments: field_id [integer]
|
||||
|
||||
destroys the given field
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.destroyField = function(field_id)
|
||||
{
|
||||
if ("undefined" == typeof xajax.ext.SWFupload.fields[field_id]) return;
|
||||
|
||||
var key = xajax.ext.SWFupload.fields[field_id];
|
||||
xajax.ext.SWFupload.queues[key].destroy();
|
||||
delete(xajax.ext.SWFupload.queues[key]);
|
||||
delete xajax.ext.SWFupload.fields[field_id];
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.FadeOut
|
||||
arguments: elm [object], opacity [integer]
|
||||
|
||||
fades a div
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.FadeOut = function(elm,opacity)
|
||||
{
|
||||
var reduceOpacityBy = 15;
|
||||
var rate = 40;
|
||||
if (opacity > 0)
|
||||
{
|
||||
opacity -= reduceOpacityBy;
|
||||
if (opacity < 0)
|
||||
{
|
||||
opacity = 0;
|
||||
}
|
||||
|
||||
if (elm.filters)
|
||||
{
|
||||
try
|
||||
{
|
||||
elm.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
elm.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
|
||||
}
|
||||
} else {
|
||||
elm.style.opacity = opacity / 100;
|
||||
}
|
||||
}
|
||||
|
||||
if ( opacity > 0)
|
||||
{
|
||||
var oSelf = this;
|
||||
setTimeout(function ()
|
||||
{
|
||||
xajax.ext.SWFupload.tools.FadeOut(elm,opacity);
|
||||
}, rate);
|
||||
} else {
|
||||
var parent = elm.parentNode;
|
||||
parent.removeChild(elm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.formatBytes
|
||||
arguments: bytes [integer]
|
||||
|
||||
returns string with formatted size (kB / MB)
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.formatBytes = function(bytes)
|
||||
{
|
||||
|
||||
var ret = {};
|
||||
if (bytes / 1204 < 1024)
|
||||
{
|
||||
return (Math.round(bytes / 1024 * 100)/100).toString()+ " kB";
|
||||
} else {
|
||||
return (Math.round(bytes / 1024 / 1024 * 100)/100).toString()+ " MB";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.mergeObj
|
||||
arguments: n objects
|
||||
|
||||
Merges all objects and returns a single object.
|
||||
Newrt keys override existing keys.
|
||||
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.mergeObj = function()
|
||||
{
|
||||
if ('object' != typeof arguments) return;
|
||||
|
||||
var res = {};
|
||||
var len = arguments.length;
|
||||
for (var i=0;i<len;i++)
|
||||
{
|
||||
var obj = arguments[i];
|
||||
for (a in obj)
|
||||
{
|
||||
res[a] = obj[a];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.ext.SWFupload.tools.getId
|
||||
arguments:
|
||||
|
||||
returns a 'unique' (rand) id
|
||||
*/
|
||||
|
||||
xajax.ext.SWFupload.tools.getId = function()
|
||||
{
|
||||
var pid_str = "";
|
||||
for (i=0;i<=3;i++) {
|
||||
var pid = 0;
|
||||
pid = Math.random();
|
||||
while( Math.ceil(pid).toString().length<8)
|
||||
{
|
||||
pid *= 10;
|
||||
}
|
||||
pid = Math.ceil(pid).toString();
|
||||
pid_str = pid_str+pid.toString();
|
||||
}
|
||||
return pid_str;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_dfi')
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.destroyField
|
||||
*/
|
||||
xajax.command.handler.register('SWFup_dfi', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.destroyField';
|
||||
xajax.ext.SWFupload.tools.destroyField(args.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_dfo')
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.destroyForm
|
||||
*/
|
||||
|
||||
xajax.command.handler.register('SWFup_dfo', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.destroyForm';
|
||||
xajax.ext.SWFupload.tools.destroyForm(args.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_tfi'I
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.transField
|
||||
*/
|
||||
|
||||
xajax.command.handler.register('SWFup_tfi', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.SWFupload.tools.transField';
|
||||
|
||||
// if ("string" == typeof args.data.config.upload_complete_handler) {
|
||||
// try {
|
||||
// eval("var foo = "+args.data.config.upload_complete_handler);
|
||||
// args.data.config.upload_complete_handler = foo;
|
||||
// } catch(ex) {delete(args.data.config.upload_complete_handler);}
|
||||
// }
|
||||
|
||||
if ("string" == typeof args.data.config.upload_success_handler) {
|
||||
try {
|
||||
eval("var foo = "+args.data.config.upload_success_handler);
|
||||
args.data.config.upload_success_handler = foo;
|
||||
} catch(ex) {delete(args.data.config.upload_success_handler);}
|
||||
}
|
||||
|
||||
xajax.ext.SWFupload.tools.transField(args.id, args.data.config,args.data.multi);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
/*
|
||||
function: xajax.command.handler.register('SWFup_tfo']
|
||||
arguments: object
|
||||
|
||||
xajax response command for ext.SWFupload.tools.transForm
|
||||
*/
|
||||
xajax.command.handler.register('SWFup_tfo',function(args)
|
||||
{
|
||||
try {
|
||||
args.cmdFullName = 'ext.SWFupload.tools.transForm';
|
||||
// if ("string" == typeof args.data.config.upload_complete_handler)
|
||||
// {
|
||||
// try {
|
||||
// eval("var foo = "+args.data.config.upload_complete_handler);
|
||||
// args.data.config.upload_complete_handler = foo;
|
||||
// } catch(ex) {delete(args.data.config.upload_complete_handler);}
|
||||
// }
|
||||
|
||||
if ("string" == typeof args.data.config.upload_success_handler)
|
||||
{
|
||||
try
|
||||
{
|
||||
eval("var foo = "+args.data.config.upload_success_handler);
|
||||
args.data.config.upload_success_handler = foo;
|
||||
} catch(ex)
|
||||
{
|
||||
delete(args.data.config.upload_success_handler);
|
||||
}
|
||||
}
|
||||
xajax.ext.SWFupload.tools.transForm(args.id, args.data.config,args.data.multi);
|
||||
|
||||
} catch(ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
});
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
xajax.ext.SWFupload.bak = {};
|
||||
xajax.ext.SWFupload.bak.prepareRequest = xajax.prepareRequest;
|
||||
xajax.ext.SWFupload.bak.submitRequest = xajax.submitRequest;
|
||||
xajax.ext.SWFupload.bak.responseProcessor = xajax.responseProcessor;
|
||||
xajax.ext.SWFupload.bak.processParameters = xajax.processParameters;
|
||||
|
||||
xajax.prepareRequest = xajax.ext.SWFupload.request.prepareRequest;
|
||||
xajax.submitRequest = xajax.ext.SWFupload.request.submitRequest;
|
||||
xajax.processParameters = xajax.ext.SWFupload.request.processParameters;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
Function: DOMParser
|
||||
|
||||
Prototype DomParser for IE/Opera
|
||||
|
||||
*/
|
||||
if (typeof DOMParser == "undefined") {
|
||||
DOMParser = function () {}
|
||||
|
||||
DOMParser.prototype.parseFromString = function (str, contentType) {
|
||||
if (typeof ActiveXObject != "undefined") {
|
||||
var d = new ActiveXObject("Microsoft.XMLDOM");
|
||||
d.loadXML(str);
|
||||
return d;
|
||||
} else if (typeof XMLHttpRequest != "undefined") {
|
||||
var req = new XMLHttpRequest;
|
||||
req.open("GET", "data:" + (contentType || "application/xml") +
|
||||
";charset=utf-8," + encodeURIComponent(str), false);
|
||||
if (req.overrideMimeType) {
|
||||
req.overrideMimeType(contentType);
|
||||
}
|
||||
req.send(null);
|
||||
return req.responseXML;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
libraries/xajax/xajax_plugins/request/swfupload/swfupload_f9.swf
Normal file
BIN
libraries/xajax/xajax_plugins/request/swfupload/swfupload_f9.swf
Normal file
Binary file not shown.
@@ -0,0 +1,725 @@
|
||||
/**
|
||||
* SWFUpload v2.1.0 by Jacob Roberts, Feb 2008, http://www.swfupload.org, http://swfupload.googlecode.com, http://www.swfupload.org
|
||||
* -------- -------- -------- -------- -------- -------- -------- --------
|
||||
* SWFUpload is (c) 2006 Lars Huring, Olov Nilz<6C>n and Mammon Media and is released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* See Changelog.txt for version history
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* *********** */
|
||||
/* Constructor */
|
||||
/* *********** */
|
||||
|
||||
var SWFUpload = function (settings) {
|
||||
this.initSWFUpload(settings);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.initSWFUpload = function (settings) {
|
||||
try {
|
||||
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
|
||||
this.settings = settings;
|
||||
this.eventQueue = [];
|
||||
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
|
||||
this.movieElement = null;
|
||||
|
||||
// Setup global control tracking
|
||||
SWFUpload.instances[this.movieName] = this;
|
||||
|
||||
// Load the settings. Load the Flash movie.
|
||||
this.initSettings();
|
||||
this.loadFlash();
|
||||
this.displayDebugInfo();
|
||||
} catch (ex) {
|
||||
delete SWFUpload.instances[this.movieName];
|
||||
throw ex;
|
||||
}
|
||||
};
|
||||
|
||||
/* *************** */
|
||||
/* Static Members */
|
||||
/* *************** */
|
||||
SWFUpload.instances = {};
|
||||
SWFUpload.movieCount = 0;
|
||||
SWFUpload.version = "2.1.0 beta 1";
|
||||
SWFUpload.QUEUE_ERROR = {
|
||||
QUEUE_LIMIT_EXCEEDED : -100,
|
||||
FILE_EXCEEDS_SIZE_LIMIT : -110,
|
||||
ZERO_BYTE_FILE : -120,
|
||||
INVALID_FILETYPE : -130
|
||||
};
|
||||
SWFUpload.UPLOAD_ERROR = {
|
||||
HTTP_ERROR : -200,
|
||||
MISSING_UPLOAD_URL : -210,
|
||||
IO_ERROR : -220,
|
||||
SECURITY_ERROR : -230,
|
||||
UPLOAD_LIMIT_EXCEEDED : -240,
|
||||
UPLOAD_FAILED : -250,
|
||||
SPECIFIED_FILE_ID_NOT_FOUND : -260,
|
||||
FILE_VALIDATION_FAILED : -270,
|
||||
FILE_CANCELLED : -280,
|
||||
UPLOAD_STOPPED : -290
|
||||
};
|
||||
SWFUpload.FILE_STATUS = {
|
||||
QUEUED : -1,
|
||||
IN_PROGRESS : -2,
|
||||
ERROR : -3,
|
||||
COMPLETE : -4,
|
||||
CANCELLED : -5
|
||||
};
|
||||
|
||||
|
||||
/* ******************** */
|
||||
/* Instance Members */
|
||||
/* ******************** */
|
||||
|
||||
// Private: initSettings ensures that all the
|
||||
// settings are set, getting a default value if one was not assigned.
|
||||
SWFUpload.prototype.initSettings = function () {
|
||||
this.ensureDefault = function (settingName, defaultValue) {
|
||||
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
||||
};
|
||||
|
||||
// Upload backend settings
|
||||
this.ensureDefault("upload_url", "");
|
||||
this.ensureDefault("file_post_name", "Filedata");
|
||||
this.ensureDefault("post_params", {});
|
||||
this.ensureDefault("use_query_string", false);
|
||||
this.ensureDefault("requeue_on_error", false);
|
||||
|
||||
// File Settings
|
||||
this.ensureDefault("file_types", "*.*");
|
||||
this.ensureDefault("file_types_description", "All Files");
|
||||
this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
|
||||
this.ensureDefault("file_upload_limit", 0);
|
||||
this.ensureDefault("file_queue_limit", 0);
|
||||
|
||||
// Flash Settings
|
||||
this.ensureDefault("flash_url", "swfupload_f9.swf");
|
||||
this.ensureDefault("flash_color", "#FFFFFF");
|
||||
|
||||
// Debug Settings
|
||||
this.ensureDefault("debug", false);
|
||||
this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
|
||||
|
||||
// Event Handlers
|
||||
this.settings.return_upload_start_handler = this.returnUploadStart;
|
||||
this.ensureDefault("swfupload_loaded_handler", null);
|
||||
this.ensureDefault("file_dialog_start_handler", null);
|
||||
this.ensureDefault("file_queued_handler", null);
|
||||
this.ensureDefault("file_queue_error_handler", null);
|
||||
this.ensureDefault("file_dialog_complete_handler", null);
|
||||
|
||||
this.ensureDefault("upload_start_handler", null);
|
||||
this.ensureDefault("upload_progress_handler", null);
|
||||
this.ensureDefault("upload_error_handler", null);
|
||||
this.ensureDefault("upload_success_handler", null);
|
||||
this.ensureDefault("upload_complete_handler", null);
|
||||
|
||||
this.ensureDefault("debug_handler", this.debugMessage);
|
||||
|
||||
this.ensureDefault("custom_settings", {});
|
||||
|
||||
// Other settings
|
||||
this.customSettings = this.settings.custom_settings;
|
||||
|
||||
delete this.ensureDefault;
|
||||
};
|
||||
|
||||
// Private: loadFlash generates the HTML tag for the Flash
|
||||
// It then adds the flash to the body
|
||||
SWFUpload.prototype.loadFlash = function () {
|
||||
var targetElement, container;
|
||||
|
||||
// Make sure an element with the ID we are going to use doesn't already exist
|
||||
if (document.getElementById(this.movieName) !== null) {
|
||||
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
|
||||
}
|
||||
|
||||
// Get the body tag where we will be adding the flash movie
|
||||
targetElement = document.getElementsByTagName("body")[0];
|
||||
|
||||
if (targetElement == undefined) {
|
||||
throw "Could not find the 'body' element.";
|
||||
}
|
||||
|
||||
// Append the container and load the flash
|
||||
container = document.createElement("div");
|
||||
container.style.width = "1px";
|
||||
container.style.height = "1px";
|
||||
|
||||
targetElement.appendChild(container);
|
||||
container.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
|
||||
};
|
||||
|
||||
// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
|
||||
SWFUpload.prototype.getFlashHTML = function () {
|
||||
// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
|
||||
return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="1" height="1" style="-moz-user-focus: ignore;">',
|
||||
'<param name="movie" value="', this.settings.flash_url, '" />',
|
||||
'<param name="bgcolor" value="', this.settings.flash_color, '" />',
|
||||
'<param name="quality" value="high" />',
|
||||
'<param name="menu" value="false" />',
|
||||
'<param name="allowScriptAccess" value="always" />',
|
||||
'<param name="flashvars" value="' + this.getFlashVars() + '" />',
|
||||
'</object>'].join("");
|
||||
};
|
||||
|
||||
// Private: getFlashVars builds the parameter string that will be passed
|
||||
// to flash in the flashvars param.
|
||||
SWFUpload.prototype.getFlashVars = function () {
|
||||
// Build a string from the post param object
|
||||
var paramString = this.buildParamString();
|
||||
|
||||
// Build the parameter string
|
||||
return ["movieName=", encodeURIComponent(this.movieName),
|
||||
"&uploadURL=", encodeURIComponent(this.settings.upload_url),
|
||||
"&useQueryString=", encodeURIComponent(this.settings.use_query_string),
|
||||
"&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
|
||||
"&params=", encodeURIComponent(paramString),
|
||||
"&filePostName=", encodeURIComponent(this.settings.file_post_name),
|
||||
"&fileTypes=", encodeURIComponent(this.settings.file_types),
|
||||
"&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
|
||||
"&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
|
||||
"&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
|
||||
"&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
|
||||
"&debugEnabled=", encodeURIComponent(this.settings.debug_enabled)].join("");
|
||||
};
|
||||
|
||||
// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
|
||||
// The element is cached after the first lookup
|
||||
SWFUpload.prototype.getMovieElement = function () {
|
||||
if (this.movieElement == undefined) {
|
||||
this.movieElement = document.getElementById(this.movieName);
|
||||
}
|
||||
|
||||
if (this.movieElement === null) {
|
||||
throw "Could not find Flash element";
|
||||
}
|
||||
|
||||
return this.movieElement;
|
||||
};
|
||||
|
||||
// Private: buildParamString takes the name/value pairs in the post_params setting object
|
||||
// and joins them up in to a string formatted "name=value&name=value"
|
||||
SWFUpload.prototype.buildParamString = function () {
|
||||
var postParams = this.settings.post_params;
|
||||
var paramStringPairs = [];
|
||||
|
||||
if (typeof(postParams) === "object") {
|
||||
for (var name in postParams) {
|
||||
if (postParams.hasOwnProperty(name)) {
|
||||
paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paramStringPairs.join("&");
|
||||
};
|
||||
|
||||
// Public: displayDebugInfo prints out settings and configuration
|
||||
// information about this SWFUpload instance.
|
||||
// This function (and any references to it) can be deleted when placing
|
||||
// SWFUpload in production.
|
||||
SWFUpload.prototype.displayDebugInfo = function () {
|
||||
this.debug(
|
||||
[
|
||||
"---SWFUpload Instance Info---\n",
|
||||
"Version: ", SWFUpload.version, "\n",
|
||||
"Movie Name: ", this.movieName, "\n",
|
||||
"Settings:\n",
|
||||
"\t", "upload_url: ", this.settings.upload_url, "\n",
|
||||
"\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
|
||||
"\t", "file_post_name: ", this.settings.file_post_name, "\n",
|
||||
"\t", "post_params: ", this.settings.post_params.toString(), "\n",
|
||||
"\t", "file_types: ", this.settings.file_types, "\n",
|
||||
"\t", "file_types_description: ", this.settings.file_types_description, "\n",
|
||||
"\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
|
||||
"\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
|
||||
"\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
|
||||
"\t", "flash_url: ", this.settings.flash_url, "\n",
|
||||
"\t", "flash_color: ", this.settings.flash_color, "\n",
|
||||
"\t", "debug: ", this.settings.debug.toString(), "\n",
|
||||
"\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
|
||||
"Event Handlers:\n",
|
||||
"\t", "swfupload_loaded_handler assigned: ", (typeof(this.settings.swfupload_loaded_handler) === "function").toString(), "\n",
|
||||
"\t", "file_dialog_start_handler assigned: ", (typeof(this.settings.file_dialog_start_handler) === "function").toString(), "\n",
|
||||
"\t", "file_queued_handler assigned: ", (typeof(this.settings.file_queued_handler) === "function").toString(), "\n",
|
||||
"\t", "file_queue_error_handler assigned: ", (typeof(this.settings.file_queue_error_handler) === "function").toString(), "\n",
|
||||
"\t", "upload_start_handler assigned: ", (typeof(this.settings.upload_start_handler) === "function").toString(), "\n",
|
||||
"\t", "upload_progress_handler assigned: ", (typeof(this.settings.upload_progress_handler) === "function").toString(), "\n",
|
||||
"\t", "upload_error_handler assigned: ", (typeof(this.settings.upload_error_handler) === "function").toString(), "\n",
|
||||
"\t", "upload_success_handler assigned: ", (typeof(this.settings.upload_success_handler) === "function").toString(), "\n",
|
||||
"\t", "upload_complete_handler assigned: ", (typeof(this.settings.upload_complete_handler) === "function").toString(), "\n",
|
||||
"\t", "debug_handler assigned: ", (typeof(this.settings.debug_handler) === "function").toString(), "\n"
|
||||
].join("")
|
||||
);
|
||||
};
|
||||
|
||||
/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
|
||||
the maintain v2 API compatibility
|
||||
*/
|
||||
// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
|
||||
SWFUpload.prototype.addSetting = function (name, value, default_value) {
|
||||
if (value == undefined) {
|
||||
return (this.settings[name] = default_value);
|
||||
} else {
|
||||
return (this.settings[name] = value);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
|
||||
SWFUpload.prototype.getSetting = function (name) {
|
||||
if (this.settings[name] != undefined) {
|
||||
return this.settings[name];
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Private: callFlash handles function calls made to the Flash element.
|
||||
// Calls are made with a setTimeout for some functions to work around
|
||||
// bugs in the ExternalInterface library.
|
||||
|
||||
// NOTE: if we don't need to call StartUpload with a timeout anymore then we can simplify this
|
||||
// function and remove all the withTimeout stuff
|
||||
SWFUpload.prototype.callFlash = function (functionName, withTimeout, argumentArray) {
|
||||
withTimeout = !!withTimeout || false;
|
||||
argumentArray = argumentArray || [];
|
||||
|
||||
var self = this;
|
||||
var callFunction = function () {
|
||||
var movieElement = self.getMovieElement();
|
||||
var returnValue;
|
||||
if (typeof(movieElement[functionName]) === "function") {
|
||||
// We have to go through all this if/else stuff because the Flash functions don't have apply() and only accept the exact number of arguments.
|
||||
if (argumentArray.length === 0) {
|
||||
returnValue = movieElement[functionName]();
|
||||
} else if (argumentArray.length === 1) {
|
||||
returnValue = movieElement[functionName](argumentArray[0]);
|
||||
} else if (argumentArray.length === 2) {
|
||||
returnValue = movieElement[functionName](argumentArray[0], argumentArray[1]);
|
||||
} else if (argumentArray.length === 3) {
|
||||
returnValue = movieElement[functionName](argumentArray[0], argumentArray[1], argumentArray[2]);
|
||||
} else {
|
||||
throw "Too many arguments";
|
||||
}
|
||||
|
||||
// Unescape file post param values
|
||||
if (returnValue != undefined && typeof(returnValue.post) === "object") {
|
||||
returnValue = self.unescapeFilePostParams(returnValue);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
} else {
|
||||
throw "Invalid function name";
|
||||
}
|
||||
};
|
||||
|
||||
if (withTimeout) {
|
||||
setTimeout(callFunction, 0);
|
||||
} else {
|
||||
return callFunction();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* *****************************
|
||||
-- Flash control methods --
|
||||
Your UI should use these
|
||||
to operate SWFUpload
|
||||
***************************** */
|
||||
|
||||
// Public: selectFile causes a File Selection Dialog window to appear. This
|
||||
// dialog only allows 1 file to be selected.
|
||||
SWFUpload.prototype.selectFile = function () {
|
||||
this.callFlash("SelectFile");
|
||||
};
|
||||
|
||||
// Public: selectFiles causes a File Selection Dialog window to appear/ This
|
||||
// dialog allows the user to select any number of files
|
||||
// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
|
||||
// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
|
||||
// for this bug.
|
||||
SWFUpload.prototype.selectFiles = function () {
|
||||
this.callFlash("SelectFiles");
|
||||
};
|
||||
|
||||
|
||||
// Public: startUpload starts uploading the first file in the queue unless
|
||||
// the optional parameter 'fileID' specifies the ID
|
||||
SWFUpload.prototype.startUpload = function (fileID) {
|
||||
// NOTE: Testing this without using a setTimeout. Since StartUpload was reworked to use ReturnUploadStart
|
||||
// it might not be necessary anymore
|
||||
this.callFlash("StartUpload", false, [fileID]);
|
||||
};
|
||||
|
||||
/* Cancels a the file upload. You must specify a file_id */
|
||||
// Public: cancelUpload cancels any queued file. The fileID parameter
|
||||
// must be specified.
|
||||
SWFUpload.prototype.cancelUpload = function (fileID) {
|
||||
this.callFlash("CancelUpload", false, [fileID]);
|
||||
};
|
||||
|
||||
// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
|
||||
// If nothing is currently uploading then nothing happens.
|
||||
SWFUpload.prototype.stopUpload = function () {
|
||||
this.callFlash("StopUpload");
|
||||
};
|
||||
|
||||
/* ************************
|
||||
* Settings methods
|
||||
* These methods change the SWFUpload settings.
|
||||
* SWFUpload settings should not be changed directly on the settings object
|
||||
* since many of the settings need to be passed to Flash in order to take
|
||||
* effect.
|
||||
* *********************** */
|
||||
|
||||
// Public: getStats gets the file statistics object. It looks like this (where n is a number):
|
||||
SWFUpload.prototype.getStats = function () {
|
||||
return this.callFlash("GetStats");
|
||||
};
|
||||
|
||||
// Public: setStats changes the SWFUpload statistics. You shouldn't need to
|
||||
// change the statistics but you can. Changing the statistics does not
|
||||
// affect SWFUpload accept for the successful_uploads count which is used
|
||||
// by the upload_limit setting to determine how many files the user may upload.
|
||||
SWFUpload.prototype.setStats = function (statsObject) {
|
||||
this.callFlash("SetStats", false, [statsObject]);
|
||||
};
|
||||
|
||||
// Public: setCredentials that will be used to authenticate to the upload_url.
|
||||
// Note: This feature does not work. It has been added in anticipation of
|
||||
// the Flex 3 SDK which has not been released yet.
|
||||
SWFUpload.prototype.setCredentials = function (name, password) {
|
||||
this.callFlash("SetCrednetials", false, [name, password]);
|
||||
};
|
||||
|
||||
// Public: getFile retrieves a File object by ID or Index. If the file is
|
||||
// not found then 'null' is returned.
|
||||
SWFUpload.prototype.getFile = function (fileID) {
|
||||
if (typeof(fileID) === "number") {
|
||||
return this.callFlash("GetFileByIndex", false, [fileID]);
|
||||
} else {
|
||||
return this.callFlash("GetFile", false, [fileID]);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: addFileParam sets a name/value pair that will be posted with the
|
||||
// file specified by the Files ID. If the name already exists then the
|
||||
// exiting value will be overwritten.
|
||||
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
|
||||
return this.callFlash("AddFileParam", false, [fileID, name, value]);
|
||||
};
|
||||
|
||||
// Public: removeFileParam removes a previously set (by addFileParam) name/value
|
||||
// pair from the specified file.
|
||||
SWFUpload.prototype.removeFileParam = function (fileID, name) {
|
||||
this.callFlash("RemoveFileParam", false, [fileID, name]);
|
||||
};
|
||||
|
||||
// Public: setUploadUrl changes the upload_url setting.
|
||||
SWFUpload.prototype.setUploadURL = function (url) {
|
||||
this.settings.upload_url = url.toString();
|
||||
this.callFlash("SetUploadURL", false, [url]);
|
||||
};
|
||||
|
||||
// Public: setPostParams changes the post_params setting
|
||||
SWFUpload.prototype.setPostParams = function (paramsObject) {
|
||||
this.settings.post_params = paramsObject;
|
||||
this.callFlash("SetPostParams", false, [paramsObject]);
|
||||
};
|
||||
|
||||
// Public: addPostParam adds post name/value pair. Each name can have only one value.
|
||||
SWFUpload.prototype.addPostParam = function (name, value) {
|
||||
this.settings.post_params[name] = value;
|
||||
this.callFlash("SetPostParams", false, [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: removePostParam deletes post name/value pair.
|
||||
SWFUpload.prototype.removePostParam = function (name) {
|
||||
delete this.settings.post_params[name];
|
||||
this.callFlash("SetPostParams", false, [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: setFileTypes changes the file_types setting and the file_types_description setting
|
||||
SWFUpload.prototype.setFileTypes = function (types, description) {
|
||||
this.settings.file_types = types;
|
||||
this.settings.file_types_description = description;
|
||||
this.callFlash("SetFileTypes", false, [types, description]);
|
||||
};
|
||||
|
||||
// Public: setFileSizeLimit changes the file_size_limit setting
|
||||
SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
|
||||
this.settings.file_size_limit = fileSizeLimit;
|
||||
this.callFlash("SetFileSizeLimit", false, [fileSizeLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileUploadLimit changes the file_upload_limit setting
|
||||
SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
|
||||
this.settings.file_upload_limit = fileUploadLimit;
|
||||
this.callFlash("SetFileUploadLimit", false, [fileUploadLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileQueueLimit changes the file_queue_limit setting
|
||||
SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
|
||||
this.settings.file_queue_limit = fileQueueLimit;
|
||||
this.callFlash("SetFileQueueLimit", false, [fileQueueLimit]);
|
||||
};
|
||||
|
||||
// Public: setFilePostName changes the file_post_name setting
|
||||
SWFUpload.prototype.setFilePostName = function (filePostName) {
|
||||
this.settings.file_post_name = filePostName;
|
||||
this.callFlash("SetFilePostName", false, [filePostName]);
|
||||
};
|
||||
|
||||
// Public: setUseQueryString changes the use_query_string setting
|
||||
SWFUpload.prototype.setUseQueryString = function (useQueryString) {
|
||||
this.settings.use_query_string = useQueryString;
|
||||
this.callFlash("SetUseQueryString", false, [useQueryString]);
|
||||
};
|
||||
|
||||
// Public: setRequeueOnError changes the requeue_on_error setting
|
||||
SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
|
||||
this.settings.requeue_on_error = requeueOnError;
|
||||
this.callFlash("SetRequeueOnError", false, [requeueOnError]);
|
||||
};
|
||||
|
||||
// Public: setDebugEnabled changes the debug_enabled setting
|
||||
SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
|
||||
this.settings.debug_enabled = debugEnabled;
|
||||
this.callFlash("SetDebugEnabled", false, [debugEnabled]);
|
||||
};
|
||||
|
||||
|
||||
/* *******************************
|
||||
Flash Event Interfaces
|
||||
These functions are used by Flash to trigger the various
|
||||
events.
|
||||
|
||||
All these functions a Private.
|
||||
|
||||
Because the ExternalInterface library is buggy the event calls
|
||||
are added to a queue and the queue then executed by a setTimeout.
|
||||
This ensures that events are executed in a determinate order and that
|
||||
the ExternalInterface bugs are avoided.
|
||||
******************************* */
|
||||
|
||||
SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
if (argumentArray == undefined) {
|
||||
argumentArray = [];
|
||||
} else if (!(argumentArray instanceof Array)) {
|
||||
argumentArray = [argumentArray];
|
||||
}
|
||||
|
||||
var self = this;
|
||||
if (typeof(this.settings[handlerName]) === "function") {
|
||||
// Queue the event
|
||||
this.eventQueue.push(function () {
|
||||
this.settings[handlerName].apply(this, argumentArray);
|
||||
});
|
||||
|
||||
// Execute the next queued event
|
||||
setTimeout(function () {
|
||||
self.executeNextEvent();
|
||||
}, 0);
|
||||
|
||||
} else if (this.settings[handlerName] !== null) {
|
||||
throw "Event handler " + handlerName + " is unknown or is not a function";
|
||||
}
|
||||
};
|
||||
|
||||
SWFUpload.prototype.executeNextEvent = function () {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
var f = this.eventQueue.shift();
|
||||
f.apply(this);
|
||||
|
||||
};
|
||||
|
||||
// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterfance cannot have
|
||||
// properties that contain characters that are not valid for JavaScript identifiers. To work around this
|
||||
// the Flash Component escapes the parameter names and we must unescape again before passing them along.
|
||||
SWFUpload.prototype.unescapeFilePostParams = function (file) {
|
||||
var reg = /[$]([0-9a-f]{4})/i;
|
||||
var unescapedPost = {};
|
||||
var uk;
|
||||
|
||||
for (var k in file.post) {
|
||||
if (file.post.hasOwnProperty(k)) {
|
||||
uk = k;
|
||||
var match;
|
||||
while ((match = reg.exec(uk)) !== null) {
|
||||
uk = uk.replace(match[0], String.fromCharCode(parseInt("0x"+match[1], 16)));
|
||||
}
|
||||
unescapedPost[uk] = file.post[k];
|
||||
}
|
||||
}
|
||||
|
||||
file.post = unescapedPost;
|
||||
return file;
|
||||
};
|
||||
|
||||
SWFUpload.prototype.flashReady = function () {
|
||||
// Check that the movie element is loaded correctly with its ExternalInterface methods defined
|
||||
var movieElement = this.getMovieElement();
|
||||
if (typeof(movieElement.StartUpload) !== "function") {
|
||||
throw "ExternalInterface methods failed to initialize.";
|
||||
}
|
||||
|
||||
this.queueEvent("swfupload_loaded_handler");
|
||||
};
|
||||
|
||||
|
||||
/* This is a chance to do something before the browse window opens */
|
||||
SWFUpload.prototype.fileDialogStart = function () {
|
||||
this.queueEvent("file_dialog_start_handler");
|
||||
};
|
||||
|
||||
|
||||
/* Called when a file is successfully added to the queue. */
|
||||
SWFUpload.prototype.fileQueued = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queued_handler", file);
|
||||
};
|
||||
|
||||
|
||||
/* Handle errors that occur when an attempt to queue a file fails. */
|
||||
SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
/* Called after the file dialog has closed and the selected files have been queued.
|
||||
You could call startUpload here if you want the queued files to begin uploading immediately. */
|
||||
SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued) {
|
||||
this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadStart = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("return_upload_start_handler", file);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.returnUploadStart = function (file) {
|
||||
var returnValue;
|
||||
if (typeof(this.settings.upload_start_handler) === "function") {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
returnValue = this.settings.upload_start_handler.call(this, file);
|
||||
} else if (this.settings.upload_start_handler != undefined) {
|
||||
throw "upload_start_handler must be a function";
|
||||
}
|
||||
|
||||
// Convert undefined to true so if nothing is returned from the upload_start_handler it is
|
||||
// interpretted as 'true'.
|
||||
if (returnValue === undefined) {
|
||||
returnValue = true;
|
||||
}
|
||||
|
||||
returnValue = !!returnValue;
|
||||
|
||||
this.callFlash("ReturnUploadStart", false, [returnValue]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadSuccess = function (file, serverData) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_success_handler", [file, serverData]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadComplete = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_complete_handler", file);
|
||||
};
|
||||
|
||||
/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
|
||||
internal debug console. You can override this event and have messages written where you want. */
|
||||
SWFUpload.prototype.debug = function (message) {
|
||||
this.queueEvent("debug_handler", message);
|
||||
};
|
||||
|
||||
|
||||
/* **********************************
|
||||
Debug Console
|
||||
The debug console is a self contained, in page location
|
||||
for debug message to be sent. The Debug Console adds
|
||||
itself to the body if necessary.
|
||||
|
||||
The console is automatically scrolled as messages appear.
|
||||
|
||||
If you are using your own debug handler or when you deploy to production and
|
||||
have debug disabled you can remove these functions to reduce the file size
|
||||
and complexity.
|
||||
********************************** */
|
||||
|
||||
// Private: debugMessage is the default debug_handler. If you want to print debug messages
|
||||
// call the debug() function. When overriding the function your own function should
|
||||
// check to see if the debug setting is true before outputting debug information.
|
||||
SWFUpload.prototype.debugMessage = function (message) {
|
||||
if (this.settings.debug) {
|
||||
var exceptionMessage, exceptionValues = [];
|
||||
|
||||
// Check for an exception object and print it nicely
|
||||
if (typeof(message) === "object" && typeof(message.name) === "string" && typeof(message.message) === "string") {
|
||||
for (var key in message) {
|
||||
if (message.hasOwnProperty(key)) {
|
||||
exceptionValues.push(key + ": " + message[key]);
|
||||
}
|
||||
}
|
||||
exceptionMessage = exceptionValues.join("\n") || "";
|
||||
exceptionValues = exceptionMessage.split("\n");
|
||||
exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
|
||||
SWFUpload.Console.writeLine(exceptionMessage);
|
||||
} else {
|
||||
SWFUpload.Console.writeLine(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SWFUpload.Console = {};
|
||||
SWFUpload.Console.writeLine = function (message) {
|
||||
var console, documentForm;
|
||||
|
||||
try {
|
||||
console = document.getElementById("SWFUpload_Console");
|
||||
|
||||
if (!console) {
|
||||
documentForm = document.createElement("form");
|
||||
document.getElementsByTagName("body")[0].appendChild(documentForm);
|
||||
|
||||
console = document.createElement("textarea");
|
||||
console.id = "SWFUpload_Console";
|
||||
console.style.fontFamily = "monospace";
|
||||
console.setAttribute("wrap", "off");
|
||||
console.wrap = "off";
|
||||
console.style.overflow = "auto";
|
||||
console.style.width = "700px";
|
||||
console.style.height = "350px";
|
||||
console.style.margin = "5px";
|
||||
documentForm.appendChild(console);
|
||||
}
|
||||
|
||||
console.value += message + "\n";
|
||||
|
||||
console.scrollTop = console.scrollHeight - console.clientHeight;
|
||||
} catch (ex) {
|
||||
alert("Exception: " + ex.name + " Message: " + ex.message);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
File: TabManager.inc.php
|
||||
|
||||
Contains a class that can be used to invoke DOM calls on the browser which
|
||||
will create or update an HTML table.
|
||||
|
||||
Title: clsTabManager class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
if ( false == class_exists( 'xajaxPlugin' ) || false == class_exists( 'xajaxPluginManager' ) )
|
||||
{
|
||||
$sBaseFolder = dirname( dirname( dirname( __FILE__ ) ) );
|
||||
$sXajaxCore = $sBaseFolder.'/xajax_core';
|
||||
|
||||
if ( false == class_exists( 'xajaxPlugin' ) )
|
||||
require $sXajaxCore.'/xajaxPlugin.inc.php';
|
||||
|
||||
if ( false == class_exists( 'xajaxPluginManager' ) )
|
||||
require $sXajaxCore.'/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTabManager
|
||||
*/
|
||||
class clsTabManager
|
||||
extends xajaxResponsePlugin
|
||||
{
|
||||
/*
|
||||
String: sDefer
|
||||
|
||||
Used to store the state of the scriptDeferral configuration setting. When
|
||||
script deferral is desired, this member contains 'defer' which will request
|
||||
that the browser defer loading of the javascript until the rest of the page
|
||||
has been loaded.
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
/*
|
||||
String: sJavascriptURI
|
||||
|
||||
Used to store the base URI for where the javascript files are located. This
|
||||
enables the plugin to generate a script reference to it's javascript file
|
||||
if the javascript code is NOT inlined.
|
||||
*/
|
||||
var $sJavascriptURI;
|
||||
|
||||
/*
|
||||
Boolean: bInlineScript
|
||||
|
||||
Used to store the value of the inlineScript configuration option. When true,
|
||||
the plugin will return it's javascript code as part of the javascript header
|
||||
for the page, else, it will generate a script tag referencing the file by
|
||||
using the <clsTabManager->sJavascriptURI>.
|
||||
*/
|
||||
var $bInlineScript;
|
||||
|
||||
/*
|
||||
Function: clsTabManager
|
||||
|
||||
Constructs and initializes an instance of the table updater class.
|
||||
*/
|
||||
function clsTabManager()
|
||||
{
|
||||
$this->sDefer = '';
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Receives configuration settings set by <xajax> or user script calls to
|
||||
<xajax->configure>.
|
||||
|
||||
sName - (string): The name of the configuration option being set.
|
||||
mValue - (mixed): The value being associated with the configuration option.
|
||||
*/
|
||||
function configure( $sName, $mValue )
|
||||
{
|
||||
if ( 'scriptDeferral' == $sName )
|
||||
{
|
||||
if ( true === $mValue || false === $mValue )
|
||||
{
|
||||
if ( $mValue )
|
||||
$this->sDefer = 'defer ';
|
||||
else
|
||||
$this->sDefer = '';
|
||||
}
|
||||
}
|
||||
else if ( 'javascript URI' == $sName )
|
||||
{
|
||||
$this->sJavascriptURI = $mValue;
|
||||
}else if ( 'inlineScript' == $sName )
|
||||
{
|
||||
if ( true === $mValue || false === $mValue )
|
||||
$this->bInlineScript = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase. This
|
||||
will either inline the script or insert a script tag which references the
|
||||
<TabManager.js> file based on the value of the <clsTabManager->bInlineScript>
|
||||
configuration option.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if ( $this->bInlineScript )
|
||||
{
|
||||
echo "\n<script type='text/javascript' ".$this->sDefer."charset='UTF-8'>\n";
|
||||
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
include( dirname( __FILE__ ).'/TabManager.js' );
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
|
||||
echo "</script>\n";
|
||||
}else
|
||||
{
|
||||
echo "\n<script type='text/javascript' src='".$this->sJavascriptURI."xajax_plugins/response/TabManager/TabManager.js' ".$this->sDefer."charset='UTF-8'></script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return get_class( $this );
|
||||
}
|
||||
|
||||
function create( $id, $config )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_create',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, $config );
|
||||
}
|
||||
|
||||
function addPanel( $id, $config )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_at',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, $config );
|
||||
}
|
||||
|
||||
function on( $eventName, $target, $panel, $event )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_on',
|
||||
'id' => $target
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array
|
||||
(
|
||||
"n" => $eventName,
|
||||
"p" => $panel,
|
||||
"e" => $event,
|
||||
"key" => crc32($event)
|
||||
));
|
||||
}
|
||||
|
||||
function close( $id, $panel )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_cl',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, $panel );
|
||||
}
|
||||
|
||||
function showPanel( $id, $panel )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_sp',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, $panel );
|
||||
}
|
||||
|
||||
function setTitle( $id, $panel, $title )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_st',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array
|
||||
(
|
||||
"panel" => $panel,
|
||||
"title" => $title
|
||||
));
|
||||
}
|
||||
|
||||
function destroy( $id )
|
||||
{
|
||||
$command = array
|
||||
(
|
||||
'cmd' => 'tm_de',
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$this->addCommand( $command, array ());
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager = &xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin( new clsTabManager() );
|
||||
?>
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
installtabManager=function(){var xjxReady=false;try{if(xajax)
|
||||
xjxReady=true;}
|
||||
catch(e){}
|
||||
if(false==xjxReady){setTimeout('installtabManager();',1000);return;}
|
||||
try{if(undefined==xajax.ext.tabManager)
|
||||
xajax.ext.tabManager={};xajax.ext.tabManager.instances={};}
|
||||
catch(e){xajax.ext={};xajax.ext.tabManager={};xajax.ext.tabManager.instances={};}
|
||||
xajax.ext.tabPanel=function(config){this.config=config;this._parent=config._parent;this.id=config.id;var element=this;this.events={};this.tabWidth=0;if('undefined'!=typeof config.closeable){this.closeable=config.closeable;}
|
||||
else{this.closeable=true;}
|
||||
var parPanel=this._parent.tabPanel;this.tab_item=document.createElement('div');this.tab_item.id="tabPanel_"+this.id;this.tab_item.className="tabPanelItem";this.tab_item.onclick=function(){element._parent.show(element.id);return false;};var tab_item_left=document.createElement('div');tab_item_left.className='tabLeft';tab_item_left.innerHTML=' ';this.tab_item.appendChild(tab_item_left);var tab_title=document.createElement('div');tab_title.id="tabPanelTitel_"+this.id;tab_title.innerHTML=config.title;tab_title.className='title';this.tab_title=tab_title;this.tab_item.appendChild(tab_title);if(this.closeable){var foo=this;var tab_close=document.createElement('div');tab_close.id="tabPanelClose_"+this.id;tab_close.innerHTML=" ";tab_close.className='close';tab_close.onclick=function(){foo.fire("close");element._parent.closePanel(element.id);return false;}
|
||||
this.tab_item.appendChild(tab_close);}
|
||||
var tab_item_right=document.createElement('div');tab_item_right.className='tabRight';tab_item_right.innerHTML=' ';this.tab_item.appendChild(tab_item_right);var tab_clear=document.createElement('div');tab_clear.style.clear='both';this.tab_item.appendChild(tab_clear);var tmp_width=$(parPanel).outerWidth();parPanel.appendChild(this.tab_item);var parContent=this._parent.tabContent;this.tab_content=document.createElement('div');this.tab_content.id="tabContent_"+this.id;this.tab_content.className="tabPanelContent";this.tab_content.innerHTML=config.content;this.tab_content.style.display='none';parContent.appendChild(this.tab_content);this.tabWidth=$(this.tab_item).outerWidth()+2;this.getWidth=function(){this.tabWidth=$(this.tab_item).outerWidth()+2;return this.tabWidth;};this.show=function(){this.tab_item.className='tabPanelItemActive';this.tab_content.style.display='block';this.fire("show");};this.hide=function(){this.tab_item.className='tabPanelItem';this.tab_content.style.display='none';this.fire("hide");};this.setTitle=function(title){this.tab_title.innerHTML=title;};this.setContent=function(content){this.tab_content.innerHTML=content;};this.destroy=function(){this.fire("destroy");parPanel.removeChild(this.tab_item);parContent.removeChild(this.tab_content);};this.fire=function(EventName){if('object'==typeof this.events[EventName]){for(a in this.events[EventName])
|
||||
this.events[EventName][a]();}
|
||||
}
|
||||
this.on=function(EventName,EventFunction,EventFunctionId){if('object'!=typeof this.events[EventName])
|
||||
this.events[EventName]=new Object();if('undefined'==typeof this.events[EventName][EventFunctionId])
|
||||
this.events[EventName][EventFunctionId]=EventFunction;}
|
||||
};xajax.ext.tabManager.tabBar=function(config){this.config=config;this.tabBar=xajax.$(config.tabPanel);this.tabContent=xajax.$(config.tabContent);this.tabs={};this.activeTab=null;this.lastActiveTab=null;this.interval=null;this.maxWidth=$(this.tabBar).innerWidth();this.tabWidth=0;this.tabHeight=$(this.tabBar).innerHeight();var leftHandle=document.createElement('div');leftHandle.className="leftHandle";var rightHandle=document.createElement('div');rightHandle.className="rightHandle";var foo=this;leftHandle.onmouseover=function(){foo.scroll(4);}
|
||||
rightHandle.onmouseover=function(){foo.scroll(-4);}
|
||||
leftHandle.onmouseout=function(){foo.scrollStop();}
|
||||
rightHandle.onmouseout=function(){foo.scrollStop();}
|
||||
leftHandle.style.display='none';rightHandle.style.display='none';this.leftHandle=leftHandle;this.rightHandle=rightHandle;var tabContainer=document.createElement('div');tabContainer.id="tabManager_Container_"+config.tabPanel;tabContainer.style.position="absolute";tabContainer.style.top="0px";tabContainer.style.left="0px";tabContainer.style.right="0px";tabContainer.style.height=this.tabHeight+"px";tabContainer.style.overflow="hidden";var tabPanel=document.createElement('div');tabPanel.style.position="absolute";tabPanel.style.height=this.tabHeight+"px";this.tabBar.appendChild(leftHandle);this.tabBar.appendChild(tabContainer);this.tabBar.appendChild(rightHandle);tabContainer.appendChild(tabPanel);this.tabPanel=tabPanel;this.tabContainer=tabContainer;if('undefined'!=typeof config.cssClass){this.tabPanel.className=this.tabBar.className+" "+config.cssClass;}
|
||||
this.addPanel=function(config){if('undefined'!=typeof this.tabs[config.id]){if(config.hide)
|
||||
return;this.tabs[config.id].fire("destroy");this.show(config.id);return;};config._parent=this;this.tabs[config.id]=new xajax.ext.tabPanel(config);if(true!=config.hide)
|
||||
this.show(config.id);this.tabWidth+=this.tabs[config.id].getWidth();if(this.tabWidth > this.maxWidth){this.leftHandle.style.display='block';this.rightHandle.style.display='block';var lspace=$(this.leftHandle).outerWidth()+1;var rspace=$(this.rightHandle).outerWidth()+1;this.tabContainer.style.left=lspace+"px";this.tabContainer.style.right=rspace+"px";}
|
||||
};this.show=function(id){if('undefined'==typeof this.tabs[id])
|
||||
return;if(null!=this.activeTab)
|
||||
this.activeTab.hide();this.tabs[id].show();this.lastActiveTab=this.activeTab;this.activeTab=this.tabs[id];var pos=$('#tabPanel_'+id).position();var elm_left=pos.left;var elm_max=pos.left+parseInt(this.tabs[id].tabWidth);var container_width=$(this.tabContainer).innerWidth();var panel_pos=$(this.tabPanel).position();var scroll_left=panel_pos.left;var visible_left=0-scroll_left;var visible_right=visible_left+container_width;if(elm_left < visible_left){$(this.tabPanel).animate({left:(0-elm_left)+"px"
|
||||
});}
|
||||
else if(elm_max > visible_right){$(this.tabPanel).animate({left:(container_width-elm_max-22)+"px"
|
||||
});}
|
||||
};this.setContent=function(id,content){if('undefined'!=typeof this.tabs[id])
|
||||
return;this.tabs[id].setContent(content);};this.setTitle=function(id,title){if('undefined'==typeof this.tabs[id])
|
||||
return;this.tabs[id].setTitle(title);};this.updateInnerWidth=function(){var tmpwidth=0;for(a in this.tabs){tmpwidth+=this.tabs[a].getWidth();}
|
||||
this.tabWidth=tmpwidth+22;};this.closePanel=function(id){if('undefined'==typeof this.tabs[id])
|
||||
return;if(null!=this.lastActiveTab){if(this.activeTab.id==id)
|
||||
this.show(this.lastActiveTab.id);}
|
||||
this.tabs[id].destroy();delete(this.tabs[id]);this.updateInnerWidth();if(this.tabWidth < this.maxWidth){this.leftHandle.style.display='none';this.rightHandle.style.display='none';this.tabContainer.style.left="0px";this.tabContainer.style.right="0px";this.tabPanel.style.left="0px";}
|
||||
};this.on=function(EventName,id,EventFunction,EventFunctionId){this.tabs[id].on(EventName,EventFunction,EventFunctionId);}
|
||||
this.scroll=function(value){if(null!=this.interval)
|
||||
return;var tab=this;var i=value;this.interval=setInterval(function(){var lspace=$(tab.leftHandle).innerWidth()+1;var rspace=$(tab.rightHandle).innerWidth()+1;var sLeft=tab.tabPanel.style.left;var iLeft=sLeft.replace("px","");if(""==iLeft)
|
||||
iLeft=0;iLeft=parseInt(iLeft);iLeft+=i;var iMin=tab.maxWidth-tab.tabWidth-rspace-lspace;if((iLeft > 0)||((iLeft < iMin)&&(i < 0))){tab.scrollStop();return;}
|
||||
tab.tabPanel.style.left=iLeft+"px";},25);}
|
||||
this.scrollStop=function(){if(null==this.interval)
|
||||
return;clearInterval(this.interval);this.interval=null;}
|
||||
this.destroy=function(){for(a in this.tabs){this.tabs[a].destroy();delete(this.tabs[a]);}
|
||||
};};xajax.ext.tabManager.create=function(id,config){if("undefined"==typeof xajax.ext.tabManager.instances[id]){try{xajax.ext.tabManager.instances[id]=new xajax.ext.tabManager.tabBar(config);}
|
||||
catch(ex){}
|
||||
}
|
||||
}
|
||||
xajax.ext.tabManager.addPanel=function(id,config){try{xajax.ext.tabManager.instances[id].addPanel(config);}
|
||||
catch(ex){}
|
||||
}
|
||||
xajax.ext.tabManager.showPanel=function(id,sPanel){try{xajax.ext.tabManager.instances[id].show(sPanel);}
|
||||
catch(ex){}
|
||||
}
|
||||
xajax.ext.tabManager.setTitle=function(id,sPanel,title){try{xajax.ext.tabManager.instances[id].setTitle(sPanel,title);}
|
||||
catch(ex){}
|
||||
}
|
||||
xajax.ext.tabManager.on=function(id,sEventName,sTarget,sEventFunc,sEventId){xajax.ext.tabManager.instances[id].on(sEventName,sTarget,sEventFunc,sEventId);}
|
||||
xajax.ext.tabManager.closePanel=function(id,sPanel){xajax.ext.tabManager.instances[id].closePanel(sPanel);}
|
||||
xajax.ext.tabManager.destroy=function(id){xajax.ext.tabManager.instances[id].destroy();delete(xajax.ext.tabManager.instances[id]);}
|
||||
xajax.command.handler.register('tm_create',function(args){args.cmdFullName='ext.tabManager.create';xajax.ext.tabManager.create(args.id,args.data);return true;});xajax.command.handler.register('tm_at',function(args){args.cmdFullName='ext.tabManager.addPanel';xajax.ext.tabManager.addPanel(args.id,args.data);return true;});xajax.command.handler.register('tm_on',function(args){try{args.cmdFullName='ext.tabManager.on';eval("var sEvent = "+args.data.e+";");xajax.ext.tabManager.on(args.id,args.data.n,args.data.p,sEvent,args.data.key);}
|
||||
catch(ex){}
|
||||
return true;});xajax.command.handler.register('tm_cl',function(args){try{args.cmdFullName='ext.tabManager.closePanel';xajax.ext.tabManager.closePanel(args.id,args.data);}
|
||||
catch(ex){debugObj(ex);}
|
||||
return true;});xajax.command.handler.register('tm_sp',function(args){args.cmdFullName='ext.tabManager.showPanel';xajax.ext.tabManager.showPanel(args.id,args.data);return true;});xajax.command.handler.register('tm_st',function(args){try{args.cmdFullName='ext.tabManager.setTitle';xajax.ext.tabManager.setTitle(args.id,args.data.panel,args.data.title);}
|
||||
catch(ex){}
|
||||
return true;});xajax.command.handler.register('tm_de',function(args){try{args.cmdFullName='ext.tabManager.destroy';xajax.ext.tabManager.destroy(args.id);}
|
||||
catch(ex){debugObj(ex);}
|
||||
return true;});}
|
||||
installtabManager();
|
||||
@@ -0,0 +1,614 @@
|
||||
// if xajax has not yet been initialized, wait a second and try again
|
||||
// once xajax has been initialized, install the table command handlers.
|
||||
installtabManager = function()
|
||||
{
|
||||
var xjxReady = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (xajax)
|
||||
xjxReady = true;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
|
||||
if (false == xjxReady)
|
||||
{
|
||||
setTimeout('installtabManager();', 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (undefined == xajax.ext.tabManager)
|
||||
xajax.ext.tabManager = {
|
||||
};
|
||||
|
||||
xajax.ext.tabManager.instances = {
|
||||
};
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
xajax.ext = {
|
||||
};
|
||||
|
||||
xajax.ext.tabManager = {
|
||||
};
|
||||
|
||||
xajax.ext.tabManager.instances = {
|
||||
};
|
||||
}
|
||||
|
||||
xajax.ext.tabPanel = function(config)
|
||||
{
|
||||
this.config = config;
|
||||
this._parent = config._parent;
|
||||
this.id = config.id;
|
||||
var element = this;
|
||||
this.events = {
|
||||
};
|
||||
|
||||
this.tabWidth = 0;
|
||||
|
||||
if ('undefined' != typeof config.closeable)
|
||||
{
|
||||
this.closeable = config.closeable;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.closeable = true;
|
||||
}
|
||||
|
||||
var parPanel = this._parent.tabPanel;
|
||||
this.tab_item = document.createElement('div');
|
||||
this.tab_item.id = "tabPanel_" + this.id;
|
||||
this.tab_item.className = "tabPanelItem";
|
||||
this.tab_item.onclick = function()
|
||||
{
|
||||
element._parent.show(element.id);
|
||||
return false;
|
||||
};
|
||||
|
||||
var tab_item_left = document.createElement('div');
|
||||
tab_item_left.className = 'tabLeft';
|
||||
tab_item_left.innerHTML = ' ';
|
||||
this.tab_item.appendChild(tab_item_left);
|
||||
|
||||
var tab_title = document.createElement('div');
|
||||
tab_title.id = "tabPanelTitel_" + this.id;
|
||||
tab_title.innerHTML = config.title;
|
||||
tab_title.className = 'title';
|
||||
this.tab_title = tab_title;
|
||||
this.tab_item.appendChild(tab_title);
|
||||
|
||||
if (this.closeable)
|
||||
{
|
||||
var foo = this;
|
||||
var tab_close = document.createElement('div');
|
||||
tab_close.id = "tabPanelClose_" + this.id;
|
||||
tab_close.innerHTML = " ";
|
||||
tab_close.className = 'close';
|
||||
tab_close.onclick = function()
|
||||
{
|
||||
foo.fire("close");
|
||||
element._parent.closePanel(element.id);
|
||||
return false;
|
||||
}
|
||||
this.tab_item.appendChild(tab_close);
|
||||
}
|
||||
|
||||
var tab_item_right = document.createElement('div');
|
||||
tab_item_right.className = 'tabRight';
|
||||
tab_item_right.innerHTML = ' ';
|
||||
this.tab_item.appendChild(tab_item_right);
|
||||
|
||||
var tab_clear = document.createElement('div');
|
||||
tab_clear.style.clear = 'both';
|
||||
this.tab_item.appendChild(tab_clear);
|
||||
|
||||
var tmp_width = $(parPanel).outerWidth();
|
||||
//parPanel.style.width=(tmp_width+300)+"px";
|
||||
parPanel.appendChild(this.tab_item);
|
||||
|
||||
var parContent = this._parent.tabContent;
|
||||
|
||||
this.tab_content = document.createElement('div');
|
||||
this.tab_content.id = "tabContent_" + this.id;
|
||||
this.tab_content.className = "tabPanelContent";
|
||||
this.tab_content.innerHTML = config.content;
|
||||
this.tab_content.style.display = 'none';
|
||||
|
||||
parContent.appendChild(this.tab_content);
|
||||
//this.getWidth();
|
||||
this.tabWidth = $(this.tab_item).outerWidth() + 2;
|
||||
|
||||
this.getWidth = function()
|
||||
{
|
||||
this.tabWidth = $(this.tab_item).outerWidth() + 2;
|
||||
return this.tabWidth;
|
||||
};
|
||||
|
||||
this.show = function()
|
||||
{
|
||||
this.tab_item.className = 'tabPanelItemActive';
|
||||
this.tab_content.style.display = 'block';
|
||||
this.fire("show");
|
||||
};
|
||||
|
||||
this.hide = function()
|
||||
{
|
||||
this.tab_item.className = 'tabPanelItem';
|
||||
this.tab_content.style.display = 'none';
|
||||
|
||||
this.fire("hide");
|
||||
};
|
||||
|
||||
this.setTitle = function(title)
|
||||
{
|
||||
this.tab_title.innerHTML = title;
|
||||
};
|
||||
|
||||
this.setContent = function(content)
|
||||
{
|
||||
this.tab_content.innerHTML = content;
|
||||
};
|
||||
|
||||
this.destroy = function()
|
||||
{
|
||||
this.fire("destroy");
|
||||
parPanel.removeChild(this.tab_item);
|
||||
parContent.removeChild(this.tab_content);
|
||||
};
|
||||
|
||||
this.fire = function(EventName)
|
||||
{
|
||||
if ('object' == typeof this.events[EventName])
|
||||
{
|
||||
for (a in this.events[EventName])
|
||||
this.events[EventName][a]();
|
||||
}
|
||||
}
|
||||
|
||||
this.on = function(EventName, EventFunction, EventFunctionId)
|
||||
{
|
||||
if ('object' != typeof this.events[EventName])
|
||||
this.events[EventName] = new Object();
|
||||
|
||||
if ('undefined' == typeof this.events[EventName][EventFunctionId])
|
||||
this.events[EventName][EventFunctionId] = EventFunction;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
xajax.ext.tabManager.tabBar = function(config)
|
||||
{
|
||||
this.config = config;
|
||||
this.tabBar = xajax.$(config.tabPanel);
|
||||
this.tabContent = xajax.$(config.tabContent);
|
||||
this.tabs = {
|
||||
};
|
||||
|
||||
this.activeTab = null;
|
||||
this.lastActiveTab = null;
|
||||
this.interval = null;
|
||||
|
||||
this.maxWidth = $(this.tabBar).innerWidth();
|
||||
|
||||
this.tabWidth = 0;
|
||||
this.tabHeight = $(this.tabBar).innerHeight();
|
||||
|
||||
var leftHandle = document.createElement('div');
|
||||
leftHandle.className = "leftHandle";
|
||||
|
||||
var rightHandle = document.createElement('div');
|
||||
rightHandle.className = "rightHandle";
|
||||
|
||||
var foo = this;
|
||||
|
||||
leftHandle.onmouseover = function()
|
||||
{
|
||||
foo.scroll(4);
|
||||
}
|
||||
rightHandle.onmouseover = function()
|
||||
{
|
||||
foo.scroll(-4);
|
||||
}
|
||||
|
||||
leftHandle.onmouseout = function()
|
||||
{
|
||||
foo.scrollStop();
|
||||
}
|
||||
|
||||
rightHandle.onmouseout = function()
|
||||
{
|
||||
foo.scrollStop();
|
||||
}
|
||||
|
||||
leftHandle.style.display = 'none';
|
||||
rightHandle.style.display = 'none';
|
||||
|
||||
this.leftHandle = leftHandle;
|
||||
this.rightHandle = rightHandle;
|
||||
|
||||
var tabContainer = document.createElement('div');
|
||||
tabContainer.id = "tabManager_Container_" + config.tabPanel;
|
||||
tabContainer.style.position = "absolute";
|
||||
tabContainer.style.top = "0px";
|
||||
tabContainer.style.left = "0px";
|
||||
tabContainer.style.right = "0px";
|
||||
|
||||
// possible IE abs pos fix
|
||||
//tabContainer.style.width = this.maxWidth + "px";
|
||||
|
||||
tabContainer.style.height = this.tabHeight + "px";
|
||||
tabContainer.style.overflow = "hidden";
|
||||
|
||||
var tabPanel = document.createElement('div');
|
||||
tabPanel.style.position = "absolute";
|
||||
tabPanel.style.height = this.tabHeight + "px";
|
||||
|
||||
this.tabBar.appendChild(leftHandle);
|
||||
this.tabBar.appendChild(tabContainer);
|
||||
this.tabBar.appendChild(rightHandle);
|
||||
|
||||
tabContainer.appendChild(tabPanel);
|
||||
|
||||
this.tabPanel = tabPanel;
|
||||
this.tabContainer = tabContainer;
|
||||
|
||||
if ('undefined' != typeof config.cssClass)
|
||||
{
|
||||
this.tabPanel.className = this.tabBar.className + " " + config.cssClass;
|
||||
}
|
||||
|
||||
this.addPanel = function(config)
|
||||
{
|
||||
if ('undefined' != typeof this.tabs[config.id])
|
||||
{
|
||||
if (config.hide)
|
||||
return;
|
||||
|
||||
this.tabs[config.id].fire("destroy");
|
||||
this.show(config.id);
|
||||
return;
|
||||
};
|
||||
config._parent = this;
|
||||
this.tabs[config.id] = new xajax.ext.tabPanel(config);
|
||||
|
||||
if (true != config.hide)
|
||||
this.show(config.id);
|
||||
|
||||
this.tabWidth += this.tabs[config.id].getWidth();
|
||||
|
||||
// possible IE abs pos fix
|
||||
//this.tabPanel.style.width=this.tabWidth+"px";
|
||||
|
||||
if (this.tabWidth > this.maxWidth)
|
||||
{
|
||||
|
||||
this.leftHandle.style.display = 'block';
|
||||
this.rightHandle.style.display = 'block';
|
||||
|
||||
var lspace = $(this.leftHandle).outerWidth() + 1;
|
||||
var rspace = $(this.rightHandle).outerWidth() + 1;
|
||||
this.tabContainer.style.left = lspace + "px";
|
||||
this.tabContainer.style.right = rspace + "px";
|
||||
}
|
||||
};
|
||||
this.show = function(id)
|
||||
{
|
||||
if ('undefined' == typeof this.tabs[id])
|
||||
return;
|
||||
|
||||
if (null != this.activeTab)
|
||||
this.activeTab.hide();
|
||||
this.tabs[id].show();
|
||||
this.lastActiveTab = this.activeTab;
|
||||
this.activeTab = this.tabs[id];
|
||||
|
||||
var pos = $('#tabPanel_' + id).position();
|
||||
var elm_left = pos.left;
|
||||
var elm_max = pos.left + parseInt(this.tabs[id].tabWidth);
|
||||
|
||||
var container_width = $(this.tabContainer).innerWidth();
|
||||
|
||||
var panel_pos = $(this.tabPanel).position();
|
||||
|
||||
var scroll_left = panel_pos.left;
|
||||
var visible_left = 0 - scroll_left;
|
||||
var visible_right = visible_left + container_width;
|
||||
|
||||
if (elm_left < visible_left)
|
||||
{
|
||||
$(this.tabPanel).animate(
|
||||
{
|
||||
left: (0 - elm_left) + "px"
|
||||
});
|
||||
}
|
||||
else if (elm_max > visible_right)
|
||||
{
|
||||
$(this.tabPanel).animate(
|
||||
{
|
||||
left: (container_width - elm_max - 22) + "px"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.setContent = function(id, content)
|
||||
{
|
||||
if ('undefined' != typeof this.tabs[id])
|
||||
return;
|
||||
|
||||
this.tabs[id].setContent(content);
|
||||
};
|
||||
|
||||
this.setTitle = function(id, title)
|
||||
{
|
||||
if ('undefined' == typeof this.tabs[id])
|
||||
return;
|
||||
|
||||
this.tabs[id].setTitle(title);
|
||||
};
|
||||
|
||||
this.updateInnerWidth = function()
|
||||
{
|
||||
var tmpwidth = 0;
|
||||
|
||||
for (a in this.tabs)
|
||||
{
|
||||
tmpwidth += this.tabs[a].getWidth();
|
||||
}
|
||||
this.tabWidth = tmpwidth + 22;
|
||||
};
|
||||
|
||||
this.closePanel = function(id)
|
||||
{
|
||||
if ('undefined' == typeof this.tabs[id])
|
||||
return;
|
||||
|
||||
if (null != this.lastActiveTab)
|
||||
{
|
||||
if (this.activeTab.id == id)
|
||||
this.show(this.lastActiveTab.id);
|
||||
}
|
||||
|
||||
this.tabs[id].destroy();
|
||||
delete (this.tabs[id]);
|
||||
|
||||
this.updateInnerWidth();
|
||||
|
||||
if (this.tabWidth < this.maxWidth)
|
||||
{
|
||||
this.leftHandle.style.display = 'none';
|
||||
this.rightHandle.style.display = 'none';
|
||||
|
||||
this.tabContainer.style.left = "0px";
|
||||
this.tabContainer.style.right = "0px";
|
||||
// possible IE fix
|
||||
//this.tabContainer.style.width = this.maxWidth + "px";
|
||||
this.tabPanel.style.left = "0px";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.on = function(EventName, id, EventFunction, EventFunctionId)
|
||||
{
|
||||
this.tabs[id].on(EventName, EventFunction, EventFunctionId);
|
||||
}
|
||||
|
||||
this.scroll = function(value)
|
||||
{
|
||||
if (null != this.interval)
|
||||
return;
|
||||
|
||||
var tab = this;
|
||||
var i = value;
|
||||
this.interval = setInterval(function()
|
||||
{
|
||||
var lspace = $(tab.leftHandle).innerWidth() + 1;
|
||||
var rspace = $(tab.rightHandle).innerWidth() + 1;
|
||||
|
||||
var sLeft = tab.tabPanel.style.left;
|
||||
var iLeft = sLeft.replace("px", "");
|
||||
|
||||
if ("" == iLeft)
|
||||
iLeft = 0;
|
||||
iLeft = parseInt(iLeft);
|
||||
iLeft += i;
|
||||
var iMin = tab.maxWidth - tab.tabWidth - rspace - lspace;
|
||||
|
||||
if ((iLeft > 0) || ((iLeft < iMin) && (i < 0)))
|
||||
{
|
||||
tab.scrollStop();
|
||||
return;
|
||||
}
|
||||
tab.tabPanel.style.left = iLeft + "px";
|
||||
}, 25);
|
||||
}
|
||||
this.scrollStop = function()
|
||||
{
|
||||
if (null == this.interval)
|
||||
return;
|
||||
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
|
||||
this.destroy = function()
|
||||
{
|
||||
for (a in this.tabs)
|
||||
{
|
||||
this.tabs[a].destroy();
|
||||
delete (this.tabs[a]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.create = function(id, config)
|
||||
{
|
||||
if ("undefined" == typeof xajax.ext.tabManager.instances[id])
|
||||
{
|
||||
try
|
||||
{
|
||||
xajax.ext.tabManager.instances[id] = new xajax.ext.tabManager.tabBar(config);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.addPanel = function(id, config)
|
||||
{
|
||||
try
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].addPanel(config);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.showPanel = function(id, sPanel)
|
||||
{
|
||||
try
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].show(sPanel);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.setTitle = function(id, sPanel, title)
|
||||
{
|
||||
try
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].setTitle(sPanel, title);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.on = function(id, sEventName, sTarget, sEventFunc, sEventId)
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].on(sEventName, sTarget, sEventFunc, sEventId);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.ext.tabManager.closePanel = function(id, sPanel)
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].closePanel(sPanel);
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.ext.tabManager.destroy = function(id)
|
||||
{
|
||||
xajax.ext.tabManager.instances[id].destroy();
|
||||
delete (xajax.ext.tabManager.instances[id]);
|
||||
}
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_create', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.create';
|
||||
xajax.ext.tabManager.create(args.id, args.data);
|
||||
return true;
|
||||
});
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_at', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.addPanel';
|
||||
xajax.ext.tabManager.addPanel(args.id, args.data);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_on', function(args)
|
||||
{
|
||||
try
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.on';
|
||||
|
||||
eval("var sEvent = " + args.data.e + ";");
|
||||
|
||||
xajax.ext.tabManager.on(args.id, args.data.n, args.data.p, sEvent, args.data.key);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
//console.log(ex);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_cl', function(args)
|
||||
{
|
||||
try
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.closePanel';
|
||||
xajax.ext.tabManager.closePanel(args.id, args.data);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
debugObj(ex);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_sp', function(args)
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.showPanel';
|
||||
xajax.ext.tabManager.showPanel(args.id, args.data);
|
||||
return true;
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
xajax.command.handler.register('tm_st', function(args)
|
||||
{
|
||||
try
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.setTitle';
|
||||
xajax.ext.tabManager.setTitle(args.id, args.data.panel, args.data.title);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
//console.log(ex);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
xajax.command.handler.register('tm_de', function(args)
|
||||
{
|
||||
try
|
||||
{
|
||||
args.cmdFullName = 'ext.tabManager.destroy';
|
||||
xajax.ext.tabManager.destroy(args.id);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
debugObj(ex);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
/* ------------------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
}
|
||||
|
||||
installtabManager();
|
||||
312
libraries/xajax/xajax_plugins/response/comet/comet.inc.php
Normal file
312
libraries/xajax/xajax_plugins/response/comet/comet.inc.php
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
define('FILE_APPEND', 1);
|
||||
|
||||
/*
|
||||
File: tableUpdater.inc.php
|
||||
|
||||
Contains a class that can be used to invoke DOM calls on the browser which
|
||||
will create or update an HTML table.
|
||||
|
||||
Title: clsTableUpdater class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
|
||||
{
|
||||
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
|
||||
$sXajaxCore = $sBaseFolder . '/xajax_core';
|
||||
|
||||
if (false == class_exists('xajaxPlugin'))
|
||||
require $sXajaxCore . '/xajaxPlugin.inc.php';
|
||||
if (false == class_exists('xajaxPluginManager'))
|
||||
require $sXajaxCore . '/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
//require_once dirname(__FILE__) . '/xajaxCometPlugin.inc.php';
|
||||
|
||||
/*
|
||||
Class: clsTableUpdater
|
||||
*/
|
||||
class clsCometStreaming extends xajaxResponsePlugin
|
||||
{
|
||||
/*
|
||||
String: sDefer
|
||||
|
||||
Used to store the state of the scriptDeferral configuration setting. When
|
||||
script deferral is desired, this member contains 'defer' which will request
|
||||
that the browser defer loading of the javascript until the rest of the page
|
||||
has been loaded.
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
/*
|
||||
String: sJavascriptURI
|
||||
|
||||
Used to store the base URI for where the javascript files are located. This
|
||||
enables the plugin to generate a script reference to it's javascript file
|
||||
if the javascript code is NOT inlined.
|
||||
*/
|
||||
var $sJavascriptURI;
|
||||
|
||||
/*
|
||||
Boolean: bInlineScript
|
||||
|
||||
Used to store the value of the inlineScript configuration option. When true,
|
||||
the plugin will return it's javascript code as part of the javascript header
|
||||
for the page, else, it will generate a script tag referencing the file by
|
||||
using the <clsTableUpdater->sJavascriptURI>.
|
||||
*/
|
||||
var $bInlineScript;
|
||||
|
||||
/*
|
||||
Function: clsTableUpdater
|
||||
|
||||
Constructs and initializes an instance of the table updater class.
|
||||
*/
|
||||
function clsCometStreaming()
|
||||
{
|
||||
$this->sDefer = '';
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Receives configuration settings set by <xajax> or user script calls to
|
||||
<xajax->configure>.
|
||||
|
||||
sName - (string): The name of the configuration option being set.
|
||||
mValue - (mixed): The value being associated with the configuration option.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('scriptDeferral' == $sName) {
|
||||
if (true === $mValue || false === $mValue) {
|
||||
if ($mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
}
|
||||
} else if ('javascript URI' == $sName) {
|
||||
$this->sJavascriptURI = $mValue;
|
||||
} else if ('inlineScript' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bInlineScript = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase. This
|
||||
will either inline the script or insert a script tag which references the
|
||||
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
|
||||
configuration option.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if ($this->bInlineScript)
|
||||
{
|
||||
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
include(dirname(__FILE__) . 'xajax_plugins/response/comet/comet.js');
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
} else {
|
||||
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "xajax_plugins/response/comet/comet.js' " . $this->sDefer . "charset='UTF-8'></script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class xajaxCometResponse extends xajaxResponse
|
||||
{
|
||||
var $bHeaderSent = false;
|
||||
|
||||
|
||||
/*
|
||||
Function: xajaxCometResponse
|
||||
|
||||
calls parent function xajaxResponse();
|
||||
*/
|
||||
|
||||
|
||||
function xajaxCometResponse()
|
||||
{
|
||||
parent::xajaxResponse();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: printOutput
|
||||
|
||||
override the original printOutput function. It's no longer needed since the output is already sent.
|
||||
*/
|
||||
|
||||
function printOutput()
|
||||
{
|
||||
if ( "HTML5DRAFT" == $_GET['xjxstreaming']) {
|
||||
|
||||
$response = "";
|
||||
$response .= "Event: xjxendstream\n";
|
||||
$response .= "data: done\n";
|
||||
$response .= "\n";
|
||||
print $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Function: flush_XHR
|
||||
|
||||
Flushes the command queue for comet browsers.
|
||||
*/
|
||||
|
||||
function flush_XHR()
|
||||
{
|
||||
|
||||
if (!$this->bHeaderSent)
|
||||
{
|
||||
$this->_sendHeaders();
|
||||
$this->bHeaderSent=true;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->_printResponse_XML();
|
||||
$c = ob_get_contents();
|
||||
ob_get_clean();
|
||||
$c = str_replace(chr(1)," ",$c);
|
||||
$c = str_replace(chr(2)," ",$c);
|
||||
$c = str_replace(chr(31)," ",$c);
|
||||
$c = str_replace(""," ",$c);
|
||||
if ($c == "<xjx></xjx>") return false;
|
||||
print $c;
|
||||
ob_flush();
|
||||
flush();
|
||||
$this->sleep(1.1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function: flush_activeX
|
||||
|
||||
Flushes the command queue for ActiveX browsers.
|
||||
*/
|
||||
|
||||
function flush_activeX()
|
||||
{
|
||||
ob_start();
|
||||
$this->_printResponse_XML();
|
||||
$c = ob_get_contents();
|
||||
ob_get_clean();
|
||||
|
||||
$c = '<?xml version="1.0" ?>'.$c;
|
||||
$c = str_replace('"','\"',$c);
|
||||
$c = str_replace("\n",'\n',$c);
|
||||
$c = str_replace("\r",'\r',$c);
|
||||
|
||||
$response = "";
|
||||
$response .= "<script>top.document.callback(\"";
|
||||
$response .= $c;
|
||||
$response .= "\");</script>";
|
||||
|
||||
print $response;
|
||||
ob_flush();
|
||||
flush();
|
||||
$this->sleep(0.99);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: flush_HTML5DRAFT
|
||||
|
||||
Flushes the command queue for HTML5DRAFT browsers.
|
||||
*/
|
||||
|
||||
function flush_HTML5DRAFT()
|
||||
{
|
||||
|
||||
|
||||
if (!$this->bHeaderSent)
|
||||
{
|
||||
header("Content-Type: application/x-dom-event-stream");
|
||||
$this->bHeaderSent=1;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->_printResponse_XML();
|
||||
$c = ob_get_contents();
|
||||
ob_get_clean();
|
||||
$c = str_replace("\n",'\n',$c);
|
||||
$c = str_replace("\r",'\r',$c);
|
||||
$response = "";
|
||||
$response .= "Event: xjxstream\n";
|
||||
$response .= "data: $c\n";
|
||||
$response .= "\n";
|
||||
print $response;
|
||||
ob_flush();
|
||||
flush();
|
||||
$this->sleep(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function: flush
|
||||
|
||||
Determines which browser is wating for a response and calls the according flush function.
|
||||
*/
|
||||
function flush()
|
||||
{
|
||||
if (0 == count($this->aCommands)) return false;
|
||||
if ("xhr" == $_SERVER['HTTP_STREAMING'])
|
||||
{
|
||||
$this->flush_XHR();
|
||||
}
|
||||
elseif ( "HTML5DRAFT" == $_GET['xjxstreaming'])
|
||||
{
|
||||
$this->flush_HTML5DRAFT();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->flush_activeX();
|
||||
}
|
||||
$this->aCommands=array();
|
||||
}
|
||||
|
||||
/*
|
||||
Function: sleep
|
||||
|
||||
Very accurate sleep function.
|
||||
*/
|
||||
function sleep($seconds)
|
||||
{
|
||||
usleep(floor($seconds*1000000));
|
||||
}
|
||||
|
||||
|
||||
function file_put_contents($n, $d, $flag = false)
|
||||
{
|
||||
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
|
||||
$f = @fopen($n, $mode);
|
||||
if ($f === false)
|
||||
{
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
if (is_array($d)) $d = implode($d);
|
||||
$bytes_written = fwrite($f, $d);
|
||||
fclose($f);
|
||||
return $bytes_written;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsCometStreaming());
|
||||
516
libraries/xajax/xajax_plugins/response/comet/comet.js
Normal file
516
libraries/xajax/xajax_plugins/response/comet/comet.js
Normal file
@@ -0,0 +1,516 @@
|
||||
/*
|
||||
File: comet.js
|
||||
|
||||
Title: Comet plugin for xajax
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
@package comet plugin
|
||||
@version $Id:
|
||||
@copyright Copyright (c) 2007 by Steffen Konerow (IE)
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajax.ext.comet
|
||||
|
||||
This class contains all functions for using comet streaming with xajax.
|
||||
|
||||
*/
|
||||
|
||||
try {
|
||||
if (undefined == xajax.ext)
|
||||
xajax.ext = {};
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (undefined == xajax.ext.comet)
|
||||
xajax.ext.comet = {};
|
||||
} catch (e) {
|
||||
alert("Could not create xajax.ext.comet namespace");
|
||||
}
|
||||
|
||||
// create Shorthand for xajax.ext.comet
|
||||
xjxEc = xajax.ext.comet;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: detectSupport
|
||||
|
||||
Detects browser for using fallback methods instead of multipart XHR responses.
|
||||
*/
|
||||
xjxEc.detectSupport = function()
|
||||
{
|
||||
|
||||
|
||||
var agt=navigator.userAgent.toLowerCase();
|
||||
if (agt.indexOf("opera") != -1) return 'Opera';
|
||||
if (agt.indexOf("staroffice") != -1) return 'Star Office';
|
||||
if (agt.indexOf("webtv") != -1) return 'WebTV';
|
||||
if (agt.indexOf("beonex") != -1) return 'Beonex';
|
||||
if (agt.indexOf("chimera") != -1) return 'Chimera';
|
||||
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
|
||||
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
|
||||
if (agt.indexOf("firefox") != -1) return 'Firefox';
|
||||
if (agt.indexOf("safari") != -1) return 'Safari';
|
||||
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
|
||||
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
|
||||
if (agt.indexOf("netscape") != -1) return 'Netscape';
|
||||
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
|
||||
if (agt.indexOf('\/') != -1)
|
||||
{
|
||||
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla')
|
||||
{
|
||||
return navigator.userAgent.substr(0,agt.indexOf('\/'));
|
||||
}
|
||||
else return 'Netscape';
|
||||
}
|
||||
else if (agt.indexOf(' ') != -1) return navigator.userAgent.substr(0,agt.indexOf(' '));
|
||||
else return navigator.userAgent;
|
||||
|
||||
// if (navigator.appVersion.indexOf("MSIE")!=-1)
|
||||
// {
|
||||
// var version,temp;
|
||||
// temp=navigator.appVersion.split("MSIE")
|
||||
// version=parseFloat(temp[1])
|
||||
// if (version>=5.5) return "MSIE";
|
||||
// }
|
||||
// if ( "undefined" != typeof window.opera )
|
||||
// {
|
||||
// return "OPERA";
|
||||
// }
|
||||
// if ( "undefined" != typeof window.Iterator )
|
||||
// {
|
||||
// return "FF2";
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Function: prepareRequestXHR
|
||||
|
||||
Prepares the XMLHttpRequest object for this xajax request in FF/Safari browsers.
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.prepareRequestXHR = function (oRequest)
|
||||
{
|
||||
if (true == oRequest.comet)
|
||||
{
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
oRequest.request = xt.getRequestObject();
|
||||
|
||||
oRequest.setRequestHeaders = function(headers) {
|
||||
if ('object' == typeof headers) {
|
||||
for (var optionName in headers)
|
||||
this.request.setRequestHeader(optionName, headers[optionName]);
|
||||
}
|
||||
}
|
||||
oRequest.setCommonRequestHeaders = function() {
|
||||
this.setRequestHeaders(this.commonHeaders);
|
||||
}
|
||||
oRequest.setPostRequestHeaders = function() {
|
||||
this.setRequestHeaders(this.postHeaders);
|
||||
}
|
||||
oRequest.setGetRequestHeaders = function() {
|
||||
this.setRequestHeaders(this.getHeaders);
|
||||
}
|
||||
|
||||
|
||||
oRequest.applyRequestHeaders = function() {
|
||||
}
|
||||
|
||||
oRequest.setCommonRequestHeaders = function() {
|
||||
this.request.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
|
||||
this.request.setRequestHeader('streaming', 'xhr');
|
||||
|
||||
if (typeof(oRequest.header) == "object")
|
||||
{
|
||||
for (a in oRequest.header)
|
||||
this.request.setRequestHeader(a, oRequest.header[a]);
|
||||
}
|
||||
}
|
||||
oRequest.comet = {};
|
||||
oRequest.comet.LastPosition = 0;
|
||||
|
||||
var pollLatestResponse = function() {
|
||||
xjxEc.responseProcessor.XHR(oRequest);
|
||||
}
|
||||
oRequest.pollTimer = setInterval(pollLatestResponse, 80);
|
||||
oRequest.request.onreadystatechange = function()
|
||||
{
|
||||
if (oRequest.request.readyState < 3)
|
||||
return;
|
||||
|
||||
if (oRequest.request.readyState == 4)
|
||||
{
|
||||
clearInterval(oRequest.pollTimer);
|
||||
xjxEc.responseProcessor.XHR(oRequest);
|
||||
|
||||
//xajax.responseReceived(oRequest);
|
||||
xajax.completeResponse(oRequest);
|
||||
return;
|
||||
}
|
||||
}
|
||||
oRequest.finishRequest = function()
|
||||
{
|
||||
return this.returnValue;
|
||||
}
|
||||
|
||||
if ('undefined' != typeof oRequest.userName && 'undefined' != typeof oRequest.password)
|
||||
{
|
||||
oRequest.open = function()
|
||||
{
|
||||
this.request.open(
|
||||
this.method,
|
||||
this.requestURI,
|
||||
true,
|
||||
oRequest.userName,
|
||||
oRequest.password);
|
||||
}
|
||||
} else
|
||||
{
|
||||
oRequest.open = function()
|
||||
{
|
||||
this.request.open(
|
||||
this.method,
|
||||
this.requestURI,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
if ('POST' == oRequest.method) { // W3C: Method is case sensitive
|
||||
oRequest.applyRequestHeaders = function() {
|
||||
this.setCommonRequestHeaders();
|
||||
try {
|
||||
this.setPostRequestHeaders();
|
||||
} catch (e) {
|
||||
this.method = 'GET';
|
||||
this.requestURI += this.requestURI.indexOf('?')== -1 ? '?' : '&';
|
||||
this.requestURI += this.requestData;
|
||||
this.requestData = '';
|
||||
if (0 == this.requestRetry) this.requestRetry = 1;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
oRequest.applyRequestHeaders = function() {
|
||||
this.setCommonRequestHeaders();
|
||||
this.setGetRequestHeaders();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return xjxEc.prepareRequest(oRequest);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: connect_htmlfile
|
||||
|
||||
Create a hidden iframe for IE
|
||||
|
||||
*/
|
||||
xjxEc.connect_htmlfile = function (url, callback,oRequest)
|
||||
{
|
||||
|
||||
try {
|
||||
xjxEc.transferDoc = new ActiveXObject("htmlfile");
|
||||
xjxEc.transferDoc.open();
|
||||
xjxEc.transferDoc.write("<html>");
|
||||
xjxEc.transferDoc.write("<script>document.domain='http://192.168.1.21/';</script>");
|
||||
xjxEc.transferDoc.write("</html>");
|
||||
xjxEc.transferDoc.close();
|
||||
xjxEc.ifrDiv = xjxEc.transferDoc.createElement("div");
|
||||
xjxEc.transferDoc.body.appendChild(xjxEc.ifrDiv);
|
||||
xjxEc.ifrDiv.innerHTML = "<iframe src='" + url + "'></iframe>";
|
||||
xjxEc.transferDoc.callback = function (response) {
|
||||
callback(response,oRequest);
|
||||
};
|
||||
} catch (ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Function: prepareRequestActiveX
|
||||
|
||||
Prepares the Iframe for streaming with active X
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.prepareRequestActiveX = function(oRequest) {
|
||||
if (true == oRequest.comet) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
oRequest.requestURI += oRequest.requestURI.indexOf('?')== -1 ? '?' : '&';
|
||||
oRequest.requestURI += oRequest.requestData;
|
||||
oRequest.requestData = '';
|
||||
try {
|
||||
xjxEc.connect_htmlfile(oRequest.requestURI,xjxEc.responseProcessor.ActiveX,oRequest);
|
||||
if (0 < oRequest.requestRetry) oRequest.requestRetry = 0;
|
||||
} catch (ex) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
return xjxEc.prepareRequest(oRequest);
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Function: prepareRequestHTMLDRAFT
|
||||
|
||||
Prepares streaming with HTML 5 Draft
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.prepareRequestHTMLDRAFT = function(oRequest) {
|
||||
if (true == oRequest.comet) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
oRequest.requestURI += oRequest.requestURI.indexOf('?')== -1 ? '?' : '&';
|
||||
oRequest.requestURI += oRequest.requestData;
|
||||
oRequest.requestURI += "&xjxstreaming=HTML5DRAFT";
|
||||
try {
|
||||
var uri = oRequest.requestURI;
|
||||
var es = document.createElement("event-source");
|
||||
es.setAttribute("src", uri);
|
||||
es.setAttribute("width", 200);
|
||||
es.setAttribute("height", 200);
|
||||
es.style.display="block";
|
||||
callback = function(event)
|
||||
{
|
||||
xjxEc.responseProcessor.HTMLDRAFT(event.data,oRequest);
|
||||
};
|
||||
remove = function() {
|
||||
es.removeEventListener("xjxstream",callback,false);
|
||||
es.removeEventListener("xjxendstream",remove,false);
|
||||
//document.body.removeChild(es);
|
||||
}
|
||||
|
||||
es.addEventListener("xjxstream",callback,false);
|
||||
es.addEventListener("xjxendstream",remove,false);
|
||||
document.body.appendChild(es);
|
||||
if (0 < oRequest.requestRetry) oRequest.requestRetry = 0;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
return xjxEc.prepareRequest(oRequest);
|
||||
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: responseProcessor.XHR
|
||||
|
||||
Processes the streaming response for FF/Safari
|
||||
|
||||
*/
|
||||
xajax.debug={};
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
try {
|
||||
text = text.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br />');
|
||||
return text;
|
||||
} catch (e) {
|
||||
xajax.debug.stringReplace = function(haystack, needle, newNeedle) {
|
||||
var segments = haystack.split(needle);
|
||||
haystack = '';
|
||||
for (var i = 0; i < segments.length; ++i) {
|
||||
if (0 != i)
|
||||
haystack += newNeedle;
|
||||
haystack += segments[i];
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
xajax.debug.prepareDebugText = function(text) {
|
||||
text = xajax.debug.stringReplace(text, '&', '&');
|
||||
text = xajax.debug.stringReplace(text, '<', '<');
|
||||
text = xajax.debug.stringReplace(text, '>', '>');
|
||||
text = xajax.debug.stringReplace(text, '\n', '<br />');
|
||||
return text;
|
||||
}
|
||||
xajax.debug.prepareDebugText(text);
|
||||
}
|
||||
}
|
||||
xjxEc.responseProcessor={}
|
||||
|
||||
|
||||
xjxEc.responseProcessor.XHR = function(oRequest) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xcb = xx.callback;
|
||||
var gcb = xcb.global;
|
||||
var lcb = oRequest.callback;
|
||||
var oRet = oRequest.returnValue;
|
||||
if ("" == oRequest.request.responseText) return;
|
||||
var allMessages = oRequest.request.responseText;
|
||||
do {
|
||||
var unprocessed = allMessages.substring(oRequest.comet.LastPosition);
|
||||
var messageXMLEndIndex = unprocessed.indexOf("</xjx>");
|
||||
if (messageXMLEndIndex!=-1) {
|
||||
var endOfFirstMessageIndex = messageXMLEndIndex + "</xjx>".length;
|
||||
var anUpdate = unprocessed.substring(0, endOfFirstMessageIndex);
|
||||
|
||||
var cmd = (new DOMParser()).parseFromString(anUpdate, "text/xml");
|
||||
try {
|
||||
var seq = 0;
|
||||
var child = cmd.documentElement.firstChild;
|
||||
xt.xml.processFragment(child, seq, oRequest);
|
||||
} catch (ex) {
|
||||
}
|
||||
xt.queue.process(xx.response);
|
||||
oRequest.comet.LastPosition += endOfFirstMessageIndex;
|
||||
}
|
||||
} while (messageXMLEndIndex != -1);
|
||||
|
||||
return oRet;
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: responseProcessor.ActiveX
|
||||
|
||||
Processes the streaming response for IE
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.responseProcessor.ActiveX = function(response,oRequest) {
|
||||
|
||||
response.replace('\"','"');
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xcb = xx.callback;
|
||||
var gcb = xcb.global;
|
||||
var lcb = oRequest.callback;
|
||||
var oRet = oRequest.returnValue;
|
||||
if (response) {
|
||||
var cmd = (new DOMParser()).parseFromString(response, "text/xml");
|
||||
var seq=0;
|
||||
var child = cmd.documentElement.firstChild;
|
||||
xt.xml.processFragment(child, seq, oRequest);
|
||||
|
||||
if (null == xx.response.timeout)
|
||||
xt.queue.process(xx.response);
|
||||
}
|
||||
return oRet;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: responseProcessor.HTMLDRAFT
|
||||
|
||||
Processes the streaming response for HTML 5 Draft Browsers (Opera 9+)
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.responseProcessor.HTMLDRAFT = function(response,oRequest) {
|
||||
var xx = xajax;
|
||||
var xt = xx.tools;
|
||||
var xcb = xx.callback;
|
||||
var gcb = xcb.global;
|
||||
var lcb = oRequest.callback;
|
||||
var oRet = oRequest.returnValue;
|
||||
if (response) {
|
||||
var cmd = (new DOMParser()).parseFromString(response, "text/xml");
|
||||
var seq=0;
|
||||
var child = cmd.documentElement.firstChild;
|
||||
xt.xml.processFragment(child, seq, oRequest);
|
||||
|
||||
if (null == xx.response.timeout)
|
||||
xt.queue.process(xx.response);
|
||||
|
||||
}
|
||||
return oRet;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
Function: submitRequestActiveX
|
||||
|
||||
Supresses the xajax.submitRequest() function call for IE in streaming calls.
|
||||
|
||||
*/
|
||||
|
||||
xjxEc.submitRequestActiveX = function(oRequest) {
|
||||
if (true == oRequest.comet) return;
|
||||
xjxEc.submitRequest(oRequest);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
variable setup. Detects IE and replaces the according functions
|
||||
|
||||
*/
|
||||
|
||||
|
||||
xjxEc.prepareRequest = xajax.prepareRequest;
|
||||
|
||||
xjxEc.stream_support = xjxEc.detectSupport();
|
||||
switch (xjxEc.stream_support)
|
||||
{
|
||||
case "Internet Explorer" :
|
||||
xajax.prepareRequest = xjxEc.prepareRequestActiveX;
|
||||
xjxEc.submitRequest=xajax.submitRequest;
|
||||
xajax.submitRequest=xjxEc.submitRequestActiveX;
|
||||
break;
|
||||
case "Firefox" :
|
||||
case "Safari" :
|
||||
xajax.prepareRequest = xjxEc.prepareRequestXHR;
|
||||
break;
|
||||
|
||||
|
||||
case "Opera" :
|
||||
xajax.prepareRequest = xjxEc.prepareRequestHTMLDRAFT;
|
||||
xjxEc.submitRequest=xajax.submitRequest;
|
||||
xajax.submitRequest=xjxEc.submitRequestActiveX;
|
||||
break;
|
||||
default : alert("Xajax.Ext.Comet: Your browser does not support comet streaming or is not yet supported by this plugin!");
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
Function: DOMParser
|
||||
|
||||
Prototype DomParser for IE/Opera
|
||||
|
||||
*/
|
||||
if (typeof DOMParser == "undefined") {
|
||||
DOMParser = function () {}
|
||||
|
||||
DOMParser.prototype.parseFromString = function (str, contentType) {
|
||||
if (typeof ActiveXObject != "undefined") {
|
||||
var d = new ActiveXObject("Microsoft.XMLDOM");
|
||||
d.loadXML(str);
|
||||
return d;
|
||||
} else if (typeof XMLHttpRequest != "undefined") {
|
||||
var req = new XMLHttpRequest;
|
||||
req.open("GET", "data:" + (contentType || "application/xml") +
|
||||
";charset=utf-8," + encodeURIComponent(str), false);
|
||||
if (req.overrideMimeType) {
|
||||
req.overrideMimeType(contentType);
|
||||
}
|
||||
req.send(null);
|
||||
return req.responseXML;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/*
|
||||
File: xajaxCometFunction.inc.php
|
||||
|
||||
Contains the xajaxCometFunction class
|
||||
|
||||
Title: xajaxCometFunction class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
/*
|
||||
@package xajax
|
||||
@version $Id: xajaxCometFunction.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
|
||||
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
|
||||
@license http://www.xajaxproject.org/bsd_license.txt BSD License
|
||||
*/
|
||||
|
||||
/*
|
||||
Class: xajaxCometFunction
|
||||
|
||||
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.
|
||||
*/
|
||||
class xajaxCometFunction
|
||||
{
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
var $sAlias;
|
||||
|
||||
/*
|
||||
Object: uf
|
||||
|
||||
A string or array which defines the function to be registered.
|
||||
*/
|
||||
var $uf;
|
||||
|
||||
/*
|
||||
String: sInclude
|
||||
|
||||
The path and file name of the include file that contains the function.
|
||||
*/
|
||||
var $sInclude;
|
||||
|
||||
/*
|
||||
Array: aConfiguration
|
||||
|
||||
An associative array containing call options that will be sent to the
|
||||
browser curing client script generation.
|
||||
*/
|
||||
var $aConfiguration;
|
||||
|
||||
/*
|
||||
Function: xajaxCometFunction
|
||||
|
||||
Constructs and initializes the <xajaxCometFunction> 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 - (string, optional): The path and file name of the include file
|
||||
that contains the class or function to be called.
|
||||
|
||||
$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 xajaxCometFunction($myFunction, 'myFile.inc.php', array(
|
||||
'method' => 'get',
|
||||
'mode' => 'synchronous'
|
||||
));
|
||||
|
||||
$xajax->register(XAJAX_FUNCTION, $myUserFunction);
|
||||
*/
|
||||
function xajaxCometFunction($uf, $sInclude=NULL, $aConfiguration=array())
|
||||
{
|
||||
$this->sAlias = '';
|
||||
$this->uf =& $uf;
|
||||
$this->sInclude = $sInclude;
|
||||
$this->aConfiguration = array();
|
||||
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 xajaxCometFunction.',
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
function configure($sName, $sValue)
|
||||
{
|
||||
if ('alias' == $sName)
|
||||
$this->sAlias = $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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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 "{ xjxcomet: '{$sFunction}' }, ";
|
||||
echo "{ parameters: arguments, mode:'comet'";
|
||||
|
||||
$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.
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
?>
|
||||
165
libraries/xajax/xajax_plugins/response/googleMap.inc.php
Normal file
165
libraries/xajax/xajax_plugins/response/googleMap.inc.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/*
|
||||
File: googleMap.inc.php
|
||||
|
||||
Contains a class that can be used to invoke DOM calls on the browser which
|
||||
will create or update a google map.
|
||||
|
||||
Title: clsGoogleMap class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
//$sBaseFolder = dirname(dirname(dirname(__FILE__)));
|
||||
//$sXajaxCore = $sBaseFolder . '/xajax_core';
|
||||
|
||||
//require $sXajaxCore . '/xajaxPlugin.inc.php';
|
||||
//require $sXajaxCore . '/xajaxPluginManager.inc.php';
|
||||
|
||||
/*
|
||||
Class: clsGoogleMap
|
||||
*/
|
||||
class clsGoogleMap extends xajaxResponsePlugin
|
||||
{
|
||||
/*
|
||||
String: sJavascriptURI
|
||||
|
||||
Used to store the base URI for where the javascript files are located. This
|
||||
enables the plugin to generate a script reference to it's javascript file
|
||||
if the javascript code is NOT inlined.
|
||||
*/
|
||||
var $sJavascriptURI;
|
||||
|
||||
/*
|
||||
Boolean: bInlineScript
|
||||
|
||||
Used to store the value of the inlineScript configuration option. When true,
|
||||
the plugin will return it's javascript code as part of the javascript header
|
||||
for the page, else, it will generate a script tag referencing the file by
|
||||
using the <clsTableUpdater->sJavascriptURI>.
|
||||
*/
|
||||
var $bInlineScript;
|
||||
|
||||
/*
|
||||
String: sGoogleSiteKey
|
||||
|
||||
The key that google has assigned to your site. Set this with <clsGoogleMap->setKey>
|
||||
*/
|
||||
|
||||
/*
|
||||
Function: clsTableUpdater
|
||||
|
||||
Constructs and initializes an instance of the table updater class.
|
||||
*/
|
||||
function clsGoogleMap()
|
||||
{
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Receives configuration settings set by <xajax> or user script calls to
|
||||
<xajax->configure>.
|
||||
|
||||
sName - (string): The name of the configuration option being set.
|
||||
mValue - (mixed): The value being associated with the configuration option.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('javascript URI' == $sName) {
|
||||
$this->sJavascriptURI = $mValue;
|
||||
} else if ('inlineScript' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bInlineScript = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase. This
|
||||
will either inline the script or insert a script tag which references the
|
||||
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
|
||||
configuration option.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
echo "\n<script src='http://maps.google.com/maps?file=api&v=2&key=";
|
||||
echo $this->sGoogleSiteKey;
|
||||
echo "' type='text/javascript'>\n</script>\n";
|
||||
|
||||
echo "\n<script type='text/javascript' charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
echo "maps = {};\n";
|
||||
|
||||
echo "xajax.commands['gm:cr'] = function(args) {\n";
|
||||
echo "\tmaps[args.data] = new GMap2(args.objElement);\n";
|
||||
echo "\tvar ptCenter = new GLatLng(0, 10);\n";
|
||||
echo "\tmaps[args.data].setCenter(ptCenter, 10);\n";
|
||||
echo "\tmaps[args.data].addControl(new GSmallMapControl());\n";
|
||||
echo "\tmaps[args.data].addControl(new GMapTypeControl());\n";
|
||||
echo "\tmaps[args.data].setMapType(maps[args.data].getMapTypes()[2]);\n";
|
||||
echo "}\n";
|
||||
|
||||
echo "xajax.commands['gm:zm'] = function(args) {\n";
|
||||
echo "\tmaps[args.id].setZoom(parseInt(args.data));\n";
|
||||
echo "}\n";
|
||||
|
||||
echo "xajax.commands['gm:sm'] = function(args) {\n";
|
||||
echo "\tvar ptCenter = new GLatLng(args.data[0], args.data[1]);\n";
|
||||
echo "\tvar markerNew = new GMarker(ptCenter);\n";
|
||||
echo "\tmarkerNew.text = args.data[2];\n";
|
||||
echo "\tmaps[args.id].addOverlay(markerNew);\n";
|
||||
echo "\tGEvent.addListener(maps[args.id], 'click', function(marker, point) {\n";
|
||||
echo "\t\tif (marker && undefined != marker.openInfoWindowHtml) {\n";
|
||||
echo "\t\t\tmarker.openInfoWindowHtml(marker.text);\n";
|
||||
echo "\t\t}\n";
|
||||
echo "\t} );\n";
|
||||
echo "}\n";
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
function setGoogleSiteKey($sKey)
|
||||
{
|
||||
$this->sGoogleSiteKey = $sKey;
|
||||
}
|
||||
|
||||
function create($sMap, $sParentId)
|
||||
{
|
||||
$command = array('n'=>'gm:cr', 't'=>$sParentId);
|
||||
$this->addCommand($command, $sMap);
|
||||
}
|
||||
function zoom($sMap, $nZoom) {
|
||||
$command = array('n'=>'gm:zm', 't'=>$sMap);
|
||||
$this->addCommand($command, $nZoom);
|
||||
}
|
||||
function setMarker($sMap, $nLat, $nLon, $sText) {
|
||||
$this->addCommand(
|
||||
array('n'=>'gm:sm', 't'=>$sMap),
|
||||
array($nLat, $nLon, $sText)
|
||||
);
|
||||
}
|
||||
function moveTo($sMap, $nLat, $nLon) {
|
||||
// 39.928005,
|
||||
// -82.70784,
|
||||
// 15);
|
||||
$command = array('n'=>'et_ar', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, $row);
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsGoogleMap());
|
||||
151
libraries/xajax/xajax_plugins/response/preloader/preload.inc.php
Normal file
151
libraries/xajax/xajax_plugins/response/preloader/preload.inc.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
|
||||
{
|
||||
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
|
||||
$sXajaxCore = $sBaseFolder . '/xajax_core';
|
||||
|
||||
if (false == class_exists('xajaxPlugin'))
|
||||
require $sXajaxCore . '/xajaxPlugin.inc.php';
|
||||
if (false == class_exists('xajaxPluginManager'))
|
||||
require $sXajaxCore . '/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
//require_once dirname(__FILE__) . '/xajaxCometPlugin.inc.php';
|
||||
|
||||
/*
|
||||
Class: clsTableUpdater
|
||||
*/
|
||||
class clsPreloader extends xajaxResponsePlugin
|
||||
{
|
||||
/*
|
||||
String: sDefer
|
||||
|
||||
Used to store the state of the scriptDeferral configuration setting. When
|
||||
script deferral is desired, this member contains 'defer' which will request
|
||||
that the browser defer loading of the javascript until the rest of the page
|
||||
has been loaded.
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
/*
|
||||
String: sJavascriptURI
|
||||
|
||||
Used to store the base URI for where the javascript files are located. This
|
||||
enables the plugin to generate a script reference to it's javascript file
|
||||
if the javascript code is NOT inlined.
|
||||
*/
|
||||
var $sJavascriptURI;
|
||||
|
||||
/*
|
||||
Boolean: bInlineScript
|
||||
|
||||
Used to store the value of the inlineScript configuration option. When true,
|
||||
the plugin will return it's javascript code as part of the javascript header
|
||||
for the page, else, it will generate a script tag referencing the file by
|
||||
using the <clsTableUpdater->sJavascriptURI>.
|
||||
*/
|
||||
var $bInlineScript;
|
||||
|
||||
|
||||
var $aScripts = array();
|
||||
var $aImages = array();
|
||||
var $aStyles = array();
|
||||
/*
|
||||
Function: clsTableUpdater
|
||||
|
||||
Constructs and initializes an instance of the table updater class.
|
||||
*/
|
||||
function clsPreloader()
|
||||
{
|
||||
$this->sDefer = '';
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = false;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Receives configuration settings set by <xajax> or user script calls to
|
||||
<xajax->configure>.
|
||||
|
||||
sName - (string): The name of the configuration option being set.
|
||||
mValue - (mixed): The value being associated with the configuration option.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('scriptDeferral' == $sName) {
|
||||
if (true === $mValue || false === $mValue) {
|
||||
if ($mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
}
|
||||
} else if ('javascript URI' == $sName) {
|
||||
$this->sJavascriptURI = $mValue;
|
||||
} else if ('inlineScript' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bInlineScript = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase. This
|
||||
will either inline the script or insert a script tag which references the
|
||||
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
|
||||
configuration option.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if ($this->bInlineScript)
|
||||
{
|
||||
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
include(dirname(__FILE__) . 'xajax_plugins/response/preloader/preload.js');
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
} else {
|
||||
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "xajax_plugins/response/preloader/preload.js' " . $this->sDefer . "charset='UTF-8'></script>\n";
|
||||
echo "\n<script type='text/javascript'>";
|
||||
print "try {";
|
||||
echo "
|
||||
try {
|
||||
if (undefined == xajax.ext)
|
||||
xajax.ext = {};
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (undefined == xajax.ext.preloader)
|
||||
xajax.ext.preloader = {};
|
||||
} catch (e) {
|
||||
alert('Could not create xajax.ext.preloader namespace');
|
||||
}
|
||||
|
||||
";
|
||||
echo "xajax.ext.preloader.aScripts = ".json_encode($this->aScripts).";\n";
|
||||
echo "xajax.ext.preloader.aStyles = ".json_encode($this->aStyles).";\n";
|
||||
echo "xajax.ext.preloader.aImages = ".json_encode($this->aImages).";\n";
|
||||
echo "xajax.ext.preloader.ready=true;";
|
||||
echo "} catch(ex) { alert(ex);}";
|
||||
echo "</script>";
|
||||
}
|
||||
}
|
||||
|
||||
function addScript($uri) {
|
||||
$this->aScripts[] = $uri;
|
||||
}
|
||||
function addImages($uri) {
|
||||
$this->aImages[] = $uri;
|
||||
}
|
||||
function addStyleSheet($uri) {
|
||||
$this->aStyles[] = $uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsPreloader());
|
||||
46
libraries/xajax/xajax_plugins/response/preloader/preload.js
Normal file
46
libraries/xajax/xajax_plugins/response/preloader/preload.js
Normal file
@@ -0,0 +1,46 @@
|
||||
try {
|
||||
if (undefined == xajax.ext)
|
||||
xajax.ext = {};
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (undefined == xajax.ext.preloader)
|
||||
xajax.ext.preloader = {};
|
||||
} catch (e) {
|
||||
alert("Could not create xajax.ext.preloader namespace");
|
||||
}
|
||||
|
||||
|
||||
xajax.ext.preloader.aScripts = [];
|
||||
xajax.ext.preloader.aImages = [];
|
||||
xajax.ext.preloader.aStyles = [];
|
||||
xajax.ext.preloader.ready = false;
|
||||
|
||||
xajax.ext.preloader.run = function() {
|
||||
if (!xajax.ext.preloader.ready)
|
||||
{
|
||||
window.setTimout(xajax.ext.preloader.run,200);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var splash = document.createElement("div");
|
||||
splash.id = "inhalt";
|
||||
document.body.appendChild(splash);
|
||||
|
||||
var l = xajax.ext.preloader.aScripts.length;
|
||||
for (i=0;i<l;++i)
|
||||
{
|
||||
var command =
|
||||
{
|
||||
data : xajax.ext.preloader.aScripts[i],
|
||||
onload : function() {alert(aScripts[i]+ " loaded");}
|
||||
}
|
||||
xajax.js.includeScript(command);
|
||||
splash.innerHTML += xajax.ext.preloader.aScripts[i]+"\n<br />\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.onload=xajax.ext.preloader.run;
|
||||
227
libraries/xajax/xajax_plugins/response/tableUpdater.inc.php
Normal file
227
libraries/xajax/xajax_plugins/response/tableUpdater.inc.php
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
/*
|
||||
File: tableUpdater.inc.php
|
||||
|
||||
Contains a class that can be used to invoke DOM calls on the browser which
|
||||
will create or update an HTML table.
|
||||
|
||||
Title: clsTableUpdater class
|
||||
|
||||
Please see <copyright.inc.php> for a detailed description, copyright
|
||||
and license information.
|
||||
*/
|
||||
|
||||
if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager'))
|
||||
{
|
||||
$sBaseFolder = dirname(dirname(dirname(__FILE__)));
|
||||
$sXajaxCore = $sBaseFolder . '/xajax_core';
|
||||
|
||||
if (false == class_exists('xajaxPlugin'))
|
||||
require $sXajaxCore . '/xajaxPlugin.inc.php';
|
||||
if (false == class_exists('xajaxPluginManager'))
|
||||
require $sXajaxCore . '/xajaxPluginManager.inc.php';
|
||||
}
|
||||
|
||||
/*
|
||||
Class: clsTableUpdater
|
||||
*/
|
||||
class clsTableUpdater extends xajaxResponsePlugin
|
||||
{
|
||||
/*
|
||||
String: sDefer
|
||||
|
||||
Used to store the state of the scriptDeferral configuration setting. When
|
||||
script deferral is desired, this member contains 'defer' which will request
|
||||
that the browser defer loading of the javascript until the rest of the page
|
||||
has been loaded.
|
||||
*/
|
||||
var $sDefer;
|
||||
|
||||
/*
|
||||
String: sJavascriptURI
|
||||
|
||||
Used to store the base URI for where the javascript files are located. This
|
||||
enables the plugin to generate a script reference to it's javascript file
|
||||
if the javascript code is NOT inlined.
|
||||
*/
|
||||
var $sJavascriptURI;
|
||||
|
||||
/*
|
||||
Boolean: bInlineScript
|
||||
|
||||
Used to store the value of the inlineScript configuration option. When true,
|
||||
the plugin will return it's javascript code as part of the javascript header
|
||||
for the page, else, it will generate a script tag referencing the file by
|
||||
using the <clsTableUpdater->sJavascriptURI>.
|
||||
*/
|
||||
var $bInlineScript;
|
||||
|
||||
/*
|
||||
Function: clsTableUpdater
|
||||
|
||||
Constructs and initializes an instance of the table updater class.
|
||||
*/
|
||||
function clsTableUpdater()
|
||||
{
|
||||
$this->sDefer = '';
|
||||
$this->sJavascriptURI = '';
|
||||
$this->bInlineScript = true;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: configure
|
||||
|
||||
Receives configuration settings set by <xajax> or user script calls to
|
||||
<xajax->configure>.
|
||||
|
||||
sName - (string): The name of the configuration option being set.
|
||||
mValue - (mixed): The value being associated with the configuration option.
|
||||
*/
|
||||
function configure($sName, $mValue)
|
||||
{
|
||||
if ('scriptDeferral' == $sName) {
|
||||
if (true === $mValue || false === $mValue) {
|
||||
if ($mValue) $this->sDefer = 'defer ';
|
||||
else $this->sDefer = '';
|
||||
}
|
||||
} else if ('javascript URI' == $sName) {
|
||||
$this->sJavascriptURI = $mValue;
|
||||
} else if ('inlineScript' == $sName) {
|
||||
if (true === $mValue || false === $mValue)
|
||||
$this->bInlineScript = $mValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function: generateClientScript
|
||||
|
||||
Called by the <xajaxPluginManager> during the script generation phase. This
|
||||
will either inline the script or insert a script tag which references the
|
||||
<tableUpdater.js> file based on the value of the <clsTableUpdater->bInlineScript>
|
||||
configuration option.
|
||||
*/
|
||||
function generateClientScript()
|
||||
{
|
||||
if ($this->bInlineScript)
|
||||
{
|
||||
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
|
||||
echo "/* <![CDATA[ */\n";
|
||||
|
||||
include(dirname(__FILE__) . '/tableUpdater.js');
|
||||
|
||||
echo "/* ]]> */\n";
|
||||
echo "</script>\n";
|
||||
} else {
|
||||
echo "\n<script type='text/javascript' src='" . $this->sJavascriptURI . "tableUpdater.js' " . $this->sDefer . "charset='UTF-8'>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
// tables
|
||||
function appendTable($table, $parent) {
|
||||
$command = array('n'=>'et_at', 't'=>$parent);
|
||||
$this->addCommand($command, $table);
|
||||
}
|
||||
function insertTable($table, $parent, $position) {
|
||||
$command = array('n'=>'et_it', 't'=>$parent, 'p'=>$position);
|
||||
$this->addCommand($command, $table);
|
||||
}
|
||||
function deleteTable($table) {
|
||||
$this->addCommand(array('n'=>'et_dt'), $table);
|
||||
}
|
||||
// rows
|
||||
function appendRow($row, $parent, $position = null) {
|
||||
$command = array('n'=>'et_ar', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, $row);
|
||||
}
|
||||
function insertRow($row, $parent, $position = null, $before = null) {
|
||||
$command = array('n'=>'et_ir', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
if (null != $before)
|
||||
$command['c'] = $before;
|
||||
$this->addCommand($command, $row);
|
||||
}
|
||||
function replaceRow($row, $parent, $position = null, $before = null) {
|
||||
$command = array('n'=>'et_rr', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
if (null != $before)
|
||||
$command['c'] = $before;
|
||||
$this->addCommand($command, $row);
|
||||
}
|
||||
function deleteRow($parent, $position = null) {
|
||||
$command = array('n'=>'et_dr', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, null);
|
||||
}
|
||||
function assignRow($values, $parent, $position = null, $start_column = null) {
|
||||
$command = array('n'=>'et_asr', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
if (null != $start_column)
|
||||
$command['c'] = $start_column;
|
||||
$this->addCommand($command, $values);
|
||||
}
|
||||
function assignRowProperty($property, $value, $parent, $position = null) {
|
||||
$command = array('n'=>'et_asr', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, array('p'=>$property, 'v'=>$value));
|
||||
}
|
||||
// columns
|
||||
function appendColumn($column, $parent, $position = null) {
|
||||
$command = array('n'=>'et_acol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, $column);
|
||||
}
|
||||
function insertColumn($column, $parent, $position = null) {
|
||||
$command = array('n'=>'et_icol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, $column);
|
||||
}
|
||||
function replaceColumn($column, $parent, $position = null) {
|
||||
$command = array('n'=>'et_rcol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, $column);
|
||||
}
|
||||
function deleteColumn($parent, $position = null) {
|
||||
$command = array('n'=>'et_dcol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, null);
|
||||
}
|
||||
function assignColumn($values, $parent, $position = null, $start_row = null) {
|
||||
$command = array('n'=>'et_ascol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
if (null != $start_row)
|
||||
$command['c'] = $start_row;
|
||||
$this->addCommand($command, $values);
|
||||
}
|
||||
function assignColumnProperty($property, $value, $parent, $position = null) {
|
||||
$command = array('n'=>'et_ascol', 't'=>$parent);
|
||||
if (null != $position)
|
||||
$command['p'] = $position;
|
||||
$this->addCommand($command, array('p'=>$property, 'v'=>$value));
|
||||
}
|
||||
function assignCell($row, $column, $value) {
|
||||
$this->addCommand(array('n'=>'et_asc', 't'=>$row, 'p'=>$column), $value);
|
||||
}
|
||||
function assignCellProperty($row, $column, $property, $value) {
|
||||
$this->addCommand(array('n'=>'et_asc', 't'=>$row, 'p'=>$column), array('p'=>$property, 'v'=>$value));
|
||||
}
|
||||
}
|
||||
|
||||
$objPluginManager =& xajaxPluginManager::getInstance();
|
||||
$objPluginManager->registerPlugin(new clsTableUpdater());
|
||||
499
libraries/xajax/xajax_plugins/response/tableUpdater.js
Normal file
499
libraries/xajax/xajax_plugins/response/tableUpdater.js
Normal file
@@ -0,0 +1,499 @@
|
||||
// if xajax has not yet been initialized, wait a second and try again
|
||||
// once xajax has been initialized, then install the table command
|
||||
// handlers.
|
||||
installTableUpdater = function() {
|
||||
var xjxReady = false;
|
||||
try {
|
||||
if (xajax) xjxReady = true;
|
||||
} catch (e) {
|
||||
}
|
||||
if (false == xjxReady) {
|
||||
setTimeout('installTableUpdater();', 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (undefined == xajax.ext.tables)
|
||||
xajax.ext.tables = {};
|
||||
} catch (e) {
|
||||
xajax.ext = {};
|
||||
xajax.ext.tables = {};
|
||||
}
|
||||
|
||||
// internal helper functions
|
||||
xajax.ext.tables.internal = {};
|
||||
xajax.ext.tables.internal.createTable = function(table) {
|
||||
if ('string' != typeof (table))
|
||||
throw { name: 'TableError', message: 'Invalid table name specified.' }
|
||||
var newTable = document.createElement('table');
|
||||
newTable.id = table;
|
||||
// save the column configuration
|
||||
xajax.ext.tables.appendHeader(table + '_header', newTable);
|
||||
xajax.ext.tables.appendBody(table + '_body', newTable);
|
||||
xajax.ext.tables.appendFooter(table + '_footer', newTable);
|
||||
return newTable;
|
||||
}
|
||||
xajax.ext.tables.internal.createRow = function(objects, id) {
|
||||
var row = document.createElement('tr');
|
||||
if (null != id)
|
||||
row.id = id;
|
||||
return row;
|
||||
}
|
||||
xajax.ext.tables.internal.createCell = function(objects, id) {
|
||||
var cell = document.createElement('td');
|
||||
if (null != id)
|
||||
cell.id = id;
|
||||
cell.innerHTML = '...';
|
||||
return cell;
|
||||
}
|
||||
xajax.ext.tables.internal.getColumnNumber = function(objects, cell) {
|
||||
var position;
|
||||
var columns = objects.header.getElementsByTagName('td');
|
||||
for (var column = 0; column < columns.length; ++column)
|
||||
if (columns[column].id == cell)
|
||||
return column;
|
||||
throw { name: 'TableError', message: 'Column not found. (getColumnNumber)' }
|
||||
return undefined;
|
||||
}
|
||||
xajax.ext.tables.internal.objectify = function(params, required) {
|
||||
if (undefined == params.source)
|
||||
return false;
|
||||
var source = params.source;
|
||||
if ('string' == typeof (source))
|
||||
source = xajax.$(source);
|
||||
if ('TBODY' == source.nodeName) {
|
||||
params.table = source.parentNode;
|
||||
} else if ('TABLE' == source.nodeName) {
|
||||
params.table = source;
|
||||
} else if ('TR' == source.nodeName) {
|
||||
params.row = source;
|
||||
params.body = source.parentNode;
|
||||
params.table = source.parentNode.parentNode;
|
||||
} else if ('TD' == source.nodeName) {
|
||||
params.cell = source;
|
||||
params.row = source.parentNode;
|
||||
params.columns = params.row.getElementsByTagName('TD');
|
||||
for (var column = 0; undefined == params.column && column < params.columns.length; ++column)
|
||||
if (params.cell.id == params.columns[column].id)
|
||||
params.column = column;
|
||||
params.table = source.parentNode.parentNode.parentNode;
|
||||
} else if ('THEAD' == source.nodeName) {
|
||||
params.table = source.parentNode;
|
||||
} else if ('TFOOT' == source.nodeName) {
|
||||
params.table = source.parentNode;
|
||||
} else
|
||||
params.source = source;
|
||||
|
||||
var bodies = params.table.getElementsByTagName('TBODY');
|
||||
if (0 < bodies.length)
|
||||
params.body = bodies[0];
|
||||
var headers = params.table.getElementsByTagName('THEAD');
|
||||
if (0 < headers.length)
|
||||
params.header = headers[0];
|
||||
var feet = params.table.getElementsByTagName('TFOOT');
|
||||
if (0 < feet.length)
|
||||
params.footer = feet[0];
|
||||
if (undefined != params.body)
|
||||
params.rows = params.body.getElementsByTagName('TR');
|
||||
if (undefined != params.row)
|
||||
params.cells = params.row.getElementsByTagName('TD');
|
||||
if (undefined != params.header)
|
||||
params.columns = params.header.getElementsByTagName('TD');
|
||||
|
||||
if (undefined == required)
|
||||
return true;
|
||||
|
||||
for (var index = 0; index < required.length; ++index) {
|
||||
var require = required[index];
|
||||
var is_defined = false;
|
||||
eval('is_defined = (undefined != params.' + require + ');');
|
||||
if (false == is_defined)
|
||||
throw { name: 'TableError', message: 'Unable to locate required object [' + require + '].' };
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// table
|
||||
xajax.ext.tables.append = function(table, parent) {
|
||||
if ('string' == typeof (parent))
|
||||
parent = xajax.$(parent);
|
||||
parent.appendChild(xajax.ext.tables.internal.createTable(table));
|
||||
}
|
||||
xajax.ext.tables.insert = function(table, parent, before) {
|
||||
if ('string' == typeof (parent))
|
||||
parent = xajax.$(parent);
|
||||
if ('string' == typeof (before))
|
||||
before = xajax.$(before);
|
||||
parent.insertBefore(xajax.ext.tables.internal.createTable(table), before);
|
||||
}
|
||||
xajax.ext.tables.remove = function(table) {
|
||||
var objects = { source: table };
|
||||
xajax.ext.tables.internal.objectify(objects, ['table']);
|
||||
objects.table.parentNode.removeChild(objects.table);
|
||||
}
|
||||
xajax.ext.tables.appendHeader = function(id, table) {
|
||||
var objects = { source: table };
|
||||
xajax.ext.tables.internal.objectify(objects, ['table']);
|
||||
if (undefined == objects.header) {
|
||||
var thead = document.createElement('thead');
|
||||
if (null != id)
|
||||
thead.id = id;
|
||||
objects.header = thead;
|
||||
thead.appendChild(xajax.ext.tables.internal.createRow(objects, null));
|
||||
if (undefined == objects.table.firstChild)
|
||||
table.appendChild(thead);
|
||||
else
|
||||
table.insertBefore(thead, table.firstChild);
|
||||
}
|
||||
}
|
||||
xajax.ext.tables.appendBody = function(id, table) {
|
||||
var objects = { source: table };
|
||||
xajax.ext.tables.internal.objectify(objects, ['table']);
|
||||
if (undefined == objects.body) {
|
||||
var tbody = document.createElement('tbody');
|
||||
if (null != id)
|
||||
tbody.id = id;
|
||||
objects.body = tbody;
|
||||
}
|
||||
if (undefined != objects.rows) {
|
||||
for (var rn = 0; rn < objects.rows.length; ++rn) {
|
||||
var row = objects.rows[rn];
|
||||
objects.table.removeChild(row);
|
||||
objects.body.appendChild(row);
|
||||
}
|
||||
}
|
||||
if (undefined != objects.footer)
|
||||
objects.table.insertBefore(objects.body, objects.footer);
|
||||
else
|
||||
objects.table.appendChild(objects.body);
|
||||
}
|
||||
xajax.ext.tables.appendFooter = function(id, table) {
|
||||
var objects = { source: table }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table']);
|
||||
if (undefined == objects.footer) {
|
||||
var tfoot = document.createElement('tfoot');
|
||||
if (null != id)
|
||||
tfoot.id = id;
|
||||
objects.footer = tfoot;
|
||||
tfoot.appendChild(xajax.ext.tables.internal.createRow(objects, null));
|
||||
objects.table.appendChild(tfoot);
|
||||
}
|
||||
}
|
||||
// rows
|
||||
xajax.ext.tables.rows = {}
|
||||
xajax.ext.tables.rows.internal = {}
|
||||
xajax.ext.tables.rows.internal.calculateRow = function(objects, position) {
|
||||
if (undefined == position)
|
||||
throw { name: 'TableError', message: 'Missing row number / id.' }
|
||||
if (undefined == objects.row)
|
||||
if (undefined != objects.rows)
|
||||
if (undefined != objects.rows[position])
|
||||
objects.row = objects.rows[position];
|
||||
if (undefined == objects.row)
|
||||
objects.row = xajax.$(position);
|
||||
if (undefined == objects.row)
|
||||
throw { name: 'TableError', message: 'Invalid row number / row id specified.' }
|
||||
}
|
||||
xajax.ext.tables.rows.append = function(id, table) {
|
||||
var objects = { source: table }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
|
||||
var row = xajax.ext.tables.internal.createRow(objects, id);
|
||||
if (undefined != objects.columns) {
|
||||
for (var column = 0; column < objects.columns.length; ++column) {
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, null);
|
||||
cell.innerHTML = '...';
|
||||
row.appendChild(cell);
|
||||
}
|
||||
}
|
||||
objects.body.appendChild(row);
|
||||
}
|
||||
xajax.ext.tables.rows.insert = function(id, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
|
||||
if (undefined == objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
var row = xajax.ext.tables.internal.createRow(objects, id);
|
||||
if (undefined != objects.columns) {
|
||||
for (var column = 0; column < objects.columns.length; ++column) {
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, null);
|
||||
cell.innerHTML = '...';
|
||||
row.appendChild(cell);
|
||||
}
|
||||
}
|
||||
objects.body.insertBefore(row, objects.row);
|
||||
}
|
||||
xajax.ext.tables.rows.replace = function(id, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
|
||||
if (undefined == objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
var row = xajax.ext.tables.internal.createRow(objects, id);
|
||||
if (undefined != objects.columns) {
|
||||
for (var column = 0; column < objects.columns.length; ++column) {
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, null);
|
||||
cell.innerHTML = '...';
|
||||
row.appendChild(cell);
|
||||
}
|
||||
}
|
||||
objects.body.insertBefore(row, objects.row);
|
||||
objects.body.removeChild(objects.row);
|
||||
}
|
||||
xajax.ext.tables.rows.remove = function(source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body']);
|
||||
if (undefined == objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
objects.body.removeChild(objects.row);
|
||||
}
|
||||
xajax.ext.tables.rows.assign = function(values, source, position, start_column) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'body', 'header']);
|
||||
if (undefined == objects.row)
|
||||
xajax.ext.tables.rows.internal.calculateRow(objects, position);
|
||||
if (undefined == start_column)
|
||||
start_column = 0;
|
||||
if ('object' == typeof (values) && undefined != values['p'] && undefined != values['v'])
|
||||
eval('objects.row.' + values['p'] + ' = values["v"];');
|
||||
else for (var column = 0; column < values.length; ++column)
|
||||
xajax.ext.tables.cells.assign(values[column], objects.row, start_column + column);
|
||||
}
|
||||
// columns
|
||||
xajax.ext.tables.columns = {}
|
||||
xajax.ext.tables.columns.internal = {}
|
||||
xajax.ext.tables.columns.internal.calculateColumn = function(objects, position) {
|
||||
if (undefined == position)
|
||||
throw { name: 'TableError', message: 'Missing column number / id.' }
|
||||
if (undefined == objects.column)
|
||||
if (undefined != objects.columns)
|
||||
if (undefined != objects.columns[position])
|
||||
objects.column = position;
|
||||
if (undefined == objects.column)
|
||||
for (var column = 0; undefined == objects.column && column < objects.columns.length; ++column)
|
||||
if (objects.columns[column].id == position)
|
||||
objects.column = column;
|
||||
if (undefined == objects.column)
|
||||
throw { name: 'TableError', message: 'Invalid column number / row id specified.' }
|
||||
}
|
||||
xajax.ext.tables.columns.append = function(column_definition, table) {
|
||||
var objects = { source: table }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'header', 'body']);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, column_definition.id);
|
||||
if (undefined != column_definition.name)
|
||||
cell.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.appendChild(cell);
|
||||
if (undefined != objects.rows)
|
||||
for (var i = 0; i < objects.rows.length; ++i)
|
||||
xajax.ext.tables.cells.append({id: null}, objects.rows[i]);
|
||||
}
|
||||
xajax.ext.tables.columns.insert = function(column_definition, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'header']);
|
||||
if (undefined == objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
var column = xajax.ext.tables.internal.createCell(objects, column_definition.id);
|
||||
if (undefined != column_definition.name)
|
||||
column.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.insertBefore(column, objects.columns[objects.column]);
|
||||
if (undefined != objects.rows)
|
||||
for (var i = 0; i < objects.rows.length; ++i)
|
||||
xajax.ext.tables.cells.insert({id: null}, objects.rows[i], objects.column);
|
||||
}
|
||||
xajax.ext.tables.columns.replace = function(column_definition, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'header', 'columns']);
|
||||
if (undefined == objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
var before = objects.columns[objects.column];
|
||||
var column = xajax.ext.tables.internal.createCell(objects, column_definition.id);
|
||||
if (undefined != column_definition.name)
|
||||
column.innerHTML = column_definition.name;
|
||||
objects.header.firstChild.insertBefore(column, before);
|
||||
objects.header.firstChild.removeChild(before);
|
||||
if (undefined != objects.rows)
|
||||
for (var i = 0; i < objects.rows.length; ++i)
|
||||
xajax.ext.tables.cells.replace({id: null}, objects.rows[i], objects.column);
|
||||
}
|
||||
xajax.ext.tables.columns.remove = function(source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'header']);
|
||||
if (undefined == objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
objects.header.firstChild.removeChild(objects.columns[objects.column]);
|
||||
if (undefined != objects.rows)
|
||||
for (var i = 0; i < objects.rows.length; ++i)
|
||||
xajax.ext.tables.cells.remove(objects.rows[i], objects.column);
|
||||
}
|
||||
xajax.ext.tables.columns.assign = function(values, source, position, start_row) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'cell']);
|
||||
if (undefined == objects.column)
|
||||
xajax.ext.tables.columns.internal.calculateColumn(objects, position);
|
||||
if ('object' == typeof(values) && undefined != values['p'] && undefined != values['v'])
|
||||
for (var row = 0; row < objects.rows.length; ++row)
|
||||
xajax.ext.tables.cells.assign(values, objects.rows[row], objects.column);
|
||||
else for (var row = 0; row < values.length; ++row)
|
||||
xajax.ext.tables.cells.assign(values[row], objects.rows[start_row + row], objects.column);
|
||||
}
|
||||
// cells
|
||||
xajax.ext.tables.cells = {}
|
||||
xajax.ext.tables.cells.internal = {}
|
||||
xajax.ext.tables.cells.internal.calculateCell = function(objects, position) {
|
||||
if (undefined == position)
|
||||
throw { name: 'TableError', message: 'Missing cell number / id.' }
|
||||
if (undefined == objects.cell)
|
||||
if (undefined != objects.cells)
|
||||
if (undefined != objects.cells[position])
|
||||
objects.cell = objects.cells[position];
|
||||
if (undefined == objects.cell)
|
||||
if (undefined != objects.columns)
|
||||
for (var column = 0; undefined == objects.cell && column < objects.columns.length; ++column)
|
||||
if (objects.columns[column].id == position)
|
||||
objects.cell = objects.cells[column];
|
||||
if (undefined == objects.cell)
|
||||
throw { name: 'TableError', message: 'Invalid cell number / id specified.' }
|
||||
}
|
||||
xajax.ext.tables.cells.append = function(cell_definition, source) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
|
||||
if (undefined != cell_definition.name)
|
||||
cell.innerHTML = cell_definition.name;
|
||||
objects.row.appendChild(cell);
|
||||
}
|
||||
xajax.ext.tables.cells.insert = function(cell_definition, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
if (undefined == objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
|
||||
if (undefined != cell_definition.name)
|
||||
cell.innerHTML = cell_definition.name;
|
||||
objects.row.insertBefore(cell, objects.cell);
|
||||
}
|
||||
xajax.ext.tables.cells.replace = function(cell_definition, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
if (undefined == objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
var cell = xajax.ext.tables.internal.createCell(objects, cell_definition.id);
|
||||
if (undefined != cell_definition.name)
|
||||
cell.innerHTML = cell_definition.name;
|
||||
objects.row.insertBefore(cell, objects.cell);
|
||||
objects.row.removeChild(objects.cell);
|
||||
}
|
||||
xajax.ext.tables.cells.remove = function(source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
if (undefined == objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
objects.row.removeChild(objects.cell);
|
||||
}
|
||||
xajax.ext.tables.cells.assign = function(value, source, position) {
|
||||
var objects = { source: source }
|
||||
xajax.ext.tables.internal.objectify(objects, ['table', 'row']);
|
||||
if (undefined == objects.cell)
|
||||
xajax.ext.tables.cells.internal.calculateCell(objects, position);
|
||||
if ('object' == typeof (value) && undefined != value['p'] && undefined != value['v']) {
|
||||
eval('objects.cell.' + value['p'] + ' = value["v"];');
|
||||
} else
|
||||
objects.cell.innerHTML = value;
|
||||
}
|
||||
|
||||
// command handlers
|
||||
|
||||
// tables
|
||||
xajax.commands['et_at'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.append';
|
||||
xajax.ext.tables.append(args.data, args.id);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_it'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.insert';
|
||||
xajax.ext.tables.insert(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_dt'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.remove';
|
||||
xajax.ext.tables.remove(args.data);
|
||||
return true;
|
||||
}
|
||||
// rows
|
||||
xajax.commands['et_ar'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.rows.append';
|
||||
xajax.ext.tables.rows.append(args.data, args.id);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_ir'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.rows.insert';
|
||||
xajax.ext.tables.rows.insert(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_rr'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.rows.replace';
|
||||
xajax.ext.tables.rows.replace(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_dr'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.rows.remove';
|
||||
xajax.ext.tables.rows.remove(args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_asr'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.rows.assign';
|
||||
xajax.ext.tables.rows.assign(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
// columns
|
||||
xajax.commands['et_acol'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.columns.append';
|
||||
xajax.ext.tables.columns.append(args.data, args.id);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_icol'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.columns.insert';
|
||||
xajax.ext.tables.columns.insert(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_rcol'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.columns.replace';
|
||||
xajax.ext.tables.columns.replace(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_dcol'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.columns.remove';
|
||||
xajax.ext.tables.columns.remove(args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_ascol'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.columns.assign';
|
||||
xajax.ext.tables.columns.assign(args.data, args.id, args.property, args.type);
|
||||
return true;
|
||||
}
|
||||
// cells
|
||||
xajax.commands['et_ac'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.cells.append';
|
||||
xajax.ext.tables.cells.append(args.data, args.id);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_ic'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.cells.insert';
|
||||
xajax.ext.tables.cells.insert(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_rc'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.cells.replace';
|
||||
xajax.ext.tables.cells.replace(args.data, args.id, args.property);
|
||||
}
|
||||
xajax.commands['et_dc'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.cells.remove';
|
||||
xajax.ext.tables.cells.remove(args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
xajax.commands['et_asc'] = function(args) {
|
||||
args.cmdFullName = 'ext.tables.cells.assign';
|
||||
xajax.ext.tables.cells.assign(args.data, args.id, args.property);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
installTableUpdater();
|
||||
Reference in New Issue
Block a user