Add support for listTimeObjects API to return an 'icon' member.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 6 Jun 2009 22:07:35 +0000 (18:07 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 6 Jun 2009 22:07:35 +0000 (18:07 -0400)
listTimeObjects 'icon' member is expected to be a fully qualified URL
to an image src.

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

index 24e0464..8fb0b33 100644 (file)
@@ -1151,6 +1151,10 @@ KronolithCore = {
 
     _setEventText: function(div, event)
     {
+        if (event.icn) {
+            div.insert(new Element('IMG', { 'src': event.icn }));
+        }
+
         div.insert(event.t);
         if (event.a) {
             div.insert(' ')
index 324aaaf..7c1d69d 100644 (file)
@@ -2175,7 +2175,9 @@ abstract class Kronolith_Event
                                       Horde::url($registry->getImageDir(), true, -1));
             }
 
-            if (!empty($status)) {
+            if (!empty($this->external) && !empty($this->external_icon)) {
+                $link = $status . Horde::img($this->external_icon, '', '', '') . ' ' . $link;
+            } else if (!empty($status)) {
                 $link .= ' ' . $status;
             }
 
index 2a603e5..fd3f085 100644 (file)
@@ -45,6 +45,7 @@ class Kronolith_Event_Horde extends Kronolith_Event
         $this->eventID = '_' . $this->_api . $event['id'];
         $this->external = $this->_api;
         $this->external_params = $event['params'];
+        $this->external_icon = !empty($event['icon']) ? $event['icon'] : null;
         $this->title = $event['title'];
         $this->description = isset($event['description']) ? $event['description'] : '';
         $this->start = $eventStart;
@@ -53,6 +54,7 @@ class Kronolith_Event_Horde extends Kronolith_Event
 
         if (isset($event['recurrence'])) {
             $recurrence = new Horde_Date_Recurrence($eventStart);
+
             $recurrence->setRecurType($event['recurrence']['type']);
             if (isset($event['recurrence']['end'])) {
                 $recurrence->setRecurEnd($event['recurrence']['end']);
@@ -78,4 +80,14 @@ class Kronolith_Event_Horde extends Kronolith_Event
         $this->stored = true;
     }
 
+    public function toJson($allDay = null, $full = false, $time_format = 'H:i')
+    {
+        $json = parent::toJson($allDay, $full, $time_format);
+        $json->icn = $this->external_icon;
+        // @TODO: What is expected for external calendar links? This is currently
+        // broken in the UI.
+        //$json->link = $this->getLink();
+        return $json;
+    }
+
 }