XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
widget.controller.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class widgetController extends widget
9 {
10  // The results are not widget modify/delete and where to use the flag for
11  // layout_javascript_mode include all the results into the javascript mode Sikkim
12  var $javascript_mode = false;
14 
15  // Where the cache files are created widget
16  var $cache_path = './files/cache/widget_cache/';
17 
21  function init()
22  {
23  }
24 
29  {
30  $widget = Context::get('selected_widget');
31  $skin = Context::get('skin');
32 
33  $path = sprintf('./widgets/%s/', $widget);
34  $oModuleModel = getModel('module');
35  $skin_info = $oModuleModel->loadSkinInfo($path, $skin);
36 
37  for($i=0;$i<count($skin_info->colorset);$i++)
38  {
39  $colorset = sprintf('%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title);
40  $colorset_list[] = $colorset;
41  }
42 
43  if(count($colorset_list)) $colorsets = implode("\n", $colorset_list);
44  $this->add('colorset_list', $colorsets);
45  }
46 
51  {
52  $widget = Context::get('selected_widget');
53  if(!$widget) return new BaseObject(-1,'msg_invalid_request');
54  if(!Context::get('skin')) return new BaseObject(-1,Context::getLang('msg_widget_skin_is_null'));
55 
56  $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
57 
58  $widget_code = sprintf('<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(' ',$attribute));
59  // Code output
60  $this->add('widget_code', $widget_code);
61  }
62 
67  {
68  $widget = Context::get('selected_widget');
69  if(!$widget) return new BaseObject(-1,'msg_invalid_request');
70 
71  if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new BaseObject(-1,Context::getLang('msg_widget_skin_is_null'));
72 
73  $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
74  // Wanted results
75  $widget_code = $this->execute($widget, $vars, true, false);
76 
78  $oModuleController->replaceDefinedLangCode($widget_code);
79 
80  $this->add('widget_code', $widget_code);
81  }
82 
87  {
88  $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
89 
90  $this->setLayoutPath('./common/tpl');
91  $this->setLayoutFile('default_layout.html');
92  $this->setTemplatePath($this->module_path.'tpl');
93  $this->setTemplateFile("top_refresh.html");
94  }
95 
100  {
101  // Variable Wanted
102  $module_srl = Context::get('module_srl');
103  $document_srl = Context::get('document_srl');
104  $content = Context::get('content');
105  $editor_sequence = Context::get('editor_sequence');
106 
107  $err = 0;
108  $oLayoutModel = getModel('layout');
109  $layout_info = $oLayoutModel->getLayout($module_srl);
110  if(!$layout_info || $layout_info->type != 'faceoff') $err++;
111 
112  // Destination Information Wanted page module
113  $oModuleModel = getModel('module');
114  $columnList = array('module_srl', 'module');
115  $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
116  if(!$page_info->module_srl || $page_info->module != 'page') $err++;
117 
118  if($err > 1) return new BaseObject(-1,'msg_invalid_request');
119 
120  // Check permissions
121  $logged_info = Context::get('logged_info');
122  if(!$logged_info->member_srl)
123  {
124  return new BaseObject(-1,'msg_not_permitted');
125  }
126  $module_grant = $oModuleModel->getGrant($page_info, $logged_info);
127  if(!$module_grant->manager)
128  {
129  return new BaseObject(-1,'msg_not_permitted');
130  }
131 
132  // Enter post
133  $oDocumentModel = getModel('document');
134  $oDocumentController = getController('document');
135 
136  $obj = new stdClass();
137  $obj->module_srl = $module_srl;
138  $obj->content = $content;
139  $obj->document_srl = $document_srl;
140 
141  $oDocument = $oDocumentModel->getDocument($obj->document_srl);
142  if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
143  {
144  $output = $oDocumentController->updateDocument($oDocument, $obj);
145  }
146  else
147  {
148  $output = $oDocumentController->insertDocument($obj);
149  $obj->document_srl = $output->get('document_srl');
150  }
151 
152  // Stop when an error occurs
153  if(!$output->toBool()) return $output;
154 
155  // Return results
156  $this->add('document_srl', $obj->document_srl);
157  }
158 
163  {
164  // Variable Wanted
165  $document_srl = Context::get('document_srl');
166 
167  $oDocumentModel = getModel('document');
168  $oDocumentController = getController('document');
169  $oDocumentAdminController = getAdminController('document');
170 
171  $oDocument = $oDocumentModel->getDocument($document_srl);
172  if(!$oDocument->isExists()) return new BaseObject(-1,'msg_invalid_request');
173  $module_srl = $oDocument->get('module_srl');
174 
175  // Destination Information Wanted page module
176  $oModuleModel = getModel('module');
177  $columnList = array('module_srl', 'module');
178  $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
179  if(!$page_info->module_srl || $page_info->module != 'page') return new BaseObject(-1,'msg_invalid_request');
180 
181  // Check permissions
182  $logged_info = Context::get('logged_info');
183  if(!$logged_info->member_srl)
184  {
185  return new BaseObject(-1,'msg_not_permitted');
186  }
187  $module_grant = $oModuleModel->getGrant($page_info, $logged_info);
188  if(!$module_grant->manager)
189  {
190  return new BaseObject(-1,'msg_not_permitted');
191  }
192 
193  $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0);
194  if(!$output->toBool()) return $output;
195 
196  // Return results
197  $copied_srls = $output->get('copied_srls');
198  $this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]);
199  }
200 
205  {
206  // Variable Wanted
207  $document_srl = Context::get('document_srl');
208 
209  $oDocumentModel = getModel('document');
210  $oDocumentController = getController('document');
211 
212  $oDocument = $oDocumentModel->getDocument($document_srl);
213  if(!$oDocument->isExists()) return new BaseObject();
214  $module_srl = $oDocument->get('module_srl');
215 
216  // Destination Information Wanted page module
217  $oModuleModel = getModel('module');
218  $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
219  if(!$page_info->module_srl || $page_info->module != 'page') return new BaseObject(-1,'msg_invalid_request');
220 
221  // Check permissions
222  $logged_info = Context::get('logged_info');
223  if(!$logged_info->member_srl)
224  {
225  return new BaseObject(-1, 'msg_not_permitted');
226  }
227  $module_grant = $oModuleModel->getGrant($page_info, $logged_info);
228  if(!$module_grant->manager)
229  {
230  return new BaseObject(-1, 'msg_not_permitted');
231  }
232 
233  $output = $oDocumentController->deleteDocument($oDocument->get('document_srl'));
234  if(!$output->toBool()) return $output;
235  }
236 
241  {
242  $this->layout_javascript_mode = true;
243  }
244 
249  function triggerWidgetCompile(&$content)
250  {
251  if(Context::getResponseMethod()!='HTML') return new BaseObject();
252  $content = $this->transWidgetCode($content, $this->layout_javascript_mode);
253  return new BaseObject();
254  }
255 
259  function transWidgetCode($content, $javascript_mode = false, $isReplaceLangCode = true)
260  {
261  // Changing user-defined language
262  $oModuleController = getController('module');
263  $oModuleController->replaceDefinedLangCode($content, $isReplaceLangCode);
264  // Check whether to include information about editing
265  $this->javascript_mode = $javascript_mode;
266  // Widget code box change
267  $content = preg_replace_callback('!<div([^>]*)widget=([^>]*?)><div><div>((<img.*?>)*)!is', array($this,'transWidgetBox'), $content);
268  // Widget code information byeogyeong
269  $content = preg_replace_callback('!<img([^>]*)widget=([^>]*?)>!is', array($this,'transWidget'), $content);
270 
271  return $content;
272  }
273 
277  function transWidget($matches)
278  {
279  $buff = trim($matches[0]);
280 
281  $oXmlParser = new XmlParser();
282  $xml_doc = $oXmlParser->parse(trim($buff));
283 
284  if($xml_doc->img) $vars = $xml_doc->img->attrs;
285  else $vars = $xml_doc->attrs;
286 
287  $widget = $vars->widget;
288  if(!$widget) return $matches[0];
289  unset($vars->widget);
290 
291  return $this->execute($widget, $vars, $this->javascript_mode);
292  }
293 
297  function transWidgetBox($matches)
298  {
299  $buff = preg_replace('/<div><div>(.*)$/i','</div>',$matches[0]);
300  $oXmlParser = new XmlParser();
301  $xml_doc = $oXmlParser->parse($buff);
302 
303  $vars = $xml_doc->div->attrs;
304  $widget = $vars->widget;
305  if(!$widget) return $matches[0];
306  unset($vars->widget);
307 
308  $vars->widgetbox_content = $matches[3];
309  return $this->execute($widget, $vars, $this->javascript_mode);
310  }
311 
316  function recompileWidget($content)
317  {
318  // Language in bringing
319  $lang_list = Context::get('lang_supported');
320  // Bringing widget cache sequence
321  preg_match_all('!<img([^>]*)widget=([^>]*?)>!is', $content, $matches);
322 
323  $oXmlParser = new XmlParser();
324 
325  $cnt = count($matches[1]);
326  for($i=0;$i<$cnt;$i++)
327  {
328  $buff = $matches[0][$i];
329  $xml_doc = $oXmlParser->parse(trim($buff));
330 
331  $args = $xml_doc->img->attrs;
332  if(!$args) continue;
333  // If you are not caching path
334  $widget = $args->widget;
335  $sequence = $args->widget_sequence;
336  $cache = $args->widget_cache;
337  if(!$sequence || !$cache) continue;
338 
339  if(count($args))
340  {
341  foreach($args as $k => $v) $args->{$k} = urldecode($v);
342  }
343  // If the cache file for each language widget regeneration
344  foreach($lang_list as $lang_type => $val)
345  {
346  $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type);
347  if(!file_exists($cache_file)) continue;
348  $this->getCache($widget, $args, $lang_type, true);
349  }
350  }
351  }
352 
356  function getCache($widget, $args, $lang_type = null, $ignore_cache = false)
357  {
358  // If the specified language specifies the current language
359  if(!$lang_type) $lang_type = Context::getLangType();
360  // widget, the cache number and cache values are set
361  $widget_sequence = $args->widget_sequence;
362  $widget_cache = $args->widget_cache;
363 
367  if(!$ignore_cache && (!$widget_cache || !$widget_sequence))
368  {
369  $oWidget = $this->getWidgetObject($widget);
370  if(!$oWidget || !method_exists($oWidget, 'proc')) return;
371 
372  $widget_content = $oWidget->proc($args);
373  $oModuleController = getController('module');
374  $oModuleController->replaceDefinedLangCode($widget_content);
375  return $widget_content;
376  }
377 
378  $oCacheHandler = CacheHandler::getInstance('template');
379  if($oCacheHandler->isSupport())
380  {
381  $key = 'widget_cache:' . $widget_sequence;
382 
383  $cache_body = $oCacheHandler->get($key);
384  $cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body);
385  }
386 
387  if($cache_body)
388  {
389  return $cache_body;
390  }
391  else
392  {
396  FileHandler::makeDir($this->cache_path);
397  // Wanted cache file
398  $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
399  // If the file exists in the cache, the file validation
400  if(!$ignore_cache && file_exists($cache_file))
401  {
402  $filemtime = filemtime($cache_file);
403  // Should be modified compared to the time of the cache or in the future if creating more than widget.controller.php file a return value of the cache
404  if($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php'))
405  {
406  $cache_body = FileHandler::readFile($cache_file);
407  $cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body);
408 
409  return $cache_body;
410  }
411  }
412  // cache update and cache renewal of the file mtime
413  if(!$oCacheHandler->isSupport())
414  {
415  touch($cache_file);
416  }
417 
418  $oWidget = $this->getWidgetObject($widget);
419  if(!$oWidget || !method_exists($oWidget,'proc')) return;
420 
421  $widget_content = $oWidget->proc($args);
422  $oModuleController = getController('module');
423  $oModuleController->replaceDefinedLangCode($widget_content);
424  if($oCacheHandler->isSupport())
425  {
426  $oCacheHandler->put($key, $widget_content, $widget_cache * 60);
427  }
428  else
429  {
430  FileHandler::writeFile($cache_file, $widget_content);
431  }
432  }
433 
434  return $widget_content;
435  }
436 
443  function execute($widget, $args, $javascript_mode = false, $escaped = true)
444  {
445  // Save for debug run-time widget
446  if(__DEBUG__==3) $start = getMicroTime();
447  $before = microtime(true);
448  // urldecode the value of args haejum
449  $object_vars = get_object_vars($args);
450  if(count($object_vars))
451  {
452  foreach($object_vars as $key => $val)
453  {
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;
455  if($escaped) $args->{$key} = utf8RawUrlDecode($val);
456  }
457  }
458 
459 
463  $widget_content = '';
464  if($widget != 'widgetContent' && $widget != 'widgetBox')
465  {
466  if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) return;
467  // Hold the contents of the widget parameter
468  $widget_content = $this->getCache($widget, $args);
469  }
470 
471  if($widget == 'widgetBox')
472  {
473  $widgetbox_content = $args->widgetbox_content;
474  }
475 
479  // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed
480  $style = preg_replace('/url\((.+)(\/?)none\)/is','', $args->style);
481  // Find a style statement that based on the internal margin dropping pre-change
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);
487 
492  $widget_content_header = '';
493  $widget_content_body = '';
494  $widget_content_footer = '';
495  // If general call is given on page styles should return immediately dreamin '
496  if(!$javascript_mode)
497  {
498  if($args->id) $args->id = ' id="'.$args->id.'" ';
499  switch($widget)
500  {
501  // If a direct orthogonal addition information
502  case 'widgetContent' :
503  if($args->document_srl)
504  {
505  $oDocumentModel = getModel('document');
506  $oDocument = $oDocumentModel->getDocument($args->document_srl);
507  $body = $oDocument->getContent(false,false,false, false);
508  }
509  else
510  {
511  $body = base64_decode($args->body);
512  }
513  // Change the editor component
514  $oEditorController = getController('editor');
515  $body = $oEditorController->transComponent($body);
516 
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>';
520 
521  break;
522  // If the widget box; it could
523  case 'widgetBox' :
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;
526 
527  break;
528  // If the General wijetil
529  default :
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>';
533  break;
534  }
535  // Edit page is called when a widget if you add the code for handling
536  }
537  else
538  {
539  switch($widget)
540  {
541  // If a direct orthogonal addition information
542  case 'widgetContent' :
543  if($args->document_srl)
544  {
545  $oDocumentModel = getModel('document');
546  $oDocument = $oDocumentModel->getDocument($args->document_srl);
547  $body = $oDocument->getContent(false,false,false);
548  }
549  else
550  {
551  $body = base64_decode($args->body);
552  }
553  // by args
554  $attribute = array();
555  if($args)
556  {
557  foreach($args as $key => $val)
558  {
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));
562  }
563  }
564 
565  $oWidgetController = getController('widget');
566 
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,
573  $style,
574  $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom,
575  $args->document_srl,
576  implode(' ',$attribute),
577  $inner_style);
578 
579  $widget_content_body = $body;
580  $widget_content_footer = sprintf('</div>'.
581  '</div>'.
582  '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
583  '</div>',base64_encode($body));
584 
585  break;
586  // If the widget box; it could
587  case 'widgetBox' :
588  // by args
589  $attribute = array();
590  if($args)
591  {
592  foreach($args as $key => $val)
593  {
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));
598  }
599  }
600 
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);
606 
607  $widget_content_body = $widgetbox_content;
608 
609  break;
610  // If the General wijetil
611  default :
612  // by args
613  $attribute = array();
614  if($args)
615  {
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)
618  {
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));
623  }
624  }
625 
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));
632 
633  $widget_content_body = sprintf('<div style="%s">%s</div>',$inner_style, $widget_content);
634 
635  $widget_content_footer = '</div></div>';
636 
637  break;
638  }
639  }
640  // Compile the widget style.
641  if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode);
642 
643  $output = $widget_content_header . $widget_content_body . $widget_content_footer;
644  // Debug widget creation time information added to the results
645  if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
646 
647  $after = microtime(true);
648 
649  $elapsed_time = $after - $before;
650 
651  $slowlog = new stdClass;
652  $slowlog->caller = "widget.execute";
653  $slowlog->called = $widget;
654  $slowlog->called_extension = $widget;
655  writeSlowlog('widget', $elapsed_time, $slowlog);
656 
657  // Return result
658  return $output;
659  }
660 
664  function getWidgetObject($widget)
665  {
666  if(!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget))
667  {
668  return Context::getLang('msg_invalid_request');
669  }
670 
671  if(!$GLOBALS['_xe_loaded_widgets_'][$widget])
672  {
673  // Finding the location of a widget
674  $oWidgetModel = getModel('widget');
675  $path = $oWidgetModel->getWidgetPath($widget);
676  // If you do not find the class file error output widget (html output)
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);
679  // Widget classes include
680  require_once($class_file);
681 
682  // Creating Objects
683  if(!class_exists($widget, false))
684  {
685  return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
686  }
687 
688  $oWidget = new $widget();
689  if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
690 
691  if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
692 
693  $oWidget->widget_path = $path;
694 
695  $GLOBALS['_xe_loaded_widgets_'][$widget] = $oWidget;
696  }
697  return $GLOBALS['_xe_loaded_widgets_'][$widget];
698  }
699 
700  function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode)
701  {
702  if(!$widgetStyle) return $widget_content_body;
703 
704  $oWidgetModel = getModel('widget');
705  // Bring extra_var widget style tie
706  $widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle);
707  if(!$widgetstyle_info) return $widget_content_body;
708 
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']))
712  {
713  foreach($widgetstyle_extra_var_key['extra_var'] as $key => $val)
714  {
715  $widgetstyle_extra_var->{$key} = $args->{$key};
716  }
717  }
718  Context::set('widgetstyle_extra_var', $widgetstyle_extra_var);
719  // #18994272 오타를 수정했으나 하위 호환성을 위해 남겨둠 - deprecated
720  Context::set('widgetstyle_extar_var', $widgetstyle_extra_var);
721 
722  if($javascript_mode && $widget=='widgetBox')
723  {
724  Context::set('widget_content', '<div class="widget_inner">'.$widget_content_body.'</div>');
725  }
726  else
727  {
728  Context::set('widget_content', $widget_content_body);
729  }
730  // Compilation
731  $widgetstyle_path = $oWidgetModel->getWidgetStylePath($widgetStyle);
732  $oTemplate = &TemplateHandler::getInstance();
733  $tpl = $oTemplate->compile($widgetstyle_path, 'widgetstyle');
734 
735  return $tpl;
736  }
737 
741  function arrangeWidgetVars($widget, $request_vars, &$vars)
742  {
743  $oWidgetModel = getModel('widget');
744  $widget_info = $oWidgetModel->getWidgetInfo($widget);
745 
746  if(!$vars)
747  {
748  $vars = new stdClass();
749  }
750 
751  $widget = $vars->selected_widget;
752  $vars->css_class = $request_vars->css_class;
753  $vars->widgetstyle = $request_vars->widgetstyle;
754 
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);
765 
766  if(count($widget_info->extra_var))
767  {
768  foreach($widget_info->extra_var as $key=>$val)
769  {
770  $vars->{$key} = trim($request_vars->{$key});
771  }
772  }
773  // If the widget style
774  if($request_vars->widgetstyle)
775  {
776  $widgetStyle_info = $oWidgetModel->getWidgetStyleInfo($request_vars->widgetstyle);
777  if(count($widgetStyle_info->extra_var))
778  {
779  foreach($widgetStyle_info->extra_var as $key=>$val)
780  {
781  if($val->type =='color' || $val->type =='text' || $val->type =='select' || $val->type =='filebox' || $val->type == 'textarea')
782  {
783  $vars->{$key} = trim($request_vars->{$key});
784  }
785  }
786  }
787  }
788 
789  if($vars->widget_sequence)
790  {
791  $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $vars->widget_sequence, Context::getLangType());
792  FileHandler::removeFile($cache_file);
793  }
794 
795  if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence();
796 
797  $attribute = array();
798  foreach($vars as $key => $val)
799  {
800  if(!$val)
801  {
802  unset($vars->{$key});
803  continue;
804  }
805  if(strpos($val,'|@|') > 0) $val = str_replace('|@|', ',', $val);
806  $vars->{$key} = Context::convertEncodingStr($val);
807  $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars(Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
808  }
809 
810  return $attribute;
811  }
812 }
813 /* End of file widget.controller.php */
814 /* Location: ./modules/widget/widget.controller.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
triggerWidgetCompile(&$content)
Widget code compiles and prints the information to trigger display:: before invoked in...
procWidgetInsertDocument()
Add content widget.
removeFile($filename)
$obj
Definition: ko.install.php:262
getMicroTime()
Definition: func.inc.php:986
procWidgetGetColorsetList()
Selected photos - the return of the skin-color three.
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']
Definition: config.inc.php:324
$output
Definition: ko.install.php:193
add($key, $val)
procWidgetDeleteDocument()
Deleting widgets.
& getInstance($target= 'object', $info=null, $always_use_file=false)
compileWidgetStyle($widgetStyle, $widget, $widget_content_body, $args, $javascript_mode)
setLayoutFile($filename)
procWidgetCopyDocument()
Copy the content widget.
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
execute($widget, $args, $javascript_mode=false, $escaped=true)
Widget name and argument and produce a result and Return the results Tags used in templateHandler $th...
procWidgetGenerateCode()
Return the generated code of the widget.
widget module&#39;s high class
Definition: widget.class.php:8
$module_srl
integer value to represent a run-time instance of Module (XE Module)
$args
Definition: ko.install.php:185
arrangeWidgetVars($widget, $request_vars, &$vars)
request parameters and variables sort through the information widget
init()
Initialization.
$document_srl
Definition: ko.install.php:279
procWidgetStyleExtraImageUpload()
Upload widget styles.
recompileWidget($content)
Re-create specific content within a widget Widget on the page and create cache file in the module usi...
$oDocumentModel
Definition: ko.install.php:259
makeDir($path_string)
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
readFile($filename)
transWidgetCode($content, $javascript_mode=false, $isReplaceLangCode=true)
$oDocumentController
Definition: ko.install.php:260
getNextSequence()
Definition: func.inc.php:236
getCache($widget, $args, $lang_type=null, $ignore_cache=false)
Widget cache handling.
getModel($module_name)
Definition: func.inc.php:145
setWidgetCodeInJavascriptMode()
Modify the code in Javascript widget/Javascript edit mode for dragging and converted to...
transWidgetBox($matches)
Widget box with the actual code changes.
convertEncodingStr($str)
getAdminController($module_name)
Definition: func.inc.php:101
writeSlowlog($type, $elapsed_time, $obj)
Definition: func.inc.php:909
utf8RawUrlDecode($source)
Definition: func.inc.php:1393
$oModuleController
Definition: ko.install.php:287
getWidgetObject($widget)
Return widget object.
transWidget($matches)
Widget code with the actual code changes.
procWidgetGenerateCodeInPage()
Edit page request for the creation of the widget code.
Controller class for widget modules.