Adding theme_backup and default_template settings see #7328

Blocks added in templates in order to be overwrite.
1.9.x
Julio Montoya 11 years ago
parent 2c3da98978
commit 2db9057d7b
  1. 8
      main/inc/global_error_message.inc.php
  2. 87
      main/inc/lib/template.lib.php
  3. 4
      main/install/configuration.dist.php
  4. 10
      main/template/default/layout/layout_2_col.tpl
  5. 1
      main/template/default/layout/login_form.tpl
  6. 2
      main/template/default/layout/main.tpl
  7. 84
      main/template/default/layout/main_header.tpl
  8. 5
      main/template/default/layout/menu.tpl
  9. 12
      main/template/default/layout/show_footer.tpl
  10. 25
      main/template/default/layout/show_header.tpl
  11. 15
      main/template/experimental/layout/layout_1_col.tpl
  12. 72
      main/template/experimental/layout/layout_2_col.tpl
  13. 35
      main/template/experimental/layout/layout_3_col.tpl
  14. 1
      main/template/experimental/layout/show_footer.tpl
  15. 1
      main/template/experimental/layout/show_header.tpl

@ -50,7 +50,8 @@ $TechnicalIssuesDescription = 'This portal is currently experiencing technical i
if (is_int($global_error_code) && $global_error_code > 0) {
$theme = 'chamilo/';
$theme = Template::getThemeBackup().'/';
$css_path = 'main/css/';
$css_file = $css_path.$theme.'default.css';
$bootstrap_file = $css_path.'bootstrap.css';
@ -200,7 +201,7 @@ if (is_int($global_error_code) && $global_error_code > 0) {
</ul>
</div>
</div>
</div>
</div>
</div>
<ul class="breadcrumb">
<li><a href="#">{SECTION}</a></li>
@ -224,8 +225,7 @@ if (is_int($global_error_code) && $global_error_code > 0) {
&nbsp;<br />{POWERED_BY}
</div>
</div>
</div>
</div>
</footer>
</body>
</html>

@ -12,9 +12,23 @@ require_once api_get_path(SYS_PATH).'vendor/twig/twig/lib/Twig/Autoloader.php';
*/
class Template
{
public $style = 'default'; //see the template folder
public $preview_theme = null;
public $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc
/**
* The Template folder name see main/template
* @var string
*/
public $templateFolder = 'default';
/**
* The theme that will be used: chamilo, public_admin, chamilo_red, etc
* This variable is set from the database
* @var string
*/
public $theme = '';
/**
* @var string
*/
public $preview_theme = '';
public $title = null;
public $show_header;
public $show_footer;
@ -132,12 +146,18 @@ class Template
$this->set_header_parameters();
$this->set_footer_parameters();
$this->assign('style', $this->style);
$this->assign('css_style', $this->theme);
$this->assign('template', $this->style);
$defaultStyle = api_get_configuration_value('default_template');
if (!empty($defaultStyle)) {
$this->templateFolder = $defaultStyle;
}
$this->assign('template', $this->templateFolder);
$this->assign('css_styles', $this->theme);
$this->assign('login_class', null);
//Chamilo plugins
// Chamilo plugins
if ($this->show_header) {
if ($this->load_plugins) {
@ -276,7 +296,7 @@ class Template
* Sets the footer visibility
* @param bool true if we show the footer
*/
function set_footer($status)
public function set_footer($status)
{
$this->show_footer = $status;
$this->assign('show_footer', $status);
@ -286,7 +306,7 @@ class Template
* Sets the header visibility
* @param bool true if we show the header
*/
function set_header($status)
public function set_header($status)
{
$this->show_header = $status;
$this->assign('show_header', $status);
@ -332,9 +352,14 @@ class Template
$this->assign('show_course_navigation_menu', $show_course_navigation_menu);
}
function get_template($name)
/**
* @param string $name
*
* @return string
*/
public function get_template($name)
{
return $this->style.'/'.$name;
return $this->templateFolder.'/'.$name;
}
/** Set course parameters */
@ -418,13 +443,13 @@ class Template
}
/**
* Set theme, include CSS files */
function set_css_files()
* Set theme, include CSS files
*/
public function set_css_files()
{
global $disable_js_and_css_files;
$css = array();
//$platform_theme = api_get_setting('stylesheets');
$this->theme = api_get_visual_theme();
if (!empty($this->preview_theme)) {
@ -870,9 +895,10 @@ class Template
$this->assign('execution_stats', $stats); */
}
function show_header_template()
public function show_header_template()
{
$tpl = $this->get_template('layout/show_header.tpl');
$this->display($tpl);
}
@ -882,8 +908,12 @@ class Template
$this->display($tpl);
}
/* Sets the plugin content in a template variable */
function set_plugin_region($plugin_region)
/**
* Sets the plugin content in a template variable
* @param string $plugin_region
* @return null
*/
public function set_plugin_region($plugin_region)
{
if (!empty($plugin_region)) {
$region_content = $this->plugin->load_region($plugin_region, $this, $this->force_plugin_load);
@ -896,17 +926,28 @@ class Template
return null;
}
/**
* @param string $template
* @return string
*/
public function fetch($template = null)
{
$template = $this->twig->loadTemplate($template);
return $template->render($this->params);
}
/**
* @param $tpl_var
* @param null $value
*/
public function assign($tpl_var, $value = null)
{
$this->params[$tpl_var] = $value;
}
/**
* @param string $template
*/
public function display($template)
{
echo $this->twig->render($template, $this->params);
@ -919,4 +960,16 @@ class Template
{
$this->assign('login_class', 'section-login');
}
/**
* @return string
*/
public static function getThemeBackup()
{
$theme = api_get_configuration_value('theme_backup');
if (empty($theme)) {
$theme = 'chamilo';
}
return $theme;
}
}

@ -243,3 +243,7 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['catalog_show_courses_sessions'] = 0;
// Auto detect language custom pages.
// $_configuration['auto_detect_language_custom_pages'] = true;
// If the database is down this css style will be used to show the errors.
//$_configuration['theme_backup'] = 'chamilo'; // (main/css/chamilo)
// The default template that will be use in the system.
//$_configuration['default_template'] = 'default'; // (main/template/default)

@ -19,13 +19,15 @@
{% endif %}
{# if user is not login show the login form #}
{% block login_form %}
{% if _u.logged == 0 %}
{% include "default/layout/login_form.tpl" %}
{% endif %}
{% endblock %}
<div class="block_user_info">
{# User picture #}
{{ user_image_block }}
{# User Profile links #}
{{ profile_block }}
@ -58,7 +60,7 @@
{# Skills #}
{{ skills_block }}
{# Plugin courses sidebar #}
{# Plugins for footer section #}
@ -91,7 +93,9 @@
{# ?? #}
{{ sniff_notification }}
{% block page_body %}
{% include "default/layout/page_body.tpl" %}
{% endblock %}
{# Welcome to course block #}
{% if welcome_to_course_block %}
@ -100,11 +104,13 @@
</section>
{% endif %}
{% block content %}
{% if content is not null %}
<section id="main_content">
{{ content }}
</section>
{% endif %}
{% endblock %}
{# Announcements #}
{% if announcements_block %}

@ -1,5 +1,4 @@
{% if login_form %}
<div id="login_block" class="well sidebar-nav">
{{ login_language_form }}

@ -14,8 +14,6 @@
</div> <!-- end of #row" -->
</div> <!-- end of #main" -->
<div class="push"></div>
{% endif %}
{% include "default/layout/main_footer.tpl" %}
{% endblock %}

@ -4,7 +4,9 @@
<!--[if IE 8]> <html lang="{{ document_language }}" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--><html lang="{{ document_language }}" class="no-js"> <!--<![endif]-->
<head>
{% block head %}
{% include "default/layout/head.tpl" %}
{% endblock %}
</head>
<body dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}">
<noscript>{{ "NoJavascript"|get_lang }}</noscript>
@ -16,56 +18,59 @@
<li><a href="#content" accesskey="2">{{ "WCAGGoContent"|get_lang }}</a></li>
</ul>
</div>
<div id="wrapper">
<div id="page" class="page-section"> <!-- page section -->
{# Bug and help notifications #}
{% block help_notifications %}
<ul id="navigation" class="notification-panel">
{{ help_content }}
{{ bug_notification_link }}
</ul>
{% endblock %}
{# topbar #}
{% block topbar %}
{% include "default/layout/topbar.tpl" %}
{% endblock %}
<div id="main" class="container">
<header>
<div class="row">
<div id="header_left" class="span4">
{# logo #}
{{ logo }}
{# plugin_header left #}
{% if plugin_header_left is not null %}
<div id="plugin_header_left">
{{ plugin_header_left }}
</div>
{% endif %}
</div>
<div id="header_center" class="span3">
{# plugin_header center #}
{% if plugin_header_center is not null %}
<div id="plugin_header_center">
{{ plugin_header_center }}
</div>
{% endif %}
&nbsp;
</div>
<div id="header_right" class="span5">
<ul id="notifications" class="nav nav-pills pull-right">
{{ notification_menu }}
</ul>
<header>
<div class="row">
<div id="header_left" class="span4">
{# logo #}
{% block logo %}
{{ logo }}
{% endblock %}
{# plugin_header right #}
{% if plugin_header_right is not null %}
<div id="plugin_header_right">
{{ plugin_header_right }}
</div>
{% endif %}
&nbsp;
{# plugin_header left #}
{% if plugin_header_left is not null %}
<div id="plugin_header_left">
{{ plugin_header_left }}
</div>
{% endif %}
</div>
<div id="header_center" class="span3">
{# plugin_header center #}
{% if plugin_header_center is not null %}
<div id="plugin_header_center">
{{ plugin_header_center }}
</div>
{% endif %}
&nbsp;
</div>
<div id="header_right" class="span5">
<ul id="notifications" class="nav nav-pills pull-right">
{{ notification_menu }}
</ul>
{# plugin_header right #}
{% if plugin_header_right is not null %}
<div id="plugin_header_right">
{{ plugin_header_right }}
</div>
{% endif %}
&nbsp;
</div>
</div>
</div>
{% if plugin_header_main %}
<div class="row">
<div class="span12">
@ -75,12 +80,17 @@
</div>
</div>
{% endif %}
{# menu #}
{% block menu %}
{% include "default/layout/menu.tpl" %}
{% endblock %}
{# breadcrumb #}
{% block breadcrumb %}
{{ breadcrumb }}
{% endblock %}
</header>
<div id="top_main_content" class="row">
{# course navigation links/shortcuts need to be activated by the admin #}

@ -14,7 +14,6 @@
{% if _u.logged == 1 %}
<ul class="nav pull-right">
{% if user_notifications is not null %}
<li class="notification-marker">
<a href="{{ message_url }}">{{ user_notifications }}</a>
@ -22,9 +21,7 @@
{% endif %}
<li class="dropdown">
{% if _u.status != 6 %}
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<img src="{{ _u.avatar_small }}"/>
{{ _u.complete_name }}
@ -37,7 +34,6 @@
</li>
</ul>
{% endif %}
<li>
<a id="logout_button" class="logout" title="{{ "Logout"|get_lang }}" href="{{ logout_link }}" >
<img src="{{ "exit.png"|icon(22) }}">
@ -45,7 +41,6 @@
</li>
</ul>
{% else %}
{# Direct login to course - no visible if logged and on the index page #}
{% if course_code != "" and hide_login_link is null %}
<ul class="nav pull-right">

@ -1,13 +1,15 @@
{#
show_header and show_footer templates are only called when using the Display::display_header and Display::display_footer
for backward compatibility we suppose that the default layout is one column which means using a div with class span12
#}
show_header and show_footer templates are only called when using the
Display::display_header and Display::display_footer
for backward compatibility we suppose that the default layout is one column
which means using a div with class span12
#}
{% if show_header == true %}
</section>
</div>
{% endif %}
{# Plugin bottom #}
{# Plugin bottom #}
{% if plugin_content_bottom is not null %}
<div id="plugin_content_bottom" class="span12">
{{ plugin_content_bottom}}
@ -21,4 +23,4 @@
</div> <!-- end of #wrapper section -->
{% endif %}
{% include "default/layout/main_footer.tpl" %}
{% include "default/layout/main_footer.tpl" %}

@ -1,16 +1,17 @@
{% include "default/layout/main_header.tpl" %}
{#
show_header and show_footer templates are only called when using the Display::display_header and Display::display_footer
for backward compatibility we suppose that the default layout is one column which means using a div with class span12
show_header and show_footer templates are only called when using the
Display::display_header and Display::display_footer
for backward compatibility we suppose that the default layout is one column
which means using a div with class span12
#}
{% if show_header == true %}
{% if plugin_content_top is not null %}
<div id="plugin_content_top" class="span12">
{{ plugin_content_top }}
</div>
{% endif %}
<div class="span12">
{% include "default/layout/page_body.tpl" %}
<section id="main_content">
{% endif %}
{% if plugin_content_top is not null %}
<div id="plugin_content_top" class="span12">
{{ plugin_content_top }}
</div>
{% endif %}
<div class="span12">
{% include "default/layout/page_body.tpl" %}
<section id="main_content">
{% endif %}

@ -1,14 +1 @@
{extends file="default/layout/main.tpl"}
{block name=header}
{include file="default/layout/header.tpl"}
{/block}
{block name=body}
<h1>My experimental Template!!</h1>
{$content}
{/block}
{block name=footer}
{include file="default/layout/header.tpl"}
{/block}
{% extends "default/layout/layout_1_col.tpl" %}

@ -1,31 +1,41 @@
{extends file="default/layout/main.tpl"}
{block name="header"}
{include file="default/layout/main_header.tpl"}
{/block}
{block name=body}
<div id="maincontent" class="maincontent">
{$home_page_block}
{$plugin_courses_block}
{$content}
{$announcements_block}
</div>
<div>
{$login_block}
{$profile_block}
{$account_block}
{$teacher_block}
{$navigation_course_links}
{$plugin_courses_right_block}
{$reservation_block}
{$search_block}
{$classes_block}
</div>
{/block}
{block name=footer}
{include file="default/layout/footer.tpl"}
{/block}
{% extends "default/layout/layout_2_col.tpl" %}
{% block header %}
{% embed "default/layout/main_header.tpl" %}
{% block head %}
{{ parent() }}
{% endblock %}
{% block help_notifications %}
{{ parent() }}
{% endblock %}
{% block logo %}
{{ parent() }}
{% endblock %}
{% block breadcrumb %}
{{ parent() }}
{% endblock %}
{% block menu %}
{{ parent() }}
{% endblock %}
{% block topbar %}
{{ parent() }}
{% endblock %}
{% endembed %}
{% endblock %}
{% block login_form %}
{{ parent() }}
{% endblock %}
{% block page_body %}
{{ parent() }}
{% endblock %}
{% block content %}
{{ parent() }}
{% endblock %}

@ -1,34 +1 @@
{extends file="default/layout/main.tpl"}
{block name=header}
{include file="default/layout/header.tpl"}
{/block}
{block name=body}
<h1>{"WelcomeUserXToTheSiteX"|get_lang} </h1>
<div id="left_col">
{$announcements_block}
</div>
<div id="center_col">
{$content}
</div>
<div id="right">
{$user_complete_name}
{$login_block}
{$profile_block}
{$account_block}
{$teacher_block}
{$notice_block}
{$navigation_course_links}
{$plugin_courses_right_block}
{$reservation_block}
{$search_block}
{$classes_block}
</div>
{/block}
{block name=footer}
{include file="default/layout/footer.tpl"}
{/block}
{% extends "default/layout/layout_3_col.tpl" %}

@ -0,0 +1 @@
{% extends "default/layout/show_footer.tpl" %}

@ -0,0 +1 @@
{% extends "default/layout/show_header.tpl" %}
Loading…
Cancel
Save