Add parameter to show only the first character of the weekday in calendar popups.
authorJan Schneider <jan@horde.org>
Mon, 31 May 2010 17:23:17 +0000 (19:23 +0200)
committerJan Schneider <jan@horde.org>
Mon, 31 May 2010 17:23:17 +0000 (19:23 +0200)
framework/Ui/lib/Horde/Ui/JsCalendar.php
kronolith/lib/Kronolith.php

index b3494ac..5f15b6d 100644 (file)
@@ -16,13 +16,24 @@ class Horde_Ui_JsCalendar
     /**
      * Output the necessary javascript code to allow display of the calendar
      * widget.
+     *
+     * @param array $params  Configuration parameters for the widget:
+     *                       - short_weekdays: display only the first letter of
+     *                         weekdays?
      */
-    static public function init()
+    static public function init($params = array())
     {
+        $params += array('short_weekdays' => false);
+        $weekdays = self::weekdays();
+        if ($params['short_weekdays']) {
+            foreach ($weekdays as &$day) {
+                $day = substr($day, 0, 1);
+            }
+        }
         Horde::addScriptFile('calendar.js', 'horde');
         Horde::addInlineScript(array(
             'Horde_Calendar.firstDayOfWeek = ' . (isset($GLOBALS['prefs']) ? intval($GLOBALS['prefs']->getValue('first_week_day')) : 1),
-            'Horde_Calendar.weekdays = ' . Horde_Serialize::serialize(self::weekdays(), Horde_Serialize::JSON, Horde_Nls::getCharset()),
+            'Horde_Calendar.weekdays = ' . Horde_Serialize::serialize($weekdays, Horde_Serialize::JSON, Horde_Nls::getCharset()),
             'Horde_Calendar.months = ' . Horde_Serialize::serialize(self::months(), Horde_Serialize::JSON, Horde_Nls::getCharset()),
         ));
     }
index 343c412..39ec58f 100644 (file)
@@ -77,7 +77,7 @@ class Kronolith
         Horde::addScriptFile('date/' . $datejs, 'horde');
         Horde::addScriptFile('date/date.js', 'horde');
         Horde::addScriptFile('kronolith.js', 'kronolith');
-        Horde_Ui_JsCalendar::init();
+        Horde_Ui_JsCalendar::init(array('short_weekdays' => true));
 
         if (isset($GLOBALS['language'])) {
             header('Content-type: text/html; charset=' . Horde_Nls::getCharset());