1: <?php
2: /**
3: * A mapped query element.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Server
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Server
12: */
13:
14: /**
15: * A mapped query element.
16: *
17: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Kolab
23: * @package Kolab_Server
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Kolab_Server
27: */
28: class Horde_Kolab_Server_Query_Element_Mapped
29: implements Horde_Kolab_Server_Query_Element_Interface
30: {
31: /**
32: * Delegated element.
33: *
34: * @var Horde_Kolab_Server_Query_Element
35: */
36: private $_element;
37:
38: /**
39: * Name mapper.
40: *
41: * @var Horde_Kolab_Server_Mapped
42: */
43: private $_mapper;
44:
45: /**
46: * Constructor.
47: *
48: * @param Horde_Kolab_Server_Query_Element $element The mapped element.
49: * @param Horde_Kolab_Server_Mapped $mapper The mapping handler.
50: */
51: public function __construct(
52: Horde_Kolab_Server_Query_Element_Interface $element,
53: Horde_Kolab_Server_Decorator_Map $mapper
54: ) {
55: $this->_element = $element;
56: $this->_mapper = $mapper;
57: }
58:
59: /**
60: * Return the query element name.
61: *
62: * @return string The name of the query element.
63: */
64: public function getName()
65: {
66: return $this->_mapper->mapField($this->_element->getName());
67: }
68:
69: /**
70: * Return the value of this element.
71: *
72: * @return mixed The query value.
73: */
74: public function getValue()
75: {
76: return $this->_element->getValue();
77: }
78:
79: /**
80: * Return the elements of this group.
81: *
82: * @return mixed The group elements.
83: */
84: public function getElements()
85: {
86: $elements = array();
87: foreach ($this->_element->getElements() as $element) {
88: $elements[] = new Horde_Kolab_Server_Query_Element_Mapped(
89: $element, $this->_mapper
90: );
91: }
92: return $elements;
93: }
94:
95: /**
96: * Convert this element to a string.
97: *
98: * @return string The query string of the element.
99: */
100: public function convert(
101: Horde_Kolab_Server_Query_Interface $writer
102: ) {
103: return $this->_element->convert($writer);
104: }
105: }