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 | */
|
---|
26 | require_once 'Zend/Gdata/App/Extension.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Represents the media:hash 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 | */
|
---|
37 | class Zend_Gdata_Media_Extension_MediaHash extends Zend_Gdata_Extension
|
---|
38 | {
|
---|
39 |
|
---|
40 | protected $_rootElement = 'hash';
|
---|
41 | protected $_rootNamespace = 'media';
|
---|
42 | protected $_algo = null;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Constructs a new MediaHash element
|
---|
46 | *
|
---|
47 | * @param string $text
|
---|
48 | * @param string $algo
|
---|
49 | */
|
---|
50 | public function __construct($text = null, $algo = null)
|
---|
51 | {
|
---|
52 | $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
|
---|
53 | parent::__construct();
|
---|
54 | $this->_text = $text;
|
---|
55 | $this->_algo = $algo;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
60 | * child properties. This is used to build an entry back into a DOM
|
---|
61 | * and eventually XML text for sending to the server upon updates, or
|
---|
62 | * for application storage/persistence.
|
---|
63 | *
|
---|
64 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
65 | * @return DOMElement The DOMElement representing this element and all
|
---|
66 | * child properties.
|
---|
67 | */
|
---|
68 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
69 | {
|
---|
70 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
71 | if ($this->_algo !== null) {
|
---|
72 | $element->setAttribute('algo', $this->_algo);
|
---|
73 | }
|
---|
74 | return $element;
|
---|
75 | }
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Given a DOMNode representing an attribute, tries to map the data into
|
---|
79 | * instance members. If no mapping is defined, the name and value are
|
---|
80 | * stored in an array.
|
---|
81 | *
|
---|
82 | * @param DOMNode $attribute The DOMNode attribute needed to be handled
|
---|
83 | * @throws Zend_Gdata_App_InvalidArgumentException
|
---|
84 | */
|
---|
85 | protected function takeAttributeFromDOM($attribute)
|
---|
86 | {
|
---|
87 | switch ($attribute->localName) {
|
---|
88 | case 'algo':
|
---|
89 | $this->_algo = $attribute->nodeValue;
|
---|
90 | break;
|
---|
91 | default:
|
---|
92 | parent::takeAttributeFromDOM($attribute);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * @return string The algo
|
---|
98 | */
|
---|
99 | public function getAlgo()
|
---|
100 | {
|
---|
101 | return $this->_algo;
|
---|
102 | }
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * @param string $value
|
---|
106 | * @return Zend_Gdata_Media_Extension_MediaHash Provides a fluent interface
|
---|
107 | */
|
---|
108 | public function setAlgo($value)
|
---|
109 | {
|
---|
110 | $this->_algo = $value;
|
---|
111 | return $this;
|
---|
112 | }
|
---|
113 |
|
---|
114 | }
|
---|