New: Mutualize footer code

This commit is contained in:
Laurent Destailleur 2011-10-18 16:40:44 +02:00
parent f1e36331ea
commit c6a380d5b6
7 changed files with 142 additions and 55 deletions

View File

@ -4345,4 +4345,86 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
}
}
/**
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* DOL_TUNING
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
* @return void
*/
function printCommonFooter($zone='private')
{
global $conf;
if ($zone == 'private') print "\n".'<!-- Common footer for private page -->'."\n";
else print "\n".'<!-- Common footer for public page -->'."\n";
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
// Google Analytics (need Google module)
if (! empty($conf->global->MAIN_GOOGLE_AN_ID))
{
print "\n";
print '<script type="text/javascript">'."\n";
print ' var _gaq = _gaq || [];'."\n";
print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
print ' _gaq.push([\'_trackPageview\']);'."\n";
print ''."\n";
print ' (function() {'."\n";
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
print ' })();'."\n";
print '</script>'."\n";
}
// End of tuning
if (! empty($_SERVER['DOL_TUNING']))
{
$micro_end_time=dol_microtime_float(true);
print "\n".'<script type="text/javascript">console.log("';
if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off');
print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
if (function_exists("memory_get_usage"))
{
print ' - Mem: '.memory_get_usage();
}
if (function_exists("xdebug_memory_usage"))
{
print ' - XDebug time: '.ceil(1000*xdebug_time_index()).' ms';
print ' - XDebug mem: '.xdebug_memory_usage();
print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded"))
{
print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no');
}
print '")</script>'."\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
var_dump(xdebug_get_code_coverage());
}
}
// If there is some logs in buffer to show
if (count($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach($conf->logbuffer as $logline)
{
print $logline."<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
}
?>

View File

@ -1624,50 +1624,7 @@ if (! function_exists("llxFooter"))
print "\n";
if ($foot) print '<!-- '.$foot.' -->'."\n";
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
// If there is some logs in buffer to show
if (count($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach($conf->logbuffer as $logline)
{
print $logline."<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
// End of tuning
if (! empty($_SERVER['DOL_TUNING']))
{
$micro_end_time=dol_microtime_float(true);
print "\n".'<script type="text/javascript">console.log("';
if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off');
print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
if (function_exists("memory_get_usage"))
{
print ' - Mem: '.memory_get_usage();
}
if (function_exists("xdebug_memory_usage"))
{
print ' - XDebug time: '.ceil(1000*xdebug_time_index()).' ms';
print ' - XDebug mem: '.xdebug_memory_usage();
print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded"))
{
print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no');
}
print '")</script>'."\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) { var_dump(xdebug_get_code_coverage()); }
}
printCommonFooter();
print "</body>\n";
print "</html>\n";

View File

@ -337,8 +337,13 @@ if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN
llxFooterVierge();
/**
* Show header for demo
*
* @param string $title
* @param string $head
* @return void
*/
function llxHeaderVierge($title, $head = "")
{
global $user, $conf, $langs;
@ -368,9 +373,14 @@ function llxHeaderVierge($title, $head = "")
print '<body style="margin: 20px;">'."\n";
}
/**
* Show footer for demo
*
* @return void
*/
function llxFooterVierge()
{
printCommonFooter();
printCommonFooter('public');
print "\n";
print "</body>\n";

View File

@ -25,10 +25,7 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
// C'est un wrapper, donc header vierge
function llxHeaderVierge() {
header("Content-type: text/html; charset=".$conf->file->character_set_client);
print '<html><title>Export agenda cal</title><body>';
}
function llxHeaderVierge() { print '<html><title>Export agenda cal</title><body>'; }
function llxFooterVierge() { print '</body></html>'; }
require("../../main.inc.php");

View File

@ -67,7 +67,13 @@ if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
}
// Function for page HTML header
/**
* Show header for new member
*
* @param string $title
* @param string $head
* @return void
*/
function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
{
global $user, $conf, $langs, $mysoc;
@ -97,11 +103,17 @@ function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayo
print '<div style="margin-left: 50px; margin-right: 50px;">';
}
// Function for page HTML footer
/**
* Show footer for new member
*
* @return void
*/
function llxFooterVierge()
{
print '</div>';
printCommonFooter('public');
print "</body>\n";
print "</html>\n";
}

View File

@ -115,8 +115,14 @@ $db->close();
llxFooterVierge();
/* Functions header and footer */
/**
* Show header for card member
*
* @param string $title
* @param string $head
* @return void
*/
function llxHeaderVierge($title, $head = "")
{
global $user, $conf, $langs;
@ -130,8 +136,15 @@ function llxHeaderVierge($title, $head = "")
print "<body>\n";
}
/**
* Show footer for card member
*
* @return void
*/
function llxFooterVierge()
{
printCommonFooter('public');
print "</body>\n";
print "</html>\n";
}

View File

@ -38,6 +38,13 @@ $langs->load("companies");
$langs->load("other");
/**
* Show header for member list
*
* @param string $title
* @param string $head
* @return void
*/
function llxHeaderVierge($title, $head = "")
{
global $user, $conf, $langs;
@ -51,9 +58,18 @@ function llxHeaderVierge($title, $head = "")
print "<body>\n";
}
/**
* Show footer for member list
*
* @param string $title
* @param string $head
* @return void
*/
function llxFooterVierge()
{
print "</body>\n";
printCommonFooter('public');
print "</body>\n";
print "</html>\n";
}