00001 <?php
00002
00016 class SQuestion extends SModel {
00017
00018 protected $active;
00019 protected $type;
00020 protected $required;
00021 protected $ref;
00022
00030 public function getAttributes() {
00031 return array('id', 'active', 'type', 'required', 'ref');
00032 }
00033
00041 public function getUniqueAttributes() {
00042 return array('id');
00043 }
00044
00052 public function getXFormsOpenCloseTag() {
00053 $ref = $this->getRef();
00054 $attributes = $this->getTagAttributes();
00055 return <<<END_XML
00056 <$ref $attributes />
00057 END_XML;
00058 }
00059
00068 public function getXFormsOpenTag($dbid = "") {
00069 $ref = $this->getRef();
00070 $db = ($dbid == "") ? "" : " dbid=\"$dbid\" ";
00071 $attributes = $this->getTagAttributes();
00072 return <<<END_XML
00073 <$ref $attributes $db>
00074 END_XML;
00075 }
00076
00084 public function getXFormsCloseTag() {
00085 $ref = $this->getRef();
00086 return <<<END_XML
00087 </$ref>
00088 END_XML;
00089 }
00090
00098 public function getTagAttributes() {
00099 $req = ($this->getRequired()) ? " required=\"true()\" " : "";
00100 $type = ($this->getType() != "") ? " type=\"" . $this->getType() . "\" " : "";
00101 return <<<END_XML
00102 $type $req
00103 END_XML;
00104 }
00105
00113 public function isValidQuestion()
00114 {
00115 return (
00116 ($this->getActive() !== "")
00117 && ($this->getRef() !== "")
00118 && ($this->getRequired() !== "")
00119 );
00120 }
00121
00130 public function setActive($active) {
00131 if (!is_bool($active) && $active != 1 && $active != 0) {
00132 $this->setPrettyError('setActive', "Attempt to call setActive with \"$active\" failed:"
00133 . " active must be boolean.");
00134 return false;
00135 }
00136 $this->active = $active;
00137 }
00138
00147 public function setRequired($required) {
00148 if (!is_bool($required) && $required != 1 && $required != 0) {
00149 $this->setPrettyError('setRequired', "Attempt to call setRequired with \"$required\" failed:"
00150 . " required must be boolean.");
00151 return false;
00152 }
00153 $this->required = $required;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 }