summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitThemes.php29
-rw-r--r--templates/footer_inc.tpl4
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}