|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata/Extension.php'; 00028 00038 class Zend_Gdata_Calendar_Extension_Selected extends Zend_Gdata_Extension 00039 { 00040 00041 protected $_rootNamespace = 'gCal'; 00042 protected $_rootElement = 'selected'; 00043 protected $_value = null; 00044 00049 public function __construct($value = null) 00050 { 00051 $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces); 00052 parent::__construct(); 00053 $this->_value = $value; 00054 } 00055 00066 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 00067 { 00068 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 00069 if ($this->_value !== null) { 00070 $element->setAttribute('value', ($this->_value ? "true" : "false")); 00071 } 00072 return $element; 00073 } 00074 00082 protected function takeAttributeFromDOM($attribute) 00083 { 00084 switch ($attribute->localName) { 00085 case 'value': 00086 if ($attribute->nodeValue == "true") { 00087 $this->_value = true; 00088 } 00089 else if ($attribute->nodeValue == "false") { 00090 $this->_value = false; 00091 } 00092 else { 00093 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 00094 throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value."); 00095 } 00096 break; 00097 default: 00098 parent::takeAttributeFromDOM($attribute); 00099 } 00100 } 00101 00107 public function getValue() 00108 { 00109 return $this->_value; 00110 } 00111 00118 public function setValue($value) 00119 { 00120 $this->_value = $value; 00121 return $this; 00122 } 00123 00128 public function __toString() 00129 { 00130 return $this->_value; 00131 } 00132 00133 }