Преглед изворни кода

Minor - fixing UI, format code.

Julio Montoya пре 11 година
родитељ
комит
b62494b1a0

+ 79 - 85
main/inc/lib/formvalidator/Element/datepicker.php

@@ -1,6 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
-require_once ('HTML/QuickForm/date.php');
+require_once 'HTML/QuickForm/date.php';
 /**
  * Form element to select a date and hour (with popup datepicker)
  */
@@ -11,89 +11,83 @@ class HTML_QuickForm_datepicker extends HTML_QuickForm_date
 	 */
 	function HTML_QuickForm_datepicker($elementName = null, $elementLabel = null, $attributes = null, $optionIncrement = null)
 	{
-		$js_form_name = $attributes['form_name'];
-		unset($attributes['form_name']);
-		HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes);
-		$this->_persistantFreeze = true;
-		$this->_appendName = true;
-		$this->_type = 'datepicker';
-		$popup_link = '<a href="javascript:openCalendar(\''.$js_form_name.'\',\''.$elementName.'\')"><img src="'.api_get_path(WEB_IMG_PATH).'calendar_select.gif" style="vertical-align:middle;" alt="Select Date" /></a>';
-		$special_chars = array ('D', 'l', 'd', 'M', 'F', 'm', 'y', 'H', 'a', 'A', 's', 'i', 'h', 'g', ' ');
-		$hour_minute_devider = get_lang("HourMinuteDivider");
-		foreach ($special_chars as $index => $char)
-		{
-			$popup_link = str_replace($char, "\\".$char, $popup_link);
-			$hour_minute_devider = str_replace($char, "\\".$char, $hour_minute_devider);
-		}
-		$lang_code = api_get_language_isocode();
-		// If translation not available in PEAR::HTML_QuickForm_date, add the Chamilo-translation
-		if(! array_key_exists($lang_code,$this->_locale))
-		{
-			$this->_locale[$lang_code]['months_long'] = api_get_months_long();
-		}
-		$this->_options['format'] = 'dFY '.$popup_link.'   H '.$hour_minute_devider.' i';
-		$this->_options['minYear'] = date('Y')-5;
-		$this->_options['maxYear'] = date('Y')+10;
-		$this->_options['language'] = $lang_code;
-		//$this->_options['addEmptyOption'] = true;
-		//$this->_options['emptyOptionValue'] = 0;
-		//$this->_options['emptyOptionText'] = ' -- ';
-		if (isset($optionIncrement)) {
-        $this->_options['optionIncrement']['i'] = intval($optionIncrement);
+        $js_form_name = $attributes['form_name'];
+        unset($attributes['form_name']);
+        HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_appendName = true;
+        $this->_type = 'datepicker';
+        $popup_link = '<a href="javascript:openCalendar(\''.$js_form_name.'\',\''.$elementName.'\')">
+        <img src="'.api_get_path(WEB_IMG_PATH).'calendar_select.gif" style="vertical-align:middle;" alt="Select Date" /></a>';
+        $special_chars = array ('D', 'l', 'd', 'M', 'F', 'm', 'y', 'H', 'a', 'A', 's', 'i', 'h', 'g', ' ');
+        $hour_minute_devider = get_lang("HourMinuteDivider");
+        foreach ($special_chars as $char) {
+            $popup_link = str_replace($char, "\\".$char, $popup_link);
+            $hour_minute_devider = str_replace($char, "\\".$char, $hour_minute_devider);
         }
-		
-	}
-	/**
-	 * HTML code to display this datepicker
-	 */
-	function toHtml()
-	{
-		$js = $this->getElementJS();
-		return $js.parent :: toHtml();
-	}
-	/**
-	 * Get the necessary javascript for this datepicker
-	 */
-	function getElementJS()
-	{
-		$js = '';
-		if(!defined('DATEPICKER_JAVASCRIPT_INCLUDED'))
-		{
-			define('DATEPICKER_JAVASCRIPT_INCLUDED',1);
-			$js = "\n";
-			$js .= '<script src="';
-			$js .= api_get_path(WEB_CODE_PATH).'inc/lib/formvalidator/Element/';
-			$js .= 'tbl_change.js.php" type="text/javascript"></script>';
-			$js .= "\n";
-		}
-		return $js;
-	}
-	/**
-	 * Export the date value in MySQL format
-	 * @return string YYYY-MM-DD HH:II:SS
-	 */
-	function exportValue(&$submitValues, $assoc = false)
-	{
-		$values = parent::getValue();
-		$y = $values['Y'][0];
-		$m = $values['F'][0];
-		$d = $values['d'][0];
-		$h = $values['H'][0];
-		$i = $values['i'][0];
-		$m = $m < 10 ? '0'.$m : $m;
-		$d = $d < 10 ? '0'.$d : $d;
-		$h = $h < 10 ? '0'.$h : $h;
-		$i = $i < 10 ? '0'.$i : $i;
-		$datetime = $y.'-'.$m.'-'.$d.' '.$h.':'.$i.':00';
-		$result[$this->getName()]= $datetime;
-		return $result;
-	}
-		/**
-	 * Sets an option to a value
-	 */
-	function setLocalOption($name,$value)
-	{
-		$this->_options[$name] = $value;
-	}
+        $lang_code = api_get_language_isocode();
+        // If translation not available in PEAR::HTML_QuickForm_date, add the Chamilo-translation
+        if (! array_key_exists($lang_code, $this->_locale)) {
+            $this->_locale[$lang_code]['months_long'] = api_get_months_long();
+        }
+        $this->_options['format'] = 'dFY '.$popup_link.'   H '.$hour_minute_devider.' i';
+        $this->_options['minYear'] = date('Y')-5;
+        $this->_options['maxYear'] = date('Y')+10;
+        $this->_options['language'] = $lang_code;
+
+        if (isset($optionIncrement)) {
+            $this->_options['optionIncrement']['i'] = intval($optionIncrement);
+        }
+    }
+
+    /**
+     * HTML code to display this datepicker
+     */
+    public function toHtml()
+    {
+        $javascript = $this->getElementJS();
+        return $javascript.parent :: toHtml();
+    }
+
+    /**
+     * Get the necessary javascript for this datepicker
+     */
+    private function getElementJS()
+    {
+        $js = '';
+        if (!defined('DATEPICKER_JAVASCRIPT_INCLUDED')) {
+            define('DATEPICKER_JAVASCRIPT_INCLUDED', 1);
+            $js .= '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/formvalidator/Element/tbl_change.js.php" type="text/javascript"></script>';
+        }
+        return $js;
+    }
+
+    /**
+     * Export the date value in MySQL format
+     * @return string YYYY-MM-DD HH:II:SS
+     */
+    public function exportValue(&$submitValues, $assoc = false)
+    {
+        $values = parent::getValue();
+        $y = $values['Y'][0];
+        $m = $values['F'][0];
+        $d = $values['d'][0];
+        $h = $values['H'][0];
+        $i = $values['i'][0];
+        $m = $m < 10 ? '0'.$m : $m;
+        $d = $d < 10 ? '0'.$d : $d;
+        $h = $h < 10 ? '0'.$h : $h;
+        $i = $i < 10 ? '0'.$i : $i;
+        $datetime = $y.'-'.$m.'-'.$d.' '.$h.':'.$i.':00';
+        $result[$this->getName()]= $datetime;
+        return $result;
+    }
+
+    /**
+     * Sets an option to a value
+     */
+    function setLocalOption($name,$value)
+    {
+        $this->_options[$name] = $value;
+    }
 }
