mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
add sort function for document extra_vars
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8397 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d77165d263
commit
4b9faef300
2 changed files with 227 additions and 130 deletions
|
|
@ -153,8 +153,10 @@
|
||||||
* @brief module_srl value, bringing the list of documents
|
* @brief module_srl value, bringing the list of documents
|
||||||
**/
|
**/
|
||||||
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) {
|
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) {
|
||||||
// Check the target and sequence alignment
|
$sort_check = $this->_setSortIndex($obj, $load_extra_vars);
|
||||||
if(!in_array($obj->sort_index, array('list_order','regdate','last_update','update_order','readed_count','voted_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) $obj->sort_index = 'list_order';
|
|
||||||
|
$obj->sort_index = $sort_check->sort_index;
|
||||||
|
// Check the target and sequence alignment
|
||||||
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
||||||
// If that came across mid module_srl instead of a direct module_srl guhaejum
|
// If that came across mid module_srl instead of a direct module_srl guhaejum
|
||||||
if($obj->mid) {
|
if($obj->mid) {
|
||||||
|
|
@ -195,141 +197,149 @@
|
||||||
$searchOpt->search_keyword = $obj->search_keyword;
|
$searchOpt->search_keyword = $obj->search_keyword;
|
||||||
$this->_setSearchOption($searchOpt, $args, $query_id, $use_division);
|
$this->_setSearchOption($searchOpt, $args, $query_id, $use_division);
|
||||||
|
|
||||||
/**
|
if ($sort_check->isExtraVars)
|
||||||
* list_order asc sort of division that can be used only when
|
{
|
||||||
**/
|
$query_id = 'document.getDocumentListExtraSort';
|
||||||
if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
|
$output = executeQueryArray($query_id, $args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* list_order asc sort of division that can be used only when
|
||||||
|
**/
|
||||||
|
if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If it is true, use_division changed to use the document division
|
* If it is true, use_division changed to use the document division
|
||||||
**/
|
**/
|
||||||
if($use_division) {
|
if($use_division) {
|
||||||
// Division begins
|
// Division begins
|
||||||
$division = (int)Context::get('division');
|
$division = (int)Context::get('division');
|
||||||
|
|
||||||
// order by list_order and (module_srl===0 or module_srl many count), therefore case table full scan
|
// order by list_order and (module_srl===0 or module_srl many count), therefore case table full scan
|
||||||
if($args->sort_index == 'list_order' && ($args->exclude_module_srl === 0 || count($args->module_srl) > 10))
|
if($args->sort_index == 'list_order' && ($args->exclude_module_srl === 0 || count($args->module_srl) > 10))
|
||||||
{
|
{
|
||||||
$listSqlID = 'document.getDocumentListUseIndex';
|
$listSqlID = 'document.getDocumentListUseIndex';
|
||||||
$divisionSqlID = 'document.getDocumentDivisionUseIndex';
|
$divisionSqlID = 'document.getDocumentDivisionUseIndex';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$listSqlID = 'document.getDocumentList';
|
||||||
|
$divisionSqlID = 'document.getDocumentDivision';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If you do not value the best division top
|
||||||
|
if(!$division) {
|
||||||
|
$division_args->module_srl = $args->module_srl;
|
||||||
|
$division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$division_args->list_count = 1;
|
||||||
|
$division_args->sort_index = $args->sort_index;
|
||||||
|
$division_args->order_type = $args->order_type;
|
||||||
|
$output = executeQuery($listSqlID, $division_args, $columnList);
|
||||||
|
if($output->data) {
|
||||||
|
$item = array_pop($output->data);
|
||||||
|
$division = $item->list_order;
|
||||||
|
}
|
||||||
|
$division_args = null;
|
||||||
|
}
|
||||||
|
// The last division
|
||||||
|
$last_division = (int)Context::get('last_division');
|
||||||
|
// Division after division from the 5000 value of the specified Wanted
|
||||||
|
if(!$last_division) {
|
||||||
|
$last_division_args->module_srl = $args->module_srl;
|
||||||
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$last_division_args->list_count = 1;
|
||||||
|
$last_division_args->sort_index = $args->sort_index;
|
||||||
|
$last_division_args->order_type = $args->order_type;
|
||||||
|
$last_division_args->list_order = $division;
|
||||||
|
$last_division_args->page = 5001;
|
||||||
|
$output = executeQuery($divisionSqlID, $last_division_args, $columnList);
|
||||||
|
if($output->data) {
|
||||||
|
$item = array_pop($output->data);
|
||||||
|
$last_division = $item->list_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// Make sure that after last_division article
|
||||||
|
if($last_division) {
|
||||||
|
$last_division_args = null;
|
||||||
|
$last_division_args->module_srl = $args->module_srl;
|
||||||
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$last_division_args->list_order = $last_division;
|
||||||
|
$output = executeQuery("document.getDocumentDivisionCount", $last_division_args);
|
||||||
|
if($output->data->count<1) $last_division = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args->division = $division;
|
||||||
|
$args->last_division = $last_division;
|
||||||
|
Context::set('division', $division);
|
||||||
|
Context::set('last_division', $last_division);
|
||||||
}
|
}
|
||||||
else
|
// document.getDocumentList query execution
|
||||||
{
|
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
|
||||||
$listSqlID = 'document.getDocumentList';
|
if(in_array($query_id, array('document.getDocumentListWithinComment', 'document.getDocumentListWithinTag'))) {
|
||||||
$divisionSqlID = 'document.getDocumentDivision';
|
$group_args = clone($args);
|
||||||
|
$group_args->sort_index = 'documents.'.$args->sort_index;
|
||||||
|
$output = executeQueryArray($query_id, $group_args);
|
||||||
|
if(!$output->toBool()||!count($output->data)) return $output;
|
||||||
|
|
||||||
|
foreach($output->data as $key => $val) {
|
||||||
|
if($val->document_srl) $target_srls[] = $val->document_srl;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page_navigation = $output->page_navigation;
|
||||||
|
$keys = array_keys($output->data);
|
||||||
|
$virtual_number = $keys[0];
|
||||||
|
|
||||||
|
$target_args->document_srls = implode(',',$target_srls);
|
||||||
|
$target_args->list_order = $args->sort_index;
|
||||||
|
$target_args->order_type = $args->order_type;
|
||||||
|
$target_args->list_count = $args->list_count;
|
||||||
|
$target_args->page = 1;
|
||||||
|
$output = executeQueryArray('document.getDocuments', $target_args);
|
||||||
|
$output->page_navigation = $page_navigation;
|
||||||
|
$output->total_count = $page_navigation->total_count;
|
||||||
|
$output->total_page = $page_navigation->total_page;
|
||||||
|
$output->page = $page_navigation->cur_page;
|
||||||
|
} else {
|
||||||
|
$output = executeQueryArray($query_id, $args, $columnList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Return if no result or an error occurs
|
||||||
|
if(!$output->toBool()||!count($output->data)) return $output;
|
||||||
|
|
||||||
|
$idx = 0;
|
||||||
|
$data = $output->data;
|
||||||
|
unset($output->data);
|
||||||
|
|
||||||
|
if(!isset($virtual_number))
|
||||||
|
{
|
||||||
|
$keys = array_keys($data);
|
||||||
|
$virtual_number = $keys[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($except_notice) {
|
||||||
|
foreach($data as $key => $attribute) {
|
||||||
|
if($attribute->is_notice == 'Y') $virtual_number --;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $key => $attribute) {
|
||||||
|
if($except_notice && $attribute->is_notice == 'Y') continue;
|
||||||
|
$document_srl = $attribute->document_srl;
|
||||||
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
|
||||||
|
$oDocument = null;
|
||||||
|
$oDocument = new documentItem();
|
||||||
|
$oDocument->setAttribute($attribute, false);
|
||||||
|
if($is_admin) $oDocument->setGrant();
|
||||||
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you do not value the best division top
|
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||||
if(!$division) {
|
$virtual_number --;
|
||||||
$division_args->module_srl = $args->module_srl;
|
|
||||||
$division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$division_args->list_count = 1;
|
|
||||||
$division_args->sort_index = $args->sort_index;
|
|
||||||
$division_args->order_type = $args->order_type;
|
|
||||||
$output = executeQuery($listSqlID, $division_args, $columnList);
|
|
||||||
if($output->data) {
|
|
||||||
$item = array_pop($output->data);
|
|
||||||
$division = $item->list_order;
|
|
||||||
}
|
|
||||||
$division_args = null;
|
|
||||||
}
|
|
||||||
// The last division
|
|
||||||
$last_division = (int)Context::get('last_division');
|
|
||||||
// Division after division from the 5000 value of the specified Wanted
|
|
||||||
if(!$last_division) {
|
|
||||||
$last_division_args->module_srl = $args->module_srl;
|
|
||||||
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$last_division_args->list_count = 1;
|
|
||||||
$last_division_args->sort_index = $args->sort_index;
|
|
||||||
$last_division_args->order_type = $args->order_type;
|
|
||||||
$last_division_args->list_order = $division;
|
|
||||||
$last_division_args->page = 5001;
|
|
||||||
$output = executeQuery($divisionSqlID, $last_division_args, $columnList);
|
|
||||||
if($output->data) {
|
|
||||||
$item = array_pop($output->data);
|
|
||||||
$last_division = $item->list_order;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Make sure that after last_division article
|
|
||||||
if($last_division) {
|
|
||||||
$last_division_args = null;
|
|
||||||
$last_division_args->module_srl = $args->module_srl;
|
|
||||||
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$last_division_args->list_order = $last_division;
|
|
||||||
$output = executeQuery("document.getDocumentDivisionCount", $last_division_args);
|
|
||||||
if($output->data->count<1) $last_division = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$args->division = $division;
|
|
||||||
$args->last_division = $last_division;
|
|
||||||
Context::set('division', $division);
|
|
||||||
Context::set('last_division', $last_division);
|
|
||||||
}
|
|
||||||
// document.getDocumentList query execution
|
|
||||||
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
|
|
||||||
if(in_array($query_id, array('document.getDocumentListWithinComment', 'document.getDocumentListWithinTag'))) {
|
|
||||||
$group_args = clone($args);
|
|
||||||
$group_args->sort_index = 'documents.'.$args->sort_index;
|
|
||||||
$output = executeQueryArray($query_id, $group_args);
|
|
||||||
if(!$output->toBool()||!count($output->data)) return $output;
|
|
||||||
|
|
||||||
foreach($output->data as $key => $val) {
|
|
||||||
if($val->document_srl) $target_srls[] = $val->document_srl;
|
|
||||||
}
|
|
||||||
|
|
||||||
$page_navigation = $output->page_navigation;
|
|
||||||
$keys = array_keys($output->data);
|
|
||||||
$virtual_number = $keys[0];
|
|
||||||
|
|
||||||
$target_args->document_srls = implode(',',$target_srls);
|
|
||||||
$target_args->list_order = $args->sort_index;
|
|
||||||
$target_args->order_type = $args->order_type;
|
|
||||||
$target_args->list_count = $args->list_count;
|
|
||||||
$target_args->page = 1;
|
|
||||||
$output = executeQueryArray('document.getDocuments', $target_args);
|
|
||||||
$output->page_navigation = $page_navigation;
|
|
||||||
$output->total_count = $page_navigation->total_count;
|
|
||||||
$output->total_page = $page_navigation->total_page;
|
|
||||||
$output->page = $page_navigation->cur_page;
|
|
||||||
} else {
|
|
||||||
$output = executeQueryArray($query_id, $args, $columnList);
|
|
||||||
}
|
|
||||||
// Return if no result or an error occurs
|
|
||||||
if(!$output->toBool()||!count($output->data)) return $output;
|
|
||||||
|
|
||||||
$idx = 0;
|
|
||||||
$data = $output->data;
|
|
||||||
unset($output->data);
|
|
||||||
|
|
||||||
if(!isset($virtual_number))
|
|
||||||
{
|
|
||||||
$keys = array_keys($data);
|
|
||||||
$virtual_number = $keys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if($except_notice) {
|
|
||||||
foreach($data as $key => $attribute) {
|
|
||||||
if($attribute->is_notice == 'Y') $virtual_number --;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($data as $key => $attribute) {
|
|
||||||
if($except_notice && $attribute->is_notice == 'Y') continue;
|
|
||||||
$document_srl = $attribute->document_srl;
|
|
||||||
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
|
|
||||||
$oDocument = null;
|
|
||||||
$oDocument = new documentItem();
|
|
||||||
$oDocument->setAttribute($attribute, false);
|
|
||||||
if($is_admin) $oDocument->setGrant();
|
|
||||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
|
||||||
$virtual_number --;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
||||||
|
|
||||||
if(count($output->data)) {
|
if(count($output->data)) {
|
||||||
|
|
@ -992,6 +1002,40 @@
|
||||||
$this->add('voted_member_list',$output->data);
|
$this->add('voted_member_list',$output->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _setSortIndex($obj, $load_extra_vars)
|
||||||
|
{
|
||||||
|
$sortIndex = $obj->sort_index;
|
||||||
|
$isExtraVars = false;
|
||||||
|
if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','comment_count','trackback_count','uploaded_count','title','category_srl')))
|
||||||
|
{
|
||||||
|
// get module_srl extra_vars list
|
||||||
|
if ($load_extra_vars)
|
||||||
|
{
|
||||||
|
$extra_args->module_srl = $obj->module_srl;
|
||||||
|
$extra_output = executeQueryArray('document.getGroupsExtraVars', $extra_args);
|
||||||
|
if (!$extra_output->data || !$extra_output->toBool())
|
||||||
|
{
|
||||||
|
$sortIndex = 'list_order';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$check_array = array();
|
||||||
|
foreach($extra_output->data as $val){
|
||||||
|
$check_array[] = $val->eid;
|
||||||
|
}
|
||||||
|
if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order';
|
||||||
|
else $isExtraVars = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$sortIndex = 'list_order';
|
||||||
|
}
|
||||||
|
$returnObj->sort_index = $sortIndex;
|
||||||
|
$returnObj->isExtraVars = $isExtraVars;
|
||||||
|
|
||||||
|
return $returnObj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 게시물 목록의 검색 옵션을 Setting함(2011.03.08 - cherryfilter)
|
* @brief 게시물 목록의 검색 옵션을 Setting함(2011.03.08 - cherryfilter)
|
||||||
* page변수가 없는 상태에서 page 값을 알아오는 method(getDocumentPage)는 검색하지 않은 값을 return해서 검색한 값을 가져오도록 검색옵션이 추가 됨.
|
* page변수가 없는 상태에서 page 값을 알아오는 method(getDocumentPage)는 검색하지 않은 값을 return해서 검색한 값을 가져오도록 검색옵션이 추가 됨.
|
||||||
|
|
|
||||||
53
modules/document/queries/getDocumentListExtraSort.xml
Normal file
53
modules/document/queries/getDocumentListExtraSort.xml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
<query id="getDocumentList" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="documents" alias="d" />
|
||||||
|
<table name="document_extra_vars" alias="ev" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="d.*" />
|
||||||
|
</columns>
|
||||||
|
<index_hint name="idx_document_list_order" type="use" />
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="ev.eid" var="sort_index" />
|
||||||
|
<condition operation="equal" column="ev.document_srl" default="d.document_srl" pipe="and" />
|
||||||
|
<condition operation="in" column="d.module_srl" var="module_srl" filter="number" pipe="and" />
|
||||||
|
<condition operation="notin" column="d.module_srl" var="exclude_module_srl" filter="number" pipe="and" />
|
||||||
|
<condition operation="in" column="d.category_srl" var="category_srl" pipe="and" />
|
||||||
|
<condition operation="equal" column="d.is_notice" var="s_is_notice" pipe="and" />
|
||||||
|
<condition operation="equal" column="d.member_srl" var="member_srl" filter="number" pipe="and" />
|
||||||
|
<group pipe="and">
|
||||||
|
<condition operation="more" column="d.list_order" var="division" pipe="and" />
|
||||||
|
<condition operation="below" column="d.list_order" var="last_division" pipe="and" />
|
||||||
|
</group>
|
||||||
|
<group pipe="and">
|
||||||
|
<condition operation="like" column="d.title" var="s_title" />
|
||||||
|
<condition operation="like" column="d.content" var="s_content" pipe="or" />
|
||||||
|
<condition operation="like" column="d.user_name" var="s_user_name" pipe="or" />
|
||||||
|
<condition operation="like" column="d.user_id" var="s_user_id" pipe="or" />
|
||||||
|
<condition operation="like" column="d.nick_name" var="s_nick_name" pipe="or" />
|
||||||
|
<condition operation="like" column="d.email_address" var="s_email_addres" pipe="or" />
|
||||||
|
<condition operation="like" column="d.homepage" var="s_homepage" pipe="or" />
|
||||||
|
<condition operation="like" column="d.tags" var="s_tags" pipe="or" />
|
||||||
|
<condition operation="equal" column="d.is_secret" var="s_is_secret" pipe="or" />
|
||||||
|
<condition operation="equal" column="d.member_srl" var="s_member_srl" pipe="or" />
|
||||||
|
<condition operation="more" column="d.readed_count" var="s_readed_count" pipe="or" />
|
||||||
|
<condition operation="more" column="d.voted_count" var="s_voted_count" pipe="or" />
|
||||||
|
<condition operation="more" column="d.comment_count" var="s_comment_count" pipe="or" />
|
||||||
|
<condition operation="more" column="d.trackback_count" var="s_trackback_count" pipe="or" />
|
||||||
|
<condition operation="more" column="d.uploaded_count" var="s_uploaded_count" pipe="or" />
|
||||||
|
<condition operation="like_prefix" column="d.regdate" var="s_regdate" pipe="or" />
|
||||||
|
<condition operation="like_prefix" column="d.last_update" var="s_last_update" pipe="or" />
|
||||||
|
<condition operation="like_prefix" column="d.ipaddress" var="s_ipaddress" pipe="or" />
|
||||||
|
</group>
|
||||||
|
<group pipe="and">
|
||||||
|
<condition operation="more" column="d.last_update" var="start_date" pipe="and" />
|
||||||
|
<condition operation="less" column="d.last_update" var="end_date" pipe="and" />
|
||||||
|
</group>
|
||||||
|
</conditions>
|
||||||
|
<navigation>
|
||||||
|
<index var="ev.value" default="ev.value" order="order_type" />
|
||||||
|
<list_count var="list_count" default="20" />
|
||||||
|
<page_count var="page_count" default="10" />
|
||||||
|
<page var="page" default="1" />
|
||||||
|
</navigation>
|
||||||
|
</query>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue