|
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 * @version $Id: Link.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_Gdata_Extension |
|
26 */ |
|
27 require_once 'Zend/Gdata/Extension.php'; |
|
28 |
|
29 /** |
|
30 * Data model for representing an atom:link element |
|
31 * |
|
32 * @category Zend |
|
33 * @package Zend_Gdata |
|
34 * @subpackage App |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Gdata_App_Extension_Link extends Zend_Gdata_App_Extension |
|
39 { |
|
40 |
|
41 protected $_rootElement = 'link'; |
|
42 protected $_href = null; |
|
43 protected $_rel = null; |
|
44 protected $_type = null; |
|
45 protected $_hrefLang = null; |
|
46 protected $_title = null; |
|
47 protected $_length = null; |
|
48 |
|
49 public function __construct($href = null, $rel = null, $type = null, |
|
50 $hrefLang = null, $title = null, $length = null) |
|
51 { |
|
52 parent::__construct(); |
|
53 $this->_href = $href; |
|
54 $this->_rel = $rel; |
|
55 $this->_type = $type; |
|
56 $this->_hrefLang = $hrefLang; |
|
57 $this->_title = $title; |
|
58 $this->_length = $length; |
|
59 } |
|
60 |
|
61 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
|
62 { |
|
63 $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
|
64 if ($this->_href !== null) { |
|
65 $element->setAttribute('href', $this->_href); |
|
66 } |
|
67 if ($this->_rel !== null) { |
|
68 $element->setAttribute('rel', $this->_rel); |
|
69 } |
|
70 if ($this->_type !== null) { |
|
71 $element->setAttribute('type', $this->_type); |
|
72 } |
|
73 if ($this->_hrefLang !== null) { |
|
74 $element->setAttribute('hreflang', $this->_hrefLang); |
|
75 } |
|
76 if ($this->_title !== null) { |
|
77 $element->setAttribute('title', $this->_title); |
|
78 } |
|
79 if ($this->_length !== null) { |
|
80 $element->setAttribute('length', $this->_length); |
|
81 } |
|
82 return $element; |
|
83 } |
|
84 |
|
85 protected function takeAttributeFromDOM($attribute) |
|
86 { |
|
87 switch ($attribute->localName) { |
|
88 case 'href': |
|
89 $this->_href = $attribute->nodeValue; |
|
90 break; |
|
91 case 'rel': |
|
92 $this->_rel = $attribute->nodeValue; |
|
93 break; |
|
94 case 'type': |
|
95 $this->_type = $attribute->nodeValue; |
|
96 break; |
|
97 case 'hreflang': |
|
98 $this->_hrefLang = $attribute->nodeValue; |
|
99 break; |
|
100 case 'title': |
|
101 $this->_title = $attribute->nodeValue; |
|
102 break; |
|
103 case 'length': |
|
104 $this->_length = $attribute->nodeValue; |
|
105 break; |
|
106 default: |
|
107 parent::takeAttributeFromDOM($attribute); |
|
108 } |
|
109 } |
|
110 |
|
111 /** |
|
112 * @return string|null |
|
113 */ |
|
114 public function getHref() |
|
115 { |
|
116 return $this->_href; |
|
117 } |
|
118 |
|
119 /** |
|
120 * @param string|null $value |
|
121 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
122 */ |
|
123 public function setHref($value) |
|
124 { |
|
125 $this->_href = $value; |
|
126 return $this; |
|
127 } |
|
128 |
|
129 /** |
|
130 * @return string|null |
|
131 */ |
|
132 public function getRel() |
|
133 { |
|
134 return $this->_rel; |
|
135 } |
|
136 |
|
137 /** |
|
138 * @param string|null $value |
|
139 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
140 */ |
|
141 public function setRel($value) |
|
142 { |
|
143 $this->_rel = $value; |
|
144 return $this; |
|
145 } |
|
146 |
|
147 /** |
|
148 * @return string|null |
|
149 */ |
|
150 public function getType() |
|
151 { |
|
152 return $this->_type; |
|
153 } |
|
154 |
|
155 /** |
|
156 * @param string|null $value |
|
157 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
158 */ |
|
159 public function setType($value) |
|
160 { |
|
161 $this->_type = $value; |
|
162 return $this; |
|
163 } |
|
164 |
|
165 /** |
|
166 * @return string|null |
|
167 */ |
|
168 public function getHrefLang() |
|
169 { |
|
170 return $this->_hrefLang; |
|
171 } |
|
172 |
|
173 /** |
|
174 * @param string|null $value |
|
175 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
176 */ |
|
177 public function setHrefLang($value) |
|
178 { |
|
179 $this->_hrefLang = $value; |
|
180 return $this; |
|
181 } |
|
182 |
|
183 /** |
|
184 * @return string|null |
|
185 */ |
|
186 public function getTitle() |
|
187 { |
|
188 return $this->_title; |
|
189 } |
|
190 |
|
191 /** |
|
192 * @param string|null $value |
|
193 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
194 */ |
|
195 public function setTitle($value) |
|
196 { |
|
197 $this->_title = $value; |
|
198 return $this; |
|
199 } |
|
200 |
|
201 /** |
|
202 * @return string|null |
|
203 */ |
|
204 public function getLength() |
|
205 { |
|
206 return $this->_length; |
|
207 } |
|
208 |
|
209 /** |
|
210 * @param string|null $value |
|
211 * @return Zend_Gdata_App_Entry Provides a fluent interface |
|
212 */ |
|
213 public function setLength($value) |
|
214 { |
|
215 $this->_length = $value; |
|
216 return $this; |
|
217 } |
|
218 |
|
219 } |