-?>

+ 8 - 10
main/inc/lib/pear/HTML/QuickForm/advmultiselect.php

@@ -298,7 +298,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
         $this->_tableAttributes = $this->getAttribute('class');
         $attr = null;
         if (is_null($this->_tableAttributes)) {
-            $this->updateAttributes(array('class' => 'span4'));
+            $this->updateAttributes(array('class' => 'col-md-4'));
         } else {
             $attr = array('class' => $this->_tableAttributes);
             $this->_removeAttr('class', $this->_attributes);
@@ -565,15 +565,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
         if (isset($html) && is_string($html)) {
             // $this->_elementTemplate = $html;
         } else {
-            /*<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
-            <!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->*/
 
             $this->_elementTemplate = '
             {javascript}
             <div class="advmultiselect row">
-                <div class="span4">{unselected}</div>
-                <div class="span1">{add} <br /><br />{remove}</div>
-                <div class="span4">{selected}</div>
+                <div class="col-md-5">{unselected}</div>
+                <div class="col-md-2">{add} <br /><br />{remove}</div>
+                <div class="col-md-5">{selected}</div>
             </div>
             ';
         }
@@ -903,7 +901,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
 
             // build the remove button with all its attributes
             $attributes = array(
-                'class' => 'btn btn-block ',
+                'class' => 'btn btn-default ',
                 'onclick' => $jsName.
                     "('{$selectId}', ".
                     "this.form.elements['".$selectNameFrom."'], ".
@@ -915,12 +913,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
                 = array_merge($this->_removeButtonAttributes, $attributes);
             $attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes);
             //$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL;
-            $strHtmlRemove = "<button$attrStrRemove /><i class='icon-arrow-left icon-large'></i></button>".PHP_EOL;
+            $strHtmlRemove = "<button$attrStrRemove /><i class='fa fa-arrow-left fa2'></i></button>".PHP_EOL;
 
             // build the add button with all its attributes
             $attributes
                 = array(
-                'class' => 'btn btn-block ',
+                'class' => 'btn btn-default',
                 'onclick' => $jsName.
                     "('{$selectId}', ".
                     "this.form.elements['".$selectNameFrom."'], ".
@@ -931,7 +929,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
             $this->_addButtonAttributes
                 = array_merge($this->_addButtonAttributes, $attributes);
             $attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
-            $strHtmlAdd = "<button$attrStrAdd /><i class='icon-arrow-right icon-large'></i></button>".PHP_EOL;
+            $strHtmlAdd = "<button$attrStrAdd /><i class='fa fa-arrow-right fa2'></i></button>".PHP_EOL;
 
             // build the select all button with all its attributes
             $attributes

+ 84 - 96
main/inc/lib/pear/HTML/QuickForm/date.php

@@ -1,33 +1,33 @@
 <?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
-/**
- * Class for a group of elements used to input dates (and times).
- *
- * PHP versions 4 and 5
- *
- * LICENSE: This source file is subject to version 3.01 of the PHP license
- * that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_01.txt If you did not receive a copy of
- * the PHP License and are unable to obtain it through the web, please
- * send a note to license@php.net so we can mail you a copy immediately.
- *
- * @category    HTML
- * @package     HTML_QuickForm
- * @author      Alexey Borzov <avb@php.net>
- * @copyright   2001-2009 The PHP Group
- * @license     http://www.php.net/license/3_01.txt PHP License 3.01
- * @version     CVS: $Id: date.php,v 1.62 2009/04/04 21:34:02 avb Exp $
- * @link        http://pear.php.net/package/HTML_QuickForm
- */
-
-/**
- * Class for a group of form elements
- */
+/**
+ * Class for a group of elements used to input dates (and times).
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2009 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id: date.php,v 1.62 2009/04/04 21:34:02 avb Exp $
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Class for a group of form elements
+ */
 require_once 'HTML/QuickForm/group.php';
-/**
- * Class for <select></select> elements
- */
+/**
+ * Class for <select></select> elements
+ */
 require_once 'HTML/QuickForm/select.php';
 
 /**
@@ -36,11 +36,11 @@ require_once 'HTML/QuickForm/select.php';
  * Inspired by original 'date' element but reimplemented as a subclass
  * of HTML_QuickForm_group
  *
- * @category    HTML
- * @package     HTML_QuickForm
- * @author      Alexey Borzov <avb@php.net>
- * @version     Release: 3.2.11
- * @since       3.1
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.11
+ * @since       3.1
  */
 class HTML_QuickForm_date extends HTML_QuickForm_group
 {
@@ -244,34 +244,34 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
    /**
     * Class constructor
     *
-    * The following keys may appear in $options array:
-    * - 'language': date language
-    * - 'format': Format of the date, based on PHP's date() function.
-    *   The following characters are currently recognised in format string:
-    *   <pre>
-    *       D => Short names of days
-    *       l => Long names of days
-    *       d => Day numbers
-    *       M => Short names of months
-    *       F => Long names of months
-    *       m => Month numbers
-    *       Y => Four digit year
-    *       y => Two digit year
-    *       h => 12 hour format
-    *       H => 23 hour  format
-    *       i => Minutes
-    *       s => Seconds
-    *       a => am/pm
-    *       A => AM/PM
-    *   </pre>
-    * - 'minYear': Minimum year in year select
-    * - 'maxYear': Maximum year in year select
-    * - 'addEmptyOption': Should an empty option be added to the top of
-    *    each select box?
-    * - 'emptyOptionValue': The value passed by the empty option.
-    * - 'emptyOptionText': The text displayed for the empty option.
-    * - 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
-    *
+    * The following keys may appear in $options array:
+    * - 'language': date language
+    * - 'format': Format of the date, based on PHP's date() function.
+    *   The following characters are currently recognised in format string:
+    *   <pre>
+    *       D => Short names of days
+    *       l => Long names of days
+    *       d => Day numbers
+    *       M => Short names of months
+    *       F => Long names of months
+    *       m => Month numbers
+    *       Y => Four digit year
+    *       y => Two digit year
+    *       h => 12 hour format
+    *       H => 23 hour  format
+    *       i => Minutes
+    *       s => Seconds
+    *       a => am/pm
+    *       A => AM/PM
+    *   </pre>
+    * - 'minYear': Minimum year in year select
+    * - 'maxYear': Maximum year in year select
+    * - 'addEmptyOption': Should an empty option be added to the top of
+    *    each select box?
+    * - 'emptyOptionValue': The value passed by the empty option.
+    * - 'emptyOptionText': The text displayed for the empty option.
+    * - 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
+    *
     * @access   public
     * @param    string  Element's name
     * @param    mixed   Label(s) for an element
@@ -288,7 +288,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
         $current_year = intval(api_get_local_time());
         $this->_options['minYear'] = $current_year - 9;
         $this->_options['maxYear'] = $current_year + 1;
-        //
+
         // set the options, do not bother setting bogus ones
         if (is_array($options)) {
             foreach ($options as $name => $value) {
@@ -319,7 +319,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
         //    $sign = $this->_options['format']{$i};
         for ($i = 0, $length = api_strlen($this->_options['format']); $i < $length; $i++) {
             $sign = api_substr($this->_options['format'], $i, 1);
-        //
+
             if ($backslash) {
                 $backslash  = false;
                 $separator .= $sign;
@@ -423,9 +423,6 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
         $this->_wrap[1] = $separator . ($backslash? '\\': '');
     }
 
-    // }}}
-    // {{{ _createOptionList()
-
    /**
     * Creates an option list containing the numbers from the start number to the end, inclusive
     *
@@ -444,25 +441,22 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
     }
 
     // }}}
-    // {{{ _trimLeadingZeros()
-
-   /**
-    * Trims leading zeros from the (numeric) string
-    *
-    * @param    string  A numeric string, possibly with leading zeros
-    * @return   string  String with leading zeros removed
-    */
-    function _trimLeadingZeros($str)
-    {
-        if (0 == strcmp($str, $this->_options['emptyOptionValue'])) {
-            return $str;
-        }
-        $trimmed = ltrim($str, '0');
-        return strlen($trimmed)? $trimmed: '0';
-    }
-
-    // }}}
-    // {{{ setValue()
+    // {{{ _trimLeadingZeros()
+
+   /**
+    * Trims leading zeros from the (numeric) string
+    *
+    * @param    string  A numeric string, possibly with leading zeros
+    * @return   string  String with leading zeros removed
+    */
+    function _trimLeadingZeros($str)
+    {
+        if (0 == strcmp($str, $this->_options['emptyOptionValue'])) {
+            return $str;
+        }
+        $trimmed = ltrim($str, '0');
+        return strlen($trimmed)? $trimmed: '0';
+    }
 
     function setValue($value)
     {
@@ -473,7 +467,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
                 $value = strtotime($value);
             }
             // might be a unix epoch, then we fill all possible values
-            $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
+            $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
             $value = array(
                 'D' => $arr[0],
                 'l' => $arr[0],
@@ -486,21 +480,18 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
                 'h' => $arr[4],
                 'g' => $arr[4],
                 'H' => $arr[5],
-                'i' => $this->_trimLeadingZeros($arr[6]),
-                's' => $this->_trimLeadingZeros($arr[7]),
+                'i' => $this->_trimLeadingZeros($arr[6]),
+                's' => $this->_trimLeadingZeros($arr[7]),
                 'a' => $arr[8],
                 'A' => $arr[9],
-                'W' => $this->_trimLeadingZeros($arr[10])
+                'W' => $this->_trimLeadingZeros($arr[10])
             );
-        } else {
-            $value = array_map(array($this, '_trimLeadingZeros'), $value);
+        } else {
+            $value = array_map(array($this, '_trimLeadingZeros'), $value);
         }
         parent::setValue($value);
     }
 
-    // }}}
-    // {{{ toHtml()
-
     function toHtml()
     {
         include_once('HTML/QuickForm/Renderer/Default.php');
@@ -531,7 +522,4 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
             return parent::onQuickFormEvent($event, $arg, $caller);
         }
     }
-
-    // }}}
 }
-?>