Example #1
0
 protected function getXmlType($type, $previous = null, $kolab_type = 'kolab', $version = '1.0')
 {
     $factory = new Horde_Kolab_Format_Factory();
     $doc = new DOMDocument('1.0', 'UTF-8');
     if ($previous !== null) {
         $doc->loadXML($previous);
         $helper = $factory->createXmlHelper($doc);
         $root_node = $helper->findNode('/' . $kolab_type);
     } else {
         $helper = $factory->createXmlHelper($doc);
         $root_node = $helper->createNewNode($doc, $kolab_type);
         $root_node->setAttribute('version', $version);
     }
     $type = $factory->createXmlType($type);
     return array($helper, $root_node, $type);
 }
Example #2
0
File: Base.php Project: horde/horde
 /**
  * Create a handler for the sub type of this attribute.
  *
  * @param string $type   The sub type.
  * @param array  $params Additional parameters.
  *
  * @return Horde_Kolab_Format_Xml_Type The sub type handler.
  */
 protected function createSubType($type, $params)
 {
     if (isset($params['api-version'])) {
         $class = $type . '_V' . $params['api-version'];
     } else {
         $class = $type;
     }
     if (!isset(self::$_xml_types[$class])) {
         self::$_xml_types[$class] = $this->_factory->createXmlType($type, $params);
     }
     return self::$_xml_types[$class];
 }
Example #3
0
 /**
  * @expectedException Horde_Kolab_Format_Exception
  */
 public function testTypeMissing()
 {
     $factory = new Horde_Kolab_Format_Factory();
     $factory->createXmlType('Horde_Kolab_Format_Stub_Types_NOSUCH');
 }
Example #4
0
 private function _getHprefsV1()
 {
     $factory = new Horde_Kolab_Format_Factory();
     return $factory->create('Xml', 'Hprefs', array('version' => 1));
 }
Example #5
0
{
    /**
     * Specific data fields for the prefs object
     *
     * @var Kolab
     */
    protected $_fields_specific;
    /**
     * 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);
    }
}
/** Create the factory */
$factory = new Horde_Kolab_Format_Factory();
/** Generate the format handler */
$format = $factory->create('Xml', 'String');
/** Prepare a test object */
$object = array('uid' => 1, 'string' => 'test string');
/** Save this test data array in Kolab XML format */
$xml = $format->save($object);
var_dump($xml);
/** Reload the object from the XML format */
$read_object = $format->load($xml);
var_dump($read_object);
Example #6
0
<?php

/**
 * A sample script for reading/writing an event using internal API version 2.
 *
 * PHP version 5
 *
 * @category Kolab
 * @package  Kolab_Format
 * @author   Gunnar Wrobel <*****@*****.**>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @link     http://www.horde.org/libraries/Horde_Kolab_Format
 */
/**
 * The Autoloader allows us to omit "require/include" statements.
 */
require_once 'Horde/Autoloader/Default.php';
/** Create the factory */
$factory = new Horde_Kolab_Format_Factory();
/** Generate the format handler */
$format = $factory->create('Xml', 'Event');
$now = new DateTime();
/** Prepare a test object */
$object = array('uid' => 1, 'summary' => 'test event', 'start-date' => array('date' => $now), 'end-date' => array('date' => $now));
/** Save this test data array in Kolab XML format */
$xml = $format->save($object);
var_dump($xml);
/** Reload the object from the XML format */
$read_object = $format->load($xml);
var_dump($read_object);
Example #7
0
 private function _getParser($type)
 {
     return $this->_factory->create('Xml', $type, $this->_params);
 }
Example #8
0
 public function testVersion()
 {
     $factory = new Horde_Kolab_Format_Factory();
     $note = $factory->create('Xml', 'Note');
     $this->assertEquals(2, $note->getVersion());
 }
Example #9
0
 protected function getXmlType($type, $previous = null, $kolab_type = 'kolab', $version = '1.0')
 {
     $factory = new Horde_Kolab_Format_Factory();
     $doc = new DOMDocument('1.0', 'UTF-8');
     if ($previous !== null) {
         $doc->loadXML($previous);
     }
     $helper = $factory->createXmlHelper($doc);
     $type = $factory->createXmlType($type);
     return array($helper, $doc, $type);
 }
Example #10
0
 private function _getContact()
 {
     $factory = new Horde_Kolab_Format_Factory();
     return $factory->create('Xml', 'Contact');
 }
Example #11
0
File: Xml.php Project: horde/horde
 /**
  * Return the root handler.
  *
  * @param array  $params Additional parameters.
  *
  * @return Horde_Kolab_Xml_Type_Root The root handler.
  */
 private function _getRoot($params = array())
 {
     return $this->_factory->createXmlType(self::TYPE_ROOT, $params);
 }
Example #12
0
<?php

/**
 * A sample script for reading/writing an event.
 *
 * PHP version 5
 *
 * @category Kolab
 * @package  Kolab_Format
 * @author   Gunnar Wrobel <*****@*****.**>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @link     http://www.horde.org/libraries/Horde_Kolab_Format
 */
/**
 * The Autoloader allows us to omit "require/include" statements.
 */
require_once 'Horde/Autoloader/Default.php';
/** Create the factory */
$factory = new Horde_Kolab_Format_Factory();
/** Generate the format handler */
$format = $factory->create('Xml', 'Event', array('version' => 1));
/** Prepare a test object */
$object = array('uid' => 1, 'summary' => 'test event', 'start-date' => time(), 'end-date' => time() + 24 * 60 * 60);
/** Save this test data array in Kolab XML format */
$xml = $format->save($object);
var_dump($xml);
/** Reload the object from the XML format */
$read_object = $format->load($xml);
var_dump($read_object);
Example #13
0
 private function _getEnvelope()
 {
     $factory = new Horde_Kolab_Format_Factory();
     return $factory->create('Xml', 'Envelope');
 }