move all the final page construction to a construct_page() function

This commit is contained in:
friendica 2013-01-04 20:27:41 -08:00
parent 78a65c7c1b
commit 3795720421
3 changed files with 87 additions and 91 deletions

View File

@ -1940,3 +1940,86 @@ function curPageURL() {
}
return $pageURL;
}
function construct_page(&$a) {
/**
* Build the page - now that we have all the components
*/
if($a->module != 'install') {
nav($a);
}
require_once(theme_include('theme_init.php'));
if(($p = theme_include(current_theme() . '.js')) != '')
head_add_js($p);
if(($p = theme_include('mod_' . $a->module . '.php')) != '')
require_once($p);
require_once('include/js_strings.php');
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
head_add_css('mod_' . $a->module . '.css');
head_add_css('style.css');
head_add_js('mod_' . $a->module . '.js');
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
if($interval < 10000)
$interval = 40000;
$a->page['title'] = $a->config['system']['sitename'];
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
'$baseurl' => $a->get_baseurl(),
'$local_user' => local_user(),
'$generator' => FRIENDICA_PLATFORM . ' ' . FRIENDICA_VERSION,
'$update_interval' => $interval,
'$head_css' => head_get_css(),
'$head_js' => head_get_js(),
'$js_strings' => js_strings()
));
$arr = $a->get_widgets();
if(count($arr)) {
foreach($arr as $x) {
if(! array_key_exists($x['location'],$a->page))
$a->page[$x['location']] = '';
$a->page[$x['location']] .= $x['html'];
}
}
if($a->is_mobile || $a->is_tablet) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = $a->get_baseurl() . '/toggle_mobile?f=&address=' . curPageURL();
}
else {
$link = $a->get_baseurl() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
}
$a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
'$toggle_link' => $link,
'$toggle_text' => t('toggle mobile')
));
}
$page = $a->page;
$profile = $a->profile;
header("Content-type: text/html; charset=utf-8");
require_once(theme_include(
((x($a->page,'template'))
? $a->page['template']
: 'default' )
. '.php' )
);
return;
}

View File

@ -4,14 +4,11 @@
// install and uninstall plugin
if (! function_exists('uninstall_plugin')){
function uninstall_plugin($plugin){
logger("Addons: uninstalling " . $plugin);
logger("Addons: uninstalling " . $plugin, LOGGER_DEBUG);
q("DELETE FROM `addon` WHERE `name` = '%s' ",
dbesc($plugin)
);
// define THISPLUGIN, make life easy to plugin devs :-)
define("THISPLUGIN", 'addon/' . $plugin . '/' . $plugin . '.php');
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall';
@ -23,11 +20,9 @@ if (! function_exists('install_plugin')){
function install_plugin($plugin) {
// silently fail if plugin was removed
// define THISPLUGIN, make life easy to plugin devs :-)
define("THISPLUGIN", 'addon/' . $plugin . '/' . $plugin . '.php');
if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
return false;
logger("Addons: installing " . $plugin);
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
@ -35,7 +30,7 @@ function install_plugin($plugin) {
$func = $plugin . '_install';
$func();
$plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
$plugin_admin = (function_exists($plugin . "_plugin_admin") ? 1 : 0);
$r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
dbesc($plugin),
@ -83,9 +78,6 @@ function reload_plugins() {
$fname = 'addon/' . $pl . '/' . $pl . '.php';
// define THISPLUGIN, make life easy to plugin devs :-)
define("THISPLUGIN", $fname);
if(file_exists($fname)) {
$t = @filemtime($fname);
foreach($installed as $i) {

View File

@ -329,87 +329,8 @@ if(stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
call_hooks('page_end', $a->page['content']);
/**
*
* Add the navigation (menu) template
*
*/
if($a->module != 'install') {
nav($a);
}
/**
* Build the page - now that we have all the components
*/
require_once(theme_include('theme_init.php'));
if(($p = theme_include(current_theme() . '.js')) != '')
head_add_js($p);
if(($p = theme_include('mod_' . $a->module . '.php')) != '')
require_once($p);
require_once('include/js_strings.php');
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
head_add_css('mod_' . $a->module . '.css');
head_add_css('style.css');
head_add_js('mod_' . $a->module . '.js');
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
if($interval < 10000)
$interval = 40000;
$a->page['title'] = $a->config['system']['sitename'];
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
'$baseurl' => $a->get_baseurl(),
'$local_user' => local_user(),
'$generator' => FRIENDICA_PLATFORM . ' ' . FRIENDICA_VERSION,
'$update_interval' => $interval,
'$head_css' => head_get_css(),
'$head_js' => head_get_js(),
'$js_strings' => js_strings()
));
$arr = $a->get_widgets();
if(count($arr)) {
foreach($arr as $x) {
if(! array_key_exists($x['location'],$a->page))
$a->page[$x['location']] = '';
$a->page[$x['location']] .= $x['html'];
}
}
if($a->is_mobile || $a->is_tablet) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = $a->get_baseurl() . '/toggle_mobile?f=&address=' . curPageURL();
}
else {
$link = $a->get_baseurl() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
}
$a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
'$toggle_link' => $link,
'$toggle_text' => t('toggle mobile')
));
}
$page = $a->page;
$profile = $a->profile;
header("Content-type: text/html; charset=utf-8");
require_once(theme_include(
((x($a->page,'template'))
? $a->page['template']
: 'default' )
. '.php' ));
construct_page($a);
session_write_close();
exit;