Browse Source

UI improvements, adding addButtonCreate, addButtonUpdate, etc

To improve UI consistency.
Julio Montoya 10 years ago
parent
commit
b0068c8f16

+ 1 - 1
main/admin/archive_cleanup.php

@@ -22,7 +22,7 @@ api_protect_admin_script(true);
 $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
 
 $form = new FormValidator('archive_cleanup_form');
-$form->addElement('style_submit_button','proceed', get_lang('ArchiveDirCleanupProceedButton'),'class="save"');
+$form->addButton('proceed', get_lang('ArchiveDirCleanupProceedButton'));
 
 $message = null;
 

+ 1 - 3
main/admin/course_add.php

@@ -5,8 +5,6 @@
  *	@package chamilo.admin
  */
 
-/* INITIALIZATION SECTION */
-
 // Language files that need to be included.
 $language_file = array('admin', 'create_course');
 
@@ -126,7 +124,7 @@ $(function() {
 </script>';
 
 $form->add_progress_bar();
-$form->addElement('style_submit_button', 'submit', get_lang('CreateCourse'), 'class="add"');
+$form->addButtonCreate(get_lang('CreateCourse'));
 
 // Set some default values.
 $values['course_language']  = api_get_setting('platformLanguage');

+ 1 - 3
main/admin/session_add.php

@@ -364,9 +364,7 @@ $(function() {
 });
 </script>';
 
-$form->addElement('button', 'submit', get_lang('NextStep'), array(
-    'class' => 'save'
-));
+$form->addButtonNext(get_lang('NextStep'));
 
 $formDefaults = array(
     'nb_days_acess_before' => $nb_days_acess_before,

+ 1 - 6
main/admin/session_edit.php

@@ -4,9 +4,6 @@
  * Sessions edition script
  * @package chamilo.admin
  */
-/**
- * Code
- */
 
 // name of the language file that needs to be included
 $language_file ='admin';
@@ -253,9 +250,7 @@ $(function() {
 });
 </script>';
 
-$form->addElement('button', 'submit', get_lang('ModifyThisSession'), array(
-    'class' => 'save'
-));
+$form->addButtonUpdate(get_lang('ModifyThisSession'));
 
 $formDefaults = array(
     'id_coach' => $infos['id_coach'],

+ 3 - 2
main/admin/user_add.php

@@ -274,8 +274,9 @@ $defaults = array_merge($defaults, $extra_data);
 $form->setDefaults($defaults);
 
 // Submit button
-$html_results_enabled[] = $form-> createElement ('style_submit_button', 'submit_plus', get_lang('Add').'+', 'class="add"');
-$html_results_enabled[] = $form-> createElement ('style_submit_button', 'submit', get_lang('Add'), 'class="add"');
+$html_results_enabled[] = $form->createElement('button', 'submit', get_lang('Add'), 'plus', 'primary');
+$html_results_enabled[] = $form->createElement('button', 'submit_plus', get_lang('Add').'+');
+
 $form->addGroup($html_results_enabled);
 
 // Validate form

+ 1 - 0
main/admin/user_edit.php

@@ -295,6 +295,7 @@ $(document).ready(function(){
 // Submit button
 $form->addElement('style_submit_button', 'submit', get_lang('ModifyInformation'), 'class="save"');
 
+
 // Set default values
 $user_data['reset_password'] = 0;
 $expiration_date = $user_data['expiration_date'];

+ 2 - 2
main/admin/user_list.php

@@ -801,8 +801,8 @@ if (!empty($action)) {
 $form = new FormValidator('search_simple', 'get', '', '', array('class' => 'form-search'), false);
 $renderer = & $form->defaultRenderer();
 $renderer->setElementTemplate('<span>{element}</span> ');
-$form->addElement('text','keyword', get_lang('keyword'), 'size="25"');
-$form->addElement('style_submit_button', 'submit', get_lang('Search'),'class="btn"');
+$form->addElement('text','keyword', get_lang('keyword'));
+$form->addButtonSearch(get_lang('Search'));
 $form->addElement(
     'static',
     'search_advanced_link',

+ 2 - 2
main/cron/import_csv.php

@@ -941,9 +941,9 @@ class ImportCsv
                     $addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
 
                     if ($addTeacherToSession) {
-                        CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, true, false);
+                        CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, true, false);
                     } else {
-                        CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, false);
+                        CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, false);
                     }
 
                     if ($result) {

+ 1 - 1
main/document/document.php

@@ -1506,7 +1506,7 @@ if (!$is_certificate_mode) {
     $form->addElement('hidden', 'cidReq', api_get_course_id());
     $form->addElement('hidden', 'id_session', api_get_session_id());
     $form->addElement('hidden', 'gidReq', $groupId);
-    $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"');
+    $form->addButtonSearch(get_lang('Search'));
     $actions .= $form->return_form();
     $actions .= '</span>';
 }

+ 2 - 0
main/group/member_settings.php

@@ -167,6 +167,7 @@ if (!empty($group_member_list)) {
         $selected_users[] = $user['user_id'];
     }
 }
+
 $group_members_element = $form->addElement(
     'advmultiselect',
     'group_members',
@@ -209,6 +210,7 @@ switch ($action) {
 }
 
 $defaults = $current_group;
+
 $defaults['group_members'] = $selected_users;
 $action = isset($_GET['action']) ? $_GET['action'] : '';
 $defaults['action'] = $action;

+ 1 - 0
main/inc/lib/formvalidator/Element/DatePicker.php

@@ -18,6 +18,7 @@ class DatePicker extends HTML_QuickForm_text
         if (!isset($attributes['id'])) {
             $attributes['id'] = $elementName;
         }
+        //$attributes['class'] = '';
 
         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
         $this->_appendName = true;

+ 1 - 1
main/inc/lib/formvalidator/Element/DateRangePicker.php

@@ -14,7 +14,7 @@ class DateRangePicker extends HTML_QuickForm_text
         if (!isset($attributes['id'])) {
             $attributes['id'] = $elementName;
         }
-        $attributes['class'] = 'span3';
+        $attributes['class'] = 'form-control';
         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
         $this->_appendName = true;
         $this->_type = 'date_range_picker';

+ 62 - 2
main/inc/lib/formvalidator/FormValidator.class.php

@@ -214,9 +214,69 @@ EOT;
      *
      * @return HTML_QuickForm_button
      */
-    public function addButton($name, $label, $icon = 'check', $style = 'default', $size = 'default', $class = 'btn', $attributes = array())
+    public function addButton(
+        $name,
+        $label,
+        $icon = 'check',
+        $style = 'default',
+        $size = 'default',
+        $class = 'btn',
+        $attributes = array()
+    ) {
+        return $this->addElement(
+            'button',
+            $name,
+            $label,
+            $icon,
+            $style,
+            $size,
+            $class,
+            $attributes
+        );
+    }
+
+    /**
+     * @param string $label
+     */
+    public function addButtonCreate($label)
+    {
+        $this->addButton('submit', $label, 'plus', 'primary');
+    }
+
+    /**
+     * Shortcut to create/add button
+     * @param string $label
+     */
+    public function addButtonUpdate($label)
+    {
+        return $this->addButton('submit', $label, 'pencil', 'primary');
+    }
+
+    /**
+     * Shortcut to delete button
+     * @param string $label
+     */
+    public function addButtonDelete($label)
+    {
+        return $this->addButton('submit', $label, 'trash', 'danger');
+    }
+
+    /**
+     * Shortcut to search button
+     * @param string $label
+     */
+    public function addButtonSearch($label)
+    {
+        return $this->addButton('submit', $label, 'search');
+    }
+
+    /**
+     * Shortcut to update button
+     * @param string $label
+     */
+    public function addButtonNext($label)
     {
-        return $this->addElement('button', $name, $label, $icon, $style, $size, $class, $attributes);
+        return $this->addButton('submit', $label, 'arrow-right', 'primary');
     }
 
     /**

+ 1 - 0
main/inc/lib/pear/HTML/QuickForm/password.php

@@ -50,6 +50,7 @@ class HTML_QuickForm_password extends HTML_QuickForm_input
      */
     function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null)
     {
+        $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
         HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
         $this->setType('password');
     } //end constructor

+ 4 - 2
main/inc/lib/pear/HTML/QuickForm/text.php

@@ -48,9 +48,11 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
     public function HTML_QuickForm_text(
         $elementName = null,
         $elementLabel = null,
-        $attributes = null
+        $attributes = array()
     ) {
-        $attributes['class'] = 'form-control';
+        if (is_array($attributes)) {
+            $attributes['class'] = 'form-control';
+        }
 
         HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
         $this->_persistantFreeze = true;

+ 2 - 1
main/inc/lib/pear/HTML/QuickForm/textarea.php

@@ -57,8 +57,9 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
      * @access    public
      * @return    void
      */
-    function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null)
+    public function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null)
     {
+        $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
         $this->_persistantFreeze = true;
         $this->_type = 'textarea';

+ 1 - 2
main/newscorm/lp_add.php

@@ -149,8 +149,7 @@ $defaults['publicated_on']  = date('Y-m-d 08:00:00');
 $defaults['expired_on']     = date('Y-m-d 08:00:00',time()+86400);
 
 $form->setDefaults($defaults);
-$form->addElement('style_submit_button', 'Submit',get_lang('CreateLearningPath'),'class="save"');
-
+$form->addButtonCreate(get_lang('CreateLearningPath'));
 
 $form->display();
 // Footer

+ 2 - 2
main/newscorm/lp_add_item.php

@@ -179,7 +179,7 @@ $(document).ready(function() {
 echo $learnPath->build_action_menu();
 
 echo '<div class="row-fluid" style="overflow:hidden">';
-echo '<div id="lp_sidebar" class="span4">';
+echo '<div id="lp_sidebar" class="col-md-4">';
 
 echo $learnPath->return_new_tree(null, true);
 
@@ -198,7 +198,7 @@ if ($action == 'add_item' && $type == 'document' && !isset($_GET['file'])) {
     echo '<div id="hide_bar_template"></div>';
 }
 
-echo '<div id="doc_form" class="span8">';
+echo '<div id="doc_form" class="col-md-8">';
 
 //@todo use session flash messages
 if (in_array($message, array('ItemUpdated'))) {

+ 1 - 1
main/user/subscribe_user.php

@@ -64,7 +64,7 @@ $renderer = $form->defaultRenderer();
 $renderer->setElementTemplate('<span>{element}</span> ');
 $form->addText('keyword', '', false);
 $form->addElement('hidden', 'type', $type);
-$form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
+$form->addButtonSearch(get_lang('Search'));
 $form->addElement('static', 'additionalactions', null, $actions);
 $form->display();
 echo '</div>';