]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/App/Extension/Person.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / App / Extension / Person.php
1 <?php
2
3 /**
4  * Zend Framework
5  *
6  * LICENSE
7  *
8  * This source file is subject to the new BSD license that is bundled
9  * with this package in the file LICENSE.txt.
10  * It is also available through the world-wide-web at this URL:
11  * http://framework.zend.com/license/new-bsd
12  * If you did not receive a copy of the license and are unable to
13  * obtain it through the world-wide-web, please send an email
14  * to license@zend.com so we can send you a copy immediately.
15  *
16  * @category   Zend
17  * @package    Zend_Gdata
18  * @subpackage App
19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
21
22  */
23
24 /**
25  * @see Zend_Gdata_App_Extension
26  */
27 require_once 'Zend/Gdata/App/Extension.php';
28
29 /**
30  * @see Zend_Gdata_App_Extension_Name
31  */
32 require_once 'Zend/Gdata/App/Extension/Name.php';
33
34 /**
35  * @see Zend_Gdata_App_Extension_Email
36  */
37 require_once 'Zend/Gdata/App/Extension/Email.php';
38
39 /**
40  * @see Zend_Gdata_App_Extension_Uri
41  */
42 require_once 'Zend/Gdata/App/Extension/Uri.php';
43
44 /**
45  * Base class for people (currently used by atom:author, atom:contributor)
46  *
47  * @category   Zend
48  * @package    Zend_Gdata
49  * @subpackage App
50  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
51  * @license    http://framework.zend.com/license/new-bsd     New BSD License
52  */
53 abstract class Zend_Gdata_App_Extension_Person extends Zend_Gdata_App_Extension
54 {
55
56     protected $_rootElement = null;
57     protected $_name = null;
58     protected $_email = null;
59     protected $_uri = null;
60
61     public function __construct($name = null, $email = null, $uri = null)
62     {
63         parent::__construct();
64         $this->_name = $name;
65         $this->_email = $email;
66         $this->_uri = $uri;
67     }
68
69     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
70     {
71         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
72         if ($this->_name != null) {
73             $element->appendChild($this->_name->getDOM($element->ownerDocument));
74         }
75         if ($this->_email != null) {
76             $element->appendChild($this->_email->getDOM($element->ownerDocument));
77         }
78         if ($this->_uri != null) {
79             $element->appendChild($this->_uri->getDOM($element->ownerDocument));
80         }
81         return $element;
82     }
83
84     protected function takeChildFromDOM($child)
85     {
86         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
87         switch ($absoluteNodeName) {
88         case $this->lookupNamespace('atom') . ':' . 'name':
89             $name = new Zend_Gdata_App_Extension_Name();
90             $name->transferFromDOM($child);
91             $this->_name = $name;
92             break;
93         case $this->lookupNamespace('atom') . ':' . 'email':
94             $email = new Zend_Gdata_App_Extension_Email();
95             $email->transferFromDOM($child);
96             $this->_email = $email;
97             break;
98         case $this->lookupNamespace('atom') . ':' . 'uri':
99             $uri = new Zend_Gdata_App_Extension_Uri();
100             $uri->transferFromDOM($child);
101             $this->_uri = $uri;
102             break;
103         default:
104             parent::takeChildFromDOM($child);
105             break;
106         }
107     }
108
109     /**
110      * @return Zend_Gdata_App_Extension_Name
111      */
112     public function getName()
113     {
114         return $this->_name;
115     }
116
117     /**
118      * @param Zend_Gdata_App_Extension_Name $value
119      * @return Zend_Gdata_App_Entry Provides a fluent interface
120      */
121     public function setName($value)
122     {
123         $this->_name = $value;
124         return $this;
125     }
126
127     /**
128      * @return Zend_Gdata_App_Extension_Email
129      */
130     public function getEmail()
131     {
132         return $this->_email;
133     }
134
135     /**
136      * @param Zend_Gdata_App_Extension_Email $value
137      * @return Zend_Gdata_App_Extension_Person Provides a fluent interface
138      */
139     public function setEmail($value)
140     {
141         $this->_email = $value;
142         return $this;
143     }
144
145     /**
146      * @return Zend_Gdata_App_Extension_Uri
147      */
148     public function getUri()
149     {
150         return $this->_uri;
151     }
152
153     /**
154      * @param Zend_Gdata_App_Extension_Uri $value
155      * @return Zend_Gdata_App_Extension_Person Provides a fluent interface
156      */
157     public function setUri($value)
158     {
159         $this->_uri = $value;
160         return $this;
161     }
162
163 }