~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/YouTube/Extension/Statistics.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_Extension
 
25
 */
 
26
require_once 'Zend/Gdata/Extension.php';
 
27
 
 
28
/**
 
29
 * Represents the yt:statistics element used by the YouTube data API
 
30
 *
 
31
 * @category   Zend
 
32
 * @package    Zend_Gdata
 
33
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
34
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
35
 */
 
36
class Zend_Gdata_YouTube_Extension_Statistics extends Zend_Gdata_Extension
 
37
{
 
38
 
 
39
    protected $_rootNamespace = 'yt';
 
40
    protected $_rootElement = 'statistics';
 
41
    protected $_viewCount = null;
 
42
    protected $_watchCount = null;
 
43
 
 
44
    /**
 
45
     * Constructs a new Zend_Gdata_YouTube_Extension_Statistics object.
 
46
     * @param string $viewCount(optional) The viewCount value
 
47
     * @param string $watchCount(optional) The watchCount value
 
48
     */
 
49
    public function __construct($viewCount = null, $watchCount = null) 
 
50
    {
 
51
        foreach (Zend_Gdata_YouTube::$namespaces as $nsPrefix => $nsUri) {
 
52
            $this->registerNamespace($nsPrefix, $nsUri);
 
53
        }
 
54
        parent::__construct();        
 
55
        $this->_viewCount = $viewCount; 
 
56
        $this->_watchCount = $watchCount; 
 
57
    }
 
58
 
 
59
    /**
 
60
     * Retrieves a DOMElement which corresponds to this element and all 
 
61
     * child properties.  This is used to build an entry back into a DOM
 
62
     * and eventually XML text for sending to the server upon updates, or
 
63
     * for application storage/persistence.  
 
64
     *
 
65
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
 
66
     * @return DOMElement The DOMElement representing this element and all 
 
67
     * child properties.
 
68
     */
 
69
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
70
    {
 
71
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
72
        if ($this->_viewCount !== null) {
 
73
            $element->setAttribute('viewCount', $this->_viewCount);
 
74
        }
 
75
        if ($this->_watchCount !== null) {
 
76
            $element->setAttribute('watchCount', $this->_watchCount);
 
77
        }
 
78
        return $element;
 
79
    }
 
80
 
 
81
    /**
 
82
     * Given a DOMNode representing an attribute, tries to map the data into
 
83
     * instance members.  If no mapping is defined, the name and valueare 
 
84
     * stored in an array.
 
85
     * TODO: Convert attributes to proper types
 
86
     *
 
87
     * @param DOMNode $attribute The DOMNode attribute needed to be handled
 
88
     */
 
89
    protected function takeAttributeFromDOM($attribute)
 
90
    {
 
91
        switch ($attribute->localName) {
 
92
        case 'viewCount':
 
93
            $this->_viewCount = $attribute->nodeValue;
 
94
            break;
 
95
        case 'watchCount':
 
96
            $this->_watchCount = $attribute->nodeValue;
 
97
            break;
 
98
        default:
 
99
            parent::takeAttributeFromDOM($attribute);
 
100
        }
 
101
    }
 
102
 
 
103
    /**
 
104
     * Get the value for this element's viewCount attribute.
 
105
     *
 
106
     * @return int The value associated with this attribute.
 
107
     */
 
108
    public function getViewCount()
 
109
    {
 
110
        return $this->_viewCount;
 
111
    }
 
112
 
 
113
    /**
 
114
     * Set the value for this element's viewCount attribute.
 
115
     *
 
116
     * @param int $value The desired value for this attribute.
 
117
     * @return Zend_Gdata_YouTube_Extension_Statistics The element being modified.
 
118
     */
 
119
    public function setViewCount($value)
 
120
    {
 
121
        $this->_viewCount = $value;
 
122
        return $this;
 
123
    }
 
124
 
 
125
    /**
 
126
     * Get the value for this element's watchCount attribute.
 
127
     *
 
128
     * @return int The value associated with this attribute.
 
129
     */
 
130
    public function getWatchCount()
 
131
    {
 
132
        return $this->_watchCount;
 
133
    }
 
134
 
 
135
    /**
 
136
     * Set the value for this element's watchCount attribute.
 
137
     *
 
138
     * @param int $value The desired value for this attribute.
 
139
     * @return Zend_Gdata_YouTube_Extension_Statistics The element being modified.
 
140
     */
 
141
    public function setWatchCount($value)
 
142
    {
 
143
        $this->_watchCount = $value;
 
144
        return $this;
 
145
    }
 
146
 
 
147
    /**
 
148
     * Magic toString method allows using this directly via echo
 
149
     * Works best in PHP >= 4.2.0
 
150
     *
 
151
     * @return string
 
152
     */
 
153
    public function __toString() 
 
154
    {
 
155
        return 'View Count=' . $this->_viewCount;
 
156
    }
 
157
 
 
158
}