From b1c00fb7717e37d026dc2ba33ea30223b02afe56 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 8 Aug 2007 04:13:45 +0000 Subject: [PATCH] =?UTF-8?q?RSS=20=EB=B3=B4=EA=B8=B0=EC=9D=98=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20RSS=EB=A5=BC=20=EC=B5=9C=EA=B7=BC=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EB=B3=B4?= =?UTF-8?q?=EC=97=AC=EC=A3=BC=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/trunk@2249 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .htaccess | 2 + modules/document/document.item.php | 43 ++++++++++- modules/document/document.model.php | 7 +- modules/document/queries/getDocumentList.xml | 4 + modules/rss/rss.view.php | 79 ++++++++------------ modules/rss/tpl/rss20.html | 16 ++-- modules/rss/tpl/xe_rss.html | 30 ++++++++ 7 files changed, 124 insertions(+), 57 deletions(-) create mode 100644 modules/rss/tpl/xe_rss.html diff --git a/.htaccess b/.htaccess index 3a01d6cdf..12419e500 100644 --- a/.htaccess +++ b/.htaccess @@ -4,6 +4,8 @@ RewriteEngine On RewriteRule ^([a-zA-Z0-9_]+)/([[:digit:]]+)page$ ./index.php?mid=$1&page=$2 [L] # total rss +RewriteRule ^rss/([[:digit:]]+){0,14}/([[:digit:]]+){0,14}/([[:digit:]]+)$ ./index.php?module=rss&act=rss&start_date=$1&end_date=$2&page=$3 [L] +RewriteRule ^rss/([[:digit:]]+)$ ./index.php?module=rss&act=rss&page=$1 [L] RewriteRule ^rss$ ./index.php?module=rss&act=rss [L] # administrator page diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 65b6def4a..d3a5dcfca 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -147,22 +147,27 @@ return $this->get('title'); } - function getContentText() { + function getContentText($strlen = 0) { if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret'); $_SESSION['accessible'][$this->document_srl] = true; $content = $this->get('content'); + if($strlen) return cut_str(strip_tags($content),$strlen,'...'); + return htmlspecialchars($content); } - function getContent() { + function getContent($add_document_info = true) { if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret'); $_SESSION['accessible'][$this->document_srl] = true; $content = $this->get('content'); - return sprintf('%s', $this->document_srl, $this->get('member_srl'), $content, $this->document_srl, $this->get('member_srl')); + + if($add_document_info) return sprintf('%s', $this->document_srl, $this->get('member_srl'), $content, $this->document_srl, $this->get('member_srl')); + + return $content; } function getSummary($str_size = 50) { @@ -174,6 +179,38 @@ return zdate($this->get('regdate'), $format); } + function getRegdateTime() { + $year = substr($this->get('regdate'),0,4); + $month = substr($this->get('regdate'),4,2); + $day = substr($this->get('regdate'),6,2); + $hour = substr($this->get('regdate'),8,2); + $min = substr($this->get('regdate'),10,2); + $sec = substr($this->get('regdate'),12,2); + return mktime($hour,$min,$sec,$month,$day,$year); + } + + function getRegdateGM() { + return gmdate("D, d M Y H:i:s", $this->getRegdateTime()); + } + + function getUpdate($format = 'Y.m.d H:i:s') { + return zdate($this->get('last_update'), $format); + } + + function getUpdateTime() { + $year = substr($this->get('last_update'),0,4); + $month = substr($this->get('last_update'),4,2); + $day = substr($this->get('last_update'),6,2); + $hour = substr($this->get('last_update'),8,2); + $min = substr($this->get('last_update'),10,2); + $sec = substr($this->get('last_update'),12,2); + return mktime($hour,$min,$sec,$month,$day,$year); + } + + function getUpdateGM() { + return gmdate("D, d M Y H:i:s", $this->getUpdateTime()); + } + function getPermanentUrl() { return getUrl('','document_srl',$this->document_srl); } diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 664f365e0..446c6498c 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -61,7 +61,7 @@ **/ function getDocumentList($obj) { // 정렬 대상과 순서 체크 - if(!in_array($obj->sort_index, array('list_order','regdate','update_order','readed_count','voted_count'))) $obj->sort_index = 'list_order'; + if(!in_array($obj->sort_index, array('list_order','regdate','last_update','update_order','readed_count','voted_count'))) $obj->sort_index = 'list_order'; if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc'; // module_srl 대신 mid가 넘어왔을 경우는 직접 module_srl을 구해줌 @@ -76,12 +76,15 @@ else $args->module_srl = $obj->module_srl; // 변수 체크 - $args->category_srl = $obj->category_srl?$obj->category_srl:''; + $args->category_srl = $obj->category_srl?$obj->category_srl:null; $args->sort_index = $obj->sort_index; $args->order_type = $obj->order_type; $args->page = $obj->page?$obj->page:1; $args->list_count = $obj->list_count?$obj->list_count:20; $args->page_count = $obj->page_count?$obj->page_count:10; + $args->start_date = $obj->start_date?$obj->start_date:null; + $args->end_date = $obj->end_date?$obj->end_date:null; + $query_id = 'document.getDocumentList'; // 검색 옵션 정리 diff --git a/modules/document/queries/getDocumentList.xml b/modules/document/queries/getDocumentList.xml index 52a133639..1bbd0c1ef 100644 --- a/modules/document/queries/getDocumentList.xml +++ b/modules/document/queries/getDocumentList.xml @@ -49,6 +49,10 @@ + + + + diff --git a/modules/rss/rss.view.php b/modules/rss/rss.view.php index 487a88c5c..66d0b480b 100644 --- a/modules/rss/rss.view.php +++ b/modules/rss/rss.view.php @@ -20,9 +20,26 @@ * @brief RSS 출력 **/ function rss() { - // RSS를 출력하고자 하는 mid를 구함 (없으면 오류) - $mid = Context::get('mid'); + /** + * RSS 출력을 위한 변수 설정 + **/ + $mid = Context::get('mid'); ///< 대상 모듈 id, 없으면 전체로 + $page = (int)Context::get('page'); ///< 페이지, 없으면 1 + if(!$page) $page = 1; + + $list_count = (int)Context::get('list_count'); ///< 목록 갯수, 기본 20, 최고 100개 + if(!$list_count|| $list_count>100) $list_count = 20; + + $start_date = Context::get('start_date'); ///< 시작 일자, 없으면 무시 + if(strlen($start_date)!=14 || !ereg("^([0-9]){14}$", $start_date) ) unset($start_date); + + $end_date = Context::get('end_date'); ///< 종료 일자, 없으면 무시 + if(strlen($end_date)!=14 || !ereg("^([0-9]){14}$", $end_date) ) unset($end_date); + + /** + * 요청된 모듈 혹은 전체 모듈의 정보를 구하고 open_rss의 값을 체크 + **/ $oModuleModel = &getModel('module'); $mid_list = array(); @@ -59,22 +76,18 @@ unset($args); } - // 변수 설정 - $page = (int)Context::get('page'); - if(!$page) $page = 1; - $list_count = (int)Context::get('list_count'); - if(!$list_count|| $list_count>100) $list_count = 100; - - // 출력할 컨텐츠 추출을 위한 인자 정리 + /** + * 출력할 컨텐츠 추출을 위한 인자 정리 + **/ $args->module_srl = $module_srl; $args->page = $page; $args->list_count = $list_count; $args->page_count = 10; - $args->search_target = Context::get('search_target'); - $args->search_keyword = Context::get('search_keyword'); - if($module_info->use_category=='Y') $args->category_srl = Context::get('category'); - $args->sort_index = 'list_order'; - $args->order_type = 'asc'; + if($start_date) $args->start_date = $start_date; + if($end_date) $args->end_date = $end_date; + + $args->sort_index = 'last_update'; + $args->order_type = 'desc'; // 대상 문서들을 가져옴 $oDocumentModel = &getModel('document'); @@ -90,49 +103,23 @@ $info->title = $info->link = Context::getRequestUri(); } $info->total_count = $output->total_count; + $info->total_page = $output->total_page; $info->date = gmdate("D, d M Y H:i:s"); $info->language = Context::getLangType(); - // rss2.0으로 출력 - if(count($document_list)) { - $idx = 0; - foreach($document_list as $key => $item) { - $year = substr($item->get('regdate'),0,4); - $month = substr($item->get('regdate'),4,2); - $day = substr($item->get('regdate'),6,2); - $hour = substr($item->get('regdate'),8,2); - $min = substr($item->get('regdate'),10,2); - $sec = substr($item->get('regdate'),12,2); - $time = mktime($hour,$min,$sec,$month,$day,$year); - - $item->author = $item->getNickName(); - $item->link = $item->getPermanentUrl(); - $item->title = $item->getTitleText(); - - $module_srl = $item->get('module_srl'); - - // 전문 공개일 경우 - if($mid_list[$module_srl]->open_rss=='Y') { - $item->description = $item->getContent(); - // 요약 공개일 경우 - } else { - $item->description = cut_str(strip_tags($item->getContent()),100,'...'); - } - $item->date = gmdate("D, d M Y H:i:s", $time); - $content[$idx++] = $item; - } - } else return $this->dispError(); - // RSS 출력물에서 사용될 변수 세팅 Context::set('info', $info); - Context::set('content', $content); + Context::set('mid_list', $mid_list); + Context::set('document_list', $document_list); // 결과 출력을 XMLRPC로 강제 지정 Context::setResponseMethod("XMLRPC"); // 템플릿 파일 지정 $this->setTemplatePath($this->module_path.'tpl/'); - $this->setTemplateFile('rss20'); + + if($args->start_date || $args->end_date) $this->setTemplateFile('xe_rss'); + else $this->setTemplateFile('rss20'); } /** diff --git a/modules/rss/tpl/rss20.html b/modules/rss/tpl/rss20.html index 8d0f60210..c9a00a067 100644 --- a/modules/rss/tpl/rss20.html +++ b/modules/rss/tpl/rss20.html @@ -8,13 +8,17 @@ {$info->language} {$info->date} {$info->total_count} - + - <![CDATA[{$item->title}]]> - author}]]> - link}]]> - description}]]> - {$item->date} + <![CDATA[{$oDocument->getTitleText()}]]> + getNickName()}]]> + getPermanentUrl()}]]> + + getContent(false)}]]> + + getContentText(100)}]]> + + {$oDocument->getRegdateGM()} diff --git a/modules/rss/tpl/xe_rss.html b/modules/rss/tpl/xe_rss.html new file mode 100644 index 000000000..2d12dbc94 --- /dev/null +++ b/modules/rss/tpl/xe_rss.html @@ -0,0 +1,30 @@ +{''} + + + + <![CDATA[{$info->title}]]> + link}]]> + description}]]> + {$info->language} + {$info->date} + {$info->total_count} + {$info->total_page} + + + <![CDATA[{$oDocument->getTitleText()}]]> + getNickName()}]]> + getPermanentUrl()}]]> + + getContent(false)}]]> + + getContentText(100)}]]> + + get('tags')}]]> + {$oDocument->getCommentCount()} + {$oDocument->getTrackbackCount()} + {$oDocument->getRegdateGM()} + {$oDocument->getUpdateGM()} + + + +