From dbe0d408b158fab8c5158364d88225b183e74b70 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 9 May 2012 13:54:20 +0200 Subject: [PATCH] Turning off strict_variables in Twig configuration see #4727 --- main/admin/index.php | 23 ++++++++++-- main/inc/lib/template.lib.php | 37 +++++++++---------- .../template/default/admin/settings_index.tpl | 4 +- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/main/admin/index.php b/main/admin/index.php index 7a551711b0..b60803c64d 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -91,6 +91,7 @@ if (api_is_platform_admin()) { ); } $blocks['users']['items'] = $items; +$blocks['users']['extra'] = null; if (api_is_platform_admin()) { /* Courses */ @@ -126,6 +127,7 @@ if (api_is_platform_admin()) { $items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse')); } $blocks['courses']['items'] = $items; + $blocks['courses']['extra'] = null; /* Platform */ $blocks['platform']['icon'] = Display::return_icon('platform.png', get_lang('Platform'), array(), ICON_SIZE_MEDIUM, false); @@ -162,6 +164,7 @@ if (api_is_platform_admin()) { $items[] = array('url'=>'legal_add.php', 'label' => get_lang('TermsAndConditions')); } $blocks['platform']['items'] = $items; + $blocks['platform']['extra'] = null; } /* Sessions */ @@ -195,6 +198,7 @@ if (api_get_setting('use_session_mode') == 'true') { $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes')); $blocks['sessions']['items'] = $items; + $blocks['sessions']['extra'] = null; } elseif (api_is_platform_admin()) { @@ -203,9 +207,9 @@ if (api_get_setting('use_session_mode') == 'true') { $blocks['classes']['label'] = api_ucfirst(get_lang('AdminClasses')); $search_form = ' '; + + + '; $blocks['classes']['search_form'] = $search_form; $items = array(); $items[] = array('url'=>'class_list.php', 'label' => get_lang('ClassList')); @@ -215,6 +219,8 @@ if (api_get_setting('use_session_mode') == 'true') { $items[] = array('url'=>'subscribe_class2course.php', 'label' => get_lang('AddClassesToACourse')); $blocks['classes']['items'] = $items; + $blocks['classes']['extra'] = null; + } /* Settings */ @@ -239,6 +245,9 @@ if (api_is_platform_admin()) { //$items[] = array('url'=>'statistics/index.php?action=activities', 'label' => get_lang('ImportantActivities')); $blocks['settings']['items'] = $items; + $blocks['settings']['extra'] = null; + + $blocks['settings']['search_form'] = null; /* Extensions */ /* @@ -266,6 +275,8 @@ if (api_is_platform_admin()) { $items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks')); $blocks['skills']['items'] = $items; + $blocks['skills']['extra'] = null; + $blocks['skills']['search_form'] = null; @@ -285,7 +296,9 @@ if (api_is_platform_admin()) { $items[] = array('url'=>'../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide')); $items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions')); - $blocks['chamilo']['items'] = $items; + $blocks['chamilo']['items'] = $items; + $blocks['chamilo']['extra'] = null; + $blocks['chamilo']['search_form'] = null; // Try to display a maximum before we check the chamilo version and all that. //session_write_close(); //close session to avoid blocking concurrent access @@ -296,6 +309,8 @@ if (api_is_platform_admin()) { $blocks['version_check']['icon'] = Display::return_icon('logo.gif', 'Chamilo.org', array(), ICON_SIZE_SMALL, false); $blocks['version_check']['label'] = get_lang('VersionCheck'); $blocks['version_check']['extra'] = version_check(); + $blocks['version_check']['search_form'] = null; + $blocks['version_check']['items'] = null; } $tpl = new Template(); diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 49bce70e52..16e02e1552 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -50,7 +50,7 @@ class Template { 'debug' => true, 'auto_reload' => true, 'optimizations' => 0, // turn on optimizations with -1 - 'strict_variables' => true, //If set to false, Twig will silently ignore invalid variables + 'strict_variables' => false, //If set to false, Twig will silently ignore invalid variables ); } else { $options = array ( @@ -229,20 +229,21 @@ class Template { $this->assign('show_toolbar', $show_toolbar); //Only if course is available - if (!empty($this->course_id) && $this->user_is_logged_in) { - + $show_course_shortcut = null; + $show_course_navigation_menu = null; + + if (!empty($this->course_id) && $this->user_is_logged_in) { if (api_get_setting('show_toolshortcuts') != 'false') { //Course toolbar - $course_tool = CourseHome::show_navigation_tool_shortcuts(); - $this->assign('show_course_shortcut', $course_tool); - } - + $show_course_shortcut = CourseHome::show_navigation_tool_shortcuts(); + } if (api_get_setting('show_navigation_menu') != 'false') { //Course toolbar - $course_tool = CourseHome::show_navigation_menu(); - $this->assign('show_course_navigation_menu', $course_tool); - } - } + $show_course_navigation_menu = CourseHome::show_navigation_menu(); + } + } + $this->assign('show_course_shortcut', $show_course_shortcut); + $this->assign('show_course_navigation_menu', $show_course_navigation_menu); } function get_template($name) { @@ -524,13 +525,12 @@ class Template { $this->assign('notification_menu', $notification); $this->assign('menu', $menu); $this->assign('breadcrumb', $breadcrumb); - + + $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); - if (!empty($extra_header)) { - $this->assign('header_extra_content', $extra_header); - } - } + } + $this->assign('header_extra_content', $extra_header); if ($this->show_header == 1) { header('Content-Type: text/html; charset='.api_get_system_encoding()); @@ -626,10 +626,7 @@ class Template { function set_plugin_region($plugin_region) { if (!empty($plugin_region)) { $content = $this->plugin->load_region($plugin_region, $this); - if (!empty($content)) { - //Assigning the plugin with the template - $this->assign('plugin_'.$plugin_region, $content); - } + $this->assign('plugin_'.$plugin_region, $content); } return null; } diff --git a/main/template/default/admin/settings_index.tpl b/main/template/default/admin/settings_index.tpl index df4fec85a2..8578c79e17 100644 --- a/main/template/default/admin/settings_index.tpl +++ b/main/template/default/admin/settings_index.tpl @@ -21,10 +21,10 @@ $(function() { {% for block_item in blocks %}
-

{{block_item.icon}} {{block_item.label}}

+

{{block_item.icon}} {{block_item.label}}

{{ block_item.search_form }} -
+
{% if block_item.items is not null %}