From: Jan Schneider Date: Fri, 20 Mar 2009 23:03:51 +0000 (+0100) Subject: Show event icons. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=93d2a94ee9e216f68b268cc8c6fe6d0e1bc77411;p=horde.git Show event icons. Use ngettext(). --- diff --git a/kronolith/js/src/kronolith.js b/kronolith/js/src/kronolith.js index 5b4220a52..da0060b75 100644 --- a/kronolith/js/src/kronolith.js +++ b/kronolith/js/src/kronolith.js @@ -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; diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index de71d6348..d7effe7c7 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -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, diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 316fc1be3..842b321cb 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -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('&', '&', 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()) . ';'); }