loadSkinInfo($path, $skin); for($i=0;$icolorset);$i++) { $colorset = sprintf('%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title); $colorset_list[] = $colorset; } if(count($colorset_list)) $colorsets = implode("\n", $colorset_list); $this->add('colorset_list', $colorsets); } /** * @brief 위젯의 생성된 코드를 return **/ function procWidgetGenerateCode() { $widget = Context::get('selected_widget'); if(!$widget) return new Object(-1,'msg_invalid_request'); if(!Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); $widget_code = sprintf('', $widget, implode(' ',$attribute)); // 코드 출력 $this->add('widget_code', $widget_code); } /** * @brief 페이지 수정시 위젯 코드의 생성 요청 **/ function procWidgetGenerateCodeInPage() { $widget = Context::get('selected_widget'); if(!$widget) return new Object(-1,'msg_invalid_request'); if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); // 결과물을 구함 $widget_code = $this->execute($widget, $vars, true, false); $this->add('widget_code', $widget_code); } /** * @brief 위젯스타일에 이미지 업로드 **/ function procWidgetStyleExtraImageUpload(){ $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); $this->setLayoutPath('./common/tpl'); $this->setLayoutFile('default_layout.html'); $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile("top_refresh.html"); } /** * @brief 컨텐츠 위젯 추가 **/ function procWidgetInsertDocument() { // 변수 구함 $module_srl = Context::get('module_srl'); $document_srl = Context::get('document_srl'); $content = Context::get('content'); $editor_sequence = Context::get('editor_sequence'); $err = 0; $oLayoutModel = &getModel('layout'); $layout_info = $oLayoutModel->getLayout($module_srl); if(!$layout_info || $layout_info->type != 'faceoff') $err++; // 대상 페이지 모듈 정보 구함 $oModuleModel = &getModel('module'); $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); if(!$page_info->module_srl || $page_info->module != 'page') $err++; if($err > 1) return new Object(-1,'msg_invalid_request'); // 권한 체크 $is_logged = Context::get('is_logged'); $logged_info = Context::get('logged_info'); $user_group = $logged_info->group_list; $is_admin = false; if(count($user_group)&&count($page_info->grants['manager'])) { $manager_group = $page_info->grants['manager']; foreach($user_group as $group_srl => $group_info) { if(in_array($group_srl, $manager_group)) $is_admin = true; } } if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_infoi->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); // 글 입력 $oDocumentModel = &getModel('document'); $oDocumentController = &getController('document'); $obj->module_srl = $module_srl; $obj->content = $content; $obj->document_srl = $document_srl; $oDocument = $oDocumentModel->getDocument($obj->document_srl, true); if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) { $output = $oDocumentController->updateDocument($oDocument, $obj); } else { $output = $oDocumentController->insertDocument($obj); $obj->document_srl = $output->get('document_srl'); } // 오류 발생시 멈춤 if(!$output->toBool()) return $output; // 결과를 리턴 $this->add('document_srl', $obj->document_srl); } /** * @brief 컨텐츠 위젯 복사 **/ function procWidgetCopyDocument() { // 변수 구함 $document_srl = Context::get('document_srl'); $oDocumentModel = &getModel('document'); $oDocumentController = &getController('document'); $oDocumentAdminController = &getAdminController('document'); $oDocument = $oDocumentModel->getDocument($document_srl, true); if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); $module_srl = $oDocument->get('module_srl'); // 대상 페이지 모듈 정보 구함 $oModuleModel = &getModel('module'); $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); // 권한 체크 $is_logged = Context::get('is_logged'); $logged_info = Context::get('logged_info'); $user_group = $logged_info->group_list; $is_admin = false; if(count($user_group)&&count($page_info->grants['manager'])) { $manager_group = $page_info->grants['manager']; foreach($user_group as $group_srl => $group_info) { if(in_array($group_srl, $manager_group)) $is_admin = true; } } if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_infoi->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0); if(!$output->toBool()) return $output; // 결과를 리턴 $copied_srls = $output->get('copied_srls'); $this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]); } /** * @brief 위젯 삭제 **/ function procWidgetDeleteDocument() { // 변수 구함 $document_srl = Context::get('document_srl'); $oDocumentModel = &getModel('document'); $oDocumentController = &getController('document'); $oDocument = $oDocumentModel->getDocument($document_srl, true); if(!$oDocument->isExists()) return new Object(); $module_srl = $oDocument->get('module_srl'); // 대상 페이지 모듈 정보 구함 $oModuleModel = &getModel('module'); $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); // 권한 체크 $is_logged = Context::get('is_logged'); $logged_info = Context::get('logged_info'); $user_group = $logged_info->group_list; $is_admin = false; if(count($user_group)&&count($page_info->grants['manager'])) { $manager_group = $page_info->grants['manager']; foreach($user_group as $group_srl => $group_info) { if(in_array($group_srl, $manager_group)) $is_admin = true; } } if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_infoi->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); $output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true); if(!$output->toBool()) return $output; } /** * @brief 위젯 코드를 Javascript로 수정/드래그등을 하기 위한 Javascript 수정 모드로 변환 **/ function setWidgetCodeInJavascriptMode() { $this->layout_javascript_mode = true; } /** * @brief 위젯 코드를 컴파일하여 내용을 출력하는 trigger * display::before 에서 호출됨 **/ function triggerWidgetCompile(&$content) { if(Context::getResponseMethod()!='HTML') return new Object(); $content = $this->transWidgetCode($content, $this->layout_javascript_mode); return new Object(); } /** * @breif 특정 content의 위젯 태그들을 변환하여 return **/ function transWidgetCode($content, $javascript_mode = false) { // 사용자 정의 언어 변경 $oModuleController = &getController('module'); $oModuleController->replaceDefinedLangCode($content); // 편집 정보 포함 여부 체크 $this->javascript_mode = $javascript_mode; // 박스 위젯 코드 변경 $content = preg_replace_callback('!]*)widget=([^\>]*?)\>
(()*)!is', array($this,'transWidgetBox'), $content); // 내용 위젯 코드 벼경 $content = preg_replace_callback('!]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content); return $content; } /** * @brief 위젯 코드를 실제 코드로 변경 **/ function transWidget($matches) { $buff = trim($matches[0]); $oXmlParser = new XmlParser(); $xml_doc = $oXmlParser->parse(trim($buff)); if($xml_doc->img) $vars = $xml_doc->img->attrs; else $vars = $xml_doc->attrs; $widget = $vars->widget; if(!$widget) return $match[0]; unset($vars->widget); return $this->execute($widget, $vars, $this->javascript_mode); } /** * @brief 위젯 박스를 실제 코드로 변경 **/ function transWidgetBox($matches) { $buff = preg_replace('/
(.*)$/i','
',$matches[0]); $oXmlParser = new XmlParser(); $xml_doc = $oXmlParser->parse($buff); $vars = $xml_doc->div->attrs; $widget = $vars->widget; if(!$widget) return $matches[0]; unset($vars->widget); $vars->widgetbox_content = $matches[3]; return $this->execute($widget, $vars, $this->javascript_mode); } /** * @brief 특정 content내의 위젯을 다시 생성 * 페이지모듈등에서 위젯 캐시파일 재생성시 사용 **/ function recompileWidget($content) { // 언어 종류 가져옴 $lang_list = Context::get('lang_supported'); // 위젯 캐시 sequence 를 가져옴 preg_match_all('!]*)widget=([^\>]*?)\>!is', $content, $matches); $oXmlParser = new XmlParser(); $cnt = count($matches[1]); for($i=0;$i<$cnt;$i++) { $buff = $matches[0][$i]; $xml_doc = $oXmlParser->parse(trim($buff)); $args = $xml_doc->img->attrs; if(!$args) continue; // 캐싱하지 않을 경우 패스 $widget = $args->widget; $sequence = $args->widget_sequence; $cache = $args->widget_cache; if(!$sequence || !$cache) continue; if(count($args)) { foreach($args as $k => $v) $args->{$k} = urldecode($v); } // 언어별로 위젯 캐시 파일이 있을 경우 재생성 foreach($lang_list as $lang_type => $val) { $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type); if(!file_exists($cache_file)) continue; $this->getCache($widget, $args, $lang_type, true); } } } /** * @brief 위젯 캐시 처리 **/ function getCache($widget, $args, $lang_type = null, $ignore_cache = false) { // 지정된 언어가 없으면 현재 언어 지정 if(!$lang_type) $lang_type = Context::getLangType(); // widget, 캐시 번호와 캐시값이 설정되어 있는지 확인 $widget_sequence = $args->widget_sequence; $widget_cache = $args->widget_cache; /** * 캐시 번호와 캐시 값이 아예 없으면 바로 데이터를 추출해서 리턴 **/ if(!$ignore_cache && (!$widget_cache || !$widget_sequence)) { $oWidget = $this->getWidgetObject($widget); if(!$oWidget || !method_exists($oWidget, 'proc')) return; return $oWidget->proc($args); } /** * 캐시 번호와 캐시값이 설정되어 있으면 캐시 파일을 불러오도록 함 **/ if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path); // 캐시파일명을 구함 $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type); // 캐시 파일이 존재하면 해당 파일의 유효성 검사 if(!$ignore_cache && file_exists($cache_file)) { $filemtime = filemtime($cache_file); // 수정 시간을 비교해서 캐싱중이어야 하거나 widget.controller.php 파일보다 나중에 만들어 졌다면 캐시값을 return if($filemtime + $widget_cache * 60 > time() && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php')) { $cache_body = FileHandler::readFile($cache_file); $cache_body = preg_replace('@<\!--#Meta:@', '