web/lib/Zend/Gdata/YouTube/ContactEntry.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 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: ContactEntry.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_YouTube_UserProfileEntry
       
    26  */
       
    27 require_once 'Zend/Gdata/YouTube/UserProfileEntry.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_YouTube_Extension_Status
       
    31  */
       
    32 require_once 'Zend/Gdata/YouTube/Extension/Status.php';
       
    33 
       
    34 /**
       
    35  * The YouTube contacts flavor of an Atom Entry with media support
       
    36  * Represents a an individual contact
       
    37  *
       
    38  * @category   Zend
       
    39  * @package    Zend_Gdata
       
    40  * @subpackage YouTube
       
    41  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    42  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    43  */
       
    44 class Zend_Gdata_YouTube_ContactEntry extends Zend_Gdata_YouTube_UserProfileEntry
       
    45 {
       
    46 
       
    47     /**
       
    48      * The classname for individual feed elements.
       
    49      *
       
    50      * @var string
       
    51      */
       
    52     protected $_entryClassName = 'Zend_Gdata_YouTube_ContactEntry';
       
    53 
       
    54     /**
       
    55      * Status of the user as a contact
       
    56      *
       
    57      * @var string
       
    58      */
       
    59     protected $_status = null;
       
    60 
       
    61     /**
       
    62      * Constructs a new Contact Entry object, to represent
       
    63      * an individual contact for a user
       
    64      *
       
    65      * @param DOMElement $element (optional) DOMElement from which this
       
    66      *          object should be constructed.
       
    67      */
       
    68     public function __construct($element = null)
       
    69     {
       
    70         $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
       
    71         parent::__construct($element);
       
    72     }
       
    73 
       
    74     /**
       
    75      * Retrieves a DOMElement which corresponds to this element and all
       
    76      * child properties.  This is used to build an entry back into a DOM
       
    77      * and eventually XML text for sending to the server upon updates, or
       
    78      * for application storage/persistence.
       
    79      *
       
    80      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    81      * @return DOMElement The DOMElement representing this element and all
       
    82      * child properties.
       
    83      */
       
    84     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    85     {
       
    86         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    87         if ($this->_status != null) {
       
    88             $element->appendChild($this->_status->getDOM($element->ownerDocument));
       
    89         }
       
    90         return $element;
       
    91     }
       
    92 
       
    93     /**
       
    94      * Creates individual Entry objects of the appropriate type and
       
    95      * stores them in the $_entry array based upon DOM data.
       
    96      *
       
    97      * @param DOMNode $child The DOMNode to process
       
    98      */
       
    99     protected function takeChildFromDOM($child)
       
   100     {
       
   101         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
   102         switch ($absoluteNodeName) {
       
   103         case $this->lookupNamespace('yt') . ':' . 'status':
       
   104             $status = new Zend_Gdata_YouTube_Extension_Status();
       
   105             $status->transferFromDOM($child);
       
   106             $this->_status = $status;
       
   107             break;
       
   108         default:
       
   109             parent::takeChildFromDOM($child);
       
   110             break;
       
   111         }
       
   112     }
       
   113 
       
   114     /**
       
   115      * Sets the status
       
   116      *
       
   117      * @param Zend_Gdata_YouTube_Extension_Status $status The status
       
   118      * @return Zend_Gdata_YouTube_ContactEntry Provides a fluent interface
       
   119      */
       
   120     public function setStatus($status = null)
       
   121     {
       
   122         $this->_status = $status;
       
   123         return $this;
       
   124     }
       
   125 
       
   126     /**
       
   127      * Returns the status
       
   128      *
       
   129      * @return Zend_Gdata_YouTube_Extension_Status  The status
       
   130      */
       
   131     public function getStatus()
       
   132     {
       
   133         return $this->_status;
       
   134     }
       
   135 
       
   136 }