Minor fixes in the template system

skala
Julio Montoya 13 years ago
parent 776688edcf
commit 4d67a9f102
  1. 6
      main/inc/lib/main_api.lib.php
  2. 35
      main/inc/lib/template.lib.php

@ -2464,7 +2464,6 @@ function api_not_allowed($print_headers = false) {
$course = api_get_course_id();
global $this_section;
$tpl = new Template();
if (api_get_setting('use_custom_pages') == 'true') {
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
@ -2486,15 +2485,14 @@ function api_not_allowed($print_headers = false) {
//$msg = Display::return_message(get_lang('NotAllowedClickBack').'<br /><br /><a href="'.$_SERVER['HTTP_REFERER'].'">'.get_lang('BackToPreviousPage').'</a><br />', 'error', false);
$msg = Display::return_message(get_lang('NotAllowedClickBack'), 'error', false);
$msg = Display::div($msg, array('align'=>'center'));
$tpl->assign('content', $msg);
$show_headers = 0;
if ((!headers_sent() || $print_headers) && $origin != 'learnpath') {
$show_headers = 1;
}
$tpl->set_header($show_headers);
$tpl->set_footer($show_headers);
$tpl = new Template(null, $show_headers, $show_headers);
$tpl->assign('content', $msg);
if ((isset($user) && !api_is_anonymous()) && (!isset($course) || $course == -1) && empty($_GET['cidReq'])) {
// if the access is not authorized and there is some login information

@ -7,10 +7,10 @@ require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php';
class Template extends Smarty {
var $style = 'default'; //see the template folder
var $show_header = true;
var $show_footer = true;
var $show_header;
var $show_footer;
function __construct($title = '') {
function __construct($title = '', $show_header = true, $show_footer = true) {
$this->title = $title;
//Smarty 3 configuration
@ -27,8 +27,8 @@ class Template extends Smarty {
//$this->cache_lifetime = 120;
//By default we show the header and footer
$this->set_footer(true);
$this->set_header(true);
$this->set_footer($show_footer);
$this->set_header($show_header);
$this->set_system_parameters();
$this->set_user_parameters();
@ -40,36 +40,31 @@ class Template extends Smarty {
//To load a smarty plugin
//$this->loadPlugin('smarty_function_get_lang');
//$this->testInstall();
}
function set_template_parameters() {
$this->set_header_parameters();
//$this->testInstall();
$this->set_header_parameters();
$this->set_footer_parameters();
$this->assign('style', $this->style);
$this->assign('style', $this->style);
}
/**
* Shortcut to display a 1 col layout
* */
function display_one_col_template() {
$this->set_template_parameters();
function display_one_col_template() {
$tpl = $this->get_template('layout/layout_1_col.tpl');
$this->display($tpl);
}
/**
* Shortcut to display a 2 col layout
* */
function display_two_col_template() {
$this->set_template_parameters();
* */
function display_two_col_template() {
$tpl = $this->get_template('layout/layout_2_col.tpl');
$this->display($tpl);
}
/**
* Displays an empty template
*/
function display_blank_template() {
$this->set_template_parameters();
$tpl = $this->get_template('layout/blank.tpl');

Loading…
Cancel
Save