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