Improve log layout
[infodrom.org/service.infodrom.org] / class / calendar_item.class.php
index 822bd79..b8fb50d 100644 (file)
@@ -105,21 +105,29 @@ class Calendar_Item extends DatabaseTable {
 
     $color = 0;
     $out = sprintf('<div class="caltitle">%s</div>', $title);
-    $out .= sprintf('<div class="row%d">%s: Item created</div>', $color, substr($this->data->created,0,16));
-    # $out .= sprintf('<div>Last modified %s</div>', $this->data->last_modified);
+
+    $items = array();
+    $items[] = array('dt' => substr($this->data->created,0,16),
+                    'log' => 'Item created');
 
     $sql = sprintf("SELECT name,url,comment,sys_edit,sys_user " .
                   "FROM calendar_item_log WHERE dav_id = %d ORDER BY sys_edit", $this->id);
     foreach ($this->fetchObjectList($sql) as $row) {
-      $color = !$color;
       if (strlen($row->url))
-       $out .= sprintf('<div class="row%d">%s: <a href="%s" target="_blank">%s</a></div>',
-                       $color,
-                       substr($row->sys_edit,0,16),
-                       $row->url,
-                       $row->name ? $row->name : 'Link');
+         $items[] = array('dt' => substr($row->sys_edit,0,16),
+                          'log' => sprintf('<a href="%s" target="_blank">%s</a>',
+                                          $row->url,
+                                          $row->name ? $row->name : 'Link'));
       if (strlen($row->comment))
-       $out .= sprintf('<div class="row%d">%s: %s</div>', $color, substr($row->sys_edit,0,16), $row->comment);
+         $items[] = array('dt' => substr($row->sys_edit,0,16),
+                          'log' => $row->comment);
+    }
+
+    foreach ($items as $item) {
+       $color = !$color;
+       $out .= sprintf('<div class="row%d"><div class="logl">%s</div><div class="logr">%s</div><div class="clear"></div></div>',
+                       $color,
+                       $item['dt'], $item['log']);
     }
 
     return array('html' => array('log' => $out));