mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Clean up ModuleController::replaceDefinedLangCode()
This commit is contained in:
parent
2e6e097272
commit
f8859769e8
15 changed files with 64 additions and 77 deletions
|
|
@ -734,8 +734,7 @@ class Context
|
|||
{
|
||||
return '';
|
||||
}
|
||||
ModuleController::getInstance()->replaceDefinedLangCode(self::$_instance->browser_title);
|
||||
return htmlspecialchars(self::$_instance->browser_title, ENT_QUOTES, 'UTF-8', FALSE);
|
||||
return escape(self::replaceUserLang(self::$_instance->browser_title), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -748,9 +747,7 @@ class Context
|
|||
$domain_info = self::get('site_module_info');
|
||||
if ($domain_info && $domain_info->settings && $domain_info->settings->title)
|
||||
{
|
||||
$title = trim($domain_info->settings->title);
|
||||
ModuleController::getInstance()->replaceDefinedLangCode($title);
|
||||
return $title;
|
||||
return escape(self::replaceUserLang($domain_info->settings->title), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -768,9 +765,7 @@ class Context
|
|||
$domain_info = self::get('site_module_info');
|
||||
if ($domain_info && $domain_info->settings && $domain_info->settings->subtitle)
|
||||
{
|
||||
$subtitle = trim($domain_info->settings->subtitle);
|
||||
ModuleController::getInstance()->replaceDefinedLangCode($subtitle);
|
||||
return $subtitle;
|
||||
return escape(self::replaceUserLang($domain_info->settings->subtitle), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -882,6 +877,33 @@ class Context
|
|||
$GLOBALS['lang']->set($code, $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Replace user-defined language codes
|
||||
*/
|
||||
public static function replaceUserLang($output)
|
||||
{
|
||||
static $lang = null;
|
||||
if($lang === null)
|
||||
{
|
||||
$lang = Rhymix\Framework\Cache::get('site_and_module:user_defined_langs:0:' . self::getLangType());
|
||||
if($lang === null)
|
||||
{
|
||||
ModuleAdminController::getInstance()->makeCacheDefinedLangCode(0);
|
||||
}
|
||||
}
|
||||
|
||||
return preg_replace_callback('/\$user_lang->([a-zA-Z0-9\_]+)/', function($matches) use($lang) {
|
||||
if(isset($lang[$matches[1]]) && !self::get($matches[1]))
|
||||
{
|
||||
return $lang[$matches[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $matches[1];
|
||||
}
|
||||
}, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert strings of variables in $source_object into UTF-8
|
||||
*
|
||||
|
|
@ -2633,8 +2655,10 @@ class Context
|
|||
*/
|
||||
public static function addMetaTag($name, $content, $is_http_equiv = false)
|
||||
{
|
||||
ModuleController::getInstance()->replaceDefinedLangCode($content);
|
||||
self::$_instance->meta_tags[$name] = array('is_http_equiv' => (bool)$is_http_equiv, 'content' => $content);
|
||||
self::$_instance->meta_tags[$name] = array(
|
||||
'is_http_equiv' => (bool)$is_http_equiv,
|
||||
'content' => self::replaceUserLang($content),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -269,8 +269,7 @@ class HTMLDisplayHandler
|
|||
$output = $oTemplate->compile('./common/tpl', 'common_layout');
|
||||
|
||||
// replace the user-defined-language
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($output);
|
||||
$output = Context::replaceUserLang($output);
|
||||
|
||||
// remove template path comment tag
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -596,9 +596,7 @@ class ExtraItem
|
|||
}
|
||||
if($this->desc)
|
||||
{
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($this->desc);
|
||||
$buff[] = '<p>' . escape($this->desc, false) . '</p>';
|
||||
$buff[] = '<p>' . escape(Context::replaceUserLang($this->desc), false) . '</p>';
|
||||
}
|
||||
|
||||
return join("\n", $buff);
|
||||
|
|
|
|||
|
|
@ -770,7 +770,7 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
$seo_title = config('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE';
|
||||
}
|
||||
ModuleController::getInstance()->replaceDefinedLangCode($seo_title);
|
||||
$seo_title = Context::replaceUserLang($seo_title);
|
||||
Context::setBrowserTitle($seo_title, array(
|
||||
'site_title' => Context::getSiteTitle(),
|
||||
'site_subtitle' => Context::getSiteSubtitle(),
|
||||
|
|
|
|||
|
|
@ -217,8 +217,7 @@ class boardController extends board
|
|||
// send an email to admin user
|
||||
if ($this->module_info->admin_mail && config('mail.default_from'))
|
||||
{
|
||||
$browser_title = $this->module_info->browser_title;
|
||||
getController('module')->replaceDefinedLangCode($browser_title);
|
||||
$browser_title = Context::replaceUserLang($this->module_info->browser_title);
|
||||
$mail_title = sprintf(lang('msg_document_notify_mail'), $browser_title, cut_str($obj->title, 20, '...'));
|
||||
$mail_content = sprintf("From : <a href=\"%s\">%s</a><br/>\r\n%s", getFullUrl('', 'document_srl', $output->get('document_srl')), getFullUrl('', 'document_srl', $output->get('document_srl')), $obj->content);
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ class boardView extends board
|
|||
// add the document title to the browser
|
||||
Context::setCanonicalURL($oDocument->getPermanentUrl());
|
||||
$seo_title = config('seo.document_title') ?: '$SITE_TITLE - $DOCUMENT_TITLE';
|
||||
getController('module')->replaceDefinedLangCode($seo_title);
|
||||
$seo_title = Context::replaceUserLang($seo_title);
|
||||
Context::setBrowserTitle($seo_title, array(
|
||||
'site_title' => Context::getSiteTitle(),
|
||||
'site_subtitle' => Context::getSiteSubtitle(),
|
||||
|
|
|
|||
|
|
@ -677,8 +677,7 @@ class commentController extends comment
|
|||
// If there is no problem to register comment then send an email to all admin were set in module admin panel
|
||||
if($module_info->admin_mail && $member_info->is_admin != 'Y')
|
||||
{
|
||||
$browser_title = $module_info->browser_title;
|
||||
getController('module')->replaceDefinedLangCode($browser_title);
|
||||
$browser_title = Context::replaceUserLang($module_info->browser_title);
|
||||
$mail_title = sprintf(lang('msg_comment_notify_mail'), $browser_title, cut_str($oDocument->getTitleText(), 20, '...'));
|
||||
$url_comment = getFullUrl('','document_srl',$obj->document_srl).'#comment_'.$obj->comment_srl;
|
||||
if($using_validation)
|
||||
|
|
|
|||
|
|
@ -222,10 +222,8 @@ class menuAdminModel extends menu
|
|||
}
|
||||
}
|
||||
$menuItem->groupList = $groupList;
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$menuItem->name_key = $menuItem->name;
|
||||
$oModuleController->replaceDefinedLangCode($menuItem->name);
|
||||
$menuItem->name = Context::replaceUserLang($menuItem->name);
|
||||
|
||||
$this->add('menu_item', $menuItem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -783,13 +783,10 @@ class moduleAdminController extends module
|
|||
$module = trim($val->module);
|
||||
if(!$module) continue;
|
||||
|
||||
// replace user defined lang.
|
||||
$oModuleController->replaceDefinedLangCode($val->browser_title);
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->module_srl = $val->module_srl;
|
||||
$obj->layout_srl = $val->layout_srl;
|
||||
$obj->browser_title = $val->browser_title;
|
||||
$obj->browser_title = Context::replaceUserLang($val->browser_title);
|
||||
$obj->mid = $val->mid;
|
||||
$obj->module_category_srl = $val->module_category_srl;
|
||||
if($val->module_category_srl > 0)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class moduleAdminModel extends module
|
|||
*/
|
||||
function getModuleAdminModuleList()
|
||||
{
|
||||
$oModuleController = getController('module');
|
||||
$oModuleModel = getModel('module');
|
||||
$args = new stdClass;
|
||||
$args->module_srls = Context::get('module_srls');
|
||||
|
|
@ -31,8 +30,12 @@ class moduleAdminModel extends module
|
|||
foreach($output->data as $key => $val)
|
||||
{
|
||||
$info_xml = $oModuleModel->getModuleInfoXml($val->module);
|
||||
$oModuleController->replaceDefinedLangCode($val->browser_title);
|
||||
$list[$val->module_srl] = array('module_srl'=>$val->module_srl,'mid'=>$val->mid,'browser_title'=>$val->browser_title, 'module_name' => $info_xml->title);
|
||||
$list[$val->module_srl] = array(
|
||||
'module_srl' => $val->module_srl,
|
||||
'mid' => $val->mid,
|
||||
'browser_title' => Context::replaceUserLang($val->browser_title),
|
||||
'module_name' => $info_xml->title,
|
||||
);
|
||||
}
|
||||
$modules = explode(',',$args->module_srls);
|
||||
$module_list = [];
|
||||
|
|
|
|||
|
|
@ -1080,35 +1080,14 @@ class moduleController extends module
|
|||
/**
|
||||
* @brief Change user-defined language
|
||||
*/
|
||||
function replaceDefinedLangCode(&$output, $isReplaceLangCode = true)
|
||||
public static function replaceDefinedLangCode(&$output, $replace = true)
|
||||
{
|
||||
static $lang = null;
|
||||
|
||||
if($isReplaceLangCode)
|
||||
if ($replace)
|
||||
{
|
||||
if($lang === null)
|
||||
{
|
||||
$lang = Rhymix\Framework\Cache::get('site_and_module:user_defined_langs:0:' . Context::getLangType());
|
||||
if($lang === null)
|
||||
{
|
||||
$oModuleAdminController = getAdminController('module');
|
||||
$lang = $oModuleAdminController->makeCacheDefinedLangCode(0);
|
||||
}
|
||||
}
|
||||
|
||||
$output = preg_replace_callback('/\$user_lang->([a-z0-9\_]+)/is', function($matches) use($lang) {
|
||||
if(isset($lang[$matches[1]]) && !Context::get($matches[1]))
|
||||
{
|
||||
return $lang[$matches[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return str_replace('$user_lang->', '', $matches[0]);
|
||||
}
|
||||
}, $output);
|
||||
$output = Context::replaceUserLang($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add and update a file into the file box
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -404,11 +404,6 @@ class moduleModel extends module
|
|||
$module_info = $mid_info;
|
||||
}
|
||||
|
||||
/*
|
||||
$oModuleController = getController('module');
|
||||
if(isset($module_info->browser_title)) $oModuleController->replaceDefinedLangCode($module_info->browser_title);
|
||||
*/
|
||||
|
||||
self::_applyDefaultSkin($module_info);
|
||||
return self::addModuleExtraVars($module_info);
|
||||
}
|
||||
|
|
@ -2342,7 +2337,7 @@ class moduleModel extends module
|
|||
$langCode = Context::get('langCode');
|
||||
if (!$langCode) return;
|
||||
|
||||
ModuleController::getInstance()->replaceDefinedLangCode($langCode);
|
||||
$langCode = Context::replaceUserLang($langCode);
|
||||
$this->add('lang', $langCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,14 +175,13 @@ class rssView extends rss
|
|||
|
||||
$info->id = $channel_url;
|
||||
$info->feed_title = $config->feed_title;
|
||||
$info->title = $obj->title ?: $info->title;
|
||||
$info->title = Context::replaceUserLang($obj->title ?: $info->title);
|
||||
$info->description = $obj->description ?: $info->description;
|
||||
$info->language = Context::getLangType();
|
||||
$info->site_url = Context::getRequestUri();
|
||||
$info->date_r = date('r');
|
||||
$info->date_c = date('c');
|
||||
$info->image = $config->image ? Context::getRequestUri() . $config->image : '';
|
||||
getController('module')->replaceDefinedLangCode($info->title);
|
||||
|
||||
Context::set('info', $info);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ class spamfilterModel extends spamfilter
|
|||
{
|
||||
if(preg_match('/^\\$user_lang->[a-zA-Z0-9]+$/', $config->custom_message))
|
||||
{
|
||||
getController('module')->replaceDefinedLangCode($config->custom_message);
|
||||
$custom_message = htmlspecialchars($config->custom_message);
|
||||
$custom_message = escape(Context::replaceUserLang($config->custom_message), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -67,13 +67,11 @@ class widgetController extends widget
|
|||
|
||||
if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) throw new Rhymix\Framework\Exception('msg_widget_skin_is_null');
|
||||
|
||||
$attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
|
||||
$this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars);
|
||||
|
||||
// Wanted results
|
||||
$widget_code = $this->execute($widget, $vars, true, false);
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($widget_code);
|
||||
|
||||
$widget_code = Context::replaceUserLang($widget_code);
|
||||
$this->add('widget_code', $widget_code);
|
||||
}
|
||||
|
||||
|
|
@ -256,8 +254,10 @@ class widgetController extends widget
|
|||
function transWidgetCode($content, $javascript_mode = false, $isReplaceLangCode = true)
|
||||
{
|
||||
// Changing user-defined language
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($content, $isReplaceLangCode);
|
||||
if($isReplaceLangCode)
|
||||
{
|
||||
$content = Context::replaceUserLang($content);
|
||||
}
|
||||
// Check whether to include information about editing
|
||||
$this->javascript_mode = $javascript_mode;
|
||||
// Widget code box change
|
||||
|
|
@ -390,8 +390,7 @@ class widgetController extends widget
|
|||
if(!$oWidget || !method_exists($oWidget, 'proc')) return;
|
||||
|
||||
$widget_content = $oWidget->proc($args);
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($widget_content);
|
||||
$widget_content = Context::replaceUserLang($widget_content);
|
||||
return $widget_content;
|
||||
}
|
||||
|
||||
|
|
@ -414,8 +413,7 @@ class widgetController extends widget
|
|||
if(!$oWidget || !method_exists($oWidget,'proc')) return;
|
||||
|
||||
$widget_content = $oWidget->proc($args);
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($widget_content);
|
||||
$widget_content = Context::replaceUserLang($widget_content);
|
||||
|
||||
Rhymix\Framework\Cache::set('widget_cache:' . $widget_sequence, $widget_content, $widget_cache, true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue