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. 4
      main/inc/global_error_message.inc.php
  2. 87
      main/inc/lib/template.lib.php
  3. 4
      main/install/configuration.dist.php
  4. 8
      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. 18
      main/template/default/layout/main_header.tpl
  8. 5
      main/template/default/layout/menu.tpl
  9. 8
      main/template/default/layout/show_footer.tpl
  10. 7
      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) { if (is_int($global_error_code) && $global_error_code > 0) {
$theme = 'chamilo/'; $theme = Template::getThemeBackup().'/';
$css_path = 'main/css/'; $css_path = 'main/css/';
$css_file = $css_path.$theme.'default.css'; $css_file = $css_path.$theme.'default.css';
$bootstrap_file = $css_path.'bootstrap.css'; $bootstrap_file = $css_path.'bootstrap.css';
@ -225,7 +226,6 @@ if (is_int($global_error_code) && $global_error_code > 0) {
</div> </div>
</div> </div>
</div> </div>
</footer> </footer>
</body> </body>
</html> </html>

@ -12,9 +12,23 @@ require_once api_get_path(SYS_PATH).'vendor/twig/twig/lib/Twig/Autoloader.php';
*/ */
class Template class Template
{ {
public $style = 'default'; //see the template folder /**
public $preview_theme = null; * The Template folder name see main/template
public $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc * @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 $title = null;
public $show_header; public $show_header;
public $show_footer; public $show_footer;
@ -132,12 +146,18 @@ class Template
$this->set_header_parameters(); $this->set_header_parameters();
$this->set_footer_parameters(); $this->set_footer_parameters();
$this->assign('style', $this->style); $defaultStyle = api_get_configuration_value('default_template');
$this->assign('css_style', $this->theme); if (!empty($defaultStyle)) {
$this->assign('template', $this->style); $this->templateFolder = $defaultStyle;
}
$this->assign('template', $this->templateFolder);
$this->assign('css_styles', $this->theme);
$this->assign('login_class', null); $this->assign('login_class', null);
//Chamilo plugins // Chamilo plugins
if ($this->show_header) { if ($this->show_header) {
if ($this->load_plugins) { if ($this->load_plugins) {
@ -276,7 +296,7 @@ class Template
* Sets the footer visibility * Sets the footer visibility
* @param bool true if we show the footer * @param bool true if we show the footer
*/ */
function set_footer($status) public function set_footer($status)
{ {
$this->show_footer = $status; $this->show_footer = $status;
$this->assign('show_footer', $status); $this->assign('show_footer', $status);
@ -286,7 +306,7 @@ class Template
* Sets the header visibility * Sets the header visibility
* @param bool true if we show the header * @param bool true if we show the header
*/ */
function set_header($status) public function set_header($status)
{ {
$this->show_header = $status; $this->show_header = $status;
$this->assign('show_header', $status); $this->assign('show_header', $status);
@ -332,9 +352,14 @@ class Template
$this->assign('show_course_navigation_menu', $show_course_navigation_menu); $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 */ /** Set course parameters */
@ -418,13 +443,13 @@ class Template
} }
/** /**
* Set theme, include CSS files */ * Set theme, include CSS files
function set_css_files() */
public function set_css_files()
{ {
global $disable_js_and_css_files; global $disable_js_and_css_files;
$css = array(); $css = array();
//$platform_theme = api_get_setting('stylesheets');
$this->theme = api_get_visual_theme(); $this->theme = api_get_visual_theme();
if (!empty($this->preview_theme)) { if (!empty($this->preview_theme)) {
@ -870,9 +895,10 @@ class Template
$this->assign('execution_stats', $stats); */ $this->assign('execution_stats', $stats); */
} }
function show_header_template() public function show_header_template()
{ {
$tpl = $this->get_template('layout/show_header.tpl'); $tpl = $this->get_template('layout/show_header.tpl');
$this->display($tpl); $this->display($tpl);
} }
@ -882,8 +908,12 @@ class Template
$this->display($tpl); $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)) { if (!empty($plugin_region)) {
$region_content = $this->plugin->load_region($plugin_region, $this, $this->force_plugin_load); $region_content = $this->plugin->load_region($plugin_region, $this, $this->force_plugin_load);
@ -896,17 +926,28 @@ class Template
return null; return null;
} }
/**
* @param string $template
* @return string
*/
public function fetch($template = null) public function fetch($template = null)
{ {
$template = $this->twig->loadTemplate($template); $template = $this->twig->loadTemplate($template);
return $template->render($this->params); return $template->render($this->params);
} }
/**
* @param $tpl_var
* @param null $value
*/
public function assign($tpl_var, $value = null) public function assign($tpl_var, $value = null)
{ {
$this->params[$tpl_var] = $value; $this->params[$tpl_var] = $value;
} }
/**
* @param string $template
*/
public function display($template) public function display($template)
{ {
echo $this->twig->render($template, $this->params); echo $this->twig->render($template, $this->params);
@ -919,4 +960,16 @@ class Template
{ {
$this->assign('login_class', 'section-login'); $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; //$_configuration['catalog_show_courses_sessions'] = 0;
// Auto detect language custom pages. // Auto detect language custom pages.
// $_configuration['auto_detect_language_custom_pages'] = true; // $_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,14 +19,16 @@
{% endif %} {% endif %}
{# if user is not login show the login form #} {# if user is not login show the login form #}
{% block login_form %}
{% if _u.logged == 0 %} {% if _u.logged == 0 %}
{% include "default/layout/login_form.tpl" %} {% include "default/layout/login_form.tpl" %}
{% endif %} {% endif %}
{% endblock %}
<div class="block_user_info"> <div class="block_user_info">
{# User picture #} {# User picture #}
{{ user_image_block }} {{ user_image_block }}
{# User Profile links #} {# User Profile links #}
{{ profile_block }} {{ profile_block }}
</div> </div>
@ -91,7 +93,9 @@
{# ?? #} {# ?? #}
{{ sniff_notification }} {{ sniff_notification }}
{% block page_body %}
{% include "default/layout/page_body.tpl" %} {% include "default/layout/page_body.tpl" %}
{% endblock %}
{# Welcome to course block #} {# Welcome to course block #}
{% if welcome_to_course_block %} {% if welcome_to_course_block %}
@ -100,11 +104,13 @@
</section> </section>
{% endif %} {% endif %}
{% block content %}
{% if content is not null %} {% if content is not null %}
<section id="main_content"> <section id="main_content">
{{ content }} {{ content }}
</section> </section>
{% endif %} {% endif %}
{% endblock %}
{# Announcements #} {# Announcements #}
{% if announcements_block %} {% if announcements_block %}

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

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

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

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

@ -1,7 +1,9 @@
{# {#
show_header and show_footer templates are only called when using the Display::display_header and Display::display_footer show_header and show_footer templates are only called when using the
for backward compatibility we suppose that the default layout is one column which means using a div with class span12 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 show_header == true %}
</section> </section>
</div> </div>

@ -1,9 +1,10 @@
{% include "default/layout/main_header.tpl" %} {% 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 show_header and show_footer templates are only called when using the
for backward compatibility we suppose that the default layout is one column which means using a div with class span12 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 show_header == true %}
{% if plugin_content_top is not null %} {% if plugin_content_top is not null %}
<div id="plugin_content_top" class="span12"> <div id="plugin_content_top" class="span12">

@ -1,14 +1 @@
{extends file="default/layout/main.tpl"} {% extends "default/layout/layout_1_col.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}

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

@ -1,34 +1 @@
{extends file="default/layout/main.tpl"} {% extends "default/layout/layout_3_col.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}

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

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