Merge branch 'develop' into pr/change-object

This commit is contained in:
Kijin Sung 2017-11-30 23:30:21 +09:00
commit 03d74a984f
19 changed files with 179 additions and 134 deletions

View file

@ -470,7 +470,7 @@ class DB
} }
if(!$this->db_type) if(!$this->db_type)
{ {
return; return new BaseObject(-1, 'msg_db_not_setted');
} }
$this->actDBClassStart(); $this->actDBClassStart();
@ -493,7 +493,7 @@ class DB
if(!isset($typeList[$target])) if(!isset($typeList[$target]))
{ {
$this->actDBClassFinish(); $this->actDBClassFinish();
return; return new BaseObject(-1, 'msg_invalid_queryid');
} }
$module = $id_args[1]; $module = $id_args[1];
$id = $id_args[2]; $id = $id_args[2];

View file

@ -30,7 +30,9 @@ class Config
{ {
if (file_exists(\RX_BASEDIR . self::$config_filename)) if (file_exists(\RX_BASEDIR . self::$config_filename))
{ {
ob_start();
self::$_config = (include \RX_BASEDIR . self::$config_filename); self::$_config = (include \RX_BASEDIR . self::$config_filename);
ob_end_clean();
} }
else else
{ {

View file

@ -22,7 +22,9 @@ class ConfigParser
// Load DB info file. // Load DB info file.
if (file_exists(\RX_BASEDIR . Config::$old_db_config_filename)) if (file_exists(\RX_BASEDIR . Config::$old_db_config_filename))
{ {
ob_start();
include \RX_BASEDIR . Config::$old_db_config_filename; include \RX_BASEDIR . Config::$old_db_config_filename;
ob_end_clean();
} }
else else
{ {
@ -32,7 +34,9 @@ class ConfigParser
// Load FTP info file. // Load FTP info file.
if (file_exists(\RX_BASEDIR . Config::$old_ftp_config_filename)) if (file_exists(\RX_BASEDIR . Config::$old_ftp_config_filename))
{ {
ob_start();
include \RX_BASEDIR . Config::$old_ftp_config_filename; include \RX_BASEDIR . Config::$old_ftp_config_filename;
ob_end_clean();
} }
// Load selected language file. // Load selected language file.

View file

@ -86,6 +86,7 @@
URITemplate : window.URITemplate, URITemplate : window.URITemplate,
SecondLevelDomains : window.SecondLevelDomains, SecondLevelDomains : window.SecondLevelDomains,
IPv6 : window.IPv6, IPv6 : window.IPv6,
baseurl : null,
/** /**
* @brief 특정 name을 가진 체크박스들의 checked 속성 변경 * @brief 특정 name을 가진 체크박스들의 checked 속성 변경
@ -198,6 +199,9 @@
/* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */ /* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */
isSameHost: function(url) { isSameHost: function(url) {
if (typeof url !== "string") {
return false;
}
if (url.match(/^\/[^\/]/)) { if (url.match(/^\/[^\/]/)) {
return true; return true;
} }
@ -205,16 +209,21 @@
return false; return false;
} }
var site_baseurl = window.XE.URI(window.request_uri).normalizePort().normalizePathname(); if (!window.XE.baseurl) {
site_baseurl = site_baseurl.hostname() + site_baseurl.directory(); window.XE.baseurl = window.XE.URI(window.request_uri).normalizePort().normalizePathname();
window.XE.baseurl = window.XE.baseurl.hostname() + window.XE.baseurl.directory();
}
var target_url = window.XE.URI(url).normalizePort().normalizePathname(); var target_url = window.XE.URI(url).normalizePort().normalizePathname();
if (target_url.is("urn")) {
return false;
}
if (!target_url.hostname()) { if (!target_url.hostname()) {
target_url = target_url.absoluteTo(window.request_uri); target_url = target_url.absoluteTo(window.request_uri);
} }
target_url = target_url.hostname() + target_url.directory(); target_url = target_url.hostname() + target_url.directory();
return target_url.indexOf(site_baseurl) === 0; return target_url.indexOf(window.XE.baseurl) === 0;
} }
}; };
@ -233,8 +242,8 @@ jQuery(function($) {
/* Tabnapping protection, step 1 */ /* Tabnapping protection, step 1 */
$('a[target]').each(function() { $('a[target]').each(function() {
var $this = $(this); var $this = $(this);
var href = $this.attr('href'); var href = $this.attr('href').trim();
var target = $this.attr('target'); var target = $this.attr('target').trim();
if (!href || !target || target === '_top' || target === '_self' || target === '_parent') { if (!href || !target || target === '_top' || target === '_self' || target === '_parent') {
return; return;
} }
@ -250,8 +259,8 @@ jQuery(function($) {
/* Tabnapping protection, step 2 */ /* Tabnapping protection, step 2 */
$('body').on('click', 'a[target]', function(event) { $('body').on('click', 'a[target]', function(event) {
var $this = $(this); var $this = $(this);
var href = $this.attr('href'); var href = $this.attr('href').trim();
var target = $this.attr('target'); var target = $this.attr('target').trim();
if (!href || !target || target === '_top' || target === '_self' || target === '_parent') { if (!href || !target || target === '_top' || target === '_self' || target === '_parent') {
return; return;
} }

View file

@ -45,6 +45,7 @@ class adminAdminController extends admin
return $output; return $output;
} }
Rhymix\Framework\Cache::delete('admin_menu_langs:' . Context::getLangType());
Rhymix\Framework\Storage::deleteDirectory(\RX_BASEDIR . 'files/cache/menu/admin_lang/'); Rhymix\Framework\Storage::deleteDirectory(\RX_BASEDIR . 'files/cache/menu/admin_lang/');
$this->setRedirectUrl(Context::get('error_return_url')); $this->setRedirectUrl(Context::get('error_return_url'));

View file

@ -624,38 +624,33 @@ class adminAdminModel extends admin
*/ */
function getAdminMenuLang() function getAdminMenuLang()
{ {
$currentLang = Context::getLangType(); static $lang = null;
$cacheFile = sprintf('./files/cache/menu/admin_lang/adminMenu.%s.lang.php', $currentLang);
// Update if no cache file exists or it is older than xml file if ($lang === null)
if(!is_readable($cacheFile))
{ {
$lang = new stdClass(); $lang = Rhymix\Framework\Cache::get('admin_menu_langs:' . Context::getLangType());
}
if ($lang === null)
{
$lang = array();
$oModuleModel = getModel('module'); $oModuleModel = getModel('module');
$installed_module_list = $oModuleModel->getModulesXmlInfo(); $installed_module_list = $oModuleModel->getModulesXmlInfo();
foreach($installed_module_list as $key => $value)
$this->gnbLangBuffer = '<?php $lang = new stdClass();';
foreach($installed_module_list AS $key => $value)
{ {
$moduleActionInfo = $oModuleModel->getModuleActionXml($value->module); $moduleActionInfo = $oModuleModel->getModuleActionXml($value->module);
if(is_object($moduleActionInfo->menu)) if(is_object($moduleActionInfo->menu))
{ {
foreach($moduleActionInfo->menu AS $key2 => $value2) foreach($moduleActionInfo->menu as $key2 => $value2)
{ {
$lang->menu_gnb_sub[$key2] = $value2->title; $lang[$key2] = $value2->title;
$this->gnbLangBuffer .=sprintf('$lang->menu_gnb_sub[\'%s\'] = \'%s\';', $key2, $value2->title);
} }
} }
} }
$this->gnbLangBuffer .= ' ?>';
FileHandler::writeFile($cacheFile, $this->gnbLangBuffer);
}
else
{
include $cacheFile;
}
return $lang->menu_gnb_sub; Rhymix\Framework\Cache::set('admin_menu_langs:' . Context::getLangType(), $lang, 0, true);
}
return $lang;
} }
/** /**

View file

@ -2299,7 +2299,7 @@ class documentController extends document
{ {
foreach($langs as $key => $val) foreach($langs as $key => $val)
{ {
$xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); $xml_header_buff .= sprintf('$_titles[%d][%s] = %s; ', $category_srl, var_export($key, true), var_export(escape($val, false), true));
} }
} }
@ -2308,12 +2308,12 @@ class documentController extends document
{ {
foreach($langx as $key => $val) foreach($langx as $key => $val)
{ {
$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); $xml_header_buff .= sprintf('$_descriptions[%d][%s] = %s; ', $category_srl, var_export($key, true), var_export(escape($val, false), true));
} }
} }
$attribute = sprintf( $attribute = sprintf(
'mid="%s" module_srl="%d" node_srl="%d" parent_srl="%d" category_srl="%d" text="<?php echo (%s?($_titles[%d][$lang_type]):"")?>" url="%s" expand="%s" color="%s" description="<?php echo (%s?($_descriptions[%d][$lang_type]):"")?>" document_count="%d" ', 'mid="%s" module_srl="%d" node_srl="%d" parent_srl="%d" category_srl="%d" text="<?php echo (%s?($_titles[%d][$lang_type]):"")?>" url=%s expand=%s color=%s description="<?php echo (%s?($_descriptions[%d][$lang_type]):"")?>" document_count="%d" ',
$mid, $mid,
$module_srl, $module_srl,
$category_srl, $category_srl,
@ -2321,9 +2321,9 @@ class documentController extends document
$category_srl, $category_srl,
$group_check_code, $group_check_code,
$category_srl, $category_srl,
getUrl('','mid',$node->mid,'category',$category_srl), str_replace("'", '"', var_export(getUrl('','mid',$node->mid,'category',$category_srl), true)),
$expand, str_replace("'", '"', var_export($expand, true)),
htmlspecialchars($color, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), str_replace("'", '"', var_export(escape($color, false), true)),
$group_check_code, $group_check_code,
$category_srl, $category_srl,
$node->document_count $node->document_count
@ -2388,10 +2388,10 @@ class documentController extends document
{ {
$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
$php_header_buff .= sprintf( $php_header_buff .= sprintf(
'$_titles[%d]["%s"] = "%s"; ', '$_titles[%d][%s] = %s; ',
$category_srl, $category_srl,
$key, var_export($key, true),
str_replace('"','\\"', $val) var_export($val, true)
); );
} }
} }
@ -2404,17 +2404,17 @@ class documentController extends document
{ {
$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
$php_header_buff .= sprintf( $php_header_buff .= sprintf(
'$_descriptions[%d]["%s"] = "%s"; ', '$_descriptions[%d][%s] = %s; ',
$category_srl, $category_srl,
$key, var_export($key, true),
str_replace('"','\\"', $val) var_export($val, true)
); );
} }
} }
// Create attributes(Use the category_srl_list to check whether to belong to the menu's node. It seems to be tricky but fast fast and powerful;) // Create attributes(Use the category_srl_list to check whether to belong to the menu's node. It seems to be tricky but fast fast and powerful;)
$attribute = sprintf( $attribute = sprintf(
'"mid" => "%s", "module_srl" => "%d","node_srl"=>"%s","category_srl"=>"%s","parent_srl"=>"%s","text"=>$_titles[%d][$lang_type],"selected"=>(in_array(Context::get("category"),array(%s))?1:0),"expand"=>"%s","color"=>"%s","description"=>$_descriptions[%d][$lang_type],"list"=>array(%s),"document_count"=>"%d","grant"=>%s?true:false', '"mid" => "%s", "module_srl" => "%d","node_srl"=>"%d","category_srl"=>"%d","parent_srl"=>"%d","text"=>$_titles[%d][$lang_type],"selected"=>(in_array(Context::get("category"),array(%s))?1:0),"expand"=>%s,"color"=>%s,"description"=>$_descriptions[%d][$lang_type],"list"=>array(%s),"document_count"=>"%d","grant"=>%s?true:false',
$node->mid, $node->mid,
$node->module_srl, $node->module_srl,
$node->category_srl, $node->category_srl,
@ -2422,8 +2422,8 @@ class documentController extends document
$node->parent_srl, $node->parent_srl,
$node->category_srl, $node->category_srl,
$selected, $selected,
$expand, var_export($expand, true),
$node->color, var_export($node->color, true),
$node->category_srl, $node->category_srl,
$child_buff, $child_buff,
$node->document_count, $node->document_count,

View file

@ -492,7 +492,7 @@ class memberAdminController extends member
$signupItem->required = in_array($key, $orgRequireds); $signupItem->required = in_array($key, $orgRequireds);
$signupItem->isUse = ($config->{$key} == 'Y') || in_array($key, $orgUse); $signupItem->isUse = ($config->{$key} == 'Y') || in_array($key, $orgUse);
$signupItem->isPublic = ($signupItem->isUse) ? 'Y' : 'N'; $signupItem->isPublic = ($signupItem->isUse) ? 'Y' : 'N';
if($key == 'password') if(in_array($key, array('find_account_question', 'password', 'email_address')))
{ {
$signupItem->isPublic = 'N'; $signupItem->isPublic = 'N';
} }

View file

@ -164,24 +164,25 @@ class memberAdminView extends member
*/ */
public function dispMemberAdminAgreementsEdit() public function dispMemberAdminAgreementsEdit()
{ {
$agreement_id = intval(Context::get('id')); // Check parent input ID
Context::set('agreement_id', $agreement_id); $parent_input_id = Context::get('parent_input_id');
Context::set('agreement_content', getModel('member')->getMemberConfig()->agreements[$agreement_id]->content);
Context::addBodyClass('disable_debug_panel'); Context::addBodyClass('disable_debug_panel');
// Load editor
$oEditorModel = getModel('editor'); $oEditorModel = getModel('editor');
$option = $oEditorModel->getEditorConfig(); $option = $oEditorModel->getEditorConfig();
$option->primary_key_name = 'agreement_id'; $option->primary_key_name = 'primary_key';
$option->content_key_name = 'agreement_content'; $option->content_key_name = 'content';
$option->allow_fileupload = FALSE; $option->allow_fileupload = FALSE;
$option->enable_autosave = FALSE; $option->enable_autosave = FALSE;
$option->enable_default_component = TRUE; $option->enable_default_component = TRUE;
$option->enable_component = FALSE; $option->enable_component = FALSE;
$option->height = 300; $option->height = 300;
$option->editor_focus = 'N'; $option->editor_focus = 'Y';
$editor = $oEditorModel->getEditor($logged_info->member_srl, $option); $editor = $oEditorModel->getEditor(0, $option);
Context::set('editor', $editor); Context::set('editor', $editor);
// Set template
$this->setLayoutPath('./common/tpl/'); $this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("default_layout"); $this->setLayoutFile("default_layout");
$this->setTemplateFile('agreements_edit'); $this->setTemplateFile('agreements_edit');

View file

@ -177,6 +177,7 @@ class member extends ModuleObject {
{ {
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$oModuleModel = getModel('module'); $oModuleModel = getModel('module');
// check member directory (11/08/2007 added) // check member directory (11/08/2007 added)
if(!is_dir("./files/member_extra_info")) return true; if(!is_dir("./files/member_extra_info")) return true;
// check member directory (22/10/2007 added) // check member directory (22/10/2007 added)
@ -216,7 +217,14 @@ class member extends ModuleObject {
if(!$config->signupForm || !is_array($config->signupForm)) return true; if(!$config->signupForm || !is_array($config->signupForm)) return true;
foreach($config->signupForm as $signupItem) foreach($config->signupForm as $signupItem)
{ {
if($signupItem->name === 'find_account_question') return true; if($signupItem->name === 'find_account_question')
{
return true;
}
if($signupItem->name === 'email_address' && $signupItem->isPublic !== 'N')
{
return true;
}
} }
if(!$config->agreements) if(!$config->agreements)
{ {
@ -357,7 +365,11 @@ class member extends ModuleObject {
$config->identifier = $config->identifier ?: 'user_id'; $config->identifier = $config->identifier ?: 'user_id';
$config->signupForm = $oMemberAdminController->createSignupForm($config->identifier); $config->signupForm = $oMemberAdminController->createSignupForm($config->identifier);
$output = $oModuleController->updateModuleConfig('member', $config); $output = $oModuleController->updateModuleConfig('member', $config);
break; }
if($signupItem->name === 'email_address' && $signupItem->isPublic !== 'N')
{
$signupItem->isPublic = 'N';
$output = $oModuleController->updateModuleConfig('member', $config);
} }
} }
if(!$config->agreements) if(!$config->agreements)

View file

@ -18,8 +18,8 @@
<div class="x_control-group"> <div class="x_control-group">
<div class="x_control-label">{$lang->cmd_agreement_content}</div> <div class="x_control-label">{$lang->cmd_agreement_content}</div>
<div class="x_controls"> <div class="x_controls">
<input type="hidden" name="agreement_{$i}_content" id="agreement_{$i}_content" value="{escape($config->agreements[$i]->content)}" /> <input type="hidden" class="editor_content" name="agreement_{$i}_content" id="agreement_{$i}_content" value="{escape($config->agreements[$i]->content)}" />
<iframe id="agreement_{$i}_iframe" class="agreement_iframe" src="{getUrl('act', 'dispMemberAdminAgreementsEdit', 'id', $i)}"></iframe> <div class="editor_preview xe_content" tabindex="0">{$config->agreements[$i]->content}</div>
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">

View file

@ -2,27 +2,31 @@
$(function() { $(function() {
var editor; var editor;
var parent = window.opener ? window.opener : window.parent; var parent = window.opener ? window.opener : window.parent;
var parent_input = $("#{$parent_input_id}", parent.document);
var parent_iframe = parent_input.siblings("iframe.editor_iframe");
CKEDITOR.on('instanceReady', function(evt) { CKEDITOR.on('instanceReady', function(evt) {
editor = evt.editor; editor = evt.editor;
editor.setData(parent_input.val());
editor.on("resize", function(evt){ editor.on("resize", function(evt){
var height = evt.data.outerHeight; var height = evt.data.outerHeight;
$("#agreement_{$agreement_id}_iframe", parent.document).height(height); parent_iframe.height(height);
}); });
editor.on("change", function() { editor.on("change", function() {
var content = editor.getData(); var content = editor.getData();
$("#agreement_{$agreement_id}_content", parent.document).val(content); parent_input.val(content);
}); });
$("#agreement_{$agreement_id}_iframe", parent.document).height($(".cke_chrome").first().parent().height()); parent_iframe.height($(".cke_chrome").parent().height());
}); });
}); });
</script> </script>
<style> <style>
body { margin: 0; } body { margin: 0; }
.wfsr { display: none; }
</style> </style>
<form> <form>
<input type="hidden" name="agreement_id" id="agreement_id" value="{$agreement_id}" /> <input type="hidden" name="primary_key" id="primary_key" value="" />
<input type="hidden" name="agreement_content" id="agreement_content" value="{escape($agreement_content)}" /> <input type="hidden" name="content" id="content" value="" />
{$editor} {$editor}
</form> </form>

View file

@ -1,9 +1,22 @@
.agreement_iframe { .editor_preview {
display: inline-block;
width: 100%; width: 100%;
min-height: 240px;
max-height: 440px;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: -4px; margin: 0;
padding: 6px;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
overflow-y: auto;
cursor: text;
}
.editor_iframe {
width: 100%;
height: 440px;
box-sizing: border-box;
margin: 0 0 -4px 0;
padding: 0; padding: 0;
border: 0; border: 0;
height: 440px;
} }

View file

@ -0,0 +1,29 @@
(function($) {
// Editor replacement callback function
var editor_replace = function(input) {
var iframe = $('<iframe class="editor_iframe"></iframe>');
iframe.attr("src", current_url.setQuery("act", "dispMemberAdminAgreementsEdit").setQuery("parent_input_id", input.attr("id")));
iframe.insertAfter(input);
input.siblings(".editor_preview").hide();
if (input.attr("type") !== "hidden") {
input.hide();
}
};
// Editor replacement
$(function() {
$(".editor_preview").on("click", function() {
var input = $(this).siblings(".editor_content");
if (input.size()) {
$(this).off("click").off("focus");
editor_replace(input.first());
}
});
$(".editor_preview").on("focus", function() {
$(this).triggerHandler("click");
});
});
})(jQuery);

View file

@ -1,9 +1,4 @@
jQuery(function($){ jQuery(function($){
$('input[name=enable_join]').click(function(){
var checked = $('input[name=enable_join]:checked').val();
enableSignUpTab(checked == 'Y');
});
$('.__sync').click(function (){ $('.__sync').click(function (){
exec_xml( exec_xml(
'importer', // module 'importer', // module

View file

@ -101,7 +101,7 @@
</thead> </thead>
<tbody class="uDrag"> <tbody class="uDrag">
{@ $disabled_list = array('find_account_question')} {@ $disabled_list = array('find_account_question')}
{@ $fixed_public_list = array('nick_name', 'password')} {@ $fixed_public_list = array('nick_name', 'password', 'email_address')}
<!--@foreach($config->signupForm as $item)--> <!--@foreach($config->signupForm as $item)-->
<!--@if(in_array($item->name, $disabled_list))--> <!--@if(in_array($item->name, $disabled_list))-->
<!--@elseif($item->isIdentifier)--> <!--@elseif($item->isIdentifier)-->
@ -114,7 +114,7 @@
</th> </th>
<td style="text-align:center"><input type="radio" name="identifier" value="{$item->name}" checked="checked" /></td> <td style="text-align:center"><input type="radio" name="identifier" value="{$item->name}" checked="checked" /></td>
<td style="text-align:center"><input type="checkbox" name="usable_list[]" value="{$item->name}" title="{$lang->use}" checked="checked" disabled="disabled" /></td> <td style="text-align:center"><input type="checkbox" name="usable_list[]" value="{$item->name}" title="{$lang->use}" checked="checked" disabled="disabled" /></td>
<td style="text-align:center"><input type="checkbox" name="is_{$item->name}_public" value="Y" checked="checked"|cond="$item->isPublic == 'Y'"/></td> <td style="text-align:center"><input type="checkbox" name="is_{$item->name}_public" value="Y" checked="checked"|cond="$item->isPublic == 'Y'" disabled="disabled"|cond="in_array($item->name, $fixed_public_list) || !$item->isUse" /></td>
<td class="nowr"> <td class="nowr">
<label for="{$item->name}_re" class="x_inline"><input type="radio" id="{$item->name}_re" name="{$item->name}" value="requierd" checked="checked" disabled="disabled" /> {$lang->cmd_required}</label> <label for="{$item->name}_re" class="x_inline"><input type="radio" id="{$item->name}_re" name="{$item->name}" value="requierd" checked="checked" disabled="disabled" /> {$lang->cmd_required}</label>
<label for="{$item->name}_op" class="x_inline"><input type="radio" id="{$item->name}_op" name="{$item->name}" value="option" disabled="disabled" /> {$lang->cmd_optional}</label> <label for="{$item->name}_op" class="x_inline"><input type="radio" id="{$item->name}_op" name="{$item->name}" value="option" disabled="disabled" /> {$lang->cmd_optional}</label>

View file

@ -1896,7 +1896,7 @@ class menuAdminController extends menu
$names = $oMenuAdminModel->getMenuItemNames($node->name, $site_srl); $names = $oMenuAdminModel->getMenuItemNames($node->name, $site_srl);
foreach($names as $key => $val) foreach($names as $key => $val)
{ {
$name_arr_str .= sprintf('"%s"=>%s,', $key, var_export($val, true)); $name_arr_str .= sprintf('%s => %s, ', var_export($key, true), var_export($val, true));
} }
$name_str = sprintf('$_names = array(%s); print $_names[$lang_type];', $name_arr_str); $name_str = sprintf('$_names = array(%s); print $_names[$lang_type];', $name_arr_str);
@ -1940,23 +1940,23 @@ class menuAdminController extends menu
if($group_srls)$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s))))||($is_logged&&%s))',$group_srls,$group_srls == -1?1:0); if($group_srls)$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s))))||($is_logged&&%s))',$group_srls,$group_srls == -1?1:0);
else $group_check_code = "true"; else $group_check_code = "true";
$attribute = sprintf( $attribute = sprintf(
'node_srl="%s" parent_srl="%s" menu_name_key=\'%s\' text="<?php if(%s) { %s }?>" url="<?php print(%s?"%s":"")?>" href="<?php print(%s?%s:"")?>" is_shortcut="%s" desc="%s" open_window="%s" expand="%s" normal_btn="%s" hover_btn="%s" active_btn="%s" link="<?php if(%s) {?>%s<?php }?>"', 'node_srl="%d" parent_srl="%d" menu_name_key=%s text="<?php if(%s) { %s }?>" url="<?php print(%s?%s:"")?>" href="<?php print(%s?%s:"")?>" is_shortcut=%s desc=%s open_window=%s expand=%s normal_btn=%s hover_btn=%s active_btn=%s link="<?php if(%s) {?>%s<?php }?>"',
$menu_item_srl, $menu_item_srl,
$node->parent_srl, $node->parent_srl,
addslashes($node->name), var_export($node->name, true),
$group_check_code, $group_check_code,
$name_str, $name_str,
$group_check_code, $group_check_code,
$url, var_export($url, true),
$group_check_code, $group_check_code,
$href, $href,
$is_shortcut, var_export($is_shortcut, true),
$desc, var_export($desc, true),
$open_window, var_export($open_window, true),
$expand, var_export($expand, true),
$normal_btn, var_export($normal_btn, true),
$hover_btn, var_export($hover_btn, true),
$active_btn, var_export($active_btn, true),
$group_check_code, $group_check_code,
$link $link
); );
@ -2069,26 +2069,26 @@ class menuAdminController extends menu
} }
// Create properties (check if it belongs to the menu node by url_list. It looks a trick but fast and powerful) // Create properties (check if it belongs to the menu node by url_list. It looks a trick but fast and powerful)
$attribute = sprintf( $attribute = sprintf(
'"node_srl" => %d, "parent_srl" => %d, "menu_name_key" => \'%s\', "isShow" => (%s ? true : false), "text" => (%s ? $_menu_names[%d][$lang_type] : ""), "href" => (%s ? %s : ""), "url" => (%s ? "%s" : ""), "is_shortcut" => "%s", "desc" => \'%s\', "open_window" => "%s", "normal_btn" => "%s", "hover_btn" => "%s", "active_btn" => "%s", "selected" => (array(%s) && in_array(Context::get("mid"), array(%s)) ? 1 : 0), "expand" => \'%s\', "list" => array(%s), "link" => (%s ? (array(%s) && in_array(Context::get("mid"), array(%s)) ? %s : %s) : ""),', '"node_srl" => %d, "parent_srl" => %d, "menu_name_key" => %s, "isShow" => (%s ? true : false), "text" => (%s ? $_menu_names[%d][$lang_type] : ""), "href" => (%s ? %s : ""), "url" => (%s ? %s : ""), "is_shortcut" => %s, "desc" => %s, "open_window" => %s, "normal_btn" => %s, "hover_btn" => %s, "active_btn" => %s, "selected" => (array(%s) && in_array(Context::get("mid"), array(%s)) ? 1 : 0), "expand" => %s, "list" => array(%s), "link" => (%s ? (array(%s) && in_array(Context::get("mid"), array(%s)) ? %s : %s) : ""),',
$node->menu_item_srl, $node->menu_item_srl,
$node->parent_srl, $node->parent_srl,
strip_tags(addslashes($node->name)), var_export(strip_tags($node->name), true),
$group_check_code, $group_check_code,
$group_check_code, $group_check_code,
$node->menu_item_srl, $node->menu_item_srl,
$group_check_code, $group_check_code,
$href, $href,
$group_check_code, $group_check_code,
$url, var_export($url, true),
$is_shortcut, var_export($is_shortcut, true),
$desc, var_export($desc, true),
$open_window, var_export($open_window, true),
$normal_btn, var_export($normal_btn, true),
$hover_btn, var_export($hover_btn, true),
$active_btn, var_export($active_btn, true),
$selected, $selected,
$selected, $selected,
$expand, var_export($expand, true),
$child_buff, $child_buff,
$group_check_code, $group_check_code,
$selected, $selected,

View file

@ -864,14 +864,11 @@ class moduleAdminController extends module
} }
$output = executeQueryArray('module.getLang', $args); $output = executeQueryArray('module.getLang', $args);
if(!$output->toBool() || !$output->data) return; if(!$output->toBool() || !$output->data) return;
// Set the cache directory
$cache_path = _XE_PATH_.'files/cache/lang_defined/';
FileHandler::makeDir($cache_path);
$langMap = array(); $langMap = array();
foreach($output->data as $val) foreach($output->data as $lang)
{ {
$langMap[$val->lang_code][$val->name] = $val->value; $langMap[$lang->lang_code][$lang->name] = $lang->value;
} }
$lang_supported = Context::loadLangSelected(); $lang_supported = Context::loadLangSelected();
@ -905,16 +902,10 @@ class moduleAdminController extends module
$langMap[$langCode] += $langMap[$targetLangCode]; $langMap[$langCode] += $langMap[$targetLangCode];
} }
$buff = array("<?php if(!defined('__XE__')) exit();"); Rhymix\Framework\Cache::set('site_and_module:user_defined_langs:' . $args->site_srl . ':' . $langCode, $langMap[$langCode], 0, true);
foreach($langMap[$langCode] as $code => $value)
{
$buff[] = sprintf('$lang[%s] = %s;', var_export(strval($code), true), var_export(strval($value), true));
}
if (!Rhymix\Framework\Storage::write(sprintf('%s/%d.%s.php', $cache_path, $args->site_srl, $langCode), implode(PHP_EOL, $buff)))
{
return;
}
} }
return $langMap[Context::getLangType()];
} }
public function procModuleAdminSetDesignInfo() public function procModuleAdminSetDesignInfo()

View file

@ -1041,44 +1041,33 @@ class moduleController extends module
* @brief Change user-defined language * @brief Change user-defined language
*/ */
function replaceDefinedLangCode(&$output, $isReplaceLangCode = true) function replaceDefinedLangCode(&$output, $isReplaceLangCode = true)
{
if($isReplaceLangCode)
{
$output = preg_replace_callback('!\$user_lang->([a-z0-9\_]+)!is', array($this,'_replaceLangCode'), $output);
}
}
function _replaceLangCode($matches)
{ {
static $lang = null; static $lang = null;
if(is_null($lang)) if($isReplaceLangCode)
{ {
$cache_file = sprintf('%sfiles/cache/lang_defined/%d.%s.php', _XE_PATH_, 0, Context::getLangType()); if($lang === null)
if(!file_exists($cache_file)) {
$lang = Rhymix\Framework\Cache::get('site_and_module:user_defined_langs:' . $args->site_srl . ':' . Context::getLangType());
if($lang === null)
{ {
$oModuleAdminController = getAdminController('module'); $oModuleAdminController = getAdminController('module');
$oModuleAdminController->makeCacheDefinedLangCode(0); $lang = $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl);
}
} }
if(file_exists($cache_file)) $output = preg_replace_callback('!\$user_lang->([a-z0-9\_]+)!is', function($matches) use($lang) {
if(isset($lang[$matches[1]]) && !Context::get($matches[1]))
{ {
$moduleAdminControllerMtime = filemtime(_XE_PATH_ . 'modules/module/module.admin.controller.php'); return $lang[$matches[1]];
$cacheFileMtime = filemtime($cache_file); }
if($cacheFileMtime < $moduleAdminControllerMtime) else
{ {
$oModuleAdminController = getAdminController('module');
$oModuleAdminController->makeCacheDefinedLangCode(0);
}
require_once($cache_file);
}
}
if(!Context::get($matches[1]) && $lang[$matches[1]]) return $lang[$matches[1]];
return str_replace('$user_lang->', '', $matches[0]); return str_replace('$user_lang->', '', $matches[0]);
} }
}, $output);
}
}
/** /**
* @brief Add and update a file into the file box * @brief Add and update a file into the file box