Re-order classes, only iCalendar has its own base component, but it still
authorJan Schneider <jan@horde.org>
Thu, 10 Sep 2009 22:00:57 +0000 (00:00 +0200)
committerJan Schneider <jan@horde.org>
Thu, 10 Sep 2009 22:00:57 +0000 (00:00 +0200)
works like a regular component. So drop components altogether to save one
level in the filesystem/class hierarchy.

20 files changed:
framework/Icalendar/lib/Horde/Icalendar/Base.php
framework/Icalendar/lib/Horde/Icalendar/Component/Base.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Valarm.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Vevent.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Vfreebusy.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Vjournal.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Vtimezone.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Component/Vtodo.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Icalendar.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Valarm.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vcalendar.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vevent.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vjournal.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Vtodo.php [new file with mode: 0644]
framework/Icalendar/lib/Horde/Icalendar/Writer/Base.php
framework/Icalendar/lib/Horde/Icalendar/Writer/Icalendar/20.php [deleted file]
framework/Icalendar/lib/Horde/Icalendar/Writer/Vcalendar/20.php [new file with mode: 0644]
framework/Icalendar/test/Horde/Icalendar/WriterTest.php

index b455f19..59ad336 100644 (file)
@@ -1,11 +1,16 @@
 <?php
 
-abstract class Horde_Icalendar_Base
+abstract class Horde_Icalendar_Base implements Iterator
 {
     /**
      * @var array
      */
-    protected $_components = array();
+    public $components = array();
+
+    /**
+     * @var array
+     */
+    protected $_properties = array();
 
     protected $_params;
 
@@ -14,9 +19,194 @@ abstract class Horde_Icalendar_Base
         $this->_params = $params;
     }
 
