$val) { if(in_array($key, array('body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right'))) continue; $args->{$key} = utf8RawUrlDecode(utf8RawUrlDecode($val)); } } /** * 위젯이 widgetContent/ widgetBox가 아니라면 내용을 구함 **/ if($widget != 'widgetContent' && $widget != 'widgetBox') { if(!is_dir(sprintf('./widgets/%s/',$widget))) return; // 위젯의 내용을 담을 변수 $widget_content = ''; // 캐시된 코드가 있는지 확인 $widget_sequence = $args->widget_sequence; $widget_cache = $args->widget_cache; if($widget_cache && $widget_sequence) $widget_content = WidgetHandler::getCache($widget_sequence, $widget_cache); // 캐시된 코드가 없을 경우 코드 생성 if(!$widget_content) { $oWidget = WidgetHandler::getObject($widget); if(!$oWidget) return; $widget_content = $oWidget->proc($args); if(is_object($widget_content) && (is_a($widget_content, 'Object')||is_subclass_of($widget_content, 'Object'))) $widget_content = $widget_content->getMessage(); } // 위젯의 캐시값과 위젯 sequence가 있을 경우 캐시 파일에 저장 if($widget_cache && $widget_sequence) WidgetHandler::writeCache($widget_sequence, $widget_content); } /** * 관리자가 지정한 위젯의 style을 구함 **/ // 가끔 잘못된 코드인 background-image:url(none)이 들어 있을 수가 있는데 이럴 경우 none에 대한 url을 요청하므로 무조건 제거함 $style = preg_replace('/background\-image: url\(none\)/is','', $args->style); // 내부 여백을 둔 것을 구해서 style문으로 미리 변경해 놓음 $widget_padding_left = $args->widget_padding_left; $widget_padding_right = $args->widget_padding_right; $widget_padding_top = $args->widget_padding_top; $widget_padding_bottom = $args->widget_padding_bottom; $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important; padding:none !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left); /** * 위젯 출력물을 구함 **/ // 일반 페이지 호출일 경우 지정된 스타일만 꾸면서 바로 return 함 if(!$include_info) { switch($widget) { // 내용 직접 추가일 경우 case 'widgetContent' : $body = base64_decode($args->body); $output = sprintf('
%s
', $style, $inner_style, $body); break; // 위젯 박스일 경우 case 'widgetBox' : $output = sprintf('
', $style, $inner_style); break; // 일반 위젯일 경우 default : $output = sprintf('
%s
', $style, $inner_style, $widget_content); break; } // 페이지 수정시에 호출되었을 경우 위젯 핸들링을 위한 코드 추가 } else { switch($widget) { // 내용 직접 추가일 경우 case 'widgetContent' : $body = base64_decode($args->body); $oWidgetController = &getController('widget'); $output = sprintf( '
'. '
'. '
'. '
'. '
'. '
'. '
'. '
'. '
'. '%s'. '
'. '
'. ''. '
', $style, $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, $inner_style, $body, base64_encode($body) ); break; // 위젯 박스일 경우 case 'widgetBox' : $output = sprintf( '
'. '
'. '
'. '
'. '
'. '
'. '
'. '
', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $inner_style); break; // 일반 위젯일 경우 default : // args 정리 $attribute = array(); if($args) { foreach($args as $key => $val) { if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget'))) continue; if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); $attribute[] = sprintf('%s="%s"', $key, str_replace('"','\"',$val)); } } $output = sprintf( '
'. '
'. '
'. '
'. '
'. '
'. '
'. '
'. '
'. '%s'. '
'. '
'. '
', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget, implode(' ',$attribute), $inner_style, $widget_content ); break; } } // 위젯 결과물 생성 시간을 debug 정보에 추가 if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; // 결과 return return $output; } /** * @brief 위젯 객체를 return **/ function getObject($widget) { if(!$GLOBALS['_xe_loaded_widgets_'][$widget]) { // 일단 위젯의 위치를 찾음 $oWidgetModel = &getModel('widget'); $path = $oWidgetModel->getWidgetPath($widget); // 위젯 클래스 파일을 찾고 없으면 에러 출력 (html output) $class_file = sprintf('%s%s.class.php', $path, $widget); if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget); // 위젯 클래스를 include require_once($class_file); // 객체 생성 $eval_str = sprintf('$oWidget = new %s();', $widget); @eval($eval_str); if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget); $oWidget->widget_path = $path; $GLOBALS['_xe_loaded_widgets_'][$widget] = $oWidget; } return $GLOBALS['_xe_loaded_widgets_'][$widget]; } } ?>