web/lib/Zend/Gdata/Gapps/Extension/EmailList.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 Gapps
       
    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: EmailList.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Extension
       
    26  */
       
    27 require_once 'Zend/Gdata/Extension.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Gapps
       
    31  */
       
    32 require_once 'Zend/Gdata/Gapps.php';
       
    33 
       
    34 /**
       
    35  * Represents the apps:emailList element used by the Apps data API. This
       
    36  * class represents properties of an email list and is usually contained
       
    37  * within an instance of Zend_Gdata_Gapps_EmailListEntry.
       
    38  *
       
    39  * @category   Zend
       
    40  * @package    Zend_Gdata
       
    41  * @subpackage Gapps
       
    42  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    43  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    44  */
       
    45 class Zend_Gdata_Gapps_Extension_EmailList extends Zend_Gdata_Extension
       
    46 {
       
    47 
       
    48     protected $_rootNamespace = 'apps';
       
    49     protected $_rootElement = 'emailList';
       
    50 
       
    51     /**
       
    52      * The name of the email list. This name is used as the email address
       
    53      * for this list.
       
    54      *
       
    55      * @var string
       
    56      */
       
    57     protected $_name = null;
       
    58 
       
    59     /**
       
    60      * Constructs a new Zend_Gdata_Gapps_Extension_EmailList object.
       
    61      *
       
    62      * @param string $name (optional) The name to be used for this email list.
       
    63      */
       
    64     public function __construct($name = null)
       
    65     {
       
    66         $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
       
    67         parent::__construct();
       
    68         $this->_name = $name;
       
    69     }
       
    70 
       
    71     /**
       
    72      * Retrieves a DOMElement which corresponds to this element and all
       
    73      * child properties.  This is used to build an entry back into a DOM
       
    74      * and eventually XML text for sending to the server upon updates, or
       
    75      * for application storage/persistence.
       
    76      *
       
    77      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    78      * @return DOMElement The DOMElement representing this element and all
       
    79      * child properties.
       
    80      */
       
    81     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    82     {
       
    83         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    84         if ($this->_name !== null) {
       
    85             $element->setAttribute('name', $this->_name);
       
    86         }
       
    87         return $element;
       
    88     }
       
    89 
       
    90     /**
       
    91      * Given a DOMNode representing an attribute, tries to map the data into
       
    92      * instance members.  If no mapping is defined, the name and value are
       
    93      * stored in an array.
       
    94      *
       
    95      * @param DOMNode $attribute The DOMNode attribute needed to be handled
       
    96      */
       
    97     protected function takeAttributeFromDOM($attribute)
       
    98     {
       
    99         switch ($attribute->localName) {
       
   100         case 'name':
       
   101             $this->_name = $attribute->nodeValue;
       
   102             break;
       
   103         default:
       
   104             parent::takeAttributeFromDOM($attribute);
       
   105         }
       
   106     }
       
   107 
       
   108     /**
       
   109      * Get the value for this element's name attribute.
       
   110      *
       
   111      * @see setName
       
   112      * @return string The requested attribute.
       
   113      */
       
   114     public function getName()
       
   115     {
       
   116         return $this->_name;
       
   117     }
       
   118 
       
   119     /**
       
   120      * Set the value for this element's name attribute. This is the unique
       
   121      * name which will be used to identify this email list within this
       
   122      * domain, and will be used to form this email list's email address.
       
   123      *
       
   124      * @param string $value The desired value for this attribute.
       
   125      * @return Zend_Gdata_Gapps_Extension_EmailList The element being modified.
       
   126      */
       
   127     public function setName($value)
       
   128     {
       
   129         $this->_name = $value;
       
   130         return $this;
       
   131     }
       
   132 
       
   133     /**
       
   134      * Magic toString method allows using this directly via echo
       
   135      * Works best in PHP >= 4.2.0
       
   136      *
       
   137      * @return string
       
   138      */
       
   139     public function __toString()
       
   140     {
       
   141         return $this->getName();
       
   142     }
       
   143 
       
   144 }