1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 17:01:43 +02:00

Added gzip function to class2, quicker loading of ajax script, ajax only loaded when needed, e_header.php for plugin and menu js/css loading. And other small fixes.

This commit is contained in:
CaMer0n
2008-01-27 11:02:34 +00:00
parent 43b337e938
commit 1eab7f9470
7 changed files with 102 additions and 34 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.47 $
| $Date: 2008-01-27 01:57:23 $
| $Revision: 1.48 $
| $Date: 2008-01-27 11:02:33 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -591,7 +591,6 @@ if (isset($pref['modules']) && $pref['modules']) {
$js_body_onload = array(); // Initialise this array in case a module wants to add to it
// Load e_modules after all the constants, but before the themes, so they can be put to use.
if(isset($pref['e_module_list']) && $pref['e_module_list']){
foreach ($pref['e_module_list'] as $mod){
@@ -804,9 +803,9 @@ if(!isset($_E107['no_menus']))
{
while ($row = $sql->db_Fetch())
{
$eMenuList[$row['menu_location']][]=$row;
$eMenuList[$row['menu_location']][] =$row;
$eMenuArea[$row['menu_location']][$row['menu_name']] =1;
$eMenuActive[]=$row['menu_name'];
$eMenuActive[$row['menu_name']] = $row['menu_name'];
}
}
$menu_data['menu_area'] = $eMenuArea;
@@ -818,8 +817,8 @@ if(!isset($_E107['no_menus']))
}
else
{
$eMenuArea = $menu_data['menu_area'];
$eMenuList = $menu_data['menu_list'];
$eMenuArea = $menu_data['menu_area'];
$eMenuList = $menu_data['menu_list'];
$eMenuActive = $menu_data['menu_active'];
unset($menu_data);
}
@@ -1670,4 +1669,32 @@ function e107_ini_set($var, $value){
}
}
function echo_gzipped_page() {
if( headers_sent() ){
$encoding = false;
}elseif( strpos($_SERVER["HTTP_ACCEPT_ENCODING"], 'x-gzip') !== false ){
$encoding = 'x-gzip';
}elseif( strpos($_SERVER["HTTP_ACCEPT_ENCODING"],'gzip') !== false ){
$encoding = 'gzip';
}else{
$encoding = false;
}
if( $encoding ){
$contents = ob_get_contents();
ob_end_clean();
header('Content-Encoding: '.$encoding);
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
$size = strlen($contents);
$contents = gzcompress($contents, 9);
$contents = substr($contents, 0, $size);
print($contents);
exit();
}else{
ob_end_flush();
exit();
}
}
?>

View File

@@ -11,13 +11,15 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_files/e_ajax.php,v $
| $Revision: 1.2 $
| $Date: 2008-01-16 22:45:55 $
| $Revision: 1.3 $
| $Date: 2008-01-27 11:02:34 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
$_E107['minimal'] = TRUE;
require_once("../class2.php");
ob_start();
ob_implicit_flush(0);
// -----------------------------------------------------------------------------
// Ajax Short-code-Replacer Routine.
@@ -38,14 +40,15 @@ require_once("../class2.php");
}
// -----------------------------------------------------------------------------
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);
echo "
$text = "
function replaceSC(sc,obj,id,scfile)
{
if(!id){ var id = sc; }
var handler = '".SITEURL.$FILES_DIRECTORY."/e_ajax.php';
var handler = '".e_FILE_ABS."e_ajax.php';
var parm = ($(obj).serialize() + '&ajax_sc=' + sc + '&ajax_scfile=' + scfile + '&ajax_used=1');
new Ajax.Updater(id, handler, { parameters: parm } );
}
@@ -57,6 +60,9 @@ echo "
}
";
header ('ETag: "' . md5($text).'"' );
echo $text;
?>
/* Prototype JavaScript framework, version 1.6.0
@@ -4245,3 +4251,6 @@ Object.extend(Element.ClassNames.prototype, Enumerable);
Element.addMethods();
<?php
echo_gzipped_page();
?>

View File

@@ -4,8 +4,8 @@
| e107 website system - Javascript File.
|
| $Source: /cvs_backup/e107_0.8/e107_files/e_js.php,v $
| $Revision: 1.3 $
| $Date: 2008-01-16 22:45:56 $
| $Revision: 1.4 $
| $Date: 2008-01-27 11:02:34 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -24,9 +24,14 @@
*/
$_E107['minimal'] = TRUE;
require_once("../class2.php");
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);
//header("Expires: 0");
//header("Cache-Control: max-age=30" );
echo "<!--
$js = "<!--
var nowLocal = new Date(); /* time at very beginning of js execution */
var localTime = Math.floor(nowLocal.getTime()/1000); /* time, in ms -- recorded at top of jscript */
@@ -393,5 +398,7 @@ function preview_image(src_val,img_path, not_found)
//-->";
header ('ETag: "' . md5($text).'"' );
echo $js;
echo_gzipped_page();
?>

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.19 $
| $Date: 2008-01-27 05:16:03 $
| $Author: mcfly_e107 $
| $Revision: 1.20 $
| $Date: 2008-01-27 11:02:34 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -21,7 +21,7 @@ if (!defined('e107_INIT')) { exit; }
class e107plugin
{
var $plugin_addons = array("e_rss", "e_notify", "e_linkgen", "e_list", "e_bb", "e_meta", "e_emailprint", "e_frontpage", "e_latest", "e_status", "e_search", "e_sc", "e_module", "e_comment", "e_sql", "e_userprofile");
var $plugin_addons = array("e_rss", "e_notify", "e_linkgen", "e_list", "e_bb", "e_meta", "e_emailprint", "e_frontpage", "e_latest", "e_status", "e_search", "e_sc", "e_module", "e_comment", "e_sql", "e_userprofile","e_header");
// List of all plugin variables which need to be checked - install required if one or more set and non-empty
var $all_eplug_install_variables = array(

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chatbox_menu.php,v $
| $Revision: 1.10 $
| $Date: 2008-01-16 11:00:21 $
| $Revision: 1.11 $
| $Date: 2008-01-27 11:02:34 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -30,7 +30,7 @@ if(($pref['cb_layer']==2) || isset($_POST['chatbox_ajax']))
@include_lan(e_PLUGIN."chatbox_menu/languages/".e_LANGUAGE."/".e_LANGUAGE.".php");
@include_lan(e_PLUGIN."chatbox_menu/languages/English/English.php");
}
$footer_js[] = e_FILE_ABS.'e_ajax.php';
// $footer_js[] = e_FILE_ABS.'e_ajax.php';
}

