~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/YouTube/SubscriptionEntry.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 YouTube
 
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_Entry
 
25
 */
 
26
require_once 'Zend/Gdata/Entry.php';
 
27
 
 
28
/**
 
29
 * @see Zend_Gdata_Extension_FeedLink
 
30
 */
 
31
require_once 'Zend/Gdata/Extension/FeedLink.php';
 
32
 
 
33
/**
 
34
 * @see Zend_Gdata_YouTube_Extension_Description
 
35
 */
 
36
require_once 'Zend/Gdata/YouTube/Extension/Description.php';
 
37
 
 
38
/**
 
39
 * Represents the YouTube video subscription flavor of an Atom entry
 
40
 *
 
41
 * @category   Zend
 
42
 * @package    Zend_Gdata
 
43
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
44
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
45
 */
 
46
class Zend_Gdata_YouTube_SubscriptionEntry extends Zend_Gdata_Entry
 
47
{
 
48
 
 
49
    protected $_entryClassName = 'Zend_Gdata_YouTube_SubscriptionEntry';
 
50
 
 
51
    /**
 
52
     * Nested feed links
 
53
     *
 
54
     * @var array
 
55
     */
 
56
    protected $_feedLink = array();
 
57
 
 
58
    /**
 
59
     * Creates a subscription entry, representing an individual subscription
 
60
     * in a list of subscriptions, usually associated with an individual user.
 
61
     *
 
62
     * @param DOMElement $element (optional) DOMElement from which this
 
63
     *          object should be constructed.
 
64
     */
 
65
    public function __construct($element = null)
 
66
    {
 
67
        foreach (Zend_Gdata_YouTube::$namespaces as $nsPrefix => $nsUri) {
 
68
            $this->registerNamespace($nsPrefix, $nsUri); 
 
69
        }
 
70
        parent::__construct($element);
 
71
    }
 
72
 
 
73
    /**
 
74
     * Retrieves a DOMElement which corresponds to this element and all 
 
75
     * child properties.  This is used to build an entry back into a DOM
 
76
     * and eventually XML text for sending to the server upon updates, or
 
77
     * for application storage/persistence.   
 
78
     *
 
79
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
 
80
     * @return DOMElement The DOMElement representing this element and all 
 
81
     * child properties. 
 
82
     */
 
83
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
84
    {
 
85
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
86
        if ($this->_feedLink != null) {
 
87
            foreach ($this->_feedLink as $feedLink) {
 
88
                $element->appendChild($feedLink->getDOM($element->ownerDocument));
 
89
            }
 
90
        }
 
91
        return $element;
 
92
    }
 
93
 
 
94
    /**
 
95
     * Creates individual Entry objects of the appropriate type and
 
96
     * stores them in the $_entry array based upon DOM data.
 
97
     *
 
98
     * @param DOMNode $child The DOMNode to process
 
99
     */
 
100
    protected function takeChildFromDOM($child)
 
101
    {
 
102
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
 
103
        switch ($absoluteNodeName) {
 
104
        case $this->lookupNamespace('gd') . ':' . 'feedLink':
 
105
            $feedLink = new Zend_Gdata_Extension_FeedLink();
 
106
            $feedLink->transferFromDOM($child);
 
107
            $this->_feedLink[] = $feedLink;
 
108
            break;
 
109
        default:
 
110
            parent::takeChildFromDOM($child);
 
111
            break;
 
112
        }
 
113
    }
 
114
 
 
115
    /**
 
116
     * Sets the array of embedded feeds related to the video
 
117
     *
 
118
     * @param array $feedLink The array of embedded feeds relating to the video
 
119
     * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
 
120
     */
 
121
    public function setFeedLink($feedLink = null)
 
122
    {
 
123
        $this->_feedLink = $feedLink;
 
124
        return $this;
 
125
    }
 
126
 
 
127
    /**
 
128
     * Get the feed link property for this entry.
 
129
     *
 
130
     * @see setFeedLink
 
131
     * @param string $rel (optional) The rel value of the link to be found.
 
132
     *          If null, the array of links is returned.
 
133
     * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink
 
134
     *          object corresponding to the requested rel value is returned
 
135
     *          if found, or null if the requested value is not found. If
 
136
     *          $rel is null or not specified, an array of all available
 
137
     *          feed links for this entry is returned, or null if no feed
 
138
     *          links are set.
 
139
     */
 
140
    public function getFeedLink($rel = null)
 
141
    {
 
142
        if ($rel == null) {
 
143
            return $this->_feedLink;
 
144
        } else {
 
145
            foreach ($this->_feedLink as $feedLink) {
 
146
                if ($feedLink->rel == $rel) {
 
147
                    return $feedLink;
 
148
                }
 
149
            }
 
150
            return null;
 
151
        }
 
152
    }
 
153
 
 
154
}