source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Media/Extension/MediaCategory.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
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 Media
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_App_Extension
25 */
26require_once 'Zend/Gdata/App/Extension.php';
27
28/**
29 * Represents the media:category element
30 *
31 * @category Zend
32 * @package Zend_Gdata
33 * @subpackage Media
34 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
36 */
37class Zend_Gdata_Media_Extension_MediaCategory extends Zend_Gdata_Extension
38{
39
40 protected $_rootElement = 'category';
41 protected $_rootNamespace = 'media';
42
43 /**
44 * @var string
45 */
46 protected $_scheme = null;
47 protected $_label = null;
48
49 /**
50 * Creates an individual MediaCategory object.
51 *
52 * @param string $text Indication of the type and content of the media
53 * @param string $scheme URI that identifies the categorization scheme
54 * @param string $label Human-readable label to be displayed in applications
55 */
56 public function __construct($text = null, $scheme = null, $label = null)
57 {
58 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
59 parent::__construct();
60 $this->_text = $text;
61 $this->_scheme = $scheme;
62 $this->_label = $label;
63 }
64
65 /**
66 * Retrieves a DOMElement which corresponds to this element and all
67 * child properties. This is used to build an entry back into a DOM
68 * and eventually XML text for sending to the server upon updates, or
69 * for application storage/persistence.
70 *
71 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
72 * @return DOMElement The DOMElement representing this element and all
73 * child properties.
74 */
75 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
76 {
77 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
78 if ($this->_scheme !== null) {
79 $element->setAttribute('scheme', $this->_scheme);
80 }
81 if ($this->_label !== null) {
82 $element->setAttribute('label', $this->_label);
83 }
84 return $element;
85 }
86
87 /**
88 * Given a DOMNode representing an attribute, tries to map the data into
89 * instance members. If no mapping is defined, the name and value are
90 * stored in an array.
91 *
92 * @param DOMNode $attribute The DOMNode attribute needed to be handled
93 */
94 protected function takeAttributeFromDOM($attribute)
95 {
96 switch ($attribute->localName) {
97 case 'scheme':
98 $this->_scheme = $attribute->nodeValue;
99 break;
100 case 'label':
101 $this->_label = $attribute->nodeValue;
102 break;
103 default:
104 parent::takeAttributeFromDOM($attribute);
105 }
106 }
107
108 /**
109 * Returns the URI that identifies the categorization scheme
110 * Optional.
111 *
112 * @return string URI that identifies the categorization scheme
113 */
114 public function getScheme()
115 {
116 return $this->_scheme;
117 }
118
119 /**
120 * @param string $value URI that identifies the categorization scheme
121 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
122 */
123 public function setScheme($value)
124 {
125 $this->_scheme = $value;
126 return $this;
127 }
128
129 /**
130 * @return string Human-readable label to be displayed in applications
131 */
132 public function getLabel()
133 {
134 return $this->_label;
135 }
136
137 /**
138 * @param string $value Human-readable label to be displayed in applications
139 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
140 */
141 public function setLabel($value)
142 {
143 $this->_label = $value;
144 return $this;
145 }
146
147}
Note: See TracBrowser for help on using the repository browser.