26 require_once(
"widget.class.php");
29 if(! defined(
"ENT_XML1") ){
30 define(
"ENT_XML1",16);
39 $this->doc =
new SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?><widget_list></widget_list>');
47 public function import($xml){
48 $this->doc =
new SimpleXMLElement($xml);
49 $name = $this->doc->getName();
51 if( $name ==
"widget_list" ){
53 $widget_list = array();
54 foreach( $this->doc->xpath(
"/widget_list/*") as $sxe){
59 }
else if( $name ==
"poll" ){
61 }
else if( $name ==
"poll_list"){
64 foreach( $this->doc->xpath(
"/poll_list/*") as $sxe){
81 if( $objects instanceof
poll ){
83 $this->doc =
new SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?><poll_list></poll_list>');
85 $xml = $this->doc->asXML();
89 }
else if( $objects instanceof
widget ){
92 $xml = $this->doc->asXML();
96 }
else if ( is_array($objects) ){
111 $sxe = $parent->addChild(
"widget");
112 $sxe->addAttribute(
"version",
"1.1");
114 $sxe->addChild(
"typ", $widget->typ );
118 $sxe->addChild(
"name", htmlspecialchars($widget->name , ENT_XML1&ENT_QUOTES ,
"UTF-8" ,
false ) );
119 $sxe->addChild(
"dispName", htmlspecialchars($widget->dispName,ENT_XML1&ENT_QUOTES,
"UTF-8",
false) );
120 $sxe->addChild(
"value", htmlspecialchars($widget->value,ENT_XML1&ENT_QUOTES,
"UTF-8",
false) );
121 $sxe->addChild(
"is_required", $this->
bool2string((
bool) $widget->is_required) );
122 $sxe->addChild(
"is_child", $this->
bool2string((
bool) $widget->is_child) );
123 $sxe->addChild(
"parent", (
string) $widget->parent );
124 $sxe->addChild(
"index", $widget->index );
125 $sxe->addChild(
"ID", $widget->ID );
127 $c_sxe = $sxe->addChild(
"config");
129 $keys = array_keys($widget->config);
130 foreach(
$keys as $key){
132 $k = $c_sxe->addchild(
"key");
133 $k->addAttribute(
"name",$key);
135 if( ($cnf ===
true) OR ($cnf ===
false) ){
138 $k->addChild(
"value",(
string) $cnf);
154 $sxe = $parent->addChild(
"poll");
155 $sxe->addAttribute(
"version",
"1.0");
157 $sxe->addChild(
"ID", $poll->ID );
158 $sxe->addChild(
"hashID", $poll->hashID );
159 $sxe->addChild(
"name", htmlspecialchars($poll->name , ENT_XML1&ENT_QUOTES ,
"UTF-8" ,
false ) );
160 $sxe->addChild(
"timeout", $poll->timeout );
161 $sxe->addChild(
"active_since", $poll->active_since );
162 $sxe->addChild(
"groups", implode(
",",$poll->groups) );
163 $sxe->addChild(
"status", (
int) $poll->status );
164 $sxe->addChild(
"type", (
int) $poll->type );
165 $sxe->addChild(
"anonymous", $this->
bool2string((
bool) $poll->anonymous) );
166 $sxe->addChild(
"is_public", $this->
bool2string((
bool) $poll->is_public) );
167 $sxe->addChild(
"noDisplay", $this->
bool2string((
bool) $poll->noDisplay) );
168 $sxe->addChild(
"theme", htmlspecialchars($poll->theme , ENT_XML1&ENT_QUOTES ,
"UTF-8" ,
false ) );
174 $w_list_sxe = $sxe->addChild(
"widget_list");
175 foreach( $poll->widget_list as
$widget ){
190 foreach($sxe->attributes() as $attr){
191 if( $attr->getName() ===
"version" ){
192 $ver = (string) $attr;
201 $widget->name = htmlspecialchars_decode( $sxe->name , ENT_XML1&ENT_QUOTES);
202 $widget->dispName = htmlspecialchars_decode( $sxe->dispName , ENT_XML1&ENT_QUOTES);
203 $widget->value = htmlspecialchars_decode( $sxe->value , ENT_XML1&ENT_QUOTES);
206 $widget->parent = intval( $sxe->parent );
207 $widget->index = intval( $sxe->index );
209 foreach($sxe->config->children() as $key){
210 $name = (string) $key->attributes()->name;
211 $val = (string) $key->value;
212 if( $this->is_string_bool($val) ){
215 $widget->set_config($name,$val);
221 foreach( $sxe->option_list->children() as $child){
223 $widget->option_list[] = $option;
225 foreach( $sxe->widget_list->children() as $child){
227 $widget->widget_list[] = $child_widget;
232 throw new Exception(
"Bad widget version");
244 foreach($sxe->attributes() as $attr){
245 if( $attr->getName() ===
"version" ){
246 $ver = (string) $attr;
253 $poll->name = htmlspecialchars_decode( $sxe->name , ENT_XML1&ENT_QUOTES);
254 $poll->timeout = $sxe->timeout;
255 $poll->active_since = $sxe->active_since;
256 $poll->groups = explode(
",",$sxe->groups);
257 $poll->status = (int) $sxe->status;
258 $poll->type = (
int) $sxe->type;
259 $poll->anonymous = $this->
string2bool( $sxe->anonymous );
260 $poll->is_public = $this->
string2bool( $sxe->is_public );
261 $poll->noDisplay = $this->
string2bool( $sxe->noDisplay );
262 $poll->theme = htmlspecialchars_decode( $sxe->theme , ENT_XML1&ENT_QUOTES);
265 $poll->widget_list = array();
266 foreach( $sxe->widget_list->children() as $child){
268 $poll->insert_widget(-1,$child_widget);
273 throw new Exception(
"Bad poll version");
284 $option_list_sxe = $parent->addChild(
"option_list");
285 foreach($list as $option){
296 $option_list_sxe = $parent->addChild(
"widget_list");
297 foreach($list as $option){
311 if( mb_strtoupper(trim($str)) ===
"TRUE" ){
325 if( $bool ===
true ){
339 $str = mb_strtoupper( trim($str));
340 if ( ($str ===
"TRUE") OR ($str ===
"FALSE") ){