For implementing a new format type you will have to inherit this class and provide a _load/_save function. Copyright 2007-2009 Klarälvdalens Datakonsult AB Copyright 2010-2014 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Thomas Jarosch (thomas.jarosch@intra2net.com)
Author: Gunnar Wrobel (wrobel@pardus.de)
Inheritance: implements Horde_Kolab_Format
Exemple #1
0
 public function testRoundtripWithPreviousOnApiV1()
 {
     $xml = new Horde_Kolab_Format_Xml(new Horde_Kolab_Format_Xml_Parser(new DOMDocument('1.0', 'UTF-8')), new Horde_Kolab_Format_Factory(), array('version' => 1));
     $first = $xml->save(array('uid' => 1));
     $second = $xml->save($xml->load($first));
     $this->assertEquals($this->removeLastModification($first), $this->removeLastModification($second));
 }
Exemple #2
0
 /**
  * Constructor
  */
 public function __construct($parser, $params = array())
 {
     $this->_root_name = 'string';
     /** Specific preferences fields, in kolab format specification order
      */
     $this->_fields_specific = array('string' => array('type' => self::TYPE_STRING, 'value' => self::VALUE_MAYBE_MISSING));
     parent::__construct($parser, $params);
 }
Exemple #3
0
 /**
  * Convert the data to a XML stream. Strings contained in the data array may
  * only be provided as UTF-8 data.
  *
  * @param array $object  The data array representing the object.
  * @param array $options Additional options when parsing the XML.
  * <pre>
  * - previous: The previous XML text (default: empty string)
  * - relaxed: Relaxed error checking (default: false)
  * </pre>
  *
  * @return resource The data as XML stream.
  *
  * @throws Horde_Kolab_Format_Exception If converting the data to XML failed.
  */
 public function save($object, $options = array())
 {
     if (!isset($object['type'])) {
         throw new Horde_Kolab_Format_Exception('The "type" value is missing!');
     }
     $this->_root_name = $object['type'];
     return parent::save($object, $options);
 }
Exemple #4
0
 /**
  * Convert the data to a XML stream. Strings contained in the data array may
  * only be provided as UTF-8 data.
  *
  * @param array $object  The data array representing the object.
  * @param array $options Additional options when writing the XML.
  * <pre>
  * - previous: The previous XML text (default: empty string)
  * - relaxed: Relaxed error checking (default: false)
  * </pre>
  *
  * @return resource The data as XML stream.
  *
  * @throws Horde_Kolab_Format_Exception If converting the data to XML failed.
  */
 public function save($object, $options = array())
 {
     if (!empty($object['_is_all_day'])) {
         $this->_fields_specific['start-date'] = 'Horde_Kolab_Format_Xml_Type_EventDate';
         $this->_fields_specific['end-date'] = 'Horde_Kolab_Format_Xml_Type_EventDate';
         $end_date = clone $object['end-date'];
         if ($end_date->hour == 0 && $end_date->min == 0 && $end_date->sec == 0) {
             // move date to previous day 23:59:59. We cut off the time anyway.
             $end_date->sub(new DateInterval('PT1S'));
             $object['end-date'] = $end_date;
         }
     }
     return parent::save($object, $options);
 }