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