css 및 js 호출순서 조정기능 추가

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5785 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2009-03-06 05:33:56 +00:00
parent 4f380d9c48
commit 61851f1dfe
2149 changed files with 109090 additions and 18689 deletions

View file

@ -9,33 +9,23 @@
/**
* @brief 초기화
*
* board 모듈은 일반 사용과 관리자용으로 나누어진다.\n
**/
function init() {
/**
* 스킨등에서 사용될 module_srl이나 module_info등을 context set
* 기본 모듈 정보들 설정 (list_count, page_count는 게시판 모듈 전용 정보이고 기본 값에 대한 처리를 )
**/
// 템플릿에서 사용할 변수를 Context::set()
if($this->module_srl) Context::set('module_srl',$this->module_srl);
// 현재 호출된 게시판의 모듈 정보를 module_info 라는 이름으로 context setting
Context::set('module_info',$this->module_info);
// 기본 모듈 정보들 설정 (list_count, page_count는 게시판 모듈 전용 정보이고 기본 값에 대한 처리를 함)
if($this->module_info->list_count) $this->list_count = $this->module_info->list_count;
if($this->module_info->search_list_count) $this->search_list_count = $this->module_info->search_list_count;
if($this->module_info->page_count) $this->page_count = $this->module_info->page_count;
$this->except_notice = $this->module_info->except_notice == 'N' ? false : true;
// 일반 목록에서 공지사항을 제외하는 기능의 체크
if($this->module_info->except_notice == 'N') $this->except_notice = false;
else $this->except_notice = true;
// 상담 기능 체크. 현재 게시판의 관리자이면 상담기능을 off시킴
/**
* 상담 기능 체크. 현재 게시판의 관리자이면 상담기능을 off시킴
* 현재 사용자가 비로그인 사용자라면 글쓰기/댓글쓰기/목록보기/글보기 권한을 제거함
**/
if($this->module_info->consultation == 'Y' && !$this->grant->manager) {
$this->consultation = true;
// 현재 사용자가 비로그인 사용자라면 글쓰기/댓글쓰기/목록보기/글보기 권한을 제거함
if(!Context::get('is_logged')) $this->grant->list = $this->grant->write_document = $this->grant->write_comment = $this->grant->view = false;
} else {
$this->consultation = false;
@ -43,16 +33,27 @@
/**
* 스킨 경로를 미리 template_path 라는 변수로 설정함
* 스킨이 존재하지 않는다면 xe_board로 변경
**/
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
// 만약 스킨 경로가 없다면 xe_board로 변경
if(!is_dir($template_path)) {
$this->module_info->skin = 'xe_board';
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
}
$this->setTemplatePath($template_path);
/**
* 확장 변수 사용시 미리 확장변수의 대상 키들을 가져와서 context set
**/
$oDocumentModel = &getModel('document');
$extra_keys = $oDocumentModel->getExtraKeys($this->module_info->module_srl);
Context::set('extra_keys', $extra_keys);
/**
* 게시판 전반적으로 사용되는 javascript, JS 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'input_password.xml');
Context::addJsFile($this->module_path.'tpl/js/board.js');
}
/**
@ -62,7 +63,7 @@
/**
* 목록보기 권한 체크 (모든 권한은 ModuleObject에서 xml 정보와 module_info의 grant 값을 비교하여 미리 설정하여 놓음)
**/
if(!$this->grant->list) return $this->dispBoardMessage('msg_not_permitted');
if(!$this->grant->access) return $this->dispBoardMessage('msg_not_permitted');
/**
* 카테고리를 사용하는지 확인후 사용시 카테고리 목록을 구해와서 Context에 세팅
@ -71,21 +72,21 @@
/**
* 목록이 노출될때 같이 나오는 검색 옵션을 정리하여 스킨에서 있도록 context set
* 확장변수에서 검색 선택된 항목이 있으면 역시 추가
**/
// 템플릿에서 사용할 검색옵션 세팅 (검색옵션 key값은 미리 선언되어 있는데 이에 대한 언어별 변경을 함)
foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
// 모듈정보를 확인하여 확장변수에서도 검색이 설정되어 있는지 확인
for($i=1;$i<=20;$i++) {
$ex_name = trim($this->module_info->extra_vars[$i]->name);
if(!$ex_name) continue;
if($this->module_info->extra_vars[$i]->search == 'Y') $search_option['extra_vars'.$i] = $ex_name;
$extra_keys = Context::get('extra_keys');
if($extra_keys) {
foreach($extra_keys as $key => $val) {
if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
}
}
Context::set('search_option', $search_option);
// 게시글을 가져옴
$this->dispBoardContentView();
// if(!$output->toBool()) return;
// 공지사항 목록을 구해서 context set (공지사항을 매페이지 제일 상단에 위치하기 위해서)
$this->dispBoardNoticeList();
@ -93,88 +94,105 @@
// 목록
$this->dispBoardContentList();
/**
* 사용되는 javascript 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'search.xml');
// template_file을 list.html로 지정
$this->setTemplateFile('list');
}
/**
* @brief 카테고리 항목을 구해와서 스킨에서 사용할 있도록 세팅
**/
function dispBoardCategoryList(){
// 카테고리를 사용할때에만 데이터를 추출
if($this->module_info->use_category=='Y') {
$oDocumentModel = &getModel('document');
Context::set('category_list', $oDocumentModel->getCategoryList($this->module_srl));
}
}
/**
* @brief 선택된 게시글이 있을 경우 글을 가져와서 스킨에서 사용하도록 세팅
**/
function dispBoardContentView(){
$oDocumentModel = &getModel('document');
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
// 목록 구현에 필요한 변수들을 가져온다
// 요청된 변수 값들을 정리
$document_srl = Context::get('document_srl');
$page = Context::get('page');
// 혹시 선택된 문서가 있다면 해당 문서에 대한 객체를 생성함
// (일단 빈객체를 만드는 것은 선택된 글이 없을때 스킨에서 object 오류발생하는 것을 막기 위함)
$oDocument = $oDocumentModel->getDocument(0);
// document model 객체 생성
$oDocumentModel = &getModel('document');
// document_srl이 있다면 해당 글을 구해와서 $oDocument로 세팅
/**
* 요청된 문서 번호가 있다면 문서를 구함
**/
if($document_srl) {
$oDocument = $oDocumentModel->getDocument($document_srl);
// 글에 대한 정보를 구함
$oDocument->setDocument($document_srl);
// 상담기능이 사용되고 공지사항이 아니고 사용자의 글도 아니면 무시
if($oDocument->isExists() && $this->consultation && !$oDocument->isNotice()) {
$logged_info = Context::get('logged_info');
if($oDocument->get('member_srl')!=$logged_info->member_srl) $oDocument = new DocumentItem();
}
// 글이 존재하지 않으면 글이 존재 하지 않는다는 오류 메세지 출력
if(!$oDocument->isExists()) {
unset($document_srl);
Context::set('document_srl','',true);
$this->alertMessage('msg_not_founded');
// 글이 존재하면 글 보기 권한에 대한 확인과 조회수증가/ 브라우저 타이틀의 설정을 함
} else {
// 해당 문서가 존재할 경우 필요한 처리를 함
if($oDocument->isExists()) {
// 글과 요청된 모듈이 다르다면 오류 표시
if($oDocument->get('module_srl')!=Context::get('module_srl') ) return $this->stop('msg_invalid_request');
if($oDocument->get('module_srl')!=$this->module_info->module_srl ) return $this->stop('msg_invalid_request');
// 관리 권한이 있다면 권한을 부여
if($this->grant->manager) $oDocument->setGrant();
// 글 보기 권한을 체크해서 권한이 없으면 오류 메세지 출력하도록 처리
if(!$this->grant->view && !$oDocument->isGranted()) {
$oDocument = null;
$oDocument = $oDocumentModel->getDocument(0);
Context::set('document_srl','',true);
$this->alertMessage('msg_not_permitted');
} else {
// 브라우저 타이틀에 글의 제목을 추가
Context::addBrowserTitle($oDocument->getTitleText());
// 조회수 증가 (비밀글일 경우 권한 체크)
if(!$oDocument->isSecret() || $oDocument->isGranted()) $oDocument->updateReadedCount();
// 비밀글일때 컨텐츠를 보여주지 말자.
if($oDocument->isSecret() && !$oDocument->isGranted()){
$oDocument->add('content',Context::getLang('thisissecret'));
$obj = null;
for($i=1;$i<=20;$i++) $obj->{"extra_vars".$i} = '';
$oDocument->adds($obj);
}
// 상담기능이 사용되고 공지사항이 아니고 사용자의 글도 아니면 무시
if($this->consultation && !$oDocument->isNotice()) {
$logged_info = Context::get('logged_info');
if($oDocument->get('member_srl')!=$logged_info->member_srl) $oDocument = $oDocumentModel->getDocument(0);
}
// 요청된 문서번호의 문서가 없으면 document_srl null 처리 및 경고 메세지 출력
} else {
Context::set('document_srl','',true);
$this->alertMessage('msg_not_founded');
}
/**
* 요청된 문서 번호가 아예 없다면 문서 객체 생성
**/
} else {
$oDocument = $oDocumentModel->getDocument(0);
}
/**
* 보기 권한을 체크해서 권한이 없으면 오류 메세지 출력하도록 처리
**/
if($oDocument->isExists()) {
if(!$this->grant->view && !$oDocument->isGranted()) {
$oDocument = $oDocumentModel->getDocument(0);
Context::set('document_srl','',true);
$this->alertMessage('msg_not_permitted');
} else {
// 브라우저 타이틀에 글의 제목을 추가
Context::addBrowserTitle($oDocument->getTitleText());
// 조회수 증가 (비밀글일 경우 권한 체크)
if(!$oDocument->isSecret() || $oDocument->isGranted()) $oDocument->updateReadedCount();
// 비밀글일때 컨텐츠를 보여주지 말자.
if($oDocument->isSecret() && !$oDocument->isGranted()) $oDocument->add('content',Context::getLang('thisissecret'));
}
}
// 스킨에서 사용하기 위해 context set
// 스킨에서 사용할 oDocument 변수 세팅
Context::set('oDocument', $oDocument);
/**
* 사용되는 javascript 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
// return new Object();
}
/**
* @brief 선택된 글이 있을 경우 첨부파일에 대한 정보를 API 에서 사용할 있도록 세팅
**/
function dispBoardContentFileList(){
$oDocumentModel = &getModel('document');
$document_srl = Context::get('document_srl');
@ -182,6 +200,9 @@
Context::set('file_list',$oDocument->getUploadedFiles());
}
/**
* @brief 선택된 글이 있을 경우 글의 댓글 목록을 API 에서 사용할 있도록 세팅
**/
function dispBoardContentCommentList(){
$oDocumentModel = &getModel('document');
$document_srl = Context::get('document_srl');
@ -197,42 +218,61 @@
Context::set('comment_list',$comment_list);
}
/**
* @brief 공지사항이 있을 경우 API에서 사용할 있게 하기 위해서 세팅
**/
function dispBoardNoticeList(){
$oDocumentModel = &getModel('document');
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
$args->module_srl = $this->module_srl;
$notice_output = $oDocumentModel->getNoticeList($args);
Context::set('notice_list', $notice_output->data);
}
/**
* @brief 게시글 목록
**/
function dispBoardContentList(){
// 만약 목록 보기 권한이 없을 경우 목록을 보여주지 않음
if(!$this->grant->list) {
Context::set('document_list', array());
Context::set('total_count', 0);
Context::set('total_page', 1);
Context::set('page', 1);
Context::set('page_navigation', new PageHandler(0,0,1,10));
return;
}
$oDocumentModel = &getModel('document');
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
// 목록을 구하기 위한 대상 모듈/ 페이지 수/ 목록 수/ 페이지 목록 수에 대한 옵션 설정
$args->page = Context::get('page');; ///< 페이지
$args->list_count = $this->list_count; ///< 한페이지에 보여줄 글 수
$args->page_count = $this->page_count; ///< 페이지 네비게이션에 나타날 페이지의 수
$args->module_srl = $this->module_srl;
$args->page = Context::get('page');
$args->list_count = $this->list_count;
$args->page_count = $this->page_count;
// 검색과 정렬을 위한 변수 설정
$args->search_target = Context::get('search_target'); ///< 검색 대상 (title, contents...)
$args->search_keyword = Context::get('search_keyword'); ///< 검색어
$args->search_target = Context::get('search_target');
$args->search_keyword = Context::get('search_keyword');
// 카테고리를 사용한다면 카테고리 값을 받음
if($this->module_info->use_category=='Y') $args->category_srl = Context::get('category'); ///< 카테고리 사용시 선택된 카테고리
// 지정된 정렬값이 없다면 스킨에서 설정한 정렬 값을 이용함
$args->sort_index = Context::get('sort_index');
$args->order_type = Context::get('order_type');
// 지정된 정렬값이 없다면 스킨에서 설정한 정렬 값을 이용함
if(!in_array($args->sort_index, $this->order_target)) $args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order';
if(!in_array($args->order_type, array('asc','desc'))) $args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc';
$oDocument = $oDocumentModel->getDocument(Context::get('document_srl'));
// 특정 문서의 permalink로 직접 접속할 경우 page값을 직접 구함
if(count($_GET)==1 && isset($_GET['document_srl']) && $oDocument->isExists() && !$oDocument->isNotice()) {
$page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $page);
$args->page = $page;
$_get = $_GET;
if(count($_get)==2) unset($_get['mid']);
if(count($_get)==1 && ($_GET['document_srl'] || $_GET['entry'])) {
$oDocument = $oDocumentModel->getDocument(Context::get('document_srl'));
if($oDocument->isExists() && !$oDocument->isNotice()) {
$page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $page);
$args->page = $page;
}
}
// 만약 카테고리가 있거나 검색어가 있으면list_count를 search_list_count 로 이용
@ -251,8 +291,11 @@
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
}
// 목록 설정값을 세팅
$oBoardModel = &getModel('board');
Context::set('list_config', $oBoardModel->getListConfig($this->module_info->module_srl));
}
/**
* @brief 태그 목록 모두 보기
@ -298,7 +341,6 @@
* 카테고리를 사용하는지 확인후 사용시 카테고리 목록을 구해와서 Context에 세팅, 권한도 함께 체크
**/
if($this->module_info->use_category=='Y') {
// 로그인한 사용자의 그룹 정보를 구함
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
@ -327,30 +369,21 @@
// GET parameter에서 document_srl을 가져옴
$document_srl = Context::get('document_srl');
$oDocument = $oDocumentModel->getDocument(0, $this->grant->manager);
$oDocument->setDocument($document_srl);
$oDocument->add('module_srl', $this->module_srl);
// 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로
if($oDocument->isExists()&&!$oDocument->isGranted()) return $this->setTemplateFile('input_password_form');
if(!$oDocument->isExists())
{
if(!$oDocument->isExists()) {
$oModuleModel = &getModel('module');
$point_config = $oModuleModel->getModulePartConfig('point',$this->module_srl);
$logged_info = Context::get('logged_info');
$oPointModel = &getModel('point');
$pointForInsert = $point_config["insert_document"];
if($pointForInsert < 0)
{
if( !$logged_info )
{
return $this->dispBoardMessage('msg_not_permitted');
}
else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
{
return $this->dispBoardMessage('msg_not_enough_point');
}
if($pointForInsert < 0) {
if( !$logged_info ) return $this->dispBoardMessage('msg_not_permitted');
else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 ) return $this->dispBoardMessage('msg_not_enough_point');
}
}
@ -359,7 +392,15 @@
// 확장변수처리를 위해 xml_js_filter를 직접 header에 적용
$oDocumentController = &getController('document');
$oDocumentController->addXmlJsFilter($this->module_info);
$oDocumentController->addXmlJsFilter($this->module_info->module_srl);
// 존재하는 글이면 확장변수 값을 context set
if($oDocument->isExists()) Context::set('extra_keys', $oDocument->getExtraVars());
/**
* 사용되는 javascript 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
$this->setTemplateFile('write_form');
}
@ -388,6 +429,11 @@
Context::set('oDocument',$oDocument);
/**
* 필요한 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_document.xml');
$this->setTemplateFile('delete_form');
}
@ -416,6 +462,11 @@
Context::set('oSourceComment',$oSourceComment);
Context::set('oComment',$oComment);
/**
* 필요한 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
@ -449,6 +500,11 @@
Context::set('oSourceComment',$oSourceComment);
Context::set('oComment',$oComment);
/**
* 사용되는 javascript 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
@ -480,6 +536,11 @@
Context::set('oSourceComment', $oCommentModel->getComment());
Context::set('oComment', $oComment);
/**
* 사용되는 javascript 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
@ -507,6 +568,11 @@
Context::set('oComment',$oComment);
/**
* 필요한 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_comment.xml');
$this->setTemplateFile('delete_comment_form');
}
@ -527,6 +593,11 @@
Context::set('trackback',$trackback);
/**
* 필요한 필터 추가
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_trackback.xml');
$this->setTemplateFile('delete_trackback_form');
}