source: extensions/Google2Piwigo/include/Zend/Gdata/Extension/FeedLink.php @ 17475

Last change on this file since 17475 was 17475, checked in by mistic100, 12 years ago

new extension: Google2Piwigo

File size: 4.6 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 Gdata
19 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license    http://framework.zend.com/license/new-bsd     New BSD License
21 * @version    $Id: FeedLink.php 24594 2012-01-05 21:27:01Z matthew $
22 */
23
24/**
25 * @see Zend_Gdata_Extension
26 */
27require_once 'Zend/Gdata/Extension.php';
28
29/**
30 * @see Zend_Gdata_Feed
31 */
32require_once 'Zend/Gdata/Feed.php';
33
34/**
35 * Represents the gd:feedLink element
36 *
37 * @category   Zend
38 * @package    Zend_Gdata
39 * @subpackage Gdata
40 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
41 * @license    http://framework.zend.com/license/new-bsd     New BSD License
42 */
43class Zend_Gdata_Extension_FeedLink extends Zend_Gdata_Extension
44{
45
46    protected $_rootElement = 'feedLink';
47    protected $_countHint = null;
48    protected $_href = null;
49    protected $_readOnly = null;
50    protected $_rel = null;
51    protected $_feed = null;
52
53    public function __construct($href = null, $rel = null,
54            $countHint = null, $readOnly = null, $feed = null)
55    {
56        parent::__construct();
57        $this->_countHint = $countHint;
58        $this->_href = $href;
59        $this->_readOnly = $readOnly;
60        $this->_rel = $rel;
61        $this->_feed = $feed;
62    }
63
64    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
65    {
66        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
67        if ($this->_countHint !== null) {
68            $element->setAttribute('countHint', $this->_countHint);
69        }
70        if ($this->_href !== null) {
71            $element->setAttribute('href', $this->_href);
72        }
73        if ($this->_readOnly !== null) {
74            $element->setAttribute('readOnly', ($this->_readOnly ? "true" : "false"));
75        }
76        if ($this->_rel !== null) {
77            $element->setAttribute('rel', $this->_rel);
78        }
79        if ($this->_feed !== null) {
80            $element->appendChild($this->_feed->getDOM($element->ownerDocument));
81        }
82        return $element;
83    }
84
85    protected function takeChildFromDOM($child)
86    {
87        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
88        switch ($absoluteNodeName) {
89            case $this->lookupNamespace('atom') . ':' . 'feed';
90                $feed = new Zend_Gdata_Feed();
91                $feed->transferFromDOM($child);
92                $this->_feed = $feed;
93                break;
94        default:
95            parent::takeChildFromDOM($child);
96            break;
97        }
98    }
99
100    protected function takeAttributeFromDOM($attribute)
101    {
102        switch ($attribute->localName) {
103        case 'countHint':
104            $this->_countHint = $attribute->nodeValue;
105            break;
106        case 'href':
107            $this->_href = $attribute->nodeValue;
108            break;
109        case 'readOnly':
110            if ($attribute->nodeValue == "true") {
111                $this->_readOnly = true;
112            }
113            else if ($attribute->nodeValue == "false") {
114                $this->_readOnly = false;
115            }
116            else {
117                throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
118            }
119            break;
120        case 'rel':
121            $this->_rel = $attribute->nodeValue;
122            break;
123        default:
124            parent::takeAttributeFromDOM($attribute);
125        }
126    }
127
128    /**
129     * @return string
130     */
131    public function getHref()
132    {
133        return $this->_href;
134    }
135
136    public function setHref($value)
137    {
138        $this->_href = $value;
139        return $this;
140    }
141
142    public function getReadOnly()
143    {
144        return $this->_readOnly;
145    }
146
147    public function setReadOnly($value)
148    {
149        $this->_readOnly = $value;
150        return $this;
151    }
152
153    public function getRel()
154    {
155        return $this->_rel;
156    }
157
158    public function setRel($value)
159    {
160        $this->_rel = $value;
161        return $this;
162    }
163
164    public function getFeed()
165    {
166        return $this->_feed;
167    }
168
169    public function setFeed($value)
170    {
171        $this->_feed = $value;
172        return $this;
173    }
174
175}
Note: See TracBrowser for help on using the repository browser.