From 31bfa475942ffcd44a6557a9b88bd17c81c18d33 Mon Sep 17 00:00:00 2001 From: zero Date: Tue, 6 Mar 2007 01:21:27 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@261 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/context/Context.class.php | 33 ++++++ classes/display/DisplayHandler.class.php | 5 +- modules/board/board.view.php | 6 +- modules/krzip/krzip.controller.php | 2 +- modules/krzip/krzip.view.php | 2 +- modules/rss/conf/module.xml | 8 ++ modules/rss/lang/ko.lang.php | 18 +++ modules/rss/rss.class.php | 5 +- modules/rss/rss.controller.php | 34 ++++++ modules/rss/rss.view.php | 104 ++++++++++-------- modules/rss/tpl.admin/error.html | 6 + .../rss/tpl.admin/filter/insert_config.xml | 7 ++ modules/rss/tpl.admin/index.html | 32 ++++++ modules/rss/tpl/rss20.html | 22 ++++ 14 files changed, 232 insertions(+), 52 deletions(-) create mode 100644 modules/rss/conf/module.xml create mode 100644 modules/rss/lang/ko.lang.php create mode 100644 modules/rss/rss.controller.php create mode 100644 modules/rss/tpl.admin/error.html create mode 100644 modules/rss/tpl.admin/filter/insert_config.xml create mode 100644 modules/rss/tpl.admin/index.html create mode 100644 modules/rss/tpl/rss20.html diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 694d1637a..cb9f95532 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -13,6 +13,7 @@ class Context { var $request_method = 'GET'; ///< @brief GET/POST/XMLRPC 중 어떤 방식으로 요청이 왔는지에 대한 값이 세팅. GET/POST/XML 3가지가 있음 + var $response_method = ''; ///< @brief HTML/XMLRPC 중 어떤 방식으로 결과를 출력할지 결정. (강제 지정전까지는 request_method를 따름) var $context = NULL; ///< @brief request parameter 및 각종 환경 변수등을 정리하여 담을 변수 @@ -287,6 +288,38 @@ } } + /** + * @brief response method를 강제로 지정 (기본으로는 request method를 이용함) + * + * method의 종류에는 HTML/ TEXT/ XMLRPC가 있음 + **/ + function setResponseMethod($method = "HTML") { + $oContext = &Context::getInstance(); + return $oContext->_setResponseMethod($method); + } + + function _setResponseMethod($method = "HTML") { + $this->response_method = $method; + } + + /** + * @brief response method 값을 return + * + * method의 종류에는 HTML/ TEXT/ XMLRPC가 있음 + * 별도로 response method를 지정하지 않았다면 request method로 판단하여 결과 return + **/ + function getResponseMethod() { + $oContext = &Context::getInstance(); + return $oContext->_getResponseMethod(); + } + + function _getResponseMethod() { + if($this->response_method) return $this->response_method; + + if($this->_getRequestMethod()=="XMLRPC") return "XMLRPC"; + return "HTML"; + } + /** * @brief request method가 어떤것인지 판단하여 저장 (GET/POST/XMLRPC) **/ diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index fd8d92592..19fd3b602 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -26,7 +26,7 @@ $content = $this->getContent($oModule); // 요청방식에 따라 출력을 별도로 - if(Context::getRequestMethod()!="XMLRPC") { + if(Context::getResponseMethod()!="XMLRPC") { Context::set('content', $content); // content 래핑 (common/tpl/default.html) @@ -119,6 +119,7 @@ $buff .= "\n- Request/ Response info\n"; $buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']); $buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']); + $buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod()); $buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->getContentSize()); if($GLOBALS['__db_queries__']) { $buff .= "\n- DB Queries\n"; @@ -140,7 +141,7 @@ * @brief RequestMethod에 맞춰 헤더 출력 ***/ function _printHeader() { - if(Context::getRequestMethod() == 'XMLRPC') return $this->_printXMLHeader(); + if(Context::getResponseMethod() == 'XMLRPC') return $this->_printXMLHeader(); else return $this->_printHTMLHeader(); } diff --git a/modules/board/board.view.php b/modules/board/board.view.php index f1623b6bf..da94f5bd5 100644 --- a/modules/board/board.view.php +++ b/modules/board/board.view.php @@ -380,9 +380,13 @@ $info->link = sprintf("%s?mid=%s", Context::getRequestUri(), Context::get('mid')); $info->total_count = $output->total_count; - // 출력하고 끝내기 + // RSS 모듈을 불러서 출력할 내용을 지정 $oRssView = &getView('rss'); $oRssView->dispRss($info, $document_list); + + // RSS 모듈의 tempate을 가져옴 + $this->setTemplatePath($oRssView->getTemplatePath()); + $this->setTemplateFile($oRssView->getTemplateFile()); } /** diff --git a/modules/krzip/krzip.controller.php b/modules/krzip/krzip.controller.php index 6042e5f5b..f069fd071 100644 --- a/modules/krzip/krzip.controller.php +++ b/modules/krzip/krzip.controller.php @@ -14,7 +14,7 @@ } /** - * @brief 스팸필터 설정 + * @brief 설정 **/ function procInsertConfig() { // 기본 정보를 받음 diff --git a/modules/krzip/krzip.view.php b/modules/krzip/krzip.view.php index 0fe41e628..dcd03ff96 100644 --- a/modules/krzip/krzip.view.php +++ b/modules/krzip/krzip.view.php @@ -15,7 +15,7 @@ } /** - * @brief 애드온 목록을 보여줌 + * @brief 설정 **/ function dispConfig() { // 설정 정보를 받아옴 (module model 객체를 이용) diff --git a/modules/rss/conf/module.xml b/modules/rss/conf/module.xml new file mode 100644 index 000000000..0b2f74928 --- /dev/null +++ b/modules/rss/conf/module.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/rss/lang/ko.lang.php b/modules/rss/lang/ko.lang.php new file mode 100644 index 000000000..6783795d1 --- /dev/null +++ b/modules/rss/lang/ko.lang.php @@ -0,0 +1,18 @@ + + * @desc : 한국어 언어팩 (기본적인 내용만 수록) + **/ + + // 일반 단어들 + $lang->rss_disable = "RSS 끄기"; + $lang->rss_type = "출력할 RSS 형식"; + + // 설명문 + $lang->about_rss_disable = "체크하시면 RSS 출력을 하지 않습니다"; + $lang->about_rss_type = "출력하실 RSS 형식을 지정하실 수 있습니다"; + + // 에러 메세지들 + $lang->msg_rss_is_disabled = "RSS 기능이 잠겨 있습니다"; +?> diff --git a/modules/rss/rss.class.php b/modules/rss/rss.class.php index 9e020747b..b0a418772 100644 --- a/modules/rss/rss.class.php +++ b/modules/rss/rss.class.php @@ -7,7 +7,10 @@ class rss extends ModuleObject { - var $rss_type = "rss2.0"; + var $default_rss_type = "rss20"; + var $rss_types = array( + "rss20" => "rss2.0" + ); } ?> diff --git a/modules/rss/rss.controller.php b/modules/rss/rss.controller.php new file mode 100644 index 000000000..3876d17b6 --- /dev/null +++ b/modules/rss/rss.controller.php @@ -0,0 +1,34 @@ +rss_disable!='Y') $args->rss_disable = 'N'; + if(!$args->rss_type) $args->rss_type = "rss20"; + + // module Controller 객체 생성하여 입력 + $oModuleController = &getController('module'); + $output = $oModuleController->insertModuleConfig('rss',$args); + return $output; + } + } +?> diff --git a/modules/rss/rss.view.php b/modules/rss/rss.view.php index cdc56c985..737308b66 100644 --- a/modules/rss/rss.view.php +++ b/modules/rss/rss.view.php @@ -3,7 +3,6 @@ * @class rssView * @author zero (zero@nzeo.com) * @brief rss module의 view class - * @todo 다양한 형식의 format 및 제어 기능 추가 * * RSS 2.0형식으로 문서 출력 * @@ -17,40 +16,38 @@ function init() { } - function dispRss($info, $content, $type="rss2.0") { - switch($type) { - case "rss2.0" : - $this->dispRss20($info, $content); - break; - } + /** + * @brief 설정 + **/ + function dispConfig() { + // 설정 정보를 받아옴 (module model 객체를 이용) + $oModuleModel = &getModel('module'); + $config = $oModuleModel->getModuleConfig('rss'); + Context::set('config',$config); + Context::set('rss_types',$this->rss_types); - exit(); + // 템플릿 파일 지정 + $this->setTemplatePath($this->module_path.'tpl.admin/'); + $this->setTemplateFile('index'); } /** - * @brief content를 받아서 rss 형식으로 출력 + * @brief RSS 출력 **/ - function dispRss20($info, $content) { - header("Content-Type: text/xml; charset=UTF-8"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); - print ''."\n"; - print "\n"; + function dispRss($info, $content) { + // 설정 정보를 받아옴 (module model 객체를 이용) + $oModuleModel = &getModel('module'); + $config = $oModuleModel->getModuleConfig('rss'); + + // RSS 비활성화 되었는지 체크하여 비활성화시 에러 출력 + if($config->rss_disable=='Y') return $this->dispError(); + + // RSS 출력 형식을 체크 + $rss_type = $config->rss_type; + if(!$this->rss_types->{$rss_type}) $rss_type = $this->default_rss_type; -?> - -<![CDATA[<?=$info->title?>]]> -link?>]]> -description?>]]> -language?> -date?> -total_count?> - $item) { $year = substr($item->regdate,0,4); $month = substr($item->regdate,4,2); $day = substr($item->regdate,6,2); @@ -59,26 +56,41 @@ $sec = substr($item->regdate,12,2); $time = mktime($hour,$min,$sec,$month,$day,$year); - $title = $item->title; - $author = $item->user_name; - $link = sprintf("%s?document_srl=%d", Context::getRequestUri(), $item->document_srl); - $description = $item->content; - $date = gmdate("D, d M Y H:i:s", $time); -?> - -<![CDATA[<?=$title?>]]> -]]> -]]> -]]> - - -author = $item->user_name; + $item->link = sprintf("%s?document_srl=%d", Context::getRequestUri(), $item->document_srl); + $item->description = $item->content; + $item->date = gmdate("D, d M Y H:i:s", $time); + $content[$key] = $item; } } -?> - - -setTemplatePath($this->module_path.'tpl/'); + $this->setTemplateFile($rss_type); + } + + /** + * @brief 에러 출력 + **/ + function dispError() { + + // 결과 출력을 XMLRPC로 강제 지정 + Context::setResponseMethod("XMLRPC"); + + // 출력 메세지 작성 + Context::set('error', -1); + Context::set('message', Context::getLang('msg_rss_is_disabled') ); + + // 템플릿 파일 지정 + $this->setTemplatePath($this->module_path.'tpl.admin/'); + $this->setTemplateFile("error"); } } ?> diff --git a/modules/rss/tpl.admin/error.html b/modules/rss/tpl.admin/error.html new file mode 100644 index 000000000..8dbd740da --- /dev/null +++ b/modules/rss/tpl.admin/error.html @@ -0,0 +1,6 @@ +{''} + + + {$error} + + diff --git a/modules/rss/tpl.admin/filter/insert_config.xml b/modules/rss/tpl.admin/filter/insert_config.xml new file mode 100644 index 000000000..b61a6ba2a --- /dev/null +++ b/modules/rss/tpl.admin/filter/insert_config.xml @@ -0,0 +1,7 @@ + +
+ + + + + diff --git a/modules/rss/tpl.admin/index.html b/modules/rss/tpl.admin/index.html new file mode 100644 index 000000000..9ff5691d2 --- /dev/null +++ b/modules/rss/tpl.admin/index.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + +
{$lang->rss_disable}rss_disable=="Y")-->checked="true" /> +
{$lang->about_rss_disable}
{$lang->rss_type} + +
{$lang->about_rss_type}
+ + +
+
diff --git a/modules/rss/tpl/rss20.html b/modules/rss/tpl/rss20.html new file mode 100644 index 000000000..453ae71a6 --- /dev/null +++ b/modules/rss/tpl/rss20.html @@ -0,0 +1,22 @@ +{''} + + + + +<![CDATA[{$info->title}]]> +link}]]> +description}]]> +{$info->language} +{$info->date} +{$info->total_count} + + +<![CDATA[{$item->title}]]> +author}]]> +link}]]> +description}]]> +{$item->date} + + + +