New: Serious speed optimizations (time to show a page is reduced by 40%) when using the hidden option MAIN_OPTIMIZE_SPEED.

This commit is contained in:
Laurent Destailleur 2009-12-17 15:44:51 +00:00
parent 4c601248d4
commit 8924f1104a
3 changed files with 26 additions and 61 deletions

View File

@ -571,15 +571,15 @@ if (! empty($_GET["theme"]))
$conf->theme=$_GET["theme"];
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
}
// Si feuille de style en php existe
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php";
// Style sheet must be a php file
$conf->css.=".php";
if (! empty($user->conf->MAIN_DISABLE_JAVASCRIPT))
{
$conf->use_javascript_ajax=! $user->conf->MAIN_DISABLE_JAVASCRIPT;
}
// Defini gestionnaire de menu a utiliser
// Define menu manager to use
if (! $user->societe_id) // Si utilisateur interne
{
$conf->top_menu=$conf->global->MAIN_MENU_BARRETOP;
@ -843,12 +843,13 @@ function top_menu($head, $title='', $target='')
print "\n".'<!-- Start top horizontal menu -->'."\n";
print '<div class="tmenu">'."\n";
// Charge le gestionnaire des entrees de menu du haut
if (! file_exists(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu))
// Load the top menu manager
$result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu);
if (! $result) // If failed to include, we try with standard
{
$conf->top_menu='eldy_backoffice.php';
include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu);
}
require_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu);
$menutop = new MenuTop($db);
$menutop->atarget=$target;
@ -982,17 +983,18 @@ function left_menu($menu_array, $helppagename='', $moresearchform='')
// Colonne de gauche
// Left column
print '<!-- Begin left vertical menu -->'."\n";
print '<div class="vmenu">'."\n";
// Autres entrees du menu par le gestionnaire
if (! file_exists(DOL_DOCUMENT_ROOT ."/includes/menus/barre_left/".$conf->left_menu))
// Load the left menu manager
$result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_left/".$conf->left_menu);
if (! $result)
{
$conf->left_menu='eldy_backoffice.php';
include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_left/".$conf->left_menu);
}
require_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_left/".$conf->left_menu);
$menuleft=new MenuLeft($db,$menu_array);
$menuleft->showmenu();
@ -1167,7 +1169,7 @@ function llxFooter($foot='')
if (! empty($_SERVER['DOL_TUNING']))
{
$micro_end_time=dol_microtime_float(true);
print "\n".'<script type="text/javascript">window.status="Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
print "\n".'<script type="text/javascript">window.status="MAIN_OPTIMIZE_SPEED '.(empty($conf->global->MAIN_OPTIMIZE_SPEED)?'off - ':'on - ').'Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
if (function_exists("memory_get_usage"))
{
print ' - Mem: '.memory_get_usage();

View File

@ -54,14 +54,6 @@ else
define('LOG_INFO',6);
define('LOG_DEBUG',7);
}
// Definition of missing functions
if (! function_exists("preg_replace"))
{
function preg_replace($a,$b,$c)
{
}
}
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)

View File

@ -64,35 +64,6 @@ class Translate {
}
/**
* \brief Return string translated for a key
* Translation array must have been loaded before.
* \param key Key to translate
* \return string Translated string
*/
function getTransFromTab($key)
{
if (! empty($this->tab_translate[$key]))
{
return $this->tab_translate[$key];
}
else
{
return '';
}
}
/**
* \brief Positionne la chaine traduite pour une cle donnee.
* \param key Key to translate
* \return string Translated string
*/
function setTransFromTab($key,$value)
{
$this->tab_translate[$key]=$value;
}
/**
* \brief Set accessor for this->defaultlang
* \param srclang Language to use
@ -417,7 +388,7 @@ class Translate {
*/
function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0)
{
if ($this->getTransFromTab($key)) // Translation is available
if (! empty($this->tab_translate[$key])) // Translation is available
{
$str=preg_replace('/\\\"/','"',$this->tab_translate[$key]); // To solve some translation keys containing key=abc\"def\"ghi instead of abc"def"ghi
$str=sprintf($str,$param1,$param2,$param3,$param4);
@ -461,7 +432,7 @@ class Translate {
*/
function transnoentities($key, $param1='', $param2='', $param3='', $param4='')
{
if ($this->getTransFromTab($key))
if (! empty($this->tab_translate[$key]))
{
// Si la traduction est disponible
$newstr=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
@ -489,7 +460,7 @@ class Translate {
*/
function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='')
{
if ($this->getTransFromTab($key))
if (! empty($this->tab_translate[$key]))
{
// Si la traduction est disponible
$newstr=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
@ -563,24 +534,24 @@ class Translate {
/**
* \brief Renvoi si le fichier $filename existe dans la version de la langue courante ou alternative
* \param filename nom du fichier a rechercher
* \param searchalt cherche aussi dans langue alternative
* \return boolean true si existe, false sinon
* \brief Return if a filename $filename exists for current language (or alternate language)
* \param filename Language filename to search
* \param searchalt Search also alernate language file
* \return boolean true if exists and readable
*/
function file_exists($filename,$searchalt=0)
{
// Test si fichier dans repertoire de la langue
foreach($this->dir as $searchdir)
{
$htmlfile=$searchdir."/langs/".$this->defaultlang."/".$filename;
if (is_readable($htmlfile)) return true;
if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) return true;
if ($searchalt) {
if ($searchalt)
{
// Test si fichier dans repertoire de la langue alternative
if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename;
else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename;
if (is_readable($htmlfilealt)) return true;
if ($this->defaultlang != "en_US") $filenamealt = $searchdir."/langs/en_US/".$filename;
else $filenamealt = $searchdir."/langs/fr_FR/".$filename;
if (is_readable(dol_osencode($filenamealt))) return true;
}
}