diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2007-07-10 19:02:29 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2007-07-10 19:02:29 +0000 |
| commit | b937bb56c3c4fb68010996f131084b3d4b661b3e (patch) | |
| tree | 960fc86f09644d02934f0980f7aa37e5cb010601 | |
| parent | 25bd51e71f0c8eeb160d4f00892060dd5e507f54 (diff) | |
| download | themes-b937bb56c3c4fb68010996f131084b3d4b661b3e.tar.gz themes-b937bb56c3c4fb68010996f131084b3d4b661b3e.tar.bz2 themes-b937bb56c3c4fb68010996f131084b3d4b661b3e.zip | |
move loadAjax() to BitThemes
| -rw-r--r-- | BitThemes.php | 29 | ||||
| -rw-r--r-- | templates/footer_inc.tpl | 4 |
2 files changed, 31 insertions, 2 deletions
diff --git a/BitThemes.php b/BitThemes.php index 6baafd3..a9aa515 100644 --- a/BitThemes.php +++ b/BitThemes.php @@ -14,6 +14,12 @@ class BitThemes extends BitBase { // an array with style information var $mStyles = array(); + // Ajax framework that will be used for current page view + var $mAjax = NULL; + + // Ajax libraries needed by current Ajax framework (MochiKit libs, etc.) + var $mAjaxLibs = array(); + @@ -1074,6 +1080,29 @@ class BitThemes extends BitBase { return(( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) || !empty( $_REQUEST['ajax_xml'] )); } + /** + * Load Ajax libraries + * + * @param array $pAjaxLib Name of the library we want to use e.g.: prototype or mochikit + * @param array $pLibHash Array of additional libraries we need to load + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function loadAjax( $pAjaxLib, $pLibHash=NULL ) { + global $gBitSmarty, $gSniffer; + $ret = FALSE; + $ajaxLib = strtolower( $pAjaxLib ); + if( $gSniffer->_browser_info['javascript'] ) { + if( $ret = ( empty( $this->mAjaxLib ) || $this->mAjaxLib == $ajaxLib ) ) { + $this->mAjax = $ajaxLib; + if( is_array( $pLibHash ) ) { + $this->mAjaxLibs = array_merge( $this->mAjaxLibs, $pLibHash ); + } + } + } + return $ret; + } + diff --git a/templates/footer_inc.tpl b/templates/footer_inc.tpl index 48a70eb..311ddbe 100644 --- a/templates/footer_inc.tpl +++ b/templates/footer_inc.tpl @@ -1,5 +1,5 @@ -{if $gBitSystem->mAjax == 'prototype'} - {foreach from=$gBitSystem->mAjaxLibs item=ajaxLib} +{if $gBitThemes->mAjax == 'prototype'} + {foreach from=$gBitThemes->mAjaxLibs item=ajaxLib} {if $ajaxLib == 'debugger.js'} <div id="jsdebug" style="padding:1em; margin:1em; border:0.5em solid #900; background:#fff; color:#000;">Prototype Debugger:<br /></div> {/if} |
