Browse Source

Minor improvements in the template, bug link and help content are executed with twig templates

Julio Montoya 12 years ago
parent
commit
3eb2b5571c

+ 2 - 1
main/inc/global.inc.php

@@ -635,11 +635,12 @@ if ($alreadyInstalled && !$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php'))
     LoginCheck(isset($_user['user_id']) ? $_user['user_id'] : '');
 }
 
+$app['api_get_languages'] = api_get_languages();
+
 /*	Loading languages and sublanguages */
 
 // if we use the javascript version (without go button) we receive a get
 // if we use the non-javascript version (with the go button) we receive a post
-$user_language = api_get_user_language();
 
 // Include all files (first english and then current interface language)
 $app['this_script'] = isset($this_script) ? $this_script : null;

+ 3 - 1
main/inc/lib/course.lib.php

@@ -1907,6 +1907,7 @@ class CourseManager {
                 ON tcfv.field_id =  tcf.id $join_access_url
                 WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1  $where_access_url";
         $special_course_result = Database::query($sql);
+
         $special_course_list = array();
 
         if (Database::num_rows($special_course_result)>0) {
@@ -1933,7 +1934,8 @@ class CourseManager {
         $tbl_course_user            = Database::get_main_table(TABLE_MAIN_COURSE_USER);
         $tbl_user_course_category   = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
 
-        $special_course_list         = self::get_special_course_list();
+        $special_course_list = self::get_special_course_list();
+
 
         $with_special_courses = $without_special_courses = '';
         if (!empty($special_course_list)) {

+ 7 - 0
main/inc/lib/main_api.lib.php

@@ -3461,8 +3461,15 @@ function api_display_language_form($hide_if_no_choice = false) {
  *  array['folder'] = An array with the corresponding names of the language-folders in the filesystem
  */
 function api_get_languages() {
+    global $app;
+
+    if (isset($app['api_get_languages'])) {
+        return $app['api_get_languages'];
+    }
+
     $tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE);
     $sql = "SELECT * FROM $tbl_language WHERE available='1' ORDER BY original_name ASC";
+
     $result = Database::query($sql);
     $language_list = array();
     while ($row = Database::fetch_array($result)) {

+ 14 - 68
main/inc/lib/template.lib.php

@@ -47,9 +47,6 @@ class Template
 
         $this->navigation_array = $this->returnNavigationArray();
 
-//      $this->app['template_style'] = 'default';
-//        $this->app['default_layout'] = $this->app['template_style'].'/layout/layout_1_col.tpl';
-
         $show_header = $app['template.show_header'];
         $show_footer = $app['template.show_footer'];
         $show_learnpath = $app['template.show_learnpath'];
@@ -76,6 +73,7 @@ class Template
 
         //header and footer are showed by default
         $this->setFooter($show_footer);
+
         $this->setHeader($show_header);
 
         $this->setHeaderParameters();
@@ -115,32 +113,6 @@ class Template
         return api_format_date($timestamp, $format);
     }
 
-    /**
-     * Return the item's url key:
-     *
-     *      c_id=xx&id=xx
-     *
-     * @param object $item
-     * @return string
-     */
-    public static function key($item)
-    {
-        $id = isset($item->id) ? $item->id : null;
-        $c_id = isset($item->c_id) ? $item->c_id : null;
-        $result = '';
-        if ($c_id) {
-            $result = "c_id=$c_id";
-        }
-        if ($id) {
-            if ($result) {
-                $result .= "&id=$id";
-            } else {
-                $result .= "&id=$id";
-            }
-        }
-        return $result;
-    }
-
     /**
      * @param string $help_input
      */
@@ -151,20 +123,7 @@ class Template
         } else {
             $help = $this->help;
         }
-
-        $help_content = '';
-        if (api_get_setting('enable_help_link') == 'true') {
-            if (!empty($help)) {
-                $help = Security::remove_XSS($help);
-                $help_content = '<li class="help">';
-                $help_content .= '<a href="'.api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help.'&height=400&width=600" class="ajax" title="'.get_lang('Help').'">';
-                $help_content .= '<img src="'.api_get_path(WEB_IMG_PATH).'help.large.png" alt="'.get_lang(
-                    'Help'
-                ).'" title="'.get_lang('Help').'" />';
-                $help_content .= '</a></li>';
-            }
-        }
-        $this->assign('help_content', $help_content);
+        $this->assign('help_content', $help);
     }
 
     /*
@@ -305,6 +264,7 @@ class Template
             if (api_is_platform_admin()) {
                 $user_info['is_admin'] = 1;
             }
+
             $new_messages = MessageManager::get_new_messages();
             $user_info['messages_count'] = $new_messages != 0 ? Display::label($new_messages, 'warning') : null;
             $messages_invitations_count = GroupPortalManager::get_groups_by_user_count(
@@ -364,24 +324,26 @@ class Template
             $this->theme = $this->preview_theme;
         }
 
+        $cssPath = api_get_path(WEB_CSS_PATH);
+
         //Base CSS
-        $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'base.css');
+        $css[] = api_get_cdn_path($cssPath.'base.css');
         //Compressed version of default + all CSS files
         //$css[] = api_get_cdn_path(api_get_path(WEB_PATH).'web/css/'.$this->theme.'/style.css');
 
         //Default theme CSS
-        $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/default.css');
-        $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'bootstrap-responsive.css');
-        $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'responsive.css');
-        $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'font_awesome/font-awesome.css');
+        $css[] = api_get_cdn_path($cssPath.$this->theme.'/default.css');
+        $css[] = api_get_cdn_path($cssPath.'bootstrap-responsive.css');
+        $css[] = api_get_cdn_path($cssPath.'responsive.css');
+        $css[] = api_get_cdn_path($cssPath.'font_awesome/font-awesome.css');
 
         //Extra CSS files
         $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css';
         $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css';
 
         if ($this->show_learnpath) {
-            $css[] = api_get_path(WEB_CSS_PATH).$this->theme.'/learnpath.css';
-            $css[] = api_get_path(WEB_CSS_PATH).$this->theme.'/scorm.css';
+            $css[] = $cssPath.$this->theme.'/learnpath.css';
+            $css[] = $cssPath.$this->theme.'/scorm.css';
         }
 
         if (api_is_global_chat_enabled()) {
@@ -421,7 +383,7 @@ class Template
         if (!$disable_js_and_css_files) {
             $this->assign('css_file_to_string', $css_file_to_string);
 
-            $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/print.css'), 'print');
+            $style_print = api_get_css(api_get_cdn_path($cssPath.$this->theme.'/print.css'), 'print');
             $this->assign('css_style_print', $style_print);
         }
 
@@ -590,18 +552,6 @@ class Template
 
         $this->set_help();
 
-        //@todo move this in the template
-        $bug_notification_link = '';
-        if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
-            $bug_notification_link = '<li class="report">
-		        						<a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
-		        						<img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang(
-                'ReportABug'
-            ).'"/></a>
-		    						  </li>';
-        }
-        $this->assign('bug_notification_link', $bug_notification_link);
-
         $notification = $this->return_notification_menu();
         $this->assign('notification_menu', $notification);
 
@@ -794,8 +744,7 @@ class Template
 
         // Displaying the tabs
 
-        $lang = ''; //el for "Edit Language"
-        //$user_language_choice = Session::get('user_language_choice');
+        $lang = null; //el for "Edit Language"
         $user_language_choice = isset($_SESSION['user_language_choice']) ? $_SESSION['user_language_choice'] : null;
         $user_info = api_get_user_id() ? api_get_user_info() : null;
 
@@ -1287,7 +1236,6 @@ class Template
         $user_id = api_get_user_id();
         $course_id = api_get_course_id();
 
-
         /*  Plugins for banner section */
         $web_course_path = api_get_path(WEB_COURSE_PATH);
 
@@ -1426,8 +1374,6 @@ class Template
         if (!empty($final_navigation)) {
             $lis = '';
             $i = 0;
-            //$home_link = Display::url(Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('Homepage'), array('align'=>'middle')), api_get_path(WEB_PATH), array('class'=>'home'));
-            //$lis.= Display::tag('li', Display::url(get_lang('Homepage').'<span class="divider">/</span>', api_get_path(WEB_PATH)));
             $final_navigation_count = count($final_navigation);
 
             if (!empty($final_navigation)) {

+ 18 - 2
main/template/default/layout/main_header.tpl

@@ -17,10 +17,26 @@
         </ul>
     </div>
     <div id="wrapper">
+
         {# Bug and help notifications #}
+
         <ul id="navigation" class="notification-panel">
-            {{ help_content }}
-            {{ bug_notification_link }}
+
+            {% if ("enable_help_link" | get_setting) == 'true' %}
+                <li class="help">
+                    <a href="{{ _p.web_img }}help/help.php?open={{ help_content }}&height=400&width=600" class="ajax" title="{{ "help"|get_lang }}">
+                        <img src="{{ _p.web_img }}help.large.png" alt="{{ "help"|get_lang }}" title="{{ "help"|get_lang }}" />
+                    </a>
+                </li>
+            {% endif %}
+
+            {% if ("show_link_bug_notification" | get_setting) == 'true' and _u.logged != 0 %}
+            <li class="report">
+                <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
+                    <img src="{{ _p.web_img }}bug.large.png" style="vertical-align: middle;" alt="{{ "ReportABug"|get_lang }}" title="{{ "ReportABug"|get_lang }}"/>
+                </a>
+            </li>
+            {% endif %}
         </ul>
 
         {# topbar #}