diff --git a/widgets/newest_document/newest_document.class.php b/widgets/newest_document/newest_document.class.php index 7543496bb..ebf7723ed 100644 --- a/widgets/newest_document/newest_document.class.php +++ b/widgets/newest_document/newest_document.class.php @@ -18,27 +18,64 @@ // 위젯 자체적으로 설정한 변수들을 체크 $title = $args->title; $order_target = $args->order_target; + if(!in_array($order_target, array('list_order','update_order'))) $order_target = 'list_order'; $order_type = $args->order_type; + if(!in_array($order_type, array('asc','desc'))) $order_type = 'desc'; $list_count = (int)$args->list_count; if(!$list_count) $list_count = 5; $mid_list = explode(",",$args->mid_list); $subject_cut_size = $args->subject_cut_size; if(!$subject_cut_size) $subject_cut_size = 0; + /** + * order_target=list_order일 경우 document 테이블의 list_order 컬럼말고 document_srl을 이용하게 하고 순서를 반대로 한다 + * 이유는 공지사항을 적용하지 않은 순수한 글 작성 순서로만 사용하기 위해성.ㅁ + * 2007. 8. 22. zero + **/ + if($order_target == 'list_order') $order_target = 'document_srl'; + + // module_srl 대신 mid가 넘어왔을 경우는 직접 module_srl을 구해줌 + if($mid_list) { + $oModuleModel = &getModel('module'); + $module_srl = $oModuleModel->getModuleSrlByMid($mid_list); + } + // DocumentModel::getDocumentList()를 이용하기 위한 변수 정리 - $obj->mid = $mid_list; + $obj->module_srl = implode(',',$module_srl); $obj->sort_index = $order_target; + $obj->order_type = $order_type; $obj->list_count = $list_count; - // document 모듈의 model 객체를 받아서 getDocumentList() method를 실행 + $output = executeQuery('widgets.newest_document.getNewestDocuments', $obj); + + // document 모듈의 model 객체를 받아서 결과를 객체화 시킴 $oDocumentModel = &getModel('document'); - $output = $oDocumentModel->getDocumentList($obj); + + // 오류가 생기면 그냥 무시 + if(!$output->toBool()) return; + + // 결과가 있으면 각 문서 객체화를 시킴 + if(count($output->data)) { + foreach($output->data as $key => $attribute) { + $document_srl = $attribute->document_srl; + + $oDocument = null; + $oDocument = new documentItem(); + $oDocument->setAttribute($attribute); + + $document_list[$key] = $oDocument; + } + } else { + + $document_list = array(); + + } // 템플릿 파일에서 사용할 변수들을 세팅 if(count($mid_list)==1) $widget_info->module_name = $mid_list[0]; $widget_info->title = $title; - $widget_info->document_list = $output->data; + $widget_info->document_list = $document_list; $widget_info->subject_cut_size = $subject_cut_size; Context::set('widget_info', $widget_info); diff --git a/widgets/newest_document/queries/getNewestDocuments.xml b/widgets/newest_document/queries/getNewestDocuments.xml new file mode 100644 index 000000000..6c8dcc156 --- /dev/null +++ b/widgets/newest_document/queries/getNewestDocuments.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +