web/lib/Zend/Gdata/Media/Extension/MediaThumbnail.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  * @version    $Id: MediaThumbnail.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_App_Extension
       
    26  */
       
    27 require_once 'Zend/Gdata/App/Extension.php';
       
    28 
       
    29 /**
       
    30  * Represents the media:thumbnail element
       
    31  *
       
    32  * @category   Zend
       
    33  * @package    Zend_Gdata
       
    34  * @subpackage Media
       
    35  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    37  */
       
    38 class Zend_Gdata_Media_Extension_MediaThumbnail extends Zend_Gdata_Extension
       
    39 {
       
    40 
       
    41     protected $_rootElement = 'thumbnail';
       
    42     protected $_rootNamespace = 'media';
       
    43 
       
    44     /**
       
    45      * @var string
       
    46      */
       
    47     protected $_url = null;
       
    48 
       
    49     /**
       
    50      * @var int
       
    51      */
       
    52     protected $_width = null;
       
    53 
       
    54     /**
       
    55      * @var int
       
    56      */
       
    57     protected $_height = null;
       
    58 
       
    59     /**
       
    60      * @var string
       
    61      */
       
    62     protected $_time = null;
       
    63 
       
    64     /**
       
    65      * Constructs a new MediaThumbnail element
       
    66      *
       
    67      * @param string $url
       
    68      * @param int $width
       
    69      * @param int $height
       
    70      * @param string $time
       
    71      */
       
    72     public function __construct($url = null, $width = null, $height = null,
       
    73             $time = null)
       
    74     {
       
    75         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
       
    76         parent::__construct();
       
    77         $this->_url = $url;
       
    78         $this->_width = $width;
       
    79         $this->_height = $height;
       
    80         $this->_time = $time ;
       
    81     }
       
    82 
       
    83     /**
       
    84      * Retrieves a DOMElement which corresponds to this element and all
       
    85      * child properties.  This is used to build an entry back into a DOM
       
    86      * and eventually XML text for sending to the server upon updates, or
       
    87      * for application storage/persistence.
       
    88      *
       
    89      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    90      * @return DOMElement The DOMElement representing this element and all
       
    91      * child properties.
       
    92      */
       
    93     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    94     {
       
    95         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    96         if ($this->_url !== null) {
       
    97             $element->setAttribute('url', $this->_url);
       
    98         }
       
    99         if ($this->_width !== null) {
       
   100             $element->setAttribute('width', $this->_width);
       
   101         }
       
   102         if ($this->_height !== null) {
       
   103             $element->setAttribute('height', $this->_height);
       
   104         }
       
   105         if ($this->_time !== null) {
       
   106             $element->setAttribute('time', $this->_time);
       
   107         }
       
   108         return $element;
       
   109     }
       
   110 
       
   111     /**
       
   112      * Given a DOMNode representing an attribute, tries to map the data into
       
   113      * instance members.  If no mapping is defined, the name and value are
       
   114      * stored in an array.
       
   115      *
       
   116      * @param DOMNode $attribute The DOMNode attribute needed to be handled
       
   117      */
       
   118     protected function takeAttributeFromDOM($attribute)
       
   119     {
       
   120         switch ($attribute->localName) {
       
   121         case 'url':
       
   122             $this->_url = $attribute->nodeValue;
       
   123             break;
       
   124         case 'width':
       
   125             $this->_width = $attribute->nodeValue;
       
   126             break;
       
   127         case 'height':
       
   128             $this->_height = $attribute->nodeValue;
       
   129             break;
       
   130         case 'time':
       
   131             $this->_time = $attribute->nodeValue;
       
   132             break;
       
   133         default:
       
   134             parent::takeAttributeFromDOM($attribute);
       
   135         }
       
   136     }
       
   137 
       
   138     /**
       
   139      * @return string
       
   140      */
       
   141     public function getUrl()
       
   142     {
       
   143         return $this->_url;
       
   144     }
       
   145 
       
   146     /**
       
   147      * @param string $value
       
   148      * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
       
   149      */
       
   150     public function setUrl($value)
       
   151     {
       
   152         $this->_url = $value;
       
   153         return $this;
       
   154     }
       
   155 
       
   156     /**
       
   157      * @return int
       
   158      */
       
   159     public function getWidth()
       
   160     {
       
   161         return $this->_width;
       
   162     }
       
   163 
       
   164     /**
       
   165      * @param int $value
       
   166      * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
       
   167      */
       
   168     public function setWidth($value)
       
   169     {
       
   170         $this->_width = $value;
       
   171         return $this;
       
   172     }
       
   173 
       
   174     /**
       
   175      * @return int
       
   176      */
       
   177     public function getHeight()
       
   178     {
       
   179         return $this->_height;
       
   180     }
       
   181 
       
   182     /**
       
   183      * @param int $value
       
   184      * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
       
   185      */
       
   186     public function setHeight($value)
       
   187     {
       
   188         $this->_height = $value;
       
   189         return $this;
       
   190     }
       
   191 
       
   192     /**
       
   193      * @return string
       
   194      */
       
   195     public function getTime()
       
   196     {
       
   197         return $this->_time;
       
   198     }
       
   199 
       
   200     /**
       
   201      * @param string $value
       
   202      * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
       
   203      */
       
   204     public function setTime($value)
       
   205     {
       
   206         $this->_time = $value;
       
   207         return $this;
       
   208     }
       
   209 
       
   210 }