게시판 모듈에서 조회/추천/제목/댓글수 정렬외의 정렬대상에서 문서번호만으로 접속시 해당 문서의 페이지를 자동으로 구하는 루틴을 보다 정교하게 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4276 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-06-12 04:27:01 +00:00
parent cf8d8c720a
commit 4496358bad
4 changed files with 51 additions and 12 deletions

View file

@ -35,6 +35,7 @@
var $errno = 0; ///< 에러 발생시 에러 코드 (0이면 에러가 없다고 정의) var $errno = 0; ///< 에러 발생시 에러 코드 (0이면 에러가 없다고 정의)
var $errstr = ''; ///< 에러 발생시 에러 메세지 var $errstr = ''; ///< 에러 발생시 에러 메세지
var $query = ''; ///< 가장 최근에 수행된 query string var $query = ''; ///< 가장 최근에 수행된 query string
var $elapsed_time = 0; ///< 가장 최근에 수행된 query 의 실행시간
var $transaction_started = false; ///< 트랙잭션 처리 flag var $transaction_started = false; ///< 트랙잭션 처리 flag
@ -126,12 +127,14 @@
$this->setError(0,'success'); $this->setError(0,'success');
$this->query = $query; $this->query = $query;
$this->act_start = getMicroTime(); $this->act_start = getMicroTime();
$this->elapsed_time = 0;
} }
function actFinish() { function actFinish() {
if(!$this->query ) return; if(!$this->query ) return;
$this->act_finish = getMicroTime(); $this->act_finish = getMicroTime();
$elapsed_time = $this->act_finish - $this->act_start; $elapsed_time = $this->act_finish - $this->act_start;
$this->elapsed_time = $elapsed_time;
$GLOBALS['__db_elapsed_time__'] += $elapsed_time; $GLOBALS['__db_elapsed_time__'] += $elapsed_time;
$str = sprintf("\t%02d. %s (%0.6f sec)\n", ++$GLOBALS['__dbcnt'], $this->query, $elapsed_time); $str = sprintf("\t%02d. %s (%0.6f sec)\n", ++$GLOBALS['__dbcnt'], $this->query, $elapsed_time);
@ -169,8 +172,6 @@
} }
} }
$this->query = null;
} }
/** /**
@ -270,9 +271,11 @@
break; break;
} }
if($this->errno !=0 ) return new Object($this->errno, $this->errstr); if($this->errno != 0 ) $output = new Object($this->errno, $this->errstr);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) return $output; else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) $output = new Object();
return new Object(); $output->add('_query', $this->query);
$output->add('_elapsed_time', sprintf("%0.5f",$this->elapsed_time));
return $output;
} }
/** /**

View file

@ -177,7 +177,7 @@
// 특정 문서의 permalink로 직접 접속할 경우 page값을 직접 구함 // 특정 문서의 permalink로 직접 접속할 경우 page값을 직접 구함
if(count($_GET)==1 && isset($_GET['document_srl']) && $oDocument->isExists() && !$oDocument->isNotice()) { if(count($_GET)==1 && isset($_GET['document_srl']) && $oDocument->isExists() && !$oDocument->isNotice()) {
$page = $oDocumentModel->getDocumentPage($oDocument->document_srl, $this->module_srl, $this->list_count); $page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $page); Context::set('page', $page);
$args->page = $page; $args->page = $page;
} }

View file

@ -412,15 +412,35 @@
/** /**
* @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서.. * @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서..
**/ **/
function getDocumentPage($document_srl, $module_srl=0, $list_count) { function getDocumentPage($oDocument, $opt) {
// 변수 설정 // 정렬 형식에 따라서 query args 변경
$args->document_srl = $document_srl; switch($opt->sort_index) {
$args->module_srl = $module_srl; case 'update_order' :
if($opt->order_type == 'desc') $args->rev_update_order = $oDocument->get('update_order');
else $args->update_order = $oDocument->get('update_order');
break;
case 'regdate' :
if($opt->order_type == 'desc') $args->rev_regdate = $oDocument->get('regdate');
else $args->regdate = $oDocument->get('regdate');
break;
case 'voted_count' :
case 'readed_count' :
case 'comment_count' :
case 'title' :
return 1;
break;
default :
if($opt->order_type == 'desc') $args->rev_list_order = $oDocument->get('list_order');
else $args->list_order = $oDocument->get('list_order');
break;
}
$args->sort_index = $opt->sort_index;
$args->order_type = $opt->order_type;
// 전체 갯수를 구한후 해당 글의 페이지를 검색 // 전체 갯수를 구한후 해당 글의 페이지를 검색
$output = executeQuery('document.getDocumentPage', $args); $output = executeQuery('document.getDocumentPage', $args);
$count = $output->data->count; $count = $output->data->count;
$page = (int)(($count-1)/$list_count)+1; $page = (int)(($count-1)/$opt->list_count)+1;
return $page; return $page;
} }

View file

@ -7,6 +7,22 @@
</columns> </columns>
<conditions> <conditions>
<condition operation="equal" column="module_srl" var="module_srl" /> <condition operation="equal" column="module_srl" var="module_srl" />
<condition operation="more" column="document_srl" var="document_srl" filter="number" notnull="notnull" pipe="and" /> <condition operation="more" column="comment_count" var="comment_count" filter="number" pipe="and" />
<condition operation="less" column="comment_count" var="rev_comment_count" filter="number" pipe="and" />
<condition operation="more" column="voted_count" var="voted_count" filter="number" pipe="and" />
<condition operation="less" column="voted_count" var="rev_voted_count" filter="number" pipe="and" />
<condition operation="more" column="readed_count" var="readed_count" filter="number" pipe="and" />
<condition operation="less" column="readed_count" var="rev_readed_count" filter="number" pipe="and" />
<condition operation="less" column="list_order" var="list_order" filter="number" pipe="and" />
<condition operation="more" column="list_order" var="rev_list_order" filter="number" pipe="and" />
<condition operation="more" column="title" var="title" filter="number" pipe="and" />
<condition operation="less" column="title" var="rev_title" filter="number" pipe="and" />
<condition operation="more" column="regdate" var="regdate" filter="number" pipe="and" />
<condition operation="less" column="regdate" var="rev_regdate" filter="number" pipe="and" />
<condition operation="less" column="update_order" var="update_order" filter="number" pipe="and" />
<condition operation="more" column="update_order" var="rev_update_order" filter="number" pipe="and" />
</conditions> </conditions>
<navigation>
<index var="sort_index" default="list_order" order="order_type" />
</navigation>
</query> </query>