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:category 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_MediaCategory extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'category';
0042     protected $_rootNamespace = 'media';
0043 
0044     /**
0045      * @var string
0046      */
0047     protected $_scheme = null;
0048     protected $_label = null;
0049 
0050     /**
0051      * Creates an individual MediaCategory object.
0052      *
0053      * @param string $text      Indication of the type and content of the media
0054      * @param string $scheme    URI that identifies the categorization scheme
0055      * @param string $label     Human-readable label to be displayed in applications
0056      */
0057     public function __construct($text = null, $scheme = null, $label = null)
0058     {
0059         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
0060         parent::__construct();
0061         $this->_text = $text;
0062         $this->_scheme = $scheme;
0063         $this->_label = $label;
0064     }
0065 
0066     /**
0067      * Retrieves a DOMElement which corresponds to this element and all
0068      * child properties.  This is used to build an entry back into a DOM
0069      * and eventually XML text for sending to the server upon updates, or
0070      * for application storage/persistence.
0071      *
0072      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0073      * @return DOMElement The DOMElement representing this element and all
0074      * child properties.
0075      */
0076     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0077     {
0078         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0079         if ($this->_scheme !== null) {
0080             $element->setAttribute('scheme', $this->_scheme);
0081         }
0082         if ($this->_label !== null) {
0083             $element->setAttribute('label', $this->_label);
0084         }
0085         return $element;
0086     }
0087 
0088     /**
0089      * Given a DOMNode representing an attribute, tries to map the data into
0090      * instance members.  If no mapping is defined, the name and value are
0091      * stored in an array.
0092      *
0093      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0094      */
0095     protected function takeAttributeFromDOM($attribute)
0096     {
0097         switch ($attribute->localName) {
0098         case 'scheme':
0099             $this->_scheme = $attribute->nodeValue;
0100             break;
0101         case 'label':
0102             $this->_label = $attribute->nodeValue;
0103             break;
0104         default:
0105             parent::takeAttributeFromDOM($attribute);
0106         }
0107     }
0108 
0109     /**
0110      * Returns the URI that identifies the categorization scheme
0111      * Optional.
0112      *
0113      * @return string URI that identifies the categorization scheme
0114      */
0115     public function getScheme()
0116     {
0117         return $this->_scheme;
0118     }
0119 
0120     /**
0121      * @param string $value     URI that identifies the categorization scheme
0122      * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
0123      */
0124     public function setScheme($value)
0125     {
0126         $this->_scheme = $value;
0127         return $this;
0128     }
0129 
0130     /**
0131      * @return string Human-readable label to be displayed in applications
0132      */
0133     public function getLabel()
0134     {
0135         return $this->_label;
0136     }
0137 
0138     /**
0139      * @param string $value     Human-readable label to be displayed in applications
0140      * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
0141      */
0142     public function setLabel($value)
0143     {
0144         $this->_label = $value;
0145         return $this;
0146     }
0147 
0148 }