/** * Check whether to use RSS rss url by adding * * @return Object */ function triggerRssUrlInsert() { $oModuleModel = getModel('module'); $total_config = $oModuleModel->getModuleConfig('rss'); $current_module_srl = Context::get('module_srl'); $site_module_info = Context::get('site_module_info'); if (is_array($current_module_srl)) { unset($current_module_srl); } if (!$current_module_srl) { $current_module_info = Context::get('current_module_info'); $current_module_srl = $current_module_info->module_srl; } if (!$current_module_srl) { return new Object(); } // Imported rss settings of the selected module $oRssModel = getModel('rss'); $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); if ($rss_config->open_rss != 'N') { Context::set('rss_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'rss')); Context::set('atom_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'atom')); } if (Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') { if (Context::isAllowRewrite() && !Context::get('vid')) { $request_uri = Context::getRequestUri(); Context::set('general_rss_url', $request_uri . 'rss'); Context::set('general_atom_url', $request_uri . 'atom'); } else { Context::set('general_rss_url', getUrl('', 'module', 'rss', 'act', 'rss')); Context::set('general_atom_url', getUrl('', 'module', 'rss', 'act', 'atom')); } } return new Object(); }
/** * Create the Feed url. * * @param string $vid Vid * @param string $mid mid * @param string $format Feed format. ef)xe, atom, rss1.0 * @return string **/ function getModuleFeedUrl($vid = null, $mid, $format) { if (Context::isAllowRewrite()) { $request_uri = Context::getRequestUri(); // If the virtual site variable exists and it is different from mid (vid and mid should not be the same) if ($vid && $vid != $mid) { return $request_uri . $vid . '/' . $mid . '/' . $format; } else { return $request_uri . $mid . '/' . $format; } } else { return getUrl('', 'mid', $mid, 'act', $format); } }
/** * @brief RSS 사용 유무를 체크하여 rss url 추가 **/ function triggerRssUrlInsert() { $oModuleModel =& getModel('module'); $total_config = $oModuleModel->getModuleConfig('rss'); $current_module_srl = Context::get('module_srl'); $site_module_info = Context::get('site_module_info'); if (!$current_module_srl) { $current_module_info = Context::get('current_module_info'); $current_module_srl = $current_module_info->module_srl; } if (!$current_module_srl) { return new Object(); } // 선택된 모듈의 rss설정을 가져옴 $oRssModel =& getModel('rss'); $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); if ($rss_config->open_rss != 'N') { if (Context::isAllowRewrite()) { $request_uri = Context::getRequestUri(); // 가상 사이트 변수가 있고 이 변수가 mid와 다를때. (vid와 mid는 같을 수 없다고 함) if (Context::get('vid') && Context::get('vid') != Context::get('mid')) { Context::set('rss_url', Context::getRequestUri() . Context::get('vid') . '/' . Context::get('mid') . '/rss'); Context::set('atom_url', Context::getRequestUri() . Context::get('vid') . '/' . Context::get('mid') . '/atom'); } else { Context::set('rss_url', $request_uri . Context::get('mid') . '/rss'); Context::set('atom_url', $request_uri . Context::get('mid') . '/atom'); } } else { Context::set('rss_url', getUrl('', 'mid', Context::get('mid'), 'act', 'rss')); Context::set('atom_url', getUrl('', 'mid', Context::get('mid'), 'act', 'atom')); } } if (Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') { if (Context::isAllowRewrite() && !Context::get('vid')) { $request_uri = Context::getRequestUri(); Context::set('general_rss_url', $request_uri . 'rss'); Context::set('general_atom_url', $request_uri . 'atom'); } else { Context::set('general_rss_url', getUrl('', 'module', 'rss', 'act', 'rss')); Context::set('general_atom_url', getUrl('', 'module', 'rss', 'act', 'atom')); } } return new Object(); }
/** * when display mode is HTML, prepare code before print. * @param string $output compiled template string * @return void */ function prepareToPrint(&$output) { if (Context::getResponseMethod() != 'HTML') { return; } if (__DEBUG__ == 3) { $start = getMicroTime(); } // move <style ..></style> in body to the header $output = preg_replace_callback('!<style(.*?)>(.*?)<\\/style>!is', array($this, '_moveStyleToHeader'), $output); // move <link ..></link> in body to the header $output = preg_replace_callback('!<link(.*?)/>!is', array($this, '_moveLinkToHeader'), $output); // move <meta ../> in body to the header $output = preg_replace_callback('!<meta(.*?)(?:\\/|)>!is', array($this, '_moveMetaToHeader'), $output); // change a meta fine(widget often put the tag like <!--Meta:path--> to the content because of caching) $output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\\_\\-\\/\\.\\@]+)-->/is', array($this, '_transMeta'), $output); // handles a relative path generated by using the rewrite module if (Context::isAllowRewrite()) { $url = parse_url(Context::getRequestUri()); $real_path = $url['path']; $pattern = '/src=("|\'){1}(\\.\\/)?(files\\/attach|files\\/cache|files\\/faceOff|files\\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\\/([^"\']+)\\.(jpg|jpeg|png|gif)("|\'){1}/s'; $output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output); $pattern = '/href=("|\'){1}(\\?[^"\']+)/s'; $output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output); if (Context::get('vid')) { $pattern = '/\\/' . Context::get('vid') . '\\?([^=]+)=/is'; $output = preg_replace($pattern, '/?$1=', $output); } } // prevent the 2nd request due to url(none) of the background-image $output = preg_replace('/url\\((["\']?)none(["\']?)\\)/is', 'none', $output); if (is_array(Context::get('INPUT_ERROR'))) { $INPUT_ERROR = Context::get('INPUT_ERROR'); $keys = array_keys($INPUT_ERROR); $keys = '(' . implode('|', $keys) . ')'; $output = preg_replace_callback('@(<input)([^>]*?)\\sname="' . $keys . '"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output); $output = preg_replace_callback('@<select[^>]*\\sname="' . $keys . '".+</select>@isU', array(&$this, '_preserveSelectValue'), $output); $output = preg_replace_callback('@<textarea[^>]*\\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output); } if (__DEBUG__ == 3) { $GLOBALS['__trans_content_elapsed__'] = getMicroTime() - $start; } // Remove unnecessary information $output = preg_replace('/member\\_\\-([0-9]+)/s', 'member_0', $output); // set icon $oAdminModel = getAdminModel('admin'); $favicon_url = $oAdminModel->getFaviconUrl(); $mobicon_url = $oAdminModel->getMobileIconUrl(); Context::set('favicon_url', $favicon_url); Context::set('mobicon_url', $mobicon_url); // convert the final layout Context::set('content', $output); $oTemplate = TemplateHandler::getInstance(); if (Mobile::isFromMobilePhone()) { $this->_loadMobileJSCSS(); $output = $oTemplate->compile('./common/tpl', 'mobile_layout'); } else { $this->_loadJSCSS(); $output = $oTemplate->compile('./common/tpl', 'common_layout'); } // replace the user-defined-language $oModuleController = getController('module'); $oModuleController->replaceDefinedLangCode($output); }
/** * @brie display textule tool post manage write **/ function dispTextyleToolPostManageWrite() { // set filter Context::addJsFilter($this->module_path . 'tpl/filter', 'save_post.xml'); $oDocumentModel =& getModel('document'); $document_srl = Context::get('document_srl'); $material_srl = Context::get('material_srl'); if ($document_srl) { $oDocument = $oDocumentModel->getDocument($document_srl, false, false); } else { $document_srl = 0; $oDocument = $oDocumentModel->getDocument(0); if ($material_srl) { $oMaterialModel =& getModel('material'); $output = $oMaterialModel->getMaterial($material_srl); if ($output->data) { $material_content = $output->data[0]->content; Context::set('material_content', $material_content); } } } $category_list = $oDocumentModel->getCategoryList($this->module_srl); Context::set('category_list', $category_list); $oTagModel =& getModel('tag'); $args->module_srl = $this->module_srl; $args->list_count = 20; $output = $oTagModel->getTagList($args); Context::set('tag_list', $output->data); $oEditorModel =& getModel('editor'); $option->skin = $this->textyle->getPostEditorSkin(); $option->primary_key_name = 'document_srl'; $option->content_key_name = 'content'; $option->allow_fileupload = true; $option->enable_autosave = true; $option->enable_default_component = true; $option->enable_component = $option->skin == 'dreditor' ? false : true; $option->resizable = true; $option->height = 500; $option->content_font = $this->textyle->getFontFamily(); $option->content_font_size = $this->textyle->getFontSize(); $editor = $oEditorModel->getEditor($document_srl, $option); Context::set('editor', $editor); Context::set('editor_skin', $option->skin); // permalink $permalink = ''; if (isSiteID($this->textyle->domain)) { if (Context::isAllowRewrite()) { $permalink = getFullSiteUrl($this->textyle->domain, '') . '/entry/'; } else { $permalink = getFullSiteUrl($this->textyle->domain) . '?vid=' . $this->textyle->domain . '&mid=' . Context::get('mid') . '&entry='; } } else { if (Context::isAllowRewrite()) { $permalink = getFullSiteUrl($this->textyle->domain, '') . 'entry/'; } else { $premalink = getFullSiteUrl($this->textyle->domain, '', 'mid', Context::get('mid')) . '&entry='; } } Context::set('permalink', $permalink); $oTextyleModel =& getModel('textyle'); $alias = $oDocumentModel->getAlias($document_srl); Context::set('alias', $alias); $output = $oTextyleModel->getSubscriptionByDocumentSrl($document_srl); if ($output->data) { $publish_date = $output->data[0]->publish_date; $publish_date = sscanf($publish_date, '%04d%02d%02d%02d%02d'); Context::set('publish_date_yyyymmdd', sprintf("%s-%02d-%02d", $publish_date[0], $publish_date[1], $publish_date[2])); Context::set('publish_date_hh', sprintf("%02d", $publish_date[3])); Context::set('publish_date_ii', sprintf("%02d", $publish_date[4])); Context::set('subscription', 'Y'); } if ($oDocument->get('module_srl') != $this->module_srl && !$document_srl) { Context::set('from_saved', true); } $oPublish = $oTextyleModel->getPublishObject($this->module_srl, $oDocument->document_srl); if (count($oPublish->trackbacks)) { $trackbacks = $oPublish->getTrackbacks(); } if (count($oPublish->blogapis)) { $_apis = $oPublish->getApis(); } Context::set('oDocument', $oDocument); Context::set('oTextyle', $oTextyleModel->getTextyle($this->module_srl)); Context::set('oPublish', $oPublish); Context::set('category_list', $oDocumentModel->getCategoryList($this->module_srl)); Context::set('trackbacks', $trackbacks); Context::set('_apis', $_apis); }
/** * @brief 모듈객체를 받아서 content 출력 **/ function printContent(&$oModule) { // gzip encoding 지원 여부 체크 if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler') && extension_loaded('zlib')) { $this->gz_enabled = true; } // request method에 따른 컨텐츠 결과물 추출 if (Context::get('xeVirtualRequestMethod') == 'xml') { $output = $this->_toVirtualXmlDoc($oModule); } else { if (Context::getRequestMethod() == 'XMLRPC') { $output = $this->_toXmlDoc($oModule); } else { if (Context::getRequestMethod() == 'JSON') { $output = $this->_toJSON($oModule); } else { $output = $this->_toHTMLDoc($oModule); } } } // HTML 출력 요청일 경우 레이아웃 컴파일과 더블어 완성된 코드를 제공 if (Context::getResponseMethod() == "HTML") { // 관리자 모드일 경우 #xeAdmin id를 가지는 div 추가 if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0) { $output = '<div id="xeAdmin">' . $output . '</div>'; } // 내용을 content라는 변수로 설정 (layout에서 {$output}에서 대체됨) Context::set('content', $output); // 레이아웃을 컴파일 $oTemplate =& TemplateHandler::getInstance(); // layout이라는 변수가 none으로 설정되면 기본 레이아웃으로 변경 if (Context::get('layout') != 'none') { if (__DEBUG__ == 3) { $start = getMicroTime(); } $layout_path = $oModule->getLayoutPath(); $layout_file = $oModule->getLayoutFile(); $edited_layout_file = $oModule->getEditedLayoutFile(); // 현재 요청된 레이아웃 정보를 구함 $oLayoutModel =& getModel('layout'); $current_module_info = Context::get('current_module_info'); $layout_srl = $current_module_info->layout_srl; // 레이아웃과 연결되어 있으면 레이아웃 컴파일 if ($layout_srl > 0) { $layout_info = Context::get('layout_info'); // faceoff 레이아웃일 경우 별도 처리 if ($layout_info && $layout_info->type == 'faceoff') { $oLayoutModel->doActivateFaceOff($layout_info); Context::set('layout_info', $layout_info); } // 관리자 레이아웃 수정화면에서 변경된 CSS가 있는지 조사 $edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl); if (file_exists($edited_layout_css)) { Context::addCSSFile($edited_layout_css, true, 'all', '', 100); } } if (!$layout_path) { $layout_path = "./common/tpl"; } if (!$layout_file) { $layout_file = "default_layout"; } $output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); if (__DEBUG__ == 3) { $GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start; } } } // 출력하기 전에 trigger 호출 (before) ModuleHandler::triggerCall('display', 'before', $output); // 애드온 실행 $called_position = 'before_display_content'; $oAddonController =& getController('addon'); $addon_file = $oAddonController->getCacheFilePath(); if (file_exists($addon_file)) { @(include $addon_file); } // HTML 출력일 경우 최종적으로 common layout을 씌워서 출력 if (Context::getResponseMethod() == "HTML") { if (__DEBUG__ == 3) { $start = getMicroTime(); } // body 내의 <style ..></style>를 header로 이동 $output = preg_replace_callback('!<style(.*?)<\\/style>!is', array($this, 'moveStyleToHeader'), $output); // 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음 $output = preg_replace_callback('/<!--Meta:([a-z0-9\\_\\/\\.\\@]+)-->/is', array($this, 'transMeta'), $output); // rewrite module 사용시 생기는 상대경로에 대한 처리를 함 if (Context::isAllowRewrite()) { $url = parse_url(Context::getRequestUri()); $real_path = $url['path']; $pattern = '/src=("|\'){1}(\\.\\/)?(files\\/attach|files\\/cache|files\\/faceOff|files\\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\\/([^"\']+)\\.(jpg|jpeg|png|gif)("|\'){1}/s'; $output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output); if (Context::get('vid')) { $pattern = '/\\/' . Context::get('vid') . '\\?([^=]+)=/is'; $output = preg_replace($pattern, '/?$1=', $output); } } // 간혹 background-image에 url(none) 때문에 request가 한번 더 일어나는 경우가 생기는 것을 방지 $output = preg_replace('/url\\((["\']?)none(["\']?)\\)/is', 'none', $output); if (__DEBUG__ == 3) { $GLOBALS['__trans_content_elapsed__'] = getMicroTime() - $start; } // 불필요한 정보 제거 $output = preg_replace('/member\\_\\-([0-9]+)/s', 'member_0', $output); // 최종 레이아웃 변환 Context::set('content', $output); $output = $oTemplate->compile('./common/tpl', 'common_layout'); // 사용자 정의 언어 변환 $oModuleController =& getController('module'); $oModuleController->replaceDefinedLangCode($output); } // header 출력 if ($this->gz_enabled) { header("Content-Encoding: gzip"); } if (Context::getResponseMethod() == 'JSON') { $this->_printJSONHeader(); } else { if (Context::getResponseMethod() != 'HTML') { $this->_printXMLHeader(); } else { $this->_printHTMLHeader(); } } // debugOutput 출력 $this->content_size = strlen($output); $output .= $this->_debugOutput(); // 결과물 직접 출력 if ($this->gz_enabled) { print ob_gzhandler($output, 5); } else { print $output; } // 출력 후 trigger 호출 (after) ModuleHandler::triggerCall('display', 'after', $content); }