improving css bandwidth usage, now all css files are coming in one file
This commit is contained in:
@@ -971,7 +971,7 @@ class G
|
||||
}
|
||||
|
||||
/**
|
||||
* streaming a file
|
||||
* streaming a big JS file with small js files
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
@@ -980,15 +980,71 @@ class G
|
||||
* @param string $downloadFileName
|
||||
* @return string
|
||||
*/
|
||||
function streamFile( $file, $download = false, $downloadFileName = '' )
|
||||
function streamCSSBigFile( $filename )
|
||||
{
|
||||
require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php');
|
||||
$typearray = explode ( '.', basename( $file) );
|
||||
$typefile = $typearray[ count($typearray) -1 ];
|
||||
$filename = $file;
|
||||
header('Content-Type: text/javascript');
|
||||
|
||||
//trick to generate the translation.language.js file , merging two files and then minified the content.
|
||||
if ( strtolower ($typefile ) == 'js' && $typearray[0] == 'translation' ) {
|
||||
//if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor.
|
||||
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
if ( file_exists($filename) )
|
||||
$mtime = filemtime($filename);
|
||||
else
|
||||
$mtime = date('U');
|
||||
$gmt_mtime = gmdate("D, d M Y H:i:s", $mtime ) . " GMT";
|
||||
header('Pragma: cache');
|
||||
header('ETag: "' . md5 ($mtime . $filename ) . '"' );
|
||||
header("Last-Modified: " . $gmt_mtime );
|
||||
header('Cache-Control: public');
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time () + 30*60*60*24 ) . " GMT"); //1 month
|
||||
if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ) {
|
||||
if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) {
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||
if ( str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == md5( $mtime . $filename)) {
|
||||
header("HTTP/1.1 304 Not Modified");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
$extJsSkin = 'xtheme-gray';
|
||||
$publicExtPath = PATH_HTML . 'skins' . PATH_SEP . 'ext' . PATH_SEP;
|
||||
$output = "/* css autogenerated by gulliver framework for $filename skin **/\n";
|
||||
|
||||
$output .= file_get_contents ( $publicExtPath . 'ext-all-notheme.css' );
|
||||
$output .= file_get_contents ( $publicExtPath . $extJsSkin . '.css' );
|
||||
$output .= file_get_contents ( $publicExtPath . 'pmos-' . $extJsSkin . '.css' );
|
||||
|
||||
//adding the extend css for extjs-pmos
|
||||
$cssThemeExtensions = glob(PATH_TPL . "*/css/extjs-extend/{$extJsSkin}.css");
|
||||
foreach($cssThemeExtensions as $cssThemeExtensionFile)
|
||||
//$helper->addFile($cssThemeExtensionFile);
|
||||
$output .= file_get_contents ( $cssThemeExtensionFile );
|
||||
|
||||
|
||||
//new interactive css decorator
|
||||
//$script .= " <link rel='stylesheet' type='text/css' href='/gulliver/loader?t=extjs-cssExtended&s=".$this->extJsSkin."' />\n";
|
||||
|
||||
$output .= file_get_contents ( PATH_HTML . 'images/icons_silk/sprite.css' );
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* streaming a big JS file with small js files
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @param string $file
|
||||
* @param boolean $download
|
||||
* @param string $downloadFileName
|
||||
* @return string
|
||||
*/
|
||||
function streamJSTranslationFile( $filename, $locale = 'en' )
|
||||
{
|
||||
header('Content-Type: text/javascript');
|
||||
|
||||
//if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor.
|
||||
@@ -1018,10 +1074,40 @@ class G
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$locale = $typearray[1]; //here we have the language , for example translation.en.js
|
||||
G::LoadTranslationObject($locale);
|
||||
global $translation;
|
||||
$output .= JSMin::minify ( 'var TRANSLATIONS = ' . G::json_encode($translation) . ';' );
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* streaming a file
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @param string $file
|
||||
* @param boolean $download
|
||||
* @param string $downloadFileName
|
||||
* @return string
|
||||
*/
|
||||
function streamFile( $file, $download = false, $downloadFileName = '' )
|
||||
{
|
||||
require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php');
|
||||
$folderarray = explode ( '/', $file );
|
||||
$typearray = explode ( '.', basename( $file) );
|
||||
$typefile = $typearray[ count($typearray) -1 ];
|
||||
$filename = $file;
|
||||
|
||||
//trick to generate the translation.language.js file , merging two files and then minified the content.
|
||||
if ( strtolower ($typefile ) == 'js' && $typearray[0] == 'translation' ) {
|
||||
$output = G::streamJSTranslationFile ($filename, $typearray[1]);
|
||||
print $output;
|
||||
return;
|
||||
}
|
||||
|
||||
//trick to generate the big css file for ext style .
|
||||
if ( strtolower ($typefile ) == 'css' && $folderarray[count($folderarray)-2] == 'css' ) {
|
||||
$output = G::streamCSSBigFile( $typearray[0] );
|
||||
print $output;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,8 +297,9 @@ class headPublisher {
|
||||
}
|
||||
|
||||
function getExtJsStylesheets(){
|
||||
|
||||
$script = " <link rel='stylesheet' type='text/css' href='/skins/ext/ext-all-notheme.css' />\n";
|
||||
$script = " <link rel='stylesheet' type='text/css' href='/css/classic.css' />\n";
|
||||
/*
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/ext-all-notheme.css' />\n";
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/" . $this->extJsSkin.".css' />\n";
|
||||
|
||||
// <!-- DEPRECATED, this will be removed in a future - the three next lines
|
||||
@@ -310,7 +311,7 @@ class headPublisher {
|
||||
//new interactive css decorator
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/gulliver/loader?t=extjs-cssExtended&s=".$this->extJsSkin."' />\n";
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/images/icons_silk/sprite.css' />\n";
|
||||
|
||||
*/
|
||||
// Load external/plugin css
|
||||
// NOTE is necesary to move this to decorator server
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton ();
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
$body = $oHeadPublisher->getExtJsScripts();
|
||||
|
||||
$templateFile = 'extJsInitLoad.html';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$header = $oHeadPublisher->includeExtJs();
|
||||
$styles = '';
|
||||
$body = $oHeadPublisher->renderExtJs();
|
||||
|
||||
Reference in New Issue
Block a user