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

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

new extension: Google2Piwigo

File size: 4.3 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: EntryLink.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_Entry
31 */
32require_once 'Zend/Gdata/Entry.php';
33
34/**
35 * Represents the gd:entryLink 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_EntryLink extends Zend_Gdata_Extension
44{
45
46    protected $_rootElement = 'entryLink';
47    protected $_href = null;
48    protected $_readOnly = null;
49    protected $_rel = null;
50    protected $_entry = null;
51
52    public function __construct($href = null, $rel = null,
53            $readOnly = null, $entry = null)
54    {
55        parent::__construct();
56        $this->_href = $href;
57        $this->_readOnly = $readOnly;
58        $this->_rel = $rel;
59        $this->_entry = $entry;
60    }
61
62    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
63    {
64        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
65        if ($this->_href !== null) {
66            $element->setAttribute('href', $this->_href);
67        }
68        if ($this->_readOnly !== null) {
69            $element->setAttribute('readOnly', ($this->_readOnly ? "true" : "false"));
70        }
71        if ($this->_rel !== null) {
72            $element->setAttribute('rel', $this->_rel);
73        }
74        if ($this->_entry !== null) {
75            $element->appendChild($this->_entry->getDOM($element->ownerDocument));
76        }
77        return $element;
78    }
79
80    protected function takeChildFromDOM($child)
81    {
82        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
83        switch ($absoluteNodeName) {
84            case $this->lookupNamespace('atom') . ':' . 'entry';
85                $entry = new Zend_Gdata_Entry();
86                $entry->transferFromDOM($child);
87                $this->_entry = $entry;
88                break;
89        default:
90            parent::takeChildFromDOM($child);
91            break;
92        }
93    }
94
95    protected function takeAttributeFromDOM($attribute)
96    {
97        switch ($attribute->localName) {
98        case 'href':
99            $this->_href = $attribute->nodeValue;
100            break;
101        case 'readOnly':
102            if ($attribute->nodeValue == "true") {
103                $this->_readOnly = true;
104            }
105            else if ($attribute->nodeValue == "false") {
106                $this->_readOnly = false;
107            }
108            else {
109                throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
110            }
111            break;
112        case 'rel':
113            $this->_rel = $attribute->nodeValue;
114            break;
115        default:
116            parent::takeAttributeFromDOM($attribute);
117        }
118    }
119
120    /**
121     * @return string
122     */
123    public function getHref()
124    {
125        return $this->_href;
126    }
127
128    public function setHref($value)
129    {
130        $this->_href = $value;
131        return $this;
132    }
133
134    public function getReadOnly()
135    {
136        return $this->_readOnly;
137    }
138
139    public function setReadOnly($value)
140    {
141        $this->_readOnly = $value;
142        return $this;
143    }
144
145    public function getRel()
146    {
147        return $this->_rel;
148    }
149
150    public function setRel($value)
151    {
152        $this->_rel = $value;
153        return $this;
154    }
155
156    public function getEntry()
157    {
158        return $this->_entry;
159    }
160
161    public function setEntry($value)
162    {
163        $this->_entry = $value;
164        return $this;
165    }
166
167}
Note: See TracBrowser for help on using the repository browser.