Show event icons.
authorJan Schneider <jan@horde.org>
Fri, 20 Mar 2009 23:03:51 +0000 (00:03 +0100)
committerJan Schneider <jan@horde.org>
Fri, 20 Mar 2009 23:03:51 +0000 (00:03 +0100)
Use ngettext().

kronolith/js/src/kronolith.js
kronolith/lib/Event.php
kronolith/lib/Kronolith.php

index 5b4220a..da0060b 100644 (file)
@@ -598,6 +598,14 @@ KronolithCore = {
                         div.setText(event.value.t)
                             .observe('mouseover', div.addClassName.curry('kronolithSelected'))
                             .observe('mouseout', div.removeClassName.curry('kronolithSelected'));
+                        if (event.value.a) {
+                            div.insert(' ')
+                                .insert(new Element('IMG', { 'src': Kronolith.conf.URI_IMG + 'alarm-' + event.value.fg.substr(1) + '.png', 'title': Kronolith.text.alarm + ' ' + event.value.a }));
+                        }
+                        if (event.value.r) {
+                            div.insert(' ')
+                                .insert(new Element('IMG', { 'src': Kronolith.conf.URI_IMG + 'recur-' + event.value.fg.substr(1) + '.png', 'title': Kronolith.text.recur[event.value.r] }));
+                        }
                         $('kronolithMonthDay' + date.key).insert(div);
                         if (event.value.e) {
                             new Drag('kronolithEventmonth' + r.response.cal + event.key, { threshold: 5, parentElement: function() { return $('kronolithViewMonth').select('.kronolithViewBody')[0]; }, snapToParent: true });
@@ -923,7 +931,7 @@ KronolithCore = {
             $('kronolithEventCalendar').value = ev.ty + '|' + ev.c;
             $('kronolithEventTitle').value = ev.t;
             $('kronolithEventLocation').value = ev.l;
-            $('kronolithEventAllday').checked = ev.a;
+            $('kronolithEventAllday').checked = ev.al;
             $('kronolithEventStartDate').value = ev.sd
             $('kronolithEventStartTime').value = ev.st;
             $('kronolithEventEndDate').value = ev.ed;
index de71d63..d7effe7 100644 (file)
@@ -1015,20 +1015,35 @@ abstract class Kronolith_Event
         $json->fg = $this->_foregroundColor;
         $json->e = $this->hasPermission(PERMS_EDIT);
         $json->d = $this->hasPermission(PERMS_DELETE);
+        if ($this->alarm) {
+            if ($this->alarm % 10080 == 0) {
+                $alarm_value = $this->alarm / 10080;
+                $json->a = sprintf(ngettext("%d week", "%d weeks", $alarm_value), $alarm_value);
+            } elseif ($this->alarm % 1440 == 0) {
+                $alarm_value = $this->alarm / 1440;
+                $json->a = sprintf(ngettext("%d day", "%d days", $alarm_value), $alarm_value);
+            } elseif ($this->alarm % 60 == 0) {
+                $alarm_value = $this->alarm / 60;
+                $json->a = sprintf(ngettext("%d hour", "%d hours", $alarm_value), $alarm_value);
+            } else {
+                $alarm_value = $this->alarm;
+                $json->a = sprintf(ngettext("%d minute", "%d minutes", $alarm_value), $alarm_value);
+            }
+        }
+        if ($this->recurs()) {
+            $json->r = $this->recurrence->getRecurType();
+        }
 
         if ($full) {
             $json->i = $this->getId();
             $json->ty = $this->_calendarType;
             $json->l = $this->getLocation();
-            $json->a = $this->isAllDay();
+            $json->al = $this->isAllDay();
             $json->sd = $this->start->strftime('%x');
             $json->st = $this->start->format($time_format);
             $json->ed = $this->end->strftime('%x');
             $json->et = $this->end->format($time_format);
             $json->tg = array_values($this->tags);
-            if ($this->recurs()) {
-                $json->r = $this->recurrence->getRecurType();
-            }
         }
 
         return $json;
@@ -2056,24 +2071,16 @@ abstract class Kronolith_Event
             if ($this->alarm) {
                 if ($this->alarm % 10080 == 0) {
                     $alarm_value = $this->alarm / 10080;
-                    $title = $alarm_value == 1 ?
-                        _("Alarm 1 week before") :
-                        sprintf(_("Alarm %d weeks before"), $alarm_value);
+                    $title = sprintf(ngettext("Alarm %d week before", "Alarm %d weeks before", $alarm_value), $alarm_value);
                 } elseif ($this->alarm % 1440 == 0) {
                     $alarm_value = $this->alarm / 1440;
-                    $title = $alarm_value == 1 ?
-                        _("Alarm 1 day before") :
-                        sprintf(_("Alarm %d days before"), $alarm_value);
+                    $title = sprintf(ngettext("Alarm %d day before", "Alarm %d days before", $alarm_value), $alarm_value);
                 } elseif ($this->alarm % 60 == 0) {
                     $alarm_value = $this->alarm / 60;
-                    $title = $alarm_value == 1 ?
-                        _("Alarm 1 hour before") :
-                        sprintf(_("Alarm %d hours before"), $alarm_value);
+                    $title = sprintf(ngettext("Alarm %d hour before", "Alarm %d hours before", $alarm_value), $alarm_value);
                 } else {
                     $alarm_value = $this->alarm;
-                    $title = $alarm_value == 1 ?
-                        _("Alarm 1 minute before") :
-                        sprintf(_("Alarm %d minutes before"), $alarm_value);
+                    $title = sprintf(ngettext("Alarm %d minute before", "Alarm %d minutes before", $alarm_value), $alarm_value);
                 }
                 $status .= Horde::img('alarm-' . $icon_color . '.png', $title,
                                       array('title' => $title,
index 316fc1b..842b321 100644 (file)
@@ -137,6 +137,7 @@ class Kronolith
         $code['conf'] = array(
             'URI_AJAX' => Horde::url($kronolith_webroot . '/ajax.php', true, -1),
             'URI_PREFS' => Horde::url($horde_webroot . '/services/prefs/', true, -1),
+            'URI_IMG' => $registry->getImageDir() . '/',
             //'URI_VIEW' => Util::addParameter(Horde::url($imp_webroot . '/view.php', true, -1), array('actionID' => 'view_source', 'id' => 0), null, false),
             'SESSION_ID' => defined('SID') ? SID : '',
             'prefs_url' => str_replace('&amp;', '&', Horde::getServiceLink('options', 'kronolith')),
@@ -191,6 +192,7 @@ class Kronolith
         $code['text'] = array_map('addslashes', array(
             'ajax_timeout' => _("There has been no contact with the remote server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored."),
             'ajax_recover' => _("The connection to the remote server has been restored."),
+            'alarm' => _("Alarm:"),
         ));
         for ($i = 1; $i <= 12; ++$i) {
             $code['text']['month'][$i - 1] = NLS::getLangInfo(constant('MON_' . $i));
@@ -198,6 +200,15 @@ class Kronolith
         for ($i = 1; $i <= 7; ++$i) {
             $code['text']['weekday'][$i] = NLS::getLangInfo(constant('DAY_' . $i));
         }
+        foreach (array(Horde_Date_Recurrence::RECUR_DAILY,
+                       Horde_Date_Recurrence::RECUR_WEEKLY,
+                       Horde_Date_Recurrence::RECUR_MONTHLY_DATE,
+                       Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY,
+                       Horde_Date_Recurrence::RECUR_YEARLY_DATE,
+                       Horde_Date_Recurrence::RECUR_YEARLY_DAY,
+                       Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY) as $recurType) {
+            $code['text']['recur'][$recurType] = Kronolith::recurToString($recurType);
+        }
 
         return array('var Kronolith = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, NLS::getCharset()) . ';');
     }