-    public function addComponent(Horde_Icalendar_Component_Base $component)
+    /**
+     * Validates a property-value-pair.
+     *
+     * @throws InvalidArgumentException
+     */
+    protected function _validate($property, &$value, &$params = array())
+    {
+        if (!isset($this->_properties[$property])) {
+            throw new InvalidArgumentException($property . ' is not a valid property');
+        }
+        $myProperty = &$this->_properties[$property];
+        if (isset($myProperty['type'])) {
+            $func = 'is_' . $myProperty['type'];
+            if (!$func) {
+                throw new InvalidArgumentException($value . ' is not a ' . $myProperty['type']);
+            }
+        } elseif (isset($myProperty['class'])) {
+            if (!($value instanceof $myProperty['class'])) {
+                throw new InvalidArgumentException($value . ' is not of class ' . $myProperty['class']);
+            }
+        }
+        if ($property == 'stamp') {
+            $value->setTimezone('UTC');
+        }
+    }
+
+    /**
+     * Setter.
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __set($property, $value)
+    {
+        $this->_validate($property, $value);
+        if ($this->_properties[$property]['multiple']) {
+            $this->_properties[$property]['value'] = array($value);
+            $this->_properties[$property]['params'] = array();
+        } else {
+            $this->_properties[$property]['value'] = $value;
+            $this->_properties[$property]['params'] = null;
+        }
+    }
+
+    /**
+     * Sets the value of a property.
+     *
+     * @param string $property  The name of the property.
+     * @param string $value     The value of the property.
+     * @param array $params     Array containing any addition parameters for
+     *                          this property.
+     *
+     * @throws InvalidArgumentException
+     */
+    public function setProperty($property, $value, $params = array())
+    {
+        $this->$name = $value;
+        $this->_properties[$property]['params'] = array($params);
+    }
+
+    /**
+     * Adds the value of a property.
+     *
+     * @param string $property  The name of the property.
+     * @param string $value     The value of the property.
+     * @param array $params     Array containing any addition parameters for
+     *                          this property.
+     *
+     * @throws InvalidArgumentException
+     * @throws Horde_Icalendar_Exception
+     */
+    public function addProperty($property, $value, $params = array())
+    {
+        $this->_validate($property, $value);
+        if (!$this->_properties[$property]['multiple'] &&
+            !isset($this->_properties[$property]['value'])) {
+            throw new Horde_Icalendar_Exception($property . ' properties must not occur more than once.');
+        }
+        if (isset($this->_properties[$property]['value'])) {
+            $this->_properties[$property]['value'][] = $value;
+            $this->_properties[$property]['params'][] = $params;
+        } else {
+            $this->setProperty($property, $value, $params);
+        }
+    }
+
+    /**
+     * Getter.
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __get($property)
+    {
+        if (!isset($this->_properties[$property])) {
+            throw new InvalidArgumentException($property . ' is not a valid property');
+        }
+        return isset ($this->_properties[$property]['value'])
+            ? $this->_properties[$property]['value']
+            : null;
+    }
+
+    /**
+     * Returns the value of an property.
+     *
+     * @param string $name     The name of the property.
+     * @param boolean $params  Return the parameters for this property instead
+     *                         of its value.
+     *
+     * @return mixed (object)  PEAR_Error if the property does not exist.
+     *               (string)  The value of the property.
+     *               (array)   The parameters for the property or
+     *                         multiple values for an property.
+     */
+    function getProperty($name, $params = false)
+    {
+        $result = array();
+        foreach ($this->_properties as $property) {
+            if ($property['name'] == $name) {
+                if ($params) {
+                    $result[] = $property['params'];
+                } else {
+                    $result[] = $property['value'];
+                }
+            }
+        }
+        if (!count($result)) {
+            require_once 'PEAR.php';
+            return PEAR::raiseError('Property "' . $name . '" Not Found');
+        } if (count($result) == 1 && !$params) {
+            return $result[0];
+        } else {
+            return $result;
+        }
+    }
+
+    public function getProperties()
+    {
+        return $this->_properties;
+    }
+
+    /**
+     * Validates the complete component for missing properties or invalid
+     * property combinations.
+     *
+     * @throws Horde_Icalendar_Exception
+     */
+    public function validate()
+    {
+        foreach ($this->_properties as $name => $property) {
+            if (!empty($property['required']) && !isset($property['value'])) {
+                switch ($name) {
+                case 'uid':
+                    $this->uid = (string)new Horde_Support_Guid;
+                    break;
+                case 'stamp':
+                    $this->stamp = new Horde_Date(time());
+                    break;
+                default:
+                    // @todo Use LSB (static::__CLASS__) once we require PHP 5.3
+                    $component = Horde_String::upper(str_replace('Horde_Icalendar_Component_', '', get_class($this)));
+                    throw new Horde_Icalendar_Exception($component . ' components must have a ' . $name . ' property set');
+                }
+            }
+        }
+    }
+
+    public function current()
+    {
+        return current($this->_properties);
+    }
+
+    public function key()
+    {
+        return key($this->_properties);
+    }
+
+    public function next()
+    {
+        next($this->_properties);
+    }
+
+    public function rewind()
+    {
+        reset($this->_properties);
+    }
+
+    public function valid()
     {
-        $this->_components[] = $component;
+        return current($this->_properties) !== false;
     }
 
     /**
@@ -24,9 +214,11 @@ abstract class Horde_Icalendar_Base
      */
     public function export()
     {
+        $this->validate();
         $writer = Horde_Icalendar_Writer::factory(
             str_replace('Horde_Icalendar_', '', get_class($this)),
             str_replace('.', '', $this->_params['version']));
+        return $writer->export($this);
     }
 
 }
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Base.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Base.php
deleted file mode 100644 (file)
index d2ead5a..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-<?php
-
-abstract class Horde_Icalendar_Component_Base implements Iterator
-{
-    /**
-     * @var array
-     */
-    protected $_properties = array();
-
-    /**
-     * Validates a property-value-pair.
-     *
-     * @throws InvalidArgumentException
-     */
-    protected function _validate($property, &$value, &$params = array())
-    {
-        if (!isset($this->_properties[$property])) {
-            throw new InvalidArgumentException($property . ' is not a valid property');
-        }
-        $myProperty = &$this->_properties[$property];
-        if (isset($myProperty['type'])) {
-            $func = 'is_' . $myProperty['type'];
-            if (!$func) {
-                throw new InvalidArgumentException($value . ' is not a ' . $myProperty['type']);
-            }
-        } elseif (isset($myProperty['class'])) {
-            if (!($value instanceof $myProperty['class'])) {
-                throw new InvalidArgumentException($value . ' is not of class ' . $myProperty['class']);
-            }
-        }
-        if ($property == 'stamp') {
-            $value->setTimezone('UTC');
-        }
-    }
-
-    /**
-     * Setter.
-     *
-     * @throws InvalidArgumentException
-     */
-    public function __set($property, $value)
-    {
-        $this->_validate($property, $value);
-        if ($this->_properties[$property]['multiple']) {
-            $this->_properties[$property]['value'] = array($value);
-            $this->_properties[$property]['params'] = array();
-        } else {
-            $this->_properties[$property]['value'] = $value;
-            $this->_properties[$property]['params'] = null;
-        }
-    }
-
-    /**
-     * Sets the value of a property.
-     *
-     * @param string $property  The name of the property.
-     * @param string $value     The value of the property.
-     * @param array $params     Array containing any addition parameters for
-     *                          this property.
-     *
-     * @throws InvalidArgumentException
-     */
-    public function setProperty($property, $value, $params = array())
-    {
-        $this->$name = $value;
-        $this->_properties[$property]['params'] = array($params);
-    }
-
-    /**
-     * Adds the value of a property.
-     *
-     * @param string $property  The name of the property.
-     * @param string $value     The value of the property.
-     * @param array $params     Array containing any addition parameters for
-     *                          this property.
-     *
-     * @throws InvalidArgumentException
-     * @throws Horde_Icalendar_Exception
-     */
-    public function addProperty($property, $value, $params = array())
-    {
-        $this->_validate($property, $value);
-        if (!$this->_properties[$property]['multiple'] &&
-            !isset($this->_properties[$property]['value'])) {
-            throw new Horde_Icalendar_Exception($property . ' properties must not occur more than once.');
-        }
-        if (isset($this->_properties[$property]['value'])) {
-            $this->_properties[$property]['value'][] = $value;
-            $this->_properties[$property]['params'][] = $params;
-        } else {
-            $this->setProperty($property, $value, $params);
-        }
-    }
-
-    /**
-     * Getter.
-     *
-     * @throws InvalidArgumentException
-     */
-    public function __get($property)
-    {
-        if (!isset($this->_properties[$property])) {
-            throw new InvalidArgumentException($property . ' is not a valid property');
-        }
-        return isset ($this->_properties[$property]['value'])
-            ? $this->_properties[$property]['value']
-            : null;
-    }
-
-    /**
-     * Returns the value of an property.
-     *
-     * @param string $name     The name of the property.
-     * @param boolean $params  Return the parameters for this property instead
-     *                         of its value.
-     *
-     * @return mixed (object)  PEAR_Error if the property does not exist.
-     *               (string)  The value of the property.
-     *               (array)   The parameters for the property or
-     *                         multiple values for an property.
-     */
-    function getProperty($name, $params = false)
-    {
-        $result = array();
-        foreach ($this->_properties as $property) {
-            if ($property['name'] == $name) {
-                if ($params) {
-                    $result[] = $property['params'];
-                } else {
-                    $result[] = $property['value'];
-                }
-            }
-        }
-        if (!count($result)) {
-            require_once 'PEAR.php';
-            return PEAR::raiseError('Property "' . $name . '" Not Found');
-        } if (count($result) == 1 && !$params) {
-            return $result[0];
-        } else {
-            return $result;
-        }
-    }
-
-    public function getProperties()
-    {
-        return $this->_properties;
-    }
-
-    /**
-     * Validates the complete component for missing properties or invalid
-     * property combinations.
-     *
-     * @throws Horde_Icalendar_Exception
-     */
-    public function validate()
-    {
-        foreach ($this->_properties as $name => $property) {
-            if (!empty($property['required']) && !isset($property['value'])) {
-                switch ($name) {
-                case 'uid':
-                    $this->uid = (string)new Horde_Support_Guid;
-                    break;
-                case 'stamp':
-                    $this->stamp = new Horde_Date(time());
-                    break;
-                default:
-                    $component = Horde_String::upper(str_replace('Horde_Icalendar_Component_', '', get_class($this)));
-                    throw new Horde_Icalendar_Exception($component . ' components must have a ' . $name . ' property set');
-                }
-            }
-        }
-    }
-
-    public function current()
-    {
-        return current($this->_properties);
-    }
-
-    public function key()
-    {
-        return key($this->_properties);
-    }
-
-    public function next()
-    {
-        next($this->_properties);
-    }
-
-    public function rewind()
-    {
-        reset($this->_properties);
-    }
-
-    public function valid()
-    {
-        return current($this->_properties) !== false;
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Valarm.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Valarm.php
deleted file mode 100644 (file)
index b1556ad..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Valarm extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            'summary' => array('required' => false,
-                               'multiple' => false,
-                               'type' => 'string'),
-            'description' => array('required' => false,
-                                   'multiple' => false,
-                                   'type' => 'string'));
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Vevent.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Vevent.php
deleted file mode 100644 (file)
index d82a00d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Vevent extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            'uid' => array('required' => true,
-                           'multiple' => false,
-                           'type' => 'string'),
-            'start' => array('required' => false,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'startDate' => array('required' => false,
-                                 'multiple' => false,
-                                 'class' => 'Horde_Date'),
-            'stamp' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'summary' => array('required' => false,
-                               'multiple' => false,
-                               'type' => 'string'),
-            'description' => array('required' => false,
-                                   'multiple' => false,
-                                   'type' => 'string'));
-    }
-
-    public function validate()
-    {
-        parent::validate();
-        if (!isset($this->_properties['start']['value']) &&
-            !isset($this->_properties['startDate']['value'])) {
-            throw new Horde_Icalendar_Exception('VEVENT components must have a start property set');
-        }
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Vfreebusy.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Vfreebusy.php
deleted file mode 100644 (file)
index 9295554..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Vfreebusy extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            'uid' => array('required' => true,
-                           'multiple' => false,
-                           'type' => 'string'),
-            'start' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'stamp' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-        );
-    }
-
-    /**
-     * Validates a property-value-pair.
-     *
-     * @throws InvalidArgumentException
-     */
-    protected function _validate($property, &$value)
-    {
-        parent::_validate($property, $value);
-        if ($property == 'start') {
-            $value->setTimezone('UTC');
-        }
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Vjournal.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Vjournal.php
deleted file mode 100644 (file)
index d4a8155..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Vjournal extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            'uid' => array('required' => true,
-                           'multiple' => false,
-                           'type' => 'string'),
-            'stamp' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'summary' => array('required' => false,
-                               'multiple' => false,
-                               'type' => 'string'),
-            'description' => array('required' => false,
-                                   'multiple' => false,
-                                   'type' => 'string'));
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Vtimezone.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Vtimezone.php
deleted file mode 100644 (file)
index 197f265..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Vtimezone extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            /*
-   Within the "VTIMEZONE" calendar component, this property defines the
-   effective start date and time for a time zone specification. This
-   property is REQUIRED within each STANDARD and DAYLIGHT part included
-   in "VTIMEZONE" calendar components and MUST be specified as a local
-   DATE-TIME without the "TZID" property parameter.
-            */
-            'start' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-        );
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Component/Vtodo.php b/framework/Icalendar/lib/Horde/Icalendar/Component/Vtodo.php
deleted file mode 100644 (file)
index 0235baf..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-class Horde_Icalendar_Component_Vtodo extends Horde_Icalendar_Component_Base
-{
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_properties += array(
-            'uid' => array('required' => true,
-                           'multiple' => false,
-                           'type' => 'string'),
-            'start' => array('required' => false,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'startDate' => array('required' => false,
-                                 'multiple' => false,
-                                 'class' => 'Horde_Date'),
-            'stamp' => array('required' => true,
-                             'multiple' => false,
-                             'class' => 'Horde_Date'),
-            'summary' => array('required' => false,
-                               'multiple' => false,
-                               'type' => 'string'),
-            'description' => array('required' => false,
-                                   'multiple' => false,
-                                   'type' => 'string'));
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Icalendar.php b/framework/Icalendar/lib/Horde/Icalendar/Icalendar.php
deleted file mode 100644 (file)
index 8d8c691..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-class Horde_Icalendar_Icalendar extends Horde_Icalendar_Base
-{
-    public function __construct($params = array())
-    {
-        $params = array_merge(array('version' => '2.0'), $params);
-        parent::__construct($params);
-    }
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Valarm.php b/framework/Icalendar/lib/Horde/Icalendar/Valarm.php
new file mode 100644 (file)
index 0000000..6f42e09
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+class Horde_Icalendar_Valarm extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            'summary' => array('required' => false,
+                               'multiple' => false,
+                               'type' => 'string'),
+            'description' => array('required' => false,
+                                   'multiple' => false,
+                                   'type' => 'string'));
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vcalendar.php b/framework/Icalendar/lib/Horde/Icalendar/Vcalendar.php
new file mode 100644 (file)
index 0000000..90ee456
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+class Horde_Icalendar_Vcalendar extends Horde_Icalendar_Base
+{
+    public function __construct($params = array())
+    {
+        $params = array_merge(array('version' => '2.0'), $params);
+        parent::__construct($params);
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vevent.php b/framework/Icalendar/lib/Horde/Icalendar/Vevent.php
new file mode 100644 (file)
index 0000000..cbeb56b
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+class Horde_Icalendar_Vevent extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            'uid' => array('required' => true,
+                           'multiple' => false,
+                           'type' => 'string'),
+            'start' => array('required' => false,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'startDate' => array('required' => false,
+                                 'multiple' => false,
+                                 'class' => 'Horde_Date'),
+            'stamp' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'summary' => array('required' => false,
+                               'multiple' => false,
+                               'type' => 'string'),
+            'description' => array('required' => false,
+                                   'multiple' => false,
+                                   'type' => 'string'));
+    }
+
+    public function validate()
+    {
+        parent::validate();
+        if (!isset($this->_properties['start']['value']) &&
+            !isset($this->_properties['startDate']['value'])) {
+            throw new Horde_Icalendar_Exception('VEVENT components must have a start property set');
+        }
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php b/framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php
new file mode 100644 (file)
index 0000000..b68126d
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+class Horde_Icalendar_Vfreebusy extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            'uid' => array('required' => true,
+                           'multiple' => false,
+                           'type' => 'string'),
+            'start' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'stamp' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+        );
+    }
+
+    /**
+     * Validates a property-value-pair.
+     *
+     * @throws InvalidArgumentException
+     */
+    protected function _validate($property, &$value)
+    {
+        parent::_validate($property, $value);
+        if ($property == 'start') {
+            $value->setTimezone('UTC');
+        }
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vjournal.php b/framework/Icalendar/lib/Horde/Icalendar/Vjournal.php
new file mode 100644 (file)
index 0000000..7f027d7
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+class Horde_Icalendar_Vjournal extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            'uid' => array('required' => true,
+                           'multiple' => false,
+                           'type' => 'string'),
+            'stamp' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'summary' => array('required' => false,
+                               'multiple' => false,
+                               'type' => 'string'),
+            'description' => array('required' => false,
+                                   'multiple' => false,
+                                   'type' => 'string'));
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php b/framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php
new file mode 100644 (file)
index 0000000..56297b4
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+class Horde_Icalendar_Vtimezone extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            /*
+   Within the "VTIMEZONE" calendar component, this property defines the
+   effective start date and time for a time zone specification. This
+   property is REQUIRED within each STANDARD and DAYLIGHT part included
+   in "VTIMEZONE" calendar components and MUST be specified as a local
+   DATE-TIME without the "TZID" property parameter.
+            */
+            'start' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+        );
+    }
+
+}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vtodo.php b/framework/Icalendar/lib/Horde/Icalendar/Vtodo.php
new file mode 100644 (file)
index 0000000..ea30f44
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+class Horde_Icalendar_Vtodo extends Horde_Icalendar_Base
+{
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_properties += array(
+            'uid' => array('required' => true,
+                           'multiple' => false,
+                           'type' => 'string'),
+            'start' => array('required' => false,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'startDate' => array('required' => false,
+                                 'multiple' => false,
+                                 'class' => 'Horde_Date'),
+            'stamp' => array('required' => true,
+                             'multiple' => false,
+                             'class' => 'Horde_Date'),
+            'summary' => array('required' => false,
+                               'multiple' => false,
+                               'type' => 'string'),
+            'description' => array('required' => false,
+                                   'multiple' => false,
+                                   'type' => 'string'));
+    }
+
+}
index 58ab3ae..ad5d045 100644 (file)
@@ -2,5 +2,8 @@
 
 class Horde_Icalendar_Writer_Base
 {
+    public function export($component)
+    {
+    }
 
 }
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Writer/Icalendar/20.php b/framework/Icalendar/lib/Horde/Icalendar/Writer/Icalendar/20.php
deleted file mode 100644 (file)
index 4905a2e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class Horde_Icalendar_Writer_Icalendar_20 extends Horde_Icalendar_Writer_Base
-{
-
-}
diff --git a/framework/Icalendar/lib/Horde/Icalendar/Writer/Vcalendar/20.php b/framework/Icalendar/lib/Horde/Icalendar/Writer/Vcalendar/20.php
new file mode 100644 (file)
index 0000000..a644c37
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+class Horde_Icalendar_Writer_Vcalendar_20 extends Horde_Icalendar_Writer_Base
+{
+
+}
index c91782c..3d30fde 100644 (file)
@@ -20,9 +20,9 @@ class Horde_Icalendar_WriterTest extends Horde_Test_Case
 
     public function testEscapes()
     {
-        $ical = new Horde_Icalendar_Icalendar(array('version' => '2.0'));
-        $event1 = new Horde_Icalendar_Component_Vevent();
-        $event2 = new Horde_Icalendar_Component_Vevent();
+        $ical = new Horde_Icalendar_Vcalendar(array('version' => '2.0'));
+        $event1 = new Horde_Icalendar_Vevent();
+        $event2 = new Horde_Icalendar_Vevent();
 
         $event1->uid = '20041120-8550-innerjoin-org';
         $event1->startDate = new Horde_Date(array('year' => 2005, 'month' => 5, 'mday' => 3));
@@ -36,8 +36,8 @@ class Horde_Icalendar_WriterTest extends Horde_Test_Case
         $event2->summary = 'Dash (rather than Comma) in the Description Field';
         $event2->description = 'There are important words after this dash - see anything here or have the words gone?';
 
-        $ical->addComponent($event1);
-        $ical->addComponent($event2);
+        $ical->components[] = $event1;
+        $ical->components[] = $event2;
 
         $this->assertEquals('BEGIN:VCALENDAR
 VERSION:2.0
@@ -60,7 +60,7 @@ DESCRIPTION:There are important words after this dash - see anything here
   or have the words gone?
 END:VEVENT
 END:VCALENDAR',
-        $ical->export());
+                            $ical->export());
     }
 
 }
\ No newline at end of file