Skip to content

Commit

Permalink
#1627 레이아웃 버전이 0.1 일경우 PHP8.0에서 발생하는 오류 고침
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrambo committed Feb 17, 2021
1 parent acda40e commit b0a72bb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions modules/layout/layout.model.php
Expand Up @@ -500,7 +500,7 @@ function getLayoutInfo($layout, $info = null, $layout_type = "P")
{
$cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType());
}

if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
{
include($cache_file);
Expand Down Expand Up @@ -662,35 +662,39 @@ function getLayoutInfo($layout, $info = null, $layout_type = "P")
$buff[] = sprintf('$layout_info->layout = %s;', var_export($layout, true));
$buff[] = sprintf('$layout_info->path = %s;', var_export($layout_path, true));
$buff[] = sprintf('$layout_info->title = %s;', var_export($xml_obj->title->body, true));
$buff[] = sprintf('$layout_info->description = %s;', var_export($xml_obj->author->description->body, true));
$buff[] = sprintf('$layout_info->description = %s;', var_export($xml_obj->description->body, true));
$buff[] = sprintf('$layout_info->version = %s;', var_export($xml_obj->attrs->version, true));
$buff[] = sprintf('$layout_info->date = %s;', var_export($date, true));
$buff[] = sprintf('$layout_info->layout_srl = $layout_srl;');
$buff[] = sprintf('$layout_info->layout_title = $layout_title;');
// Author information
$buff[] = '$layout_info->author[0] = new stdClass();';
$buff[] = sprintf('$layout_info->author[0]->name = %s;', var_export($xml_obj->author->name->body, true));
$buff[] = sprintf('$layout_info->author[0]->email_address = %s;', var_export($xml_obj->author->attrs->email_address, true));
$buff[] = sprintf('$layout_info->author[0]->homepage = %s;', var_export($xml_obj->author->attrs->link, true));
// Extra vars (user defined variables to use in a template)
$extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);

$extra_var_count = 0;
$buff[] = '$layout_info->extra_var = new stdClass;';
foreach($extra_var_groups as $group)
{
$extra_vars = $group->var;
if($extra_vars)
{
if(!is_array($extra_vars)) $extra_vars = array($extra_vars);

$extra_var_count = count($extra_vars);
$count = count($extra_vars);
$extra_var_count += $count;

$buff[] = sprintf('$layout_info->extra_var_count = %d;', $extra_var_count);
for($i=0;$i<$extra_var_count;$i++)
for($i=0;$i<$count;$i++)
{
unset($var, $options);
$var = $extra_vars[$i];
$name = $var->attrs->name;

$buff[] = sprintf('$layout_info->extra_var->%s = new stdClass();', $name);
$buff[] = sprintf('$layout_info->extra_var->%s->group = %s;', $name, var_export($group->title->body, true));
$buff[] = sprintf('$layout_info->extra_var->%s->title = %s;', $name, var_export($var->title->body, true));
$buff[] = sprintf('$layout_info->extra_var->%s->type = %s;', $name, var_export($var->attrs->type, true));
Expand All @@ -704,11 +708,13 @@ function getLayoutInfo($layout, $info = null, $layout_type = "P")
$options_count = count($options);
for($j=0;$j<$options_count;$j++)
{
$buff[] = sprintf('$layout_info->extra_var->%s->options[%s]->val = %s;', $var->attrs->name, var_export($options[$j]->value->body, true), var_export($options[$j]->title->body, true));
$buff[] = sprintf('$layout_info->extra_var->%s->options[%s] = new stdClass;', $var->attrs->name, var_export($options[$j]->attrs->value, true));
$buff[] = sprintf('$layout_info->extra_var->%s->options[%s]->val = %s;', $var->attrs->name, var_export($options[$j]->attrs->value, true), var_export($options[$j]->title->body, true));
}
}
}
}
$buff[] = sprintf('$layout_info->extra_var_count = %d;', $extra_var_count);
// Menu
if($xml_obj->menus->menu)
{
Expand All @@ -721,6 +727,8 @@ function getLayoutInfo($layout, $info = null, $layout_type = "P")
{
$name = $menus[$i]->attrs->name;
if($menus[$i]->attrs->default == "true") $buff[] = sprintf('$layout_info->default_menu = %s;', var_export($name, true));
$buff[] = '$layout_info->menu = new stdClass();';
$buff[] = sprintf('$layout_info->menu->%s = new stdClass();', $name);
$buff[] = sprintf('$layout_info->menu->%s->name = %s;', $name, var_export($name, true));
$buff[] = sprintf('$layout_info->menu->%s->title = %s;', $name, var_export($menus[$i]->title->body, true));
$buff[] = sprintf('$layout_info->menu->%s->maxdepth = %s;', $name, var_export($menus[$i]->maxdepth->body, true));
Expand Down

0 comments on commit b0a72bb

Please sign in to comment.