View File

@@ -0,0 +1,11 @@
<?php
if (!defined('e107_INIT')) { exit; }
if($eMenuActive['chatbox_menu'])
{
$eplug_js[] = e_FILE_ABS."e_ajax.php";
$eplug_js[] = e_FILE_ABS."e_ajax.php";
}
?>

View File

@@ -6,8 +6,8 @@
| Released under the terms and conditions of the GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $
| $Revision: 1.18 $
| $Date: 2008-01-16 10:47:06 $
| $Revision: 1.19 $
| $Date: 2008-01-27 11:02:34 $
| $Author: e107coders $
+-----------------------------------------------------------------------------------------------+
*/
@@ -98,13 +98,24 @@ if (varset($pref['wysiwyg'],FALSE) && check_class($pref['post_html']) && varset(
}else{
define("e_WYSIWYG",FALSE);
}
// Load Plugin Header Files
if (is_array($pref['e_header_list']))
{
foreach($pref['e_header_list'] as $val)
{
if(is_readable(e_PLUGIN.$val."/e_header.php"))
{
require_once(e_PLUGIN.$val."/e_header.php");
}
}
}
if (isset($theme_js_php) && $theme_js_php) {
echo "<link rel='stylesheet' href='".THEME_ABS."theme-js.php' type='text/css' />";
} else {
if (!isset($no_core_js) || !$no_core_js) {
if (!isset($no_core_js) || !$no_core_js)
{
echo "<script type='text/javascript' src='".e_FILE_ABS."e_js.php'></script>\n";
echo "<script type='text/javascript' src='".e_FILE_ABS."e_ajax.php'></script>\n";
}
if (file_exists(THEME.'theme.js')) { echo "<script type='text/javascript' src='".THEME_ABS."theme.js'></script>\n"; }
if (is_readable(e_FILE.'user.js') && filesize(e_FILE.'user.js')) { echo "<script type='text/javascript' src='".e_FILE_ABS."user.js'></script>\n"; }
@@ -117,9 +128,10 @@ if (isset($eplug_js) && $eplug_js) {
echo "\n<!-- eplug_js -->\n";
if(is_array($eplug_js))
{
foreach($eplug_js as $kjs)
$eplug_js_unique = array_unique($eplug_js);
foreach($eplug_js_unique as $kjs)
{
echo "<script type='text/javascript' src='{$kjs}'></script>\n";
echo ($kjs[0] == "<") ? $kjs : "<script type='text/javascript' src='{$kjs}'></script>\n";
}
}
else
@@ -139,13 +151,15 @@ if (function_exists('headerjs')){echo headerjs(); }
// E: Send CSS
//
if (isset($eplug_css) && $eplug_css) {
if (isset($eplug_css) && $eplug_css)
{
if(is_array($eplug_css))
{
foreach($eplug_css as $kcss)
{ // Allow inline style definition - but only if $eplug_css is an array (maybe require an array later)
if ('<style' == substr($kcss,0,6)) echo $kcss; else echo "<link rel='stylesheet' href='{$kcss}' type='text/css' />\n";
}
$eplug_css_unique = array_unique($eplug_css);
foreach($eplug_css_unique as $kcss)
{
echo ($kcss[0] == "<") ? $kcss : "<link rel='stylesheet' href='{$kcss}' type='text/css' />\n";
}
}
else
{
@@ -300,7 +314,7 @@ if (isset($script_text) && $script_text) {
// I: Calculate JS onload() functions for the BODY tag
//
// Fader menu
global $eMenuActive;
global $eMenuActive, $eMenuArea;
if(in_array('fader_menu', $eMenuActive)) $js_body_onload[] = 'changecontent(); ';
// External links handling