mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
확장변수 + 다국어 기능 수정
- 글등록시 언어가 기본 언어이고 수정시 다른 언어로 수정하면 각 언어별 데이터가 보관 잘 되도록 개선 - 확장변수 값이 없는 게시글을 수정시 변수 폼이 제대로 나타나도록 수정 - 퍼포먼스 증대 git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5947 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9e80cf561e
commit
17513d6b62
5 changed files with 108 additions and 117 deletions
|
|
@ -4,19 +4,17 @@
|
|||
* @author zero (zero@nzeo.com)
|
||||
* @brief 게시글, 회원등에서 사용하는 확장변수를 핸들링하는 클래스
|
||||
*
|
||||
* php4대비 class static 변수가 안됨으로 $GLOBALS['XE_EXTRAVARS']를 이용해서 같은 효과 냄
|
||||
**/
|
||||
class ExtraVar {
|
||||
|
||||
var $module_srl = null;
|
||||
var $keys = null;
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
**/
|
||||
function &getInstance($module_srl) {
|
||||
static $oInstance = array();
|
||||
if(!$oInstance[$module_srl]) $oInstance[$module_srl] = new ExtraVar($module_srl);
|
||||
return $oInstance[$module_srl];
|
||||
return new ExtraVar($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,29 +24,15 @@
|
|||
$this->module_srl = $module_srl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 불필요한 등록을 피하기 위해서 특정 module_srl에 확장변수가 등록되었는지 확인
|
||||
**/
|
||||
function isSettedExtraVars() {
|
||||
return isset($GLOBALS['XE_EXTRAVARS'][$this->module_srl]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 확장변수 키를 등록
|
||||
* php4를 대비해 class static 멤버변수 대신 $GLOBAL 변수 사용
|
||||
* @param module_srl, idx, name, type, default, desc, is_required, search, value
|
||||
**/
|
||||
function setExtraVarKeys($extra_keys) {
|
||||
if(!$this->isSettedExtraVars()) {
|
||||
if(!$extra_keys || !count($extra_keys)) $GLOBALS['XE_EXTRAVARS'][$this->module_srl] = array();
|
||||
else {
|
||||
if(!is_array($GLOBALS['XE_EXTRAVARS'][$this->module_srl])) $GLOBALS['XE_EXTRAVARS'][$this->module_srl] = array();
|
||||
foreach($extra_keys as $key => $val) {
|
||||
$obj = null;
|
||||
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
|
||||
$GLOBALS['XE_EXTRAVARS'][$this->module_srl][$val->idx] = $obj;
|
||||
}
|
||||
}
|
||||
foreach($extra_keys as $key => $val) {
|
||||
$obj = null;
|
||||
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
|
||||
$this->keys[$val->idx] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +40,7 @@
|
|||
* @brief 확장변수 객체 배열 return
|
||||
**/
|
||||
function getExtraVars() {
|
||||
if(!$this->isSettedExtraVars()) return array();
|
||||
return $GLOBALS['XE_EXTRAVARS'][$this->module_srl];
|
||||
return $this->keys;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,8 +363,8 @@
|
|||
}
|
||||
|
||||
// 제목/내용의 다국어 확장변수 등록
|
||||
if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title);
|
||||
if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content);
|
||||
if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
|
||||
if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
|
||||
|
||||
// 성공하였을 경우 category_srl이 있으면 카테고리 update
|
||||
if($source_obj->get('category_srl')!=$obj->category_srl) {
|
||||
|
|
|
|||
|
|
@ -24,65 +24,69 @@
|
|||
* @brief 확장변수를 매 문서마다 처리하지 않기 위해 매크로성으로 일괄 select 및 적용
|
||||
**/
|
||||
function setToAllDocumentExtraVars() {
|
||||
static $checked_documents = array();
|
||||
|
||||
// XE에서 모든 문서 객체는 XE_DOCUMENT_LIST라는 전역 변수에 세팅을 함
|
||||
if(!count($GLOBALS['XE_DOCUMENT_LIST'])) continue;
|
||||
|
||||
// 모든 호출된 문서 객체를 찾아서 확장변수가 설정되었는지를 확인
|
||||
$document_srls = array();
|
||||
foreach($GLOBALS['XE_DOCUMENT_LIST'] as $key => $val) {
|
||||
if(!$val->document_srl || isset($GLOBALS['XE_EXTRA_VARS'][$val->document_srl])) continue;
|
||||
$document_srls[$key] = $val->document_srl;
|
||||
if($checked_documents[$val->document_srl]) continue;
|
||||
$checked_documents[$val->document_srl] = true;
|
||||
$document_srls[] = $val->document_srl;
|
||||
}
|
||||
|
||||
// 검출된 문서 번호가 없으면 return
|
||||
if(!count($document_srls)) return;
|
||||
|
||||
$lang_code = Context::getLangType();
|
||||
|
||||
// 확장변수 미지정된 문서에 대해서 일단 현재 접속자의 언어코드로 확장변수를 검색
|
||||
$obj->document_srl = implode(',',$document_srls);
|
||||
$output = executeQueryArray('document.getDocumentsExtraVars', $obj);
|
||||
|
||||
$output = executeQueryArray('document.getDocumentExtraVars', $obj);
|
||||
if($output->toBool() && $output->data) {
|
||||
$setted = array();
|
||||
|
||||
foreach($output->data as $key => $val) {
|
||||
if(!$val->document_srl) continue;
|
||||
|
||||
if($val->idx<0 && $val->lang_code == $lang_code) {
|
||||
if($val->idx == -1) $GLOBALS['XE_DOCUMENT_LIST'][$val->document_srl]->add('title', $val->value);
|
||||
else if($val->idx == -2) $GLOBALS['XE_DOCUMENT_LIST'][$val->document_srl]->add('content', $val->value);
|
||||
} elseif($val->idx>0) {
|
||||
|
||||
if(!isset($GLOBALS['XE_EXTRA_VARS'][$val->document_srl])){
|
||||
$module_srl = $GLOBALS['XE_DOCUMENT_LIST'][$val->document_srl]->get('module_srl');
|
||||
$oExtraItem = $GLOBALS['XE_EXTRAVARS'][$module_srl];
|
||||
$GLOBALS['XE_EXTRA_VARS'][$val->document_srl] = $oExtraItem;
|
||||
}
|
||||
|
||||
if($lang_code == $val->lang_code) {
|
||||
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
|
||||
$GLOBALS['XE_EXTRA_VARS'][$val->document_srl][$val->idx] = $obj;
|
||||
} else if($lang_code == $GLOBALS['XE_DOCUMENT_LIST'][$val->document_srl]->lang_code && !$GLOBALS['XE_EXTRA_VARS'][$val->document_srl][$val->idx]->value) {
|
||||
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
|
||||
$GLOBALS['XE_EXTRA_VARS'][$val->document_srl][$val->idx] = $obj;
|
||||
} else if(!$GLOBALS['XE_EXTRA_VARS'][$val->document_srl][$val->idx]->value) {
|
||||
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
|
||||
$GLOBALS['XE_EXTRA_VARS'][$val->document_srl][$val->idx] = $obj;
|
||||
}
|
||||
}
|
||||
if(!trim($val->value)) continue;
|
||||
if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
|
||||
$extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value);
|
||||
}
|
||||
}
|
||||
|
||||
for($i=0,$c=count($document_srls);$i<$c;$i++) {
|
||||
$document_srl = $document_srls[$i];
|
||||
$oDocument = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
$this->_setExtraVars($oDocument, $extra_vars[$document_srl]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($document_srls as $key => $document_srl) {
|
||||
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])){
|
||||
$module_srl = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->get('module_srl');
|
||||
$oExtraItem = $GLOBALS['XE_EXTRAVARS'][$module_srl];
|
||||
$GLOBALS['XE_EXTRA_VARS'][$document_srl] = $oExtraItem;
|
||||
}
|
||||
function _setExtraVars($oDocument, $vars) {
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
$extra_keys = $this->getExtraKeys($module_srl);
|
||||
$document_srl = $oDocument->document_srl;
|
||||
|
||||
$user_lang_code = Context::getLangType();
|
||||
$document_lang_code = $oDocument->get('lang_code');
|
||||
|
||||
// 확장변수 처리
|
||||
foreach($extra_keys as $idx => $key) {
|
||||
$val = $vars[$idx];
|
||||
if($val[$user_lang_code]) $v = $val[$user_lang_code];
|
||||
else if($val[$document_lang_code]) $v = $val[$document_lang_code];
|
||||
else if($val[0]) $v = $val[0];
|
||||
else $v = null;
|
||||
$extra_keys[$idx]->value = $v;
|
||||
}
|
||||
|
||||
$extra_vars = new ExtraVar($module_srl);
|
||||
$extra_vars->setExtraVarKeys($extra_keys);
|
||||
|
||||
// 제목 처리
|
||||
if($vars[-1][$user_lang_code]) $oDocument->add('title',$vars[-1][$user_lang_code]);
|
||||
|
||||
// 내용 처리
|
||||
if($vars[-2][$user_lang_code]) $oDocument->add('content',$vars[-2][$user_lang_code]);
|
||||
|
||||
$GLOBALS['XE_EXTRA_VARS'][$document_srl] = $extra_vars->getExtraVars();
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,18 +126,27 @@
|
|||
|
||||
$document_count = count($document_list);
|
||||
foreach($document_list as $key => $attribute) {
|
||||
if(!$attribute->document_srl) continue;
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute, false);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
$document_srl = $attribute->document_srl;
|
||||
if(!$document_srl) continue;
|
||||
|
||||
$result[$attribute->document_srl] = $oDocument;
|
||||
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;
|
||||
}
|
||||
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $oDocument;
|
||||
$result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
$this->setToAllDocumentExtraVars();
|
||||
return $result;
|
||||
|
||||
$output = null;
|
||||
foreach($result as $document_srl => $val) {
|
||||
$output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -360,18 +373,24 @@
|
|||
foreach($data as $key => $attribute) {
|
||||
if($except_notice && $attribute->is_notice == 'Y') continue;
|
||||
$document_srl = $attribute->document_srl;
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute, false);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
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;
|
||||
}
|
||||
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $oDocument;
|
||||
|
||||
$output->data[$virtual_number] = $oDocument;
|
||||
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
$virtual_number --;
|
||||
|
||||
}
|
||||
$this->setToAllDocumentExtraVars();
|
||||
|
||||
foreach($output->data as $number => $document) {
|
||||
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -395,15 +414,25 @@
|
|||
$args->order_type = 'asc';
|
||||
$output = executeQueryArray('document.getDocuments', $args);
|
||||
if(!$output->toBool()||!$output->data) return;
|
||||
|
||||
foreach($output->data as $key => $val) {
|
||||
if(!$val->document_srl) continue;
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($val, false);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$val->document_srl] = $oDocument;
|
||||
$result->data[$val->document_srl] = $oDocument;
|
||||
$document_srl = $val->document_srl;
|
||||
if(!$document_srl) continue;
|
||||
|
||||
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($val, false);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
}
|
||||
$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
$this->setToAllDocumentExtraVars();
|
||||
|
||||
foreach($result->data as $document_srl => $val) {
|
||||
$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -412,15 +441,16 @@
|
|||
* $form_include : 글 작성시에 필요한 확장변수의 input form 추가 여부
|
||||
**/
|
||||
function getExtraKeys($module_srl) {
|
||||
$oExtraVar = &ExtraVar::getInstance($module_srl);
|
||||
if(!$oExtraVar->isSettedExtraVars()) {
|
||||
if(!$GLOBALS['XE_EXTRA_KEYS'][$module_srl]) {
|
||||
$oExtraVar = &ExtraVar::getInstance($module_srl);
|
||||
$obj->module_srl = $module_srl;
|
||||
$obj->sort_index = 'var_idx';
|
||||
$obj->order = 'asc';
|
||||
$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
|
||||
$oExtraVar->setExtraVarKeys($output->data);
|
||||
$GLOBALS['XE_EXTRA_KEYS'][$module_srl] = $oExtraVar->getExtraVars();
|
||||
}
|
||||
return $oExtraVar->getExtraVars();
|
||||
return $GLOBALS['XE_EXTRA_KEYS'][$module_srl];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -428,6 +458,7 @@
|
|||
**/
|
||||
function getExtraVars($module_srl, $document_srl) {
|
||||
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) {
|
||||
// 확장변수 값을 추출하여 세팅
|
||||
$oDocument = $this->getDocument($document_srl, false);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
$this->setToAllDocumentExtraVars();
|
||||
|
|
|
|||
|
|
@ -1,36 +1,13 @@
|
|||
<query id="getDocumentExtraVars" action="select">
|
||||
<tables>
|
||||
<table name="document_extra_keys" alias="extra_keys" />
|
||||
<table name="document_extra_vars" alias="extra_vars" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="extra_vars.module_srl" default="extra_keys.module_srl" />
|
||||
<condition operation="in" column="extra_vars.document_srl" var="document_srl" pipe="and" notnull="notnull" />
|
||||
<condition operation="equal" column="extra_vars.var_idx" default="extra_keys.var_idx" pipe="and" />
|
||||
<condition operation="equal" column="extra_vars.lang_code" var="lang_code" pipe="and" />
|
||||
<condition operation="in" column="extra_vars.lang_code" var="lang_codes" pipe="and" />
|
||||
</conditions>
|
||||
</table>
|
||||
<table name="document_extra_vars" alias="extra_vars" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="extra_keys.module_srl" alias="module_srl" />
|
||||
<column name="extra_keys.var_idx" alias="idx" />
|
||||
<column name="extra_keys.var_name" alias="name" />
|
||||
<column name="extra_keys.var_type" alias="type" />
|
||||
<column name="extra_keys.var_is_required" alias="is_required" />
|
||||
<column name="extra_keys.var_search" alias="search" />
|
||||
<column name="extra_keys.var_default" alias="default" />
|
||||
<column name="extra_keys.var_desc" alias="desc" />
|
||||
<column name="extra_keys.eid" alias="eid" />
|
||||
<column name="extra_vars.document_srl" alias="document_srl" />
|
||||
<column name="extra_vars.lang_code" alias="lang_code" />
|
||||
<column name="extra_vars.value" alias="value" />
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="extra_keys.module_srl" var="module_srl" pipe="and" notnull="notnull" />
|
||||
<condition operation="equal" column="extra_keys.var_idx" var="var_idx" pipe="and" />
|
||||
<condition operation="equal" column="extra_keys.eid" var="eid" pipe="and" />
|
||||
<condition operation="more" column="extra_vars.module_srl" default="-1" notnull="notnull" pipe="and" />
|
||||
<condition operation="in" column="extra_vars.document_srl" var="document_srl" notnull="notnull" pipe="and" />
|
||||
<condition operation="more" column="extra_vars.var_idx" default="-2" pipe="and" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="extra_keys.var_idx" order="asc" />
|
||||
</navigation>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
$lang->about_extra_vars_default_value = '다중/단일 선택등 기본값이 여러개가 필요한 경우 , (콤마)로 연결하시면 됩니다';
|
||||
$lang->about_search_virtual_site = '가상 사이트(카페XE등)의 도메인을 입력하신 후 검색하세요.<br/>가상 사이트이외의 모듈은 내용을 비우고 검색하시면 됩니다. (http:// 는 제
|
||||
외)';
|
||||
$lang->about_extra_vars_eid_value = '확장변수에 이름을 적어주세요. ( 영문+[영문+숫자+_] 만 가능)';
|
||||
$lang->about_extra_vars_eid_value = '확장변수의 이름을 적어주세요. ( 영문+[영문+숫자+_] 만 가능)';
|
||||
$lang->about_langcode = '언어별로 다르게 설정하고 싶으시면 언어코드 찾기를 이용해주세요';
|
||||
$lang->about_file_extension= "%s 파일만 가능합니다.";
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue