Add full_weekdays option to Horde_Core_Ui_JsCalendar::.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 27 Jul 2010 06:05:09 +0000 (00:05 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 27 Jul 2010 06:05:09 +0000 (00:05 -0600)
framework/Core/lib/Horde/Core/Ui/JsCalendar.php
horde/js/calendar.js

index 47afb15..e694622 100644 (file)
@@ -20,12 +20,22 @@ class Horde_Core_Ui_JsCalendar
      * widget.
      *
      * @param array $params  Configuration parameters for the widget:
-     *                       - short_weekdays: display only the first letter of
-     *                         weekdays?
+     * <pre>
+     * 'full_weekdays' - (boolean) Add full weekday localized list to
+     *                   javascript object.
+     *                   DEFAULT: false
+     * 'short_weekdays' - (boolean) Display only the first letter of
+     *                    weekdays?
+     *                    DEFAULT: false
+     * </pre>
      */
-    static public function init($params = array())
+    static public function init(array $params = array())
     {
-        $params += array('short_weekdays' => false);
+        $params = array_merge(array(
+            'full_weekdays' => false,
+            'short_weekdays' => false
+        ), $params);
+
         $weekdays = self::weekdays();
         if ($params['short_weekdays']) {
             foreach ($weekdays as &$day) {
@@ -37,8 +47,13 @@ class Horde_Core_Ui_JsCalendar
         Horde::addInlineScript(array(
             'Horde_Calendar.firstDayOfWeek = ' . (isset($GLOBALS['prefs']) ? intval($GLOBALS['prefs']->getValue('first_week_day')) : 1),
             'Horde_Calendar.weekdays = ' . Horde_Serialize::serialize($weekdays, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
-            'Horde_Calendar.months = ' . Horde_Serialize::serialize(self::months(), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
+            'Horde_Calendar.months = ' . Horde_Serialize::serialize(self::months(), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset())
         ));
+        if ($params['full_weekdays']) {
+            Horde::addInlineScript(array(
+                'Horde_Calendar.fullweekdays = ' . Horde_Serialize::serialize(self::fullWeekdays(), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset())
+            ));
+        }
     }
 
     /**
@@ -60,6 +75,24 @@ class Horde_Core_Ui_JsCalendar
     }
 
     /**
+     * Return the list of localized full weekday names.
+     *
+     * @return array  Full weekday names.
+     */
+    static public function fullWeekdays()
+    {
+        return array(
+            _("Sunday"),
+            _("Monday"),
+            _("Tuesday"),
+            _("Wednesday"),
+            _("Thursday"),
+            _("Friday"),
+            _("Saturday"),
+        );
+    }
+
+    /**
      * Return the localized list of months.
      *
      * @return array  Month list.
index c41b46f..9de7164 100644 (file)
@@ -9,7 +9,8 @@
 
 var Horde_Calendar =
 {
-    // Variables set externally: firstDayOfWeek, months, weekdays
+    // Variables set externally: firstDayOfWeek, fullweekdays, months,
+    //                           weekdays
     // Variables defaulting to null: date, month, openDate, trigger, year
 
     open: function(trigger, data)