]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/Extension/Comments.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / Extension / Comments.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 Gdata
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_Extension
26  */
27 require_once 'Zend/Gdata/Extension.php';
28
29 /**
30  * @see Zend_Gdata_Extension_FeedLink
31  */
32 require_once 'Zend/Gdata/Extension/FeedLink.php';
33
34 /**
35  * Represents the gd:comments element
36  *
37  * @category   Zend
38  * @package    Zend_Gdata
39  * @subpackage Gdata
40  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
41  * @license    http://framework.zend.com/license/new-bsd     New BSD License
42  */
43 class Zend_Gdata_Extension_Comments extends Zend_Gdata_Extension
44 {
45
46     protected $_rootElement = 'comments';
47     protected $_rel = null;
48     protected $_feedLink = null;
49
50     public function __construct($rel = null, $feedLink = null)
51     {
52         parent::__construct();
53         $this->_rel = $rel;
54         $this->_feedLink = $feedLink;
55     }
56
57     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
58     {
59         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
60         if ($this->_rel !== null) {
61             $element->setAttribute('rel', $this->_rel);
62         }
63         if ($this->_feedLink !== null) {
64             $element->appendChild($this->_feedLink->getDOM($element->ownerDocument));
65         }
66         return $element;
67     }
68
69     protected function takeChildFromDOM($child)
70     {
71         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
72         switch ($absoluteNodeName) {
73             case $this->lookupNamespace('gd') . ':' . 'feedLink';
74                 $feedLink = new Zend_Gdata_Extension_FeedLink();
75                 $feedLink->transferFromDOM($child);
76                 $this->_feedLink = $feedLink;
77                 break;
78             default:
79                 parent::takeChildFromDOM($child);
80                 break;
81         }
82     }
83
84     protected function takeAttributeFromDOM($attribute)
85     {
86         switch ($attribute->localName) {
87         case 'rel':
88             $this->_rel = $attribute->nodeValue;
89             break;
90         default:
91             parent::takeAttributeFromDOM($attribute);
92         }
93     }
94
95     public function getRel()
96     {
97         return $this->_rel;
98     }
99
100     public function setRel($value)
101     {
102         $this->_rel = $value;
103         return $this;
104     }
105
106     public function getFeedLink()
107     {
108         return $this->_feedLink;
109     }
110
111     public function setFeedLink($value)
112     {
113         $this->_feedLink = $value;
114         return $this;
115     }
116
117 }