File indexing completed on 2024-06-16 05:30:07

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Media
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata_App_Extension
0026  */
0027 // require_once 'Zend/Gdata/App/Extension.php';
0028 
0029 /**
0030  * Represents the media:description element
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Media
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Gdata_Media_Extension_MediaDescription extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'description';
0042     protected $_rootNamespace = 'media';
0043 
0044     /**
0045      * @var string
0046      */
0047     protected $_type = null;
0048 
0049     /**
0050      * @param string $text
0051      * @param string $type
0052      */
0053     public function __construct($text = null, $type = null)
0054     {
0055         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
0056         parent::__construct();
0057         $this->_type = $type;
0058         $this->_text = $text;
0059     }
0060 
0061     /**
0062      * Retrieves a DOMElement which corresponds to this element and all
0063      * child properties.  This is used to build an entry back into a DOM
0064      * and eventually XML text for sending to the server upon updates, or
0065      * for application storage/persistence.
0066      *
0067      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0068      * @return DOMElement The DOMElement representing this element and all
0069      * child properties.
0070      */
0071     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0072     {
0073         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0074         if ($this->_type !== null) {
0075             $element->setAttribute('type', $this->_type);
0076         }
0077         return $element;
0078     }
0079 
0080     /**
0081      * Given a DOMNode representing an attribute, tries to map the data into
0082      * instance members.  If no mapping is defined, the name and value are
0083      * stored in an array.
0084      *
0085      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0086      */
0087     protected function takeAttributeFromDOM($attribute)
0088     {
0089         switch ($attribute->localName) {
0090         case 'type':
0091             $this->_type = $attribute->nodeValue;
0092             break;
0093         default:
0094             parent::takeAttributeFromDOM($attribute);
0095         }
0096     }
0097 
0098     /**
0099      * @return string
0100      */
0101     public function getType()
0102     {
0103         return $this->_type;
0104     }
0105 
0106     /**
0107      * @param string $value
0108      * @return Zend_Gdata_Media_Extension_MediaDescription Provides a fluent interface
0109      */
0110     public function setType($value)
0111     {
0112         $this->_type = $value;
0113         return $this;
0114     }
0115 
0116 }