[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/YouTube/Extension/ -> State.php (source)

   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 [email protected] so we can send you a copy immediately.
  15   *
  16   * @category   Zend
  17   * @package    Zend_Gdata
  18   * @subpackage YouTube
  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$
  22   */
  23  
  24  /**
  25   * @see Zend_Gdata_Extension
  26   */
  27  require_once 'Zend/Gdata/Extension.php';
  28  
  29  /**
  30   * Represents the yt:state element used by the YouTube data API
  31   *
  32   * @category   Zend
  33   * @package    Zend_Gdata
  34   * @subpackage YouTube
  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_YouTube_Extension_State extends Zend_Gdata_Extension
  39  {
  40  
  41      protected $_rootNamespace = 'yt';
  42      protected $_rootElement = 'state';
  43      protected $_name = null;
  44      protected $_reasonCode = null;
  45      protected $_helpUrl = null;
  46  
  47      /**
  48       * Constructs a new Zend_Gdata_YouTube_Extension_State object.
  49       *
  50       * @param string $explanation(optional) The explanation of this state
  51       * @param string $name(optional) The name value
  52       * @param string $reasonCode(optional) The reasonCode value
  53       * @param string $helpUrl(optional) The helpUrl value
  54       */
  55      public function __construct($explanation = null, $name = null,
  56                                  $reasonCode = null, $helpUrl = null)
  57      {
  58          $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  59          parent::__construct();
  60          $this->_text = $explanation;
  61          $this->_name = $name;
  62          $this->_reasonCode = $reasonCode;
  63          $this->_helpUrl = $reasonCode;
  64      }
  65  
  66      /**
  67       * Retrieves a DOMElement which corresponds to this element and all
  68       * child properties.  This is used to build an entry back into a DOM
  69       * and eventually XML text for sending to the server upon updates, or
  70       * for application storage/persistence.
  71       *
  72       * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  73       * @return DOMElement The DOMElement representing this element and all
  74       * child properties.
  75       */
  76      public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  77      {
  78          $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  79          if ($this->_name !== null) {
  80              $element->setAttribute('name', $this->_name);
  81          }
  82          if ($this->_reasonCode !== null) {
  83              $element->setAttribute('reasonCode', $this->_reasonCode);
  84          }
  85          if ($this->_helpUrl !== null) {
  86              $element->setAttribute('helpUrl', $this->_helpUrl);
  87          }
  88          return $element;
  89      }
  90  
  91      /**
  92       * Given a DOMNode representing an attribute, tries to map the data into
  93       * instance members.  If no mapping is defined, the name and valueare
  94       * stored in an array.
  95       * TODO: Convert attributes to proper types
  96       *
  97       * @param DOMNode $attribute The DOMNode attribute needed to be handled
  98       */
  99      protected function takeAttributeFromDOM($attribute)
 100      {
 101          switch ($attribute->localName) {
 102          case 'name':
 103              $this->_name = $attribute->nodeValue;
 104              break;
 105          case 'reasonCode':
 106              $this->_reasonCode = $attribute->nodeValue;
 107              break;
 108          case 'helpUrl':
 109              $this->_helpUrl = $attribute->nodeValue;
 110              break;
 111          default:
 112              parent::takeAttributeFromDOM($attribute);
 113          }
 114      }
 115  
 116      /**
 117       * Get the value for this element's name attribute.
 118       *
 119       * @return int The value associated with this attribute.
 120       */
 121      public function getName()
 122      {
 123          return $this->_name;
 124      }
 125  
 126      /**
 127       * Set the value for this element's name attribute.
 128       *
 129       * @param int $value The desired value for this attribute.
 130       * @return Zend_Gdata_YouTube_Extension_State The element being modified.
 131       */
 132      public function setName($value)
 133      {
 134          $this->_name = $value;
 135          return $this;
 136      }
 137  
 138      /**
 139       * Get the value for this element's reasonCode attribute.
 140       *
 141       * @return int The value associated with this attribute.
 142       */
 143      public function getReasonCode()
 144      {
 145          return $this->_reasonCode;
 146      }
 147  
 148      /**
 149       * Set the value for this element's reasonCode attribute.
 150       *
 151       * @param int $value The desired value for this attribute.
 152       * @return Zend_Gdata_YouTube_Extension_State The element being modified.
 153       */
 154      public function setReasonCode($value)
 155      {
 156          $this->_reasonCode = $value;
 157          return $this;
 158      }
 159  
 160      /**
 161       * Get the value for this element's helpUrl attribute.
 162       *
 163       * @return int The value associated with this attribute.
 164       */
 165      public function getHelpUrl()
 166      {
 167          return $this->_helpUrl;
 168      }
 169  
 170      /**
 171       * Set the value for this element's helpUrl attribute.
 172       *
 173       * @param int $value The desired value for this attribute.
 174       * @return Zend_Gdata_YouTube_Extension_State The element being modified.
 175       */
 176      public function setHelpUrl($value)
 177      {
 178          $this->_helpUrl = $value;
 179          return $this;
 180      }
 181  
 182      /**
 183       * Magic toString method allows using this directly via echo
 184       * Works best in PHP >= 4.2.0
 185       *
 186       * @return string
 187       */
 188      public function __toString()
 189      {
 190          return $this->_text;
 191      }
 192  
 193  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1