1: <?php
2: /**
3: * Handles the product ID attribute.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Format
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL
11: * @link http://www.horde.org/libraries/Horde_Kolab_Format
12: */
13:
14: /**
15: * Handles the product ID attribute.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @since Horde_Kolab_Format 1.1.0
24: *
25: * @category Kolab
26: * @package Kolab_Format
27: * @author Gunnar Wrobel <wrobel@pardus.de>
28: * @license http://www.horde.org/licenses/lgpl21 LGPL
29: * @link http://www.horde.org/libraries/Horde_Kolab_Format
30: */
31: class Horde_Kolab_Format_Xml_Type_ProductId
32: extends Horde_Kolab_Format_Xml_Type_Base
33: {
34: /**
35: * Load the node value from the Kolab object.
36: *
37: * @param string $name The name of the the
38: * attribute to be fetched.
39: * @param array &$attributes The data array that
40: * holds all attribute
41: * values.
42: * @param DOMNode $parent_node The parent node of the
43: * node to be loaded.
44: * @param Horde_Kolab_Format_Xml_Helper $helper A XML helper instance.
45: * @param array $params Additiona parameters for
46: * this parse operation.
47: *
48: * @return DOMNode|boolean The named DOMNode or false if no node value was
49: * found.
50: */
51: public function load(
52: $name,
53: &$attributes,
54: $parent_node,
55: Horde_Kolab_Format_Xml_Helper $helper,
56: $params = array()
57: )
58: {
59: $result = parent::load($name, $attributes, $parent_node, $helper, $params);
60: if ($result !== false) {
61: return $result;
62: } else {
63: $attributes[$name] = '';
64: }
65: }
66:
67: /**
68: * Generate the value that should be written to the node. Override in the
69: * extending classes.
70: *
71: * @param string $name The name of the the attribute
72: * to be updated.
73: * @param array $attributes The data array that holds all
74: * attribute values.
75: * @param array $params The parameters for this write operation.
76: *
77: * @return mixed The value to be written.
78: */
79: protected function generateWriteValue($name, $attributes, $params)
80: {
81: return Horde_Kolab_Format_Xml::PRODUCT_ID . '-'
82: . Horde_Kolab_Format::VERSION
83: . ' (api version: ' . $params['api-version']
84: . ')';
85: }
86: }
87: