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

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:player 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_MediaPlayer extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'player';
0042     protected $_rootNamespace = 'media';
0043 
0044     /**
0045      * @var string
0046      */
0047     protected $_url = null;
0048 
0049     /**
0050      * @var int
0051      */
0052     protected $_width = null;
0053 
0054     /**
0055      * @var int
0056      */
0057     protected $_height = null;
0058 
0059     /**
0060      * Constructs a new MediaPlayer element
0061      *
0062      * @param string $url
0063      * @param int $width
0064      * @param int $height
0065      */
0066     public function __construct($url = null, $width = null, $height = null)
0067     {
0068         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
0069         parent::__construct();
0070         $this->_url = $url;
0071         $this->_width = $width;
0072         $this->_height = $height;
0073     }
0074 
0075     /**
0076      * Retrieves a DOMElement which corresponds to this element and all
0077      * child properties.  This is used to build an entry back into a DOM
0078      * and eventually XML text for sending to the server upon updates, or
0079      * for application storage/persistence.
0080      *
0081      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0082      * @return DOMElement The DOMElement representing this element and all
0083      * child properties.
0084      */
0085     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0086     {
0087         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0088         if ($this->_url !== null) {
0089             $element->setAttribute('url', $this->_url);
0090         }
0091         if ($this->_width !== null) {
0092             $element->setAttribute('width', $this->_width);
0093         }
0094         if ($this->_height !== null) {
0095             $element->setAttribute('height', $this->_height);
0096         }
0097         return $element;
0098     }
0099 
0100     /**
0101      * Given a DOMNode representing an attribute, tries to map the data into
0102      * instance members.  If no mapping is defined, the name and value are
0103      * stored in an array.
0104      *
0105      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0106      */
0107     protected function takeAttributeFromDOM($attribute)
0108     {
0109         switch ($attribute->localName) {
0110         case 'url':
0111             $this->_url = $attribute->nodeValue;
0112             break;
0113         case 'width':
0114             $this->_width = $attribute->nodeValue;
0115             break;
0116         case 'height':
0117             $this->_height = $attribute->nodeValue;
0118             break;
0119         default:
0120             parent::takeAttributeFromDOM($attribute);
0121         }
0122     }
0123 
0124     /**
0125      * @return string
0126      */
0127     public function getUrl()
0128     {
0129         return $this->_url;
0130     }
0131 
0132     /**
0133      * @param string $value
0134      * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
0135      */
0136     public function setUrl($value)
0137     {
0138         $this->_url = $value;
0139         return $this;
0140     }
0141 
0142     /**
0143      * @return int
0144      */
0145     public function getWidth()
0146     {
0147         return $this->_width;
0148     }
0149 
0150     /**
0151      * @param int $value
0152      * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
0153      */
0154     public function setWidth($value)
0155     {
0156         $this->_width = $value;
0157         return $this;
0158     }
0159 
0160     /**
0161      * @return int
0162      */
0163     public function getHeight()
0164     {
0165         return $this->_height;
0166     }
0167 
0168     /**
0169      * @param int $value
0170      * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
0171      */
0172     public function setHeight($value)
0173     {
0174         $this->_height = $value;
0175         return $this;
0176     }
0177 
0178 }