diff --git a/e107_admin/header.php b/e107_admin/header.php
index 779e06eab..47f5d1fad 100644
--- a/e107_admin/header.php
+++ b/e107_admin/header.php
@@ -12,9 +12,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/header.php,v $
-| $Revision: 1.45 $
-| $Date: 2009-08-31 13:12:03 $
-| $Author: e107coders $
+| $Revision: 1.46 $
+| $Date: 2009-09-29 17:40:56 $
+| $Author: secretr $
+---------------------------------------------------------------+
*/
@@ -25,6 +25,10 @@ if(!defined('ADMIN_AREA'))
define("ADMIN_AREA", TRUE);
}
define("USER_AREA", FALSE);
+
+// Header included notification
+define('HEADER_INIT', TRUE);
+
$sql->db_Mark_Time('(Header Top)');
//
@@ -214,23 +218,30 @@ else
define("e_WYSIWYG",FALSE);
}
-// Load Javascript Libraries
-$hash = md5(serialize(varset($pref['e_jslib'])).serialize(varset($THEME_JSLIB)).THEME.e_LANGUAGE.ADMIN).'_admin';
-//echo "\n";
+// [JSManager] Load JS Includes - Zone 1 - Before Library
+e107::getJs()->renderJs('header', 1);
+e107::getJs()->renderJs('header_inline', 1);
+
+// Load Javascript Library consolidation script
+// TODO - option to call libraries external (admin preferences)
+$hash = md5(serialize(varset($pref['e_jslib'])).THEME.e_LANGUAGE.ADMIN).'_admin'; //FIXME - hash is wrong, move this to e_jsmanager?
echo "\n";
-//if (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE) {
- //echo "\n";
-//}
- if (file_exists(THEME.'theme.js')) { echo "\n"; }
- if (is_readable(e_FILE.'user.js') && filesize(e_FILE.'user.js')) { echo "\n"; }
+// [JSManager] Load JS Includes - Zone 2 - After Library, before CSS
+e107::getJs()->renderJs('header', 2);
+e107::getJs()->renderJs('header_inline', 2);
+//DEPRECATED - use e107::getJs()->headerFile('{e_PLUGIN}myplug/js/my.js', $zone = 2)
if (isset($eplug_js) && $eplug_js) {
echo "\n\n";
echo "\n";
}
+//FIXME - theme.js/user.js should be registered/rendered through e_jsmanager
+ if (file_exists(THEME.'theme.js')) { echo "\n"; }
+ if (is_readable(e_FILE.'user.js') && filesize(e_FILE.'user.js')) { echo "\n"; }
+
if ((strpos(e_SELF, 'fileinspector.php') === FALSE) && getperms("0"))
{
@@ -264,8 +275,6 @@ if((isset($pref['enable_png_image_fix']) && $pref['enable_png_image_fix'] == tru
echo "\n";
}
-if (function_exists('headerjs')){echo headerjs(); }
-
//
// E: Send CSS
//
@@ -279,6 +288,10 @@ if (isset($eplug_css) && $eplug_css) {
}
echo "\n";
+if (!isset($no_core_css) || !$no_core_css)
+{
+ echo "\n";
+}
//NEW - Iframe mod
if (!defsettrue('e_IFRAME') && isset($pref['admincss']) && $pref['admincss'] && file_exists(THEME.$pref['admincss']))
{
@@ -296,12 +309,16 @@ else
$css_file = file_exists(THEME.'admin_style.css') ? THEME_ABS.'admin_style.css' : THEME_ABS.'style.css';
echo "\n";
}
-if (!isset($no_core_css) || !$no_core_css)
-{
- echo "\n";
-}
+
+// [JSManager] Load JS Includes - Zone 3 - After Theme CSS, before e_meta and headerjs()
+e107::getJs()->renderJs('header', 3);
+e107::getJs()->renderJs('header_inline', 3);
+
+//XXX - do we still need it?
+if (function_exists('headerjs')){echo headerjs(); }
+
//
// F: Send Meta Tags and Icon links
//
@@ -320,6 +337,10 @@ if (vartrue($pref['e_meta_list']))
}
}
+// [JSManager] Load JS Includes - Zone 4 - After e_meta
+e107::getJs()->renderJs('header', 4);
+e107::getJs()->renderJs('header_inline', 4);
+
// ---------- Favicon ---------
if (file_exists(THEME."favicon.ico")) {
@@ -357,6 +378,7 @@ $body_onload = "";
/*
* Admin LAN
+ * TODO - remove it from here
*/
require_once(e_HANDLER.'js_helper.php');
echo "
@@ -367,8 +389,14 @@ echo "
";
+// [JSManager] Load JS Includes - Zone 5 - After theme_head, before e107:loaded trigger
+e107::getJs()->renderJs('header', 5);
+e107::getJs()->renderJs('header_inline', 5);
+
/*
- * Fire Event e107:loaded
+ * Fire Event e107:loaded
+ * TODO - remove it from here, should be registered to e_jsmanager
+ * or better - moved to core init.js(.php)
*/
echo "';
+ echo "\n";
+ continue;
+ }
+ include_once($tp->replaceConstants($path, ''));
+ echo "\n";
}
else
{
- echo file_get_contents($tp->replaceConstants($text, ''));
- echo "\n\n";
+ if($external)
+ {
+ echo '';
+ echo "\n";
+ continue;
+ }
+ echo file_get_contents($tp->replaceConstants($path, ''));
+ echo "\n";
}
}
}
/**
* Render JS source array
- * @param object $js_content_array
- * @return
+ *
+ * @param array $js_content_array
+ * @param string $label added as comment if non-empty
+ * @return void
*/
- public function renderInline($js_content_array)
+ public function renderInline($js_content_array, $label = '')
{
if(empty($js_content_array))
{
return '';
}
- echo "\n\n";
- echo '';
- echo "\n\n";
+ echo "\n";
}
/**
@@ -406,7 +656,7 @@ class e_js_manager
* Set current script location
*
* @param object $is true - back-end, false - front-end
- * @return e_js_manager
+ * @return e_jsmanager
*/
public function setInAdmin($is)
{
@@ -424,5 +674,34 @@ class e_js_manager
return ($this->isInAdmin() ? 'admin' : 'front');
}
+ /**
+ * Get current theme name
+ *
+ * @return string
+ */
+ public function getCurrentTheme()
+ {
+ return ($this->isInAdmin() ? e107::getPref('admintheme') : e107::getPref('sitetheme'));
+ }
+ /**
+ * Get browser cache id
+ *
+ * @return integer
+ */
+ public function getCacheId()
+ {
+ return $this->_cache_id;
+ }
+
+ /**
+ * Set browser cache id
+ *
+ * @return e_jsmanager
+ */
+ public function setCacheId($cacheid)
+ {
+ $this->_cache_id = $cacheid;
+ return $this;
+ }
}
diff --git a/e107_handlers/jslib_handler.php b/e107_handlers/jslib_handler.php
index 9f8b52097..43db09e62 100644
--- a/e107_handlers/jslib_handler.php
+++ b/e107_handlers/jslib_handler.php
@@ -7,8 +7,8 @@
* GNU General Public License (http://gnu.org).
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $
- * $Revision: 1.5 $
- * $Date: 2009-09-28 19:17:58 $
+ * $Revision: 1.6 $
+ * $Date: 2009-09-29 17:40:55 $
* $Author: secretr $
*
*/
@@ -17,7 +17,7 @@ global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
class e_jslib
{
- function e_jslib()
+ function __construct()
{
}
@@ -36,14 +36,23 @@ class e_jslib
*/
function core_run()
{
- global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
+ //global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
ob_start();
ob_implicit_flush(0);
header("Last-modified: " . gmdate("D, d M Y H:i:s",mktime(0,0,0,15,2,2004)) . " GMT");
header('Content-type: text/javascript', TRUE);
-
+
+ $e_jsmanager = e107::getJs();
+ $e_jsmanager->renderJs('core', null, false);
+ $e_jsmanager->renderJs('plugin', null, false);
+ $e_jsmanager->renderJs('theme', null, false);
+
+
+ //Output
+ $this->content_out();
+ /*
//array - uses the same format as $core_jslib
if (!isset($THEME_CORE_JSLIB) || ! is_array($THEME_CORE_JSLIB))
$THEME_CORE_JSLIB = array();
@@ -65,7 +74,7 @@ class e_jslib
$where_now = $eplug_admin ? 'admin' : 'front';
//1. Core libs - prototype + scriptaculous effects
- echo "/* Prototype/Scriptaculous/Core libraries */\n";
+ echo "// Prototype/Scriptaculous/Core libraries \n";
foreach ($core_jslib as $core_path => $where)
{
if ($where != 'all' && $where != $where_now)
@@ -84,9 +93,9 @@ class e_jslib
}
//2. Plugins output - all 3-rd party libs
- if (varset($pref['e_jslib']))
+ if (varsettrue($pref['e_jslib_plugin']))
{
- foreach ($pref['e_jslib']['plugins'] as $plugin_name => $plugin_libs)
+ foreach ($pref['e_jslib_plugin'] as $plugin_name => $plugin_libs)
{
if ($plugin_libs)
{
@@ -98,7 +107,7 @@ class e_jslib
$lib_path = $plugin_name . '/' . trim($plugin_lib, '/');
- echo "/* $plugin_name libraries */\n\n";
+ echo "// $plugin_name libraries \n\n";
if (substr($plugin_lib, - 4) == '.php')
{
@@ -118,7 +127,7 @@ class e_jslib
//3. Theme libs
if (varset($THEME_JSLIB) && is_array($THEME_JSLIB))
{
- echo "/* Theme libraries */\n\n";
+ echo "// Theme libraries \n\n";
foreach ($THEME_JSLIB as $lib_path => $where)
{
if ($where != 'all' && $where != $where_now)
@@ -136,9 +145,7 @@ class e_jslib
}
}
}
-
- //Output
- $this->content_out();
+*/
}
/**