|
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_QuickAdd extends Zend_Gdata_Extension 00039 { 00040 00041 protected $_rootNamespace = 'gCal'; 00042 protected $_rootElement = 'quickadd'; 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 throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value."); 00094 } 00095 break; 00096 default: 00097 parent::takeAttributeFromDOM($attribute); 00098 } 00099 } 00100 00106 public function getValue() 00107 { 00108 return $this->_value; 00109 } 00110 00117 public function setValue($value) 00118 { 00119 $this->_value = $value; 00120 return $this; 00121 } 00122 00127 public function __toString() 00128 { 00129 return $this->getValue(); 00130 } 00131 00132 }