33 $path = sprintf(
'./widgets/%s/', $widget);
37 for($i=0;$i<count($skin_info->colorset);$i++)
39 $colorset = sprintf(
'%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title);
40 $colorset_list[] = $colorset;
43 if(count($colorset_list)) $colorsets = implode(
"\n", $colorset_list);
44 $this->
add(
'colorset_list', $colorsets);
53 if(!$widget)
return new BaseObject(-1,
'msg_invalid_request');
58 $widget_code = sprintf(
'<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(
' ',$attribute));
60 $this->
add(
'widget_code', $widget_code);
69 if(!$widget)
return new BaseObject(-1,
'msg_invalid_request');
75 $widget_code = $this->
execute($widget, $vars,
true,
false);
80 $this->
add(
'widget_code', $widget_code);
109 $layout_info = $oLayoutModel->getLayout(
$module_srl);
110 if(!$layout_info || $layout_info->type !=
'faceoff') $err++;
114 $columnList = array(
'module_srl',
'module');
116 if(!$page_info->module_srl || $page_info->module !=
'page') $err++;
118 if($err > 1)
return new BaseObject(-1,
'msg_invalid_request');
124 return new BaseObject(-1,
'msg_not_permitted');
127 if(!$module_grant->manager)
129 return new BaseObject(-1,
'msg_not_permitted');
136 $obj =
new stdClass();
138 $obj->content = $content;
142 if($oDocument->isExists() && $oDocument->document_srl ==
$obj->document_srl)
156 $this->
add(
'document_srl',
$obj->document_srl);
172 if(!$oDocument->isExists())
return new BaseObject(-1,
'msg_invalid_request');
177 $columnList = array(
'module_srl',
'module');
179 if(!$page_info->module_srl || $page_info->module !=
'page')
return new BaseObject(-1,
'msg_invalid_request');
185 return new BaseObject(-1,
'msg_not_permitted');
188 if(!$module_grant->manager)
190 return new BaseObject(-1,
'msg_not_permitted');
193 $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get(
'document_srl')), $oDocument->get(
'module_srl'),0);
197 $copied_srls =
$output->get(
'copied_srls');
198 $this->
add(
'document_srl', $copied_srls[$oDocument->get(
'document_srl')]);
213 if(!$oDocument->isExists())
return new BaseObject();
219 if(!$page_info->module_srl || $page_info->module !=
'page')
return new BaseObject(-1,
'msg_invalid_request');
225 return new BaseObject(-1,
'msg_not_permitted');
228 if(!$module_grant->manager)
230 return new BaseObject(-1,
'msg_not_permitted');
242 $this->layout_javascript_mode =
true;
252 $content = $this->
transWidgetCode($content, $this->layout_javascript_mode);
267 $content = preg_replace_callback(
'!<div([^>]*)widget=([^>]*?)><div><div>((<img.*?>)*)!is', array($this,
'transWidgetBox'), $content);
269 $content = preg_replace_callback(
'!<img([^>]*)widget=([^>]*?)>!is', array($this,
'transWidget'), $content);
279 $buff = trim($matches[0]);
282 $xml_doc = $oXmlParser->parse(trim($buff));
284 if($xml_doc->img) $vars = $xml_doc->img->attrs;
285 else $vars = $xml_doc->attrs;
287 $widget = $vars->widget;
288 if(!$widget)
return $matches[0];
289 unset($vars->widget);
291 return $this->
execute($widget, $vars, $this->javascript_mode);
299 $buff = preg_replace(
'/<div><div>(.*)$/i',
'</div>',$matches[0]);
301 $xml_doc = $oXmlParser->parse($buff);
303 $vars = $xml_doc->div->attrs;
304 $widget = $vars->widget;
305 if(!$widget)
return $matches[0];
306 unset($vars->widget);
308 $vars->widgetbox_content = $matches[3];
309 return $this->
execute($widget, $vars, $this->javascript_mode);
321 preg_match_all(
'!<img([^>]*)widget=([^>]*?)>!is', $content, $matches);
325 $cnt = count($matches[1]);
326 for($i=0;$i<$cnt;$i++)
328 $buff = $matches[0][$i];
329 $xml_doc = $oXmlParser->parse(trim($buff));
331 $args = $xml_doc->img->attrs;
334 $widget =
$args->widget;
335 $sequence =
$args->widget_sequence;
336 $cache =
$args->widget_cache;
337 if(!$sequence || !$cache)
continue;
341 foreach(
$args as $k => $v)
$args->{$k} = urldecode($v);
344 foreach($lang_list as $lang_type => $val)
346 $cache_file = sprintf(
'%s%d.%s.cache', $this->cache_path, $sequence, $lang_type);
347 if(!file_exists($cache_file))
continue;
361 $widget_sequence =
$args->widget_sequence;
362 $widget_cache =
$args->widget_cache;
367 if(!$ignore_cache && (!$widget_cache || !$widget_sequence))
369 $oWidget = $this->getWidgetObject($widget);
370 if(!$oWidget || !method_exists($oWidget,
'proc'))
return;
372 $widget_content = $oWidget->proc(
$args);
375 return $widget_content;
379 if($oCacheHandler->isSupport())
381 $key =
'widget_cache:' . $widget_sequence;
383 $cache_body = $oCacheHandler->get($key);
384 $cache_body = preg_replace(
'@<\!--#Meta:@',
'<!--Meta:', $cache_body);
398 $cache_file = sprintf(
'%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
400 if(!$ignore_cache && file_exists($cache_file))
402 $filemtime = filemtime($cache_file);
404 if($filemtime + $widget_cache * 60 > $_SERVER[
'REQUEST_TIME'] && $filemtime > filemtime(
_XE_PATH_.
'modules/widget/widget.controller.php'))
407 $cache_body = preg_replace(
'@<\!--#Meta:@',
'<!--Meta:', $cache_body);
413 if(!$oCacheHandler->isSupport())
418 $oWidget = $this->getWidgetObject($widget);
419 if(!$oWidget || !method_exists($oWidget,
'proc'))
return;
421 $widget_content = $oWidget->proc(
$args);
424 if($oCacheHandler->isSupport())
426 $oCacheHandler->put($key, $widget_content, $widget_cache * 60);
434 return $widget_content;
443 function execute($widget,
$args, $javascript_mode =
false, $escaped =
true)
447 $before = microtime(
true);
449 $object_vars = get_object_vars(
$args);
450 if(count($object_vars))
452 foreach($object_vars as $key => $val)
454 if(in_array($key, array(
'widgetbox_content',
'body',
'class',
'style',
'widget_sequence',
'widget',
'widget_padding_left',
'widget_padding_top',
'widget_padding_bottom',
'widget_padding_right',
'widgetstyle',
'document_srl')))
continue;
463 $widget_content =
'';
464 if($widget !=
'widgetContent' && $widget !=
'widgetBox')
466 if(!is_dir(sprintf(
_XE_PATH_.
'widgets/%s/',$widget)))
return;
468 $widget_content = $this->getCache($widget,
$args);
471 if($widget ==
'widgetBox')
473 $widgetbox_content =
$args->widgetbox_content;
480 $style = preg_replace(
'/url\((.+)(\/?)none\)/is',
'',
$args->style);
482 $widget_padding_left =
$args->widget_padding_left;
483 $widget_padding_right =
$args->widget_padding_right;
484 $widget_padding_top =
$args->widget_padding_top;
485 $widget_padding_bottom =
$args->widget_padding_bottom;
486 $inner_style = sprintf(
"padding:%dpx %dpx %dpx %dpx !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
492 $widget_content_header =
'';
493 $widget_content_body =
'';
494 $widget_content_footer =
'';
496 if(!$javascript_mode)
498 if(
$args->id)
$args->id =
' id="'.$args->id.
'" ';
502 case 'widgetContent' :
503 if(
$args->document_srl)
507 $body = $oDocument->getContent(
false,
false,
false,
false);
511 $body = base64_decode(
$args->body);
515 $body = $oEditorController->transComponent($body);
517 $widget_content_header = sprintf(
'<div class="xe_content xe-widget-wrapper ' .
$args->css_class .
'" %sstyle="%s"><div style="%s">',
$args->id, $style, $inner_style);
518 $widget_content_body = $body;
519 $widget_content_footer =
'</div></div>';
524 $widget_content_header = sprintf(
'<div class="xe-widget-wrapper ' .
$args->css_class .
'" %sstyle="%s;"><div style="%s"><div>',
$args->id, $style, $inner_style);
525 $widget_content_body = $widgetbox_content;
530 $widget_content_header = sprintf(
'<div class="xe-widget-wrapper ' .
$args->css_class .
'" %sstyle="%s">',
$args->id,$style);
531 $widget_content_body = sprintf(
'<div style="*zoom:1;%s">%s</div>', $inner_style,$widget_content);
532 $widget_content_footer =
'</div>';
542 case 'widgetContent' :
543 if(
$args->document_srl)
547 $body = $oDocument->getContent(
false,
false,
false);
551 $body = base64_decode(
$args->body);
554 $attribute = array();
557 foreach(
$args as $key => $val)
559 if(in_array($key, array(
'class',
'style',
'widget_padding_top',
'widget_padding_right',
'widget_padding_bottom',
'widget_padding_left',
'widget',
'widgetstyle',
'document_srl')))
continue;
560 if(strpos($val,
'|@|')>0) $val = str_replace(
'|@|',
',',$val);
561 $attribute[] = sprintf(
'%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false));
567 $widget_content_header = sprintf(
568 '<div class="xe_content widgetOutput ' .
$args->css_class .
'" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>'.
569 '<div class="widgetResize"></div>'.
570 '<div class="widgetResizeLeft"></div>'.
571 '<div class="widgetBorder">'.
572 '<div style="%s">',
$args->widgetstyle,
574 $args->widget_padding_left,
$args->widget_padding_right,
$args->widget_padding_top,
$args->widget_padding_bottom,
576 implode(
' ',$attribute),
579 $widget_content_body = $body;
580 $widget_content_footer = sprintf(
'</div>'.
582 '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
583 '</div>',base64_encode($body));
589 $attribute = array();
592 foreach(
$args as $key => $val)
594 if(in_array($key, array(
'class',
'style',
'widget_padding_top',
'widget_padding_right',
'widget_padding_bottom',
'widget_padding_left',
'widget',
'widgetstyle',
'document_srl')))
continue;
595 if(!is_numeric($val) && (!is_string($val) || strlen($val)==0))
continue;
596 if(strpos($val,
'|@|')>0) $val = str_replace(
'|@|',
',',$val);
597 $attribute[] = sprintf(
'%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false));
601 $widget_content_header = sprintf(
602 '<div class="widgetOutput ' .
$args->css_class .
'" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >'.
603 '<div class="widgetBoxResize"></div>'.
604 '<div class="widgetBoxResizeLeft"></div>'.
605 '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">',
$args->widgetstyle,$style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,implode(
' ',$attribute),$inner_style);
607 $widget_content_body = $widgetbox_content;
613 $attribute = array();
616 $allowed_key = array(
'class',
'style',
'widget_padding_top',
'widget_padding_right',
'widget_padding_bottom',
'widget_padding_left',
'widget');
617 foreach(
$args as $key => $val)
619 if(in_array($key, $allowed_key))
continue;
620 if(!is_numeric($val) && (!is_string($val) || strlen($val)==0))
continue;
621 if(strpos($val,
'|@|')>0) $val = str_replace(
'|@|',
',',$val);
622 $attribute[] = sprintf(
'%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false));
626 $widget_content_header = sprintf(
'<div class="widgetOutput ' .
$args->css_class .
'" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'.
627 '<div class="widgetResize"></div>'.
628 '<div class="widgetResizeLeft"></div>'.
629 '<div class="widgetBorder">',
$args->widgetstyle,$style,
630 $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,
631 $widget, implode(
' ',$attribute));
633 $widget_content_body = sprintf(
'<div style="%s">%s</div>',$inner_style, $widget_content);
635 $widget_content_footer =
'</div></div>';
641 if(
$args->widgetstyle) $widget_content_body = $this->compileWidgetStyle(
$args->widgetstyle,$widget, $widget_content_body,
$args, $javascript_mode);
643 $output = $widget_content_header . $widget_content_body . $widget_content_footer;
647 $after = microtime(
true);
649 $elapsed_time = $after - $before;
651 $slowlog =
new stdClass;
652 $slowlog->caller =
"widget.execute";
653 $slowlog->called = $widget;
654 $slowlog->called_extension = $widget;
666 if(!preg_match(
'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget))
671 if(!
$GLOBALS[
'_xe_loaded_widgets_'][$widget])
675 $path = $oWidgetModel->getWidgetPath($widget);
677 $class_file = sprintf(
'%s%s.class.php', $path, $widget);
678 if(!file_exists($class_file))
return sprintf(
Context::getLang(
'msg_widget_is_not_exists'), $widget);
680 require_once($class_file);
683 if(!class_exists($widget,
false))
688 $oWidget =
new $widget();
689 if(!is_object($oWidget))
return sprintf(
Context::getLang(
'msg_widget_object_is_null'), $widget);
691 if(!method_exists($oWidget,
'proc'))
return sprintf(
Context::getLang(
'msg_widget_proc_is_null'), $widget);
693 $oWidget->widget_path = $path;
695 $GLOBALS[
'_xe_loaded_widgets_'][$widget] = $oWidget;
697 return $GLOBALS[
'_xe_loaded_widgets_'][$widget];
702 if(!$widgetStyle)
return $widget_content_body;
706 $widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle);
707 if(!$widgetstyle_info)
return $widget_content_body;
709 $widgetstyle_extra_var =
new stdClass();
710 $widgetstyle_extra_var_key = get_object_vars($widgetstyle_info);
711 if(count($widgetstyle_extra_var_key[
'extra_var']))
713 foreach($widgetstyle_extra_var_key[
'extra_var'] as $key => $val)
715 $widgetstyle_extra_var->{$key} =
$args->{$key};
718 Context::set(
'widgetstyle_extra_var', $widgetstyle_extra_var);
720 Context::set(
'widgetstyle_extar_var', $widgetstyle_extra_var);
722 if($javascript_mode && $widget==
'widgetBox')
724 Context::set(
'widget_content',
'<div class="widget_inner">'.$widget_content_body.
'</div>');
731 $widgetstyle_path = $oWidgetModel->getWidgetStylePath($widgetStyle);
733 $tpl = $oTemplate->compile($widgetstyle_path,
'widgetstyle');
744 $widget_info = $oWidgetModel->getWidgetInfo($widget);
748 $vars =
new stdClass();
751 $widget = $vars->selected_widget;
752 $vars->css_class = $request_vars->css_class;
753 $vars->widgetstyle = $request_vars->widgetstyle;
755 $vars->skin = trim($request_vars->skin);
756 $vars->colorset = trim($request_vars->colorset);
757 $vars->widget_sequence = (int)($request_vars->widget_sequence);
758 $vars->widget_cache = (int)($request_vars->widget_cache);
759 $vars->style = trim($request_vars->style);
760 $vars->widget_padding_left = trim($request_vars->widget_padding_left);
761 $vars->widget_padding_right = trim($request_vars->widget_padding_right);
762 $vars->widget_padding_top = trim($request_vars->widget_padding_top);
763 $vars->widget_padding_bottom = trim($request_vars->widget_padding_bottom);
764 $vars->document_srl= trim($request_vars->document_srl);
766 if(count($widget_info->extra_var))
768 foreach($widget_info->extra_var as $key=>$val)
770 $vars->{$key} = trim($request_vars->{$key});
774 if($request_vars->widgetstyle)
776 $widgetStyle_info = $oWidgetModel->getWidgetStyleInfo($request_vars->widgetstyle);
777 if(count($widgetStyle_info->extra_var))
779 foreach($widgetStyle_info->extra_var as $key=>$val)
781 if($val->type ==
'color' || $val->type ==
'text' || $val->type ==
'select' || $val->type ==
'filebox' || $val->type ==
'textarea')
783 $vars->{$key} = trim($request_vars->{$key});
789 if($vars->widget_sequence)
791 $cache_file = sprintf(
'%s%d.%s.cache', $this->cache_path, $vars->widget_sequence,
Context::getLangType());
797 $attribute = array();
798 foreach($vars as $key => $val)
802 unset($vars->{$key});
805 if(strpos($val,
'|@|') > 0) $val = str_replace(
'|@|',
',', $val);
807 $attribute[] = sprintf(
'%s="%s"', $key, htmlspecialchars(
Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401,
'UTF-8',
false));
setTemplateFile($filename)
getController($module_name)
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
& getInstance($target= 'object', $info=null, $always_use_file=false)
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
$module_srl
integer value to represent a run-time instance of Module (XE Module)
getAdminController($module_name)
writeSlowlog($type, $elapsed_time, $obj)
utf8RawUrlDecode($source)