1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

JS manager CSS handling done, experimental feature - send CSS to site header from footer (work in progress). Calendar handler modfied to work with all new enhancements.

This commit is contained in:
secretr
2010-01-12 07:38:29 +00:00
parent aecec3967e
commit b56a380e86
4 changed files with 185 additions and 88 deletions

View File

@@ -9,9 +9,9 @@
* Admin Footer
*
* $Source: /cvs_backup/e107_0.8/e107_admin/footer.php,v $
* $Revision: 1.17 $
* $Date: 2009-11-18 01:04:25 $
* $Author: e107coders $
* $Revision: 1.18 $
* $Date: 2010-01-12 07:38:29 $
* $Author: secretr $
*/
if (!defined('e107_INIT'))
{
@@ -306,7 +306,63 @@ echo "</body></html>";
//
// I Send the buffered page data, along with appropriate headers
//
$page = ob_get_clean();
// SecretR - EXPERIMENT! SEND CSS data to header. Performance tests in progress.
$tmp = array();
$e_js = e107::getJs();
// Other CSS - from unknown location, different from core/theme/plugin location or backward compatibility
$tmp1 = $e_js->renderJs('other_css', false, 'css', true);
if($tmp1)
{
$tmp['search'][] = '<!-- footer_other_css -->';
$tmp['replace'][] = $tmp1;
}
// Core CSS
$tmp1 = $e_js->renderJs('core_css', false, 'css', true);
if($tmp1)
{
$tmp['search'][] = '<!-- footer_core_css -->';
$tmp['replace'][] = $tmp1;
}
// Plugin CSS
$tmp1 = $e_js->renderJs('plugin_css', false, 'css', true);
if($tmp1)
{
$tmp['search'][] = '<!-- footer_plugin_css -->';
$tmp['replace'][] = $tmp1;
}
//echo "<!-- Theme css -->\n";
$tmp1 = $e_js->renderJs('theme_css', false, 'css', true);
if($tmp1)
{
$tmp['search'][] = '<!-- footer_theme_css -->';
$tmp['replace'][] = $tmp1;
}
// Inline CSS - not sure if this should stay at all!
$tmp1 = $e_js->renderJs('inline_css', false, 'css', true);
if($tmp1)
{
$tmp['search'][] = '<!-- footer_inline_css -->';
$tmp['replace'][] = $tmp1;
}
if($tmp)
{
$page = str_replace($tmp['search'], $tmp['replace'], ob_get_clean());
}
else
{
$page = ob_get_clean();
}
unset($tmp1, $tmp1);
$etag = md5($page);
header("Cache-Control: must-revalidate");

View File

@@ -9,8 +9,8 @@
* Admin Header
*
* $Source: /cvs_backup/e107_0.8/e107_admin/header.php,v $
* $Revision: 1.55 $
* $Date: 2009-11-28 15:32:47 $
* $Revision: 1.56 $
* $Date: 2010-01-12 07:38:29 $
* $Author: secretr $
*/
@@ -37,8 +37,8 @@ $sql->db_Mark_Time('(Header Top)');
// A: Admin Defines and Links
// B: Send HTTP headers that come before any html
// C: Send start of HTML
// D: Send JS
// E: Send CSS
// D: Send CSS
// E: Send JS
// F: Send Meta Tags and Icon links
// G: Send final theme headers (theme_head() function)
// H: Generate JS for image preloading (setup for onload)
@@ -105,7 +105,105 @@ echo(defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_
echo "<title>".LAN_head_4.(defined("e_PAGETITLE") ? " - ".e_PAGETITLE : (defined("PAGE_NAME") ? ": ".PAGE_NAME : ""))." :: ".SITENAME."</title>\n";
//
// D: Send JS
// D: Send CSS
//
echo "<!-- *CSS* -->\n";
$e_js = e107::getJs();
if (isset($eplug_css) && $eplug_css)
{
//echo "\n<!-- eplug_css -->\n";
//echo "<link rel='stylesheet' href='{$eplug_css}' type='text/css' />\n";
$e_js->otherCSS('{e_FILE}e107.css');
}
if (!isset($no_core_css) || !$no_core_css)
{
//echo "<link rel='stylesheet' href='".e_FILE_ABS."e107.css' type='text/css' />\n";
$e_js->otherCSS('{e_FILE}e107.css');
}
//NEW - Iframe mod
if (!defsettrue('e_IFRAME') && isset($pref['admincss']) && $pref['admincss'])
{
$css_file = file_exists(THEME.'admin_'.$pref['admincss']) ? 'admin_'.$pref['admincss'] : $pref['admincss'];
//echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
$e_js->themeCSS($css_file);
}
elseif (isset($pref['themecss']) && $pref['themecss'])
{
$css_file = file_exists(THEME.'admin_'.$pref['themecss']) ? 'admin_'.$pref['themecss'] : $pref['themecss'];
//echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
$e_js->themeCSS($css_file);
}
else
{
$css_file = file_exists(THEME.'admin_style.css') ? 'admin_style.css' : 'style.css';
//echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
$e_js->themeCSS($css_file);
}
// FIXME: TEXTDIRECTION compatibility CSS (marj?)
// TODO: probably better to externalise along with some other things above
// possibility to overwrite some CSS definition according to TEXTDIRECTION
// especially usefull for rtl.css
// see _blank theme for examples
if(defined('TEXTDIRECTION') && file_exists(THEME.'/'.strtolower(TEXTDIRECTION).'.css'))
{
//echo '
//<link rel="stylesheet" href="'.THEME_ABS.strtolower(TEXTDIRECTION).'.css" type="text/css" media="all" />';
$e_js->themeCSS(strtolower(TEXTDIRECTION).'.css');
}
// ################### RENDER CSS
// Other CSS - from unknown location, different from core/theme/plugin location or backward compatibility
$e_js->renderJs('other_css', false, 'css', false);
echo "\n<!-- footer_other_css -->\n";
// Core CSS
$e_js->renderJs('core_css', false, 'css', false);
echo "\n<!-- footer_core_css -->\n";
// Plugin CSS
$e_js->renderJs('plugin_css', false, 'css', false);
echo "\n<!-- footer_plugin_css -->\n";
// Theme CSS
//echo "<!-- Theme css -->\n";
$e_js->renderJs('theme_css', false, 'css', false);
echo "\n<!-- footer_theme_css -->\n";
// Inline CSS - not sure if this should stay at all!
$e_js->renderJs('inline_css', false, 'css', false);
echo "\n<!-- footer_inline_css -->\n";
//
// Unobtrusive JS via CSS, prevent 3rd party code overload
//
require_once(e_FILE."/e_css.php");
//iepngfix - IE6 only
if ((isset($pref['enable_png_image_fix']) && $pref['enable_png_image_fix'] == true) || (isset($sleight) && $sleight == true))
{
/*
* The only problem is that the browser is REALLY,
* REALLY slow when it has to render more elements
* try e.g. "div, img, td, input" (or just *) instead only img rule
* However I hope this will force IE6 user to hate it :)
*/
echo "<!--[if lte IE 6]>\n";
echo "<style type='text/css'>\n";
echo "img {\n";
echo " behavior: url('".e_FILE_ABS."iepngfix.htc.php');\n";
echo "}\n";
echo "</style>\n";
echo "<![endif]-->\n";
}
//
// E: Send JS
//
echo "<!-- *JS* -->\n";
@@ -166,59 +264,9 @@ function savepreset(ps,pid){
</script>\n";
}
//iepngfix - IE6 only
if ((isset($pref['enable_png_image_fix']) && $pref['enable_png_image_fix'] == true) || (isset($sleight) && $sleight == true))
{
/*
* The only problem is that the browser is REALLY,
* REALLY slow when it has to render more elements
* try e.g. "div, img, td, input" (or just *) instead only img rule
* However I hope this will force IE6 user to hate it :)
*/
echo "<!--[if lte IE 6]>\n";
echo "<style type='text/css'>\n";
echo "img {\n";
echo " behavior: url('".e_FILE_ABS."iepngfix.htc.php');\n";
echo "}\n";
echo "</style>\n";
echo "<![endif]-->\n";
}
//
// E: Send CSS
//
echo "<!-- *CSS* -->\n";
if (isset($eplug_css) && $eplug_css)
{
echo "\n<!-- eplug_css -->\n";
echo "<link rel='stylesheet' href='{$eplug_css}' type='text/css' />\n";
}
echo "<!-- Theme css -->\n";
if (!isset($no_core_css) || !$no_core_css)
{
echo "<link rel='stylesheet' href='".e_FILE_ABS."e107.css' type='text/css' />\n";
}
//NEW - Iframe mod
if (!defsettrue('e_IFRAME') && isset($pref['admincss']) && $pref['admincss'] && file_exists(THEME.$pref['admincss']))
{
$css_file = file_exists(THEME.'admin_'.$pref['admincss']) ? THEME_ABS.'admin_'.$pref['admincss'] : THEME_ABS.$pref['admincss'];
echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
}
elseif (isset($pref['themecss']) && $pref['themecss'] && file_exists(THEME.$pref['themecss']))
{
$css_file = file_exists(THEME.'admin_'.$pref['themecss']) ? THEME_ABS.'admin_'.$pref['themecss'] : THEME_ABS.$pref['themecss'];
echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
}
else
{
$css_file = file_exists(THEME.'admin_style.css') ? THEME_ABS.'admin_style.css' : THEME_ABS.'style.css';
echo "<link rel='stylesheet' href='".$css_file."' type='text/css' />\n";
}
// [JSManager] Load JS Includes - Zone 3 - After Theme CSS, before e_meta and headerjs()
// [JSManager] Load JS Includes - Zone 3 - before e_meta and headerjs()
e107::getJs()->renderJs('header', 3);
e107::getJs()->renderJs('header_inline', 3);
@@ -279,21 +327,6 @@ if (function_exists('theme_head'))
echo theme_head();
}
// FIXME: TEXTDIRECTION compatibility CSS (marj?)
// TODO: probably better to externalise along with some other things above
// possibility to overwrite some CSS definition according to TEXTDIRECTION
// especially usefull for rtl.css
// see _blank theme for examples
if(defined('TEXTDIRECTION') && file_exists(THEME.'/'.strtolower(TEXTDIRECTION).'.css'))
{
echo '
<link rel="stylesheet" href="'.THEME_ABS.strtolower(TEXTDIRECTION).'.css" type="text/css" media="all" />';
}
//
// Unobtrusive JS, prevent 3rd party code overload
//
require_once(e_FILE."/e_css.php");
//
// H: Generate JS for image preloads [user mode only]
//

View File

@@ -7,9 +7,9 @@
* GNU General Public License (http://gnu.org).
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/calendar/calendar_class.php,v $
* $Revision: 1.4 $
* $Date: 2009-11-18 01:49:18 $
* $Author: marj_nl_fr $
* $Revision: 1.5 $
* $Date: 2010-01-12 07:38:29 $
* $Author: secretr $
*
*/
@@ -82,7 +82,9 @@ class DHTML_Calendar
}
function load_files() {
return $this->get_load_files_code();
//return $this->get_load_files_code();
// JS and CSS are now sent on the fly - see make_input_field()
return '';
}
function get_load_files_code() {
@@ -107,7 +109,13 @@ class DHTML_Calendar
$ret .= '<input ' . $attrstr .'/> ';
$ret .= "<a href='#' id='".$this->_trigger_id($id)."'>".$this->calendar_img."</a>";
$options = array_merge($cal_options, array('inputField' => $this->_field_id($id), 'button' => $this->_trigger_id($id)));
e107::getJs()->footerInline($this->_make_calendar($options, false)); //FIXME - get_load_files_code() to use JS Manager
e107::getJs()->footerInline($this->_make_calendar($options, false));
//JS manager to send JS to header if possible, if not - footer
e107::getJs()
->tryHeaderFile($this->calendar_file)
->tryHeaderFile($this->calendar_setup_file)
->tryHeaderFile($this->calendar_lang_file)
->otherCSS($this->calendar_theme_file); // send CSS to the site header
return $ret;
}

View File

@@ -7,8 +7,8 @@
* GNU General Public License (http://gnu.org).
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
* $Revision: 1.10 $
* $Date: 2010-01-09 18:40:15 $
* $Revision: 1.11 $
* $Date: 2010-01-12 07:38:28 $
* $Author: secretr $
*
*/
@@ -213,7 +213,7 @@ class e_jsmanager
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
* @return e_jsmanager
*/
public function coreCSS($file_path, $media = 'screen')
public function coreCSS($file_path, $media = 'all')
{
$this->addJs('core_css', $file_path, $media);
return $this;
@@ -227,7 +227,7 @@ class e_jsmanager
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
* @return e_jsmanager
*/
public function pluginCSS($plugname, $file_path, $media = 'screen')
public function pluginCSS($plugname, $file_path, $media = 'all')
{
if(is_array($file_path))
{
@@ -248,7 +248,7 @@ class e_jsmanager
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
* @return e_jsmanager
*/
protected function themeCSS($file_path, $media = 'screen')
public function themeCSS($file_path, $media = 'all')
{
$this->addJs('theme_css', $file_path, $media);
return $this;
@@ -261,7 +261,7 @@ class e_jsmanager
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
* @return e_jsmanager
*/
public function otherCSS($file_path, $media = 'screen')
public function otherCSS($file_path, $media = 'all')
{
$this->addJs('other_css', $file_path, $media);
return $this;
@@ -274,7 +274,7 @@ class e_jsmanager
* @param string $media (not implemented yet) any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
* @return e_jsmanager
*/
public function inlineCSS($css_content, $media = 'screen')
public function inlineCSS($css_content, $media = 'all')
{
$this->addJs('inline_css', $css_content, $media);
return $this;
@@ -808,7 +808,7 @@ class e_jsmanager
if('css' === $external)
{
$path = explode('|', $path, 2);
$media = $path[0];
$media = $path[0] ? $path[0] : 'all';
$path = $path[1];
echo '<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$tp->replaceConstants($path, 'abs').'?external=1&amp;cacheid='.$this->getCacheId().'" />';
echo "\n";