source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Gapps/Extension/Name.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 5.2 KB
Line 
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 Gapps
19 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23/**
24 * @see Zend_Gdata_Extension
25 */
26require_once 'Zend/Gdata/Extension.php';
27
28/**
29 * @see Zend_Gdata_Gapps
30 */
31require_once 'Zend/Gdata/Gapps.php';
32
33/**
34 * Represents the apps:name element used by the Apps data API. This is used
35 * to represent a user's full name. This class is usually contained within
36 * instances of Zend_Gdata_Gapps_UserEntry.
37 *
38 * @category Zend
39 * @package Zend_Gdata
40 * @subpackage Gapps
41 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
43 */
44class Zend_Gdata_Gapps_Extension_Name extends Zend_Gdata_Extension
45{
46
47 protected $_rootNamespace = 'apps';
48 protected $_rootElement = 'name';
49
50 /**
51 * The associated user's family name.
52 *
53 * @var string
54 */
55 protected $_familyName = null;
56
57 /**
58 * The associated user's given name.
59 *
60 * @var string
61 */
62 protected $_givenName = null;
63
64 /**
65 * Constructs a new Zend_Gdata_Gapps_Extension_Name object.
66 *
67 * @param string $familyName (optional) The familyName to be set for this
68 * object.
69 * @param string $givenName (optional) The givenName to be set for this
70 * object.
71 */
72 public function __construct($familyName = null, $givenName = null)
73 {
74 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
75 parent::__construct();
76 $this->_familyName = $familyName;
77 $this->_givenName = $givenName;
78 }
79
80 /**
81 * Retrieves a DOMElement which corresponds to this element and all
82 * child properties. This is used to build an entry back into a DOM
83 * and eventually XML text for sending to the server upon updates, or
84 * for application storage/persistence.
85 *
86 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
87 * @return DOMElement The DOMElement representing this element and all
88 * child properties.
89 */
90 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
91 {
92 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
93 if ($this->_familyName !== null) {
94 $element->setAttribute('familyName', $this->_familyName);
95 }
96 if ($this->_givenName !== null) {
97 $element->setAttribute('givenName', $this->_givenName);
98 }
99 return $element;
100 }
101
102 /**
103 * Given a DOMNode representing an attribute, tries to map the data into
104 * instance members. If no mapping is defined, the name and value are
105 * stored in an array.
106 *
107 * @param DOMNode $attribute The DOMNode attribute needed to be handled
108 */
109 protected function takeAttributeFromDOM($attribute)
110 {
111 switch ($attribute->localName) {
112 case 'familyName':
113 $this->_familyName = $attribute->nodeValue;
114 break;
115 case 'givenName':
116 $this->_givenName = $attribute->nodeValue;
117 break;
118 default:
119 parent::takeAttributeFromDOM($attribute);
120 }
121 }
122
123 /**
124 * Get the value for this element's familyName attribute.
125 *
126 * @see setFamilyName
127 * @return string The requested attribute.
128 */
129 public function getFamilyName()
130 {
131 return $this->_familyName;
132 }
133
134 /**
135 * Set the value for this element's familyName attribute. This
136 * represents a user's family name.
137 *
138 * @param string $value The desired value for this attribute.
139 * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface..
140 */
141 public function setFamilyName($value)
142 {
143 $this->_familyName = $value;
144 return $this;
145 }
146
147 /**
148 * Get the value for this element's givenName attribute.
149 *
150 * @see setGivenName
151 * @return string The requested attribute.
152 */
153 public function getGivenName()
154 {
155 return $this->_givenName;
156 }
157
158 /**
159 * Set the value for this element's givenName attribute. This
160 * represents a user's given name.
161 *
162 * @param string $value The desired value for this attribute.
163 * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface.
164 */
165 public function setGivenName($value)
166 {
167 $this->_givenName = $value;
168 return $this;
169 }
170
171 /**
172 * Magic toString method allows using this directly via echo
173 * Works best in PHP >= 4.2.0
174 */
175 public function __toString()
176 {
177 return $this->getGivenName() . ' ' . $this->getFamilyName();
178 }
179
180}
Note: See TracBrowser for help on using the repository browser.