관리페이지 첨부파일 목록 개선

* 첨부 대상 표시 : 댓글, 모듈(페이지), 임시저장 문서
  * 회원 닉네임 출력 추가
    * 대기 상태 파일의 닉네임 출력 안되는건 문제 아님
  * 모듈 업데이트 필요 (필드 추가)
    * 파일 업로드시에는 값을 주지 않고
      관리페이지에서 조회시에 업데이트 (업로드시 값 넣으면 오히려 방해)


git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6310 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2009-05-08 10:22:22 +00:00
parent a42e14c552
commit f57734760b
5 changed files with 170 additions and 73 deletions

View file

@ -31,67 +31,138 @@
$output = $oFileModel->getFileList($args);
// 목록의 loop를 돌면서 document를 구하기
if($output->total_count) {
$document_srl_list = array();
$module_srls= array();
foreach($output->data as $val) {
if(!in_array($val->upload_target_srl, $document_srl_list)) $document_srl_list[] = $val->upload_target_srl;
if(!in_array($val->module_srl, $module_srls)) $module_srls[] = $val->module_srl;
}
if(count($module_srls)) {
$module_args->module_srls = implode(',', $module_srls);
$module_output = executeQueryArray('module.getModulesInfo', $module_args);
if($module_output->data) {
foreach($module_output->data as $module) {
$module_list[$module->module_srl] = $module;
}
}
}
// comment의 첨부파일이면 document_srl을 추가로 구함
if($document_srl_list) {
if($output->data) {
$oCommentModel = &getModel('comment');
$comment_output = $oCommentModel->getComments($document_srl_list);
$oDocumentModel = &getModel('document');
$oModuleModel = &getModel('module');
if($comment_output) {
foreach($comment_output as $val) {
$comment_list[$val->comment_srl] = $val->document_srl;
$file_list = array();
$document_list = array();
$comment_list = array();
$module_list= array();
$doc_srls = array();
$com_srls = array();
$mod_srls= array();
foreach($output->data as $file) {
$file_srl = $file->file_srl;
$target_srl = $file->upload_target_srl;
$file_update_args = null;
$file_update_args->file_srl = $file_srl;
// upload_target_type이 없으면 찾아서 업데이트
if(!$file->upload_target_type) {
// 찾아둔게 있으면 패스
if($document_list[$target_srl]) {
$file->upload_target_type = 'doc';
} else if($comment_list[$target_srl]) {
$file->upload_target_type = 'com';
} else if($module_list[$target_srl]) {
$file->upload_target_type = 'mod';
} else {
// document
$document = $oDocumentModel->getDocument($target_srl);
if($document->isExists()) {
$file->upload_target_type = 'doc';
$file_update_args->upload_target_type = $file->upload_target_type;
$document_list[$target_srl] = $document;
}
$file_list_keys = array_keys($output->data);
for($i=0; $i < $file_count; $i++) {
$output->data[$file_list_keys[$i]]->target_document_srl = $comment_list[$output->data[$file_list_keys[$i]]->upload_target_srl];
// comment
if(!$file->upload_target_type) {
$comment = $oCommentModel->getComment($target_srl);
if($comment->isExists()) {
$file->upload_target_type = 'com';
$file->target_document_srl = $comment->document_srl;
debugPrint($comment->document_srl);
$file_update_args->upload_target_type = $file->upload_target_type;
$comment_list[$target_srl] = $comment;
$doc_srls[] = $comment->document_srl;
}
foreach($comment_output as $val) {
if(!in_array($val->document_srl, $document_srl_list)) $document_srl_list[] = $val->document_srl;
}
// module (페이지인 경우)
if(!$file->upload_target_type) {
$module = $oModuleModel->getModulesInfo($target_srl);
if($module) {
$file->upload_target_type = 'mod';
$file_update_args->upload_target_type = $file->upload_target_type;
$module_list[$module->comment_srl] = $module;
}
}
if($file_update_args->upload_target_type) {
executeQuery('file.updateFile', $file_update_args);
}
}
$args->document_srls = implode(',', $document_srl_list);
$args->list_order = 'document_srl';
$args->order_type = 'desc';
$document_output = executeQueryArray('document.getDocuments', $args);
// 이미 구해진 데이터가 있는 확인
for($i = 0; $i < $com_srls_count; ++$i) {
if($comment_list[$com_srls[$i]]) delete($com_srls[$i]);
}
for($i = 0; $i < $doc_srls_count; ++$i) {
if($document_list[$doc_srls[$i]]) delete($doc_srls[$i]);
}
for($i = 0; $i < $mod_srls_count; ++$i) {
if($module_list[$mod_srls[$i]]) delete($mod_srls[$i]);
}
}
if($document_output->data) {
foreach($document_output->data as $document) {
if($file->upload_target_type) {
if(!in_array($file->upload_target_srl, ${$file->upload_target_type.'_srls'})) {
${$file->upload_target_type.'_srls'}[] = $target_srl;
}
}
$file_list[$file_srl] = $file;
$mod_srls[] = $file->module_srl;
}
// 중복 제거
$doc_srls = array_unique($doc_srls);
$com_srls = array_unique($com_srls);
$mod_srls = array_unique($mod_srls);
// 댓글 목록
$com_srls_count = count($com_srls);
if($com_srls_count) {
$comment_output = $oCommentModel->getComments($com_srls);
foreach($comment_output as $comment) {
$comment_list[$comment->comment_srl] = $comment;
$doc_srls[] = $comment->document_srl;
}
}
// 문서 목록
$doc_srls_count = count($doc_srls);
if($doc_srls_count) {
$document_output = $oDocumentModel->getDocuments($doc_srls);
foreach($document_output as $document) {
$document_list[$document->document_srl] = $document;
}
}
// 모듈 목록
$mod_srls_count = count($mod_srls);
if($mod_srls_count) {
$module_output = $oModuleModel->getModulesInfo($mod_srls);
foreach($module_output as $module) {
$module_list[$module->module_srl] = $module;
}
}
foreach($file_list as $srl => $file) {
if($file->upload_target_type == 'com') {
$file_list[$srl]->target_document_srl = $comment_list[$file->upload_target_srl]->document_srl;
}
}
}
Context::set('file_list', $file_list);
Context::set('document_list', $document_list);
Context::set('comment_list', $comment_list);
Context::set('module_list', $module_list);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('file_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
Context::set('document_list', $document_list);
Context::set('module_list', $module_list);
// 템플릿 지정
$this->setTemplatePath($this->module_path.'tpl');

View file

@ -49,6 +49,7 @@
* @brief 설치가 이상이 없는지 체크하는 method
**/
function checkUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
// 2007. 10. 17 글/댓글의 입력/수정/삭제에 대한 trigger 등록
@ -69,6 +70,9 @@
// 2007. 10. 19 출력하기 전에 file 권한등을 세팅하는 트리거 호출
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before')) return true;
// 타겟 판별용 필드
if(!$oDB->isColumnExists('files', 'upload_target_type')) return true;
return false;
}
@ -76,6 +80,7 @@
* @brief 업데이트 실행
**/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
@ -118,6 +123,9 @@
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before'))
$oModuleController->insertTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before');
// 타겟 판별용 필드
if(!$oDB->isColumnExists('files', 'upload_target_type')) $oDB->addColumn('files', 'upload_target_type', 'char', '3');
return new Object(0, 'success_updated');
}

View file

@ -4,6 +4,7 @@
</tables>
<columns>
<column name="upload_target_srl" var="upload_target_srl" filter="number" default="0" notnull="notnull" />
<column name="upload_target_type" var="upload_target_type" />
<column name="module_srl" var="module_srl" filter="number" default="0" notnull="notnull" />
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
<column name="regdate" var="regdate" default="curdate()" />

View file

@ -1,6 +1,7 @@
<table name="files">
<column name="file_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="upload_target_srl" type="number" size="11" default="0" notnull="notnull" index="idx_upload_target_srl" />
<column name="upload_target_type" type="char" size="3" index="idx_upload_target_type" />
<column name="sid" type="varchar" size="60" />
<column name="module_srl" type="number" size="11" default="0" notnull="notnull" index="idx_module_srl" />
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" />

View file

@ -51,44 +51,60 @@
<th scope="col"><div>{$lang->cmd_download}</div></th>
<th scope="col"><div>{$lang->date}</div></th>
<th scope="col"><div>{$lang->ipaddress}</div></th>
<th scope="col"><div>{$lang->nick_name}</div></th>
</tr>
</thead>
<tbody>
<!--@foreach($file_list as $no => $val)-->
<!--@if($val->upload_target_srl != $cur_upload_target_srl)-->
<!--@if($val->target_document_srl)-->
<!--@if($val->upload_target_type == 'com')-->
{@ $document_srl = $val->target_document_srl}
{@ $move_uri = getUrl('', 'document_srl', $document_srl).'#comment_'.$val->upload_target_srl}
<!--@else-->
<!--@elseif($val->upload_target_type == 'doc')-->
{@ $document_srl = $val->upload_target_srl}
{@ $move_uri = getUrl('', 'document_srl', $document_srl)}
<!--@end-->
{@ $cur_upload_target_srl = $val->upload_target_srl}
<tr class="row{$cycle_idx} bg1">
<th colspan="8">
<!--@if(!$document_list[$document_srl])-->
{$lang->cmd_save}
<th colspan="9">
<!--@if(!$val->upload_target_type)-->
{$lang->is_stand_by}
<!--@else-->
<a href="{getUrl('', 'mid', $module_list[$val->module_srl]->mid)}" onclick="window.open(this.href);return false;" class="blue">{$module_list[$val->module_srl]->browser_title}</a> - <a href="{$move_uri}" onclick="window.open(this.href);return false;">{htmlspecialchars($document_list[$document_srl]->title)}</a>
<!--@if($val->upload_target_type == 'com')-->[{$lang->comment}] <!--@end-->
<!--@if($val->upload_target_type == 'mod')-->[{$lang->module}] <!--@end-->
<!--@if($val->upload_target_type == 'doc' && $document_list[$document_srl]->get('module_srl') == $document_list[$document_srl]->get('member_srl'))-->[임시저장] <!--@end-->
<a href="{getUrl('', 'mid', $module_list[$val->module_srl]->mid)}" onclick="window.open(this.href);return false;">{$module_list[$val->module_srl]->browser_title}</a>
<!--@if($val->upload_target_type == 'doc' || $val->upload_target_type == 'com')-->
- <!--@if($document_list[$document_srl]->get('module_srl') != $document_list[$document_srl]->get('member_srl'))--><a href="{$move_uri}" onclick="window.open(this.href);return false;">{$document_list[$document_srl]->getTitle()}</a><!--@else-->{$document_list[$document_srl]->getTitle()}<!--@end-->
<!--@end-->
<!--@end-->
</th>
</tr>
<!--@endif-->
<tr>
<td class="center number">{$no}</td>
<td class="center"><input type="checkbox" name="cart" value="{$val->file_srl}" /></td>
<td><a href="{$val->download_url}" class="red">{htmlspecialchars($val->source_filename)}</a></td>
<td class="tCenter number">{$no}</td>
<td class="tCenter"><input type="checkbox" name="cart" value="{$val->file_srl}" /></td>
<td class="wide"><a href="{$val->download_url}" class="red">{htmlspecialchars($val->source_filename)}</a></td>
<td class="number tRight">{FileHandler::filesize($val->file_size)}</td>
<td class="tCenter">
<!--@if($val->isvalid=='Y')-->
<td class="blue center">{$lang->is_valid}</td>
{$lang->is_valid}
<!--@else-->
<td class="red center">{$lang->is_stand_by}</td>
{$lang->is_stand_by}
<!--@end-->
<td class="number center">{$val->download_count}</td>
<td class="date center nowrap">{zdate($val->regdate,"Y-m-d")}</td>
<td class="number left nowrap"><a href="{getUrl('search_target','ipaddress','search_keyword',$val->ipaddress)}">{$val->ipaddress}</a></td>
</td>
<td class="number tCenter">{$val->download_count}</td>
<td class="date tCenter nowrap" title="{zdate($val->regdate,"Y-m-d H:i:s")}">{zdate($val->regdate,"Y-m-d")}</td>
<td class="number tCenter nowrap"><a href="{getUrl('search_target','ipaddress','search_keyword',$val->ipaddress)}">{$val->ipaddress}</a></td>
<td class="nowrap">
<!--@if($val->upload_target_type == 'doc')-->
<span class="member_{$document_list[$document_srl]->get('member_srl')}">{$document_list[$document_srl]->getNickName()}</span>
<!--@elseif($val->upload_target_type == 'com')-->
<span class="member_{$comment_list[$val->upload_target_srl]->get('member_srl')}">{$comment_list[$val->upload_target_srl]->getNickName()}</span>
<!--@end-->
</td>
</tr>
<!--@endforeach-->
</tbody>