mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Set layout and template paths in one place
This commit is contained in:
parent
9fbcda3e79
commit
340b3aa49a
3 changed files with 100 additions and 80 deletions
|
|
@ -595,6 +595,100 @@ class ModuleObject extends BaseObject
|
|||
return $this->layout_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically set layout and template path based on skin settings.
|
||||
*
|
||||
* @param string $type 'P' or 'M'
|
||||
* @param object $config
|
||||
* @return void
|
||||
*/
|
||||
public function setLayoutAndTemplatePaths($type, $config)
|
||||
{
|
||||
// Set the layout path.
|
||||
if ($type === 'P')
|
||||
{
|
||||
$layout_srl = $config->layout_srl ?? 0;
|
||||
if ($layout_srl > 0)
|
||||
{
|
||||
$layout_info = LayoutModel::getInstance()->getLayout($layout_srl);
|
||||
if($layout_info)
|
||||
{
|
||||
$this->module_info->layout_srl = $layout_srl;
|
||||
$this->setLayoutPath($layout_info->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$layout_srl = $config->mlayout_srl ?? 0;
|
||||
if ($layout_srl == -2)
|
||||
{
|
||||
$layout_srl = $config->layout_srl ?: -1;
|
||||
if ($layout_srl == -1)
|
||||
{
|
||||
$layout_srl = LayoutAdminModel::getInstance()->getSiteDefaultLayout('P');
|
||||
}
|
||||
}
|
||||
elseif ($layout_srl == -1)
|
||||
{
|
||||
$layout_srl = LayoutAdminModel::getInstance()->getSiteDefaultLayout('M');
|
||||
}
|
||||
|
||||
$layout_info = LayoutModel::getInstance()->getLayout($layout_srl);
|
||||
if($layout_info)
|
||||
{
|
||||
$this->module_info->mlayout_srl = $layout_srl;
|
||||
$this->setLayoutPath($layout_info->path);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the skin path.
|
||||
if ($type === 'P')
|
||||
{
|
||||
$skin = ($config->skin ?? '') ?: 'default';
|
||||
if ($skin === '/USE_DEFAULT/')
|
||||
{
|
||||
$skin = ModuleModel::getModuleDefaultSkin($this->module, 'P') ?: 'default';
|
||||
}
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, $skin);
|
||||
if (!Rhymix\Framework\Storage::isDirectory($template_path))
|
||||
{
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, 'default');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mskin = ($config->mskin ?? '') ?: 'default';
|
||||
if ($mskin === '/USE_DEFAULT/')
|
||||
{
|
||||
$mskin = ModuleModel::getModuleDefaultSkin($this->module, 'M') ?: 'default';
|
||||
}
|
||||
|
||||
if($mskin === '/USE_RESPONSIVE/')
|
||||
{
|
||||
$skin = ($config->skin ?? '') ?: 'default';
|
||||
if ($skin === '/USE_DEFAULT/')
|
||||
{
|
||||
$skin = ModuleModel::getModuleDefaultSkin($this->module, 'P') ?: 'default';
|
||||
}
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, $skin);
|
||||
if (!Rhymix\Framework\Storage::isDirectory($template_path))
|
||||
{
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, 'default');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_path = sprintf('%sm.skins/%s', $this->module_path, $mskin);
|
||||
if (!Rhymix\Framework\Storage::isDirectory($template_path))
|
||||
{
|
||||
$template_path = sprintf("%sm.skins/%s/", $this->module_path, 'default');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setTemplatePath($template_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* excute the member method specified by $act variable
|
||||
* @return bool
|
||||
|
|
@ -641,37 +735,10 @@ class ModuleObject extends BaseObject
|
|||
// Set module skin
|
||||
if(isset($this->module_info->skin) && $this->module_info->module === $this->module && strpos($this->act, 'Admin') === false)
|
||||
{
|
||||
$skin_type = $is_mobile ? 'M' : 'P';
|
||||
$skin_key = $is_mobile ? 'mskin' : 'skin';
|
||||
$skin_dir = $is_mobile ? 'm.skins' : 'skins';
|
||||
$module_skin = $this->module_info->{$skin_key} ?: '/USE_DEFAULT/';
|
||||
$use_default_skin = $this->module_info->{'is_' . $skin_key . '_fix'} === 'N';
|
||||
|
||||
// Set default skin
|
||||
if(!$this->getTemplatePath() || $use_default_skin)
|
||||
if(!$this->getTemplatePath())
|
||||
{
|
||||
if($module_skin === '/USE_DEFAULT/')
|
||||
{
|
||||
$module_skin = ModuleModel::getModuleDefaultSkin($this->module, $skin_type);
|
||||
$this->module_info->{$skin_key} = $module_skin;
|
||||
$this->setLayoutAndTemplatePaths($is_mobile ? 'M' : 'P', $this->module_info);
|
||||
}
|
||||
if($module_skin === '/USE_RESPONSIVE/')
|
||||
{
|
||||
$skin_dir = 'skins';
|
||||
$module_skin = $this->module_info->skin ?: '/USE_DEFAULT/';
|
||||
if($module_skin === '/USE_DEFAULT/')
|
||||
{
|
||||
$module_skin = ModuleModel::getModuleDefaultSkin($this->module, 'P');
|
||||
}
|
||||
}
|
||||
if(!is_dir(sprintf('%s%s/%s', $this->module_path, $skin_dir, $module_skin)))
|
||||
{
|
||||
$module_skin = 'default';
|
||||
}
|
||||
$this->setTemplatePath(sprintf('%s%s/%s', $this->module_path, $skin_dir, $module_skin));
|
||||
}
|
||||
|
||||
// Set skin variable
|
||||
ModuleModel::syncSkinInfoToModuleInfo($this->module_info);
|
||||
Context::set('module_info', $this->module_info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,25 +18,6 @@ class MemberMobile extends MemberView
|
|||
$oSecurity = new Security();
|
||||
$oSecurity->encodeHTML('member_config.signupForm..');
|
||||
|
||||
// Set the template path
|
||||
$mskin = $this->member_config->mskin;
|
||||
if(!$mskin)
|
||||
{
|
||||
$template_path = sprintf('%sm.skins/%s/', $this->module_path, 'default');
|
||||
}
|
||||
elseif($mskin === '/USE_RESPONSIVE/')
|
||||
{
|
||||
$template_path = sprintf("%sskins/%s/", $this->module_path, $this->member_config->skin);
|
||||
if(!is_dir($template_path) || !$this->member_config->skin)
|
||||
{
|
||||
$template_path = sprintf("%sskins/%s/", $this->module_path, 'default');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_path = sprintf('%sm.skins/%s', $this->module_path, $mskin);
|
||||
}
|
||||
|
||||
// if member_srl exists, set memberInfo
|
||||
$member_srl = Context::get('member_srl');
|
||||
if($member_srl)
|
||||
|
|
@ -53,15 +34,8 @@ class MemberMobile extends MemberView
|
|||
}
|
||||
}
|
||||
|
||||
$this->setTemplatePath($template_path);
|
||||
|
||||
$oLayoutModel = getModel('layout');
|
||||
$layout_info = $oLayoutModel->getLayout($this->member_config->mlayout_srl);
|
||||
if($layout_info)
|
||||
{
|
||||
$this->module_info->mlayout_srl = $this->member_config->mlayout_srl;
|
||||
$this->setLayoutPath($layout_info->path);
|
||||
}
|
||||
// Set layout and skin paths
|
||||
$this->setLayoutAndTemplatePaths('M', $this->member_config);
|
||||
}
|
||||
|
||||
function dispMemberModifyInfo()
|
||||
|
|
|
|||
|
|
@ -21,29 +21,8 @@ class MemberView extends Member
|
|||
$oSecurity = new Security();
|
||||
$oSecurity->encodeHTML('member_config.signupForm..');
|
||||
|
||||
// Set the skin path
|
||||
$skin = $this->member_config->skin;
|
||||
if ($skin)
|
||||
{
|
||||
if ($skin === '/USE_DEFAULT/')
|
||||
{
|
||||
$skin = 'default';
|
||||
}
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, $skin);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_path = sprintf('%sskins/%s', $this->module_path, 'default');
|
||||
}
|
||||
$this->setTemplatePath($template_path);
|
||||
|
||||
// Set the layout path
|
||||
$layout_info = LayoutModel::getInstance()->getLayout($this->member_config->layout_srl);
|
||||
if($layout_info)
|
||||
{
|
||||
$this->module_info->layout_srl = $this->member_config->layout_srl;
|
||||
$this->setLayoutPath($layout_info->path);
|
||||
}
|
||||
// Set layout and skin paths
|
||||
$this->setLayoutAndTemplatePaths('P', $this->member_config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue