Browse Source

Fixing UI see #6833

Julio Montoya 11 years ago
parent
commit
e0096eac9d

+ 36 - 19
main/auth/courses_controller.php

@@ -19,7 +19,8 @@ class CoursesController
     /**
      * Constructor
      */
-    public function __construct() {		
+    public function __construct()
+    {
         $this->toolname = 'auth';
         $actived_theme_path = api_get_template();
         $this->view = new View($this->toolname, $actived_theme_path);
@@ -32,17 +33,16 @@ class CoursesController
      * @param string   	action
      * @param string    confirmation message(optional)
      */
-    public function courses_list($action, $message = '') {
+    public function courses_list($action, $message = '')
+    {
         $data = array();
         $user_id = api_get_user_id();
-        
+
         $data['user_courses']             = $this->model->get_courses_of_user($user_id);
         $data['user_course_categories']   = $this->model->get_user_course_categories();
         $data['courses_in_category']      = $this->model->get_courses_in_category();
         $data['all_user_categories']      = $this->model->get_user_course_categories();
-
         $data['action'] = $action;
-
         $data['message'] = $message;
 
         // render to the view
@@ -60,8 +60,9 @@ class CoursesController
      * @param string    confirmation message(optional)
      * @param string    error message(optional)
      */
-    public function categories_list($action, $message='', $error='') {
-        $data = array();            
+    public function categories_list($action, $message='', $error='')
+    {
+        $data = array();
         $data['user_course_categories'] = $this->model->get_user_course_categories();
         $data['action'] = $action;
         $data['message'] = $message;
@@ -74,31 +75,46 @@ class CoursesController
         $this->view->render();
     }
 
+    /**
+     * @return FormValidator
+     */
+    private function getSearchForm()
+    {
+        $form = new FormValidator('form-search', 'post', api_get_self().'?action=subscribe&hidden_links=0', null, array('class' => 'form-search'));
+
+        $form->addElement('hidden', 'search_course', '1');
+        $form->addElement('text', 'search_term');
+        $form->addElement('button', 'submit', get_lang('Search'));
+        return $form;
+    }
+
     /**
      * It's used for listing courses with categories,
      * render to courses_categories view
      * @param string   	action
      * @param string    Category code (optional)
      */
-    public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null) {
+    public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null)
+    {
         $data = array();
-        $browse_course_categories = $this->model->browse_course_categories();        
-        
+        $browse_course_categories = $this->model->browse_course_categories();
+
         if ($action == 'display_random_courses') {
             $data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10);
         } else {
             if (!isset($category_code)) {
                 $category_code = $browse_course_categories[0][1]['code']; // by default first category
-            }            
+            }
             $data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code);
         }
-        
+
+        $data['search_form'] = $this->getSearchForm();
         $data['browse_course_categories'] = $browse_course_categories;
         $data['code'] = Security::remove_XSS($category_code);
 
         // getting all the courses to which the user is subscribed to
         $curr_user_id = api_get_user_id();
-        $user_courses = $this->model->get_courses_of_user($curr_user_id);            
+        $user_courses = $this->model->get_courses_of_user($curr_user_id);
         $user_coursecodes = array();
 
         // we need only the course codes as these will be used to match against the courses of the category
@@ -107,14 +123,14 @@ class CoursesController
                 $user_coursecodes[] = $value['code'];
             }
         }
-        
+
         if (api_is_drh()) {
             $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
             foreach ($courses as $course) {
                 $user_coursecodes[] = $course['code'];
-            }            
+            }
         }
-        
+
         $data['user_coursecodes'] = $user_coursecodes;
         $data['action']           = $action;
         $data['message']          = $message;
@@ -131,15 +147,16 @@ class CoursesController
     /**
      * Search courses
      */
-    public function search_courses($search_term, $message = '', $error = '') {
+    public function search_courses($search_term, $message = '', $error = '')
+    {
 
         $data = array();
-
         $browse_course_categories = $this->model->browse_course_categories();
 
         $data['browse_courses_in_category'] = $this->model->search_courses($search_term);
         $data['browse_course_categories']   = $browse_course_categories;
 
+        $data['search_form'] = $this->getSearchForm();
         $data['search_term'] = Security::remove_XSS($search_term); //filter before showing in template
 
         // getting all the courses to which the user is subscribed to
@@ -187,7 +204,7 @@ class CoursesController
                 $content = $result['content'];
             }
         }
-        
+
         if (!empty($search_term)) {
             $this->search_courses($search_term, $message, $error);
         } else {

+ 2 - 2
main/inc/lib/course.lib.php

@@ -3791,10 +3791,10 @@ class CourseManager
                 $my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
             }
 
-            //Description
+            // Description
             $my_course['extra_info']['description_button'] = '';
             if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) {
-                $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
+                $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn btn-default'));
             }
 
             $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['real_id']);

+ 3 - 3
main/inc/lib/sortable_table.class.php

@@ -140,7 +140,7 @@ class SortableTable extends HTML_Table
         $this->column  = isset($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column;
         $this->column  = isset($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column;
 
-        //Default direction
+        // Default direction
 
         if (in_array(strtoupper($default_order_direction), array('ASC', 'DESC'))) {
             $this->direction = $default_order_direction;
@@ -294,8 +294,8 @@ class SortableTable extends HTML_Table
             $html .= '<tr>';
             $html .= '<td>';
 
+            // Actions in table
             if (count($this->form_actions) > 0) {
-
                 $html .= '<div class="btn-toolbar">';
                 $html .= '<div class="btn-group">';
                 $html .= '<a class="btn btn-default" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" onclick="javascript: setCheckbox(true, \''.$table_id.'\'); return false;">'.get_lang('SelectAll').'</a>';
@@ -320,7 +320,7 @@ class SortableTable extends HTML_Table
             }
 
             $html .= '</td>';
-
+            // Pagination
             if ($this->get_total_number_of_items() > $this->default_items_per_page) {
                 $html .= '<td style="text-align:right;">';
                 $html .= $nav;

+ 7 - 18
main/template/default/auth/courses_categories.php

@@ -34,22 +34,11 @@ $stok = Security::get_token();
     <div class="col-md-3">
         <div id="course_category_well" class="well">
             <ul class="nav nav-list">
-                <?php if (!isset($_GET['hidden_links']) || isset($_GET['hidden_links']) && intval($_GET['hidden_links']) != 1) { ?>
-                <form class="form-search" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&amp;hidden_links=0">
-                    <fieldset>
-                        <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
-                        <input type="hidden" name="search_course" value="1" />
-                        <div class="control-group">
-                            <div class="controls">
-                                <div class="input-append">
-                                    <input class="col-md-2" type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" />
-                                    <button class="btn" type="submit"><?php echo get_lang('Search'); ?></button>
-                                </div>
-                            </div>
-                        </div>
-                    </fieldset>
-                </form>
-                <?php
+            <?php if (!isset($_GET['hidden_links']) || isset($_GET['hidden_links']) && intval($_GET['hidden_links']) != 1) {
+                $search_form->addElement('hidden', 'sec_token', $stok);
+                $term = isset($_POST['search_term']) ? Security::remove_XSS($_POST['search_term']) : null;
+                $search_form->setDefaults(array('search_term' => $term));
+                echo $search_form->return_form();
                 $hidden_links = 0;
             } else {
                 $hidden_links = 1;
@@ -60,7 +49,7 @@ $stok = Security::get_token();
              * it, as this can considerably slow down your system
              */
             if (!empty($browse_course_categories)) {
-                echo '<a class="btn" href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a><br /><br />';
+                echo '<a class="btn btn-default" href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a><br /><br />';
 
                 echo '<li class="nav-header">'.get_lang('CourseCategories').'</li>';
 
@@ -193,7 +182,7 @@ $stok = Security::get_token();
                     echo '<div class="btn-toolbar">';
 
                     if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
-                        echo '<a class="ajax btn" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&amp;code='.$course['code'].'" class="thickbox">'.get_lang('Description').'</a>';
+                        echo '<a class="ajax btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&amp;code='.$course['code'].'" class="thickbox">'.get_lang('Description').'</a>';
                     }
 
                     // Get access type for course button ("enter" or/and "register")

+ 1 - 1
main/template/default/layout/hot_course_item_popup.tpl

@@ -8,7 +8,7 @@
                             <img src="{{ hot_course.extra_info.course_image }}" />
                         </div>
                     </div>
-                    <div class="col-md-2">
+                <div class="col-md-2">
                         <div class="categories-course-description">
                             <h3>{{ hot_course.extra_info.title}}</h3>
                             <h5>{{ hot_course.extra_info.teachers }}</h5>

+ 5 - 2
main/template/default/layout/hot_courses.tpl

@@ -18,7 +18,6 @@ $(document).ready( function() {
             }
         });
     });
-
 });
 </script>
 <section id="hot_courses">
@@ -26,7 +25,11 @@ $(document).ready( function() {
         <div class="col-md-12">
             {% if _u.is_admin %}
             <span class="pull-right">
-                <a title="{{ "Hide"|get_lang }}" alt="{{ "Hide"|get_lang }}" href="{{ _p.web_main }}admin/settings.php?search_field=show_hot_courses&submit_button=&_qf__search_settings=&category=search_setting">
+                <a
+                    title = "{{ "Hide"|get_lang }}"
+                    alt = "{{ "Hide"|get_lang }}"
+                    href="{{ _p.web_main }}admin/settings.php?search_field=show_hot_courses&submit_button=&_qf__search_settings=&category=search_setting"
+                >
                     <img src="{{ "visible.png"|icon(32) }}">
                 </a>
             </span>