mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
#99 menu, layout, module cache 파일의 PHP 호환성 개선 (PHP 5.4 or later)
This commit is contained in:
parent
4a7c889981
commit
7b09dc8339
4 changed files with 56 additions and 15 deletions
|
|
@ -840,6 +840,7 @@ class Context
|
|||
{
|
||||
global $lang;
|
||||
|
||||
if(!$path) return;
|
||||
$_path = 'eval://' . $path;
|
||||
|
||||
if(in_array($_path, $this->loaded_lang_files))
|
||||
|
|
@ -870,6 +871,7 @@ class Context
|
|||
*/
|
||||
function _loadXmlLang($path)
|
||||
{
|
||||
if(!$path) return;
|
||||
$oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type);
|
||||
return $oXmlLangParser->compile();
|
||||
}
|
||||
|
|
@ -882,6 +884,7 @@ class Context
|
|||
*/
|
||||
function _loadPhpLang($path)
|
||||
{
|
||||
if(!$path) return;
|
||||
if(substr_compare($path, '/', -1) !== 0)
|
||||
{
|
||||
$path .= '/';
|
||||
|
|
|
|||
|
|
@ -524,7 +524,9 @@ class layoutModel extends layout
|
|||
|
||||
if(!$xml_obj) return;
|
||||
|
||||
$buff = array(sprintf('$layout_info->site_srl = "%s";', $site_srl));
|
||||
$buff = array();
|
||||
$buff[] = '$layout_info = new stdClass;';
|
||||
$buff[] = sprintf('$layout_info->site_srl = "%s";', $site_srl);
|
||||
|
||||
if($xml_obj->version && $xml_obj->attrs->version == '0.2')
|
||||
{
|
||||
|
|
@ -548,8 +550,10 @@ class layoutModel extends layout
|
|||
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
|
||||
else $author_list = $xml_obj->author;
|
||||
|
||||
$buff[] = '$layout_info->author = array();';
|
||||
for($i=0, $c=count($author_list); $i<$c; $i++)
|
||||
{
|
||||
$buff[] = sprintf('$layout_info->author[%d] = new stdClass;', $i);
|
||||
$buff[] = sprintf('$layout_info->author[%d]->name = "%s";', $i, $author_list[$i]->name->body);
|
||||
$buff[] = sprintf('$layout_info->author[%d]->email_address = "%s";', $i, $author_list[$i]->attrs->email_address);
|
||||
$buff[] = sprintf('$layout_info->author[%d]->homepage = "%s";', $i, $author_list[$i]->attrs->link);
|
||||
|
|
@ -568,12 +572,14 @@ class layoutModel extends layout
|
|||
$extra_var_count = count($extra_vars);
|
||||
|
||||
$buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count);
|
||||
$buff[] = '$layout_info->extra_var = new stdClass;';
|
||||
for($i=0;$i<$extra_var_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, $group->title->body);
|
||||
$buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body);
|
||||
$buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type);
|
||||
|
|
@ -588,6 +594,8 @@ class layoutModel extends layout
|
|||
$thumbnail_exist = false;
|
||||
for($j=0; $j < $options_count; $j++)
|
||||
{
|
||||
$buff[] = sprintf('$layout_info->extra_var->%s->options = array();', $var->attrs->name);
|
||||
$buff[] = sprintf('$layout_info->extra_var->%s->options["%s"] = new stdClass;', $var->attrs->name, $options[$j]->attrs->value);
|
||||
$thumbnail = $options[$j]->attrs->src;
|
||||
if($thumbnail)
|
||||
{
|
||||
|
|
@ -615,10 +623,12 @@ class layoutModel extends layout
|
|||
|
||||
$menu_count = count($menus);
|
||||
$buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count);
|
||||
$buff[] = '$layout_info->menu = new stdClass;';
|
||||
for($i=0;$i<$menu_count;$i++)
|
||||
{
|
||||
$name = $menus[$i]->attrs->name;
|
||||
if($menus[$i]->attrs->default == "true") $buff[] = sprintf('$layout_info->default_menu = "%s";', $name);
|
||||
$buff[] = sprintf('$layout_info->menu->%s = new stdClass;', $name);
|
||||
$buff[] = sprintf('$layout_info->menu->%s->name = "%s";',$name, $menus[$i]->attrs->name);
|
||||
$buff[] = sprintf('$layout_info->menu->%s->title = "%s";',$name, $menus[$i]->title->body);
|
||||
$buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";',$name, $menus[$i]->attrs->maxdepth);
|
||||
|
|
@ -635,10 +645,12 @@ class layoutModel extends layout
|
|||
if(!is_array($xml_obj->history)) $history_list[] = $xml_obj->history;
|
||||
else $history_list = $xml_obj->history;
|
||||
|
||||
$buff[] = '$layout_info->history = array();';
|
||||
for($i=0, $c=count($history_list); $i<$c; $i++)
|
||||
{
|
||||
sscanf($history_list[$i]->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$buff[] = sprintf('$layout_info->history[%d] = new stdClass;', $i);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->description = "%s";', $i, $history_list[$i]->description->body);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->version = "%s";', $i , $history_list[$i]->attrs->version);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->date = "%s";', $i, $date);
|
||||
|
|
@ -647,8 +659,10 @@ class layoutModel extends layout
|
|||
{
|
||||
(!is_array($history_list[$i]->author)) ? $obj->author_list[] = $history_list[$i]->author : $obj->author_list = $history_list[$i]->author;
|
||||
|
||||
$buff[] = sprintf('$layout_info->history[%d]->author = array();', $i);
|
||||
for($j=0, $jc=count($obj->author_list); $j<$jc; $j++)
|
||||
{
|
||||
$buff[] = sprintf('$layout_info->history[%d]->author[%d] = new stdClass;', $i, $j);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->author[%d]->name = "%s";', $i, $j, $obj->author_list[$j]->name->body);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->author[%d]->email_address = "%s";', $i, $j, $obj->author_list[$j]->attrs->email_address);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->author[%d]->homepage = "%s";', $i, $j, $obj->author_list[$j]->attrs->link);
|
||||
|
|
@ -659,8 +673,10 @@ class layoutModel extends layout
|
|||
{
|
||||
(!is_array($history_list[$i]->log)) ? $obj->log_list[] = $history_list[$i]->log : $obj->log_list = $history_list[$i]->log;
|
||||
|
||||
$buff[] = sprintf('$layout_info->history[%d]->logs = array();', $i, $j, $obj->log_list[$j]->body);
|
||||
for($j=0, $jc=count($obj->log_list); $j<$jc; $j++)
|
||||
{
|
||||
$buff[] = sprintf('$layout_info->history[%d]->logs[%d] = new stdClass;', $i, $j);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->logs[%d]->text = "%s";', $i, $j, $obj->log_list[$j]->body);
|
||||
$buff[] = sprintf('$layout_info->history[%d]->logs[%d]->link = "%s";', $i, $j, $obj->log_list[$j]->attrs->link);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1736,7 +1736,7 @@ class menuAdminController extends menu
|
|||
$names = $oMenuAdminModel->getMenuItemNames($node->name, $site_srl);
|
||||
foreach($names as $key => $val)
|
||||
{
|
||||
$name_arr_str .= sprintf('"%s"=>"%s",',$key, str_replace('\\','\\\\',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
|
||||
$name_arr_str .= sprintf('"%s"=>\'%s\',',$key, str_replace(array('\\', '\''), array('\\\\', '\\\''), $val));
|
||||
}
|
||||
$name_str = sprintf('$_names = array(%s); print $_names[$lang_type];', $name_arr_str);
|
||||
|
||||
|
|
|
|||
|
|
@ -743,16 +743,25 @@ class moduleModel extends module
|
|||
// Get a path of the requested module. Return if not exists.
|
||||
$class_path = ModuleHandler::getModulePath($module);
|
||||
if(!$class_path) return;
|
||||
|
||||
// Check if module.xml exists in the path. Return if not exist
|
||||
$xml_file = sprintf("%sconf/module.xml", $class_path);
|
||||
if(!file_exists($xml_file)) return;
|
||||
|
||||
// Check if cached file exists
|
||||
$cache_file = sprintf(_XE_PATH_ . "files/cache/module_info/%s.%s.%s.php", $module, Context::getLangType(), __XE_VERSION__);
|
||||
|
||||
// Update if no cache file exists or it is older than xml file
|
||||
if(!file_exists($cache_file) || filemtime($cache_file)<filemtime($xml_file))
|
||||
{
|
||||
$info = new stdClass();
|
||||
$buff = ""; // /< Set buff variable to use in the cache file
|
||||
$buff = array(); // /< Set buff variable to use in the cache file
|
||||
$buff[] = '<?php if(!defined("__XE__")) exit();';
|
||||
$buff[] = '$info = new stdClass;';
|
||||
$buff['default_index_act'] = '$info->default_index_act = \'%s\';';
|
||||
$buff['setup_index_act'] = '$info->setup_index_act=\'%s\';';
|
||||
$buff['simple_setup_index_act'] = '$info->simple_setup_index_act=\'%s\';';
|
||||
$buff['admin_index_act'] = '$info->admin_index_act = \'%s\';';
|
||||
|
||||
$xml_obj = XmlParser::loadXmlFile($xml_file); // /< Read xml file and convert it to xml object
|
||||
|
||||
|
|
@ -764,6 +773,7 @@ class moduleModel extends module
|
|||
$actions = $xml_obj->module->actions->action; // /< Action list (required)
|
||||
|
||||
$default_index = $admin_index = '';
|
||||
|
||||
// Arrange permission information
|
||||
if($grants)
|
||||
{
|
||||
|
|
@ -781,8 +791,9 @@ class moduleModel extends module
|
|||
$info->grant->{$name}->title = $title;
|
||||
$info->grant->{$name}->default = $default;
|
||||
|
||||
$buff .= sprintf('$info->grant->%s->title=\'%s\';', $name, $title);
|
||||
$buff .= sprintf('$info->grant->%s->default=\'%s\';', $name, $default);
|
||||
$buff[] = sprintf('$info->grant->%s = new stdClass;', $name);
|
||||
$buff[] = sprintf('$info->grant->%s->title=\'%s\';', $name, $title);
|
||||
$buff[] = sprintf('$info->grant->%s->default=\'%s\';', $name, $default);
|
||||
}
|
||||
}
|
||||
// Permissions to grant
|
||||
|
|
@ -791,6 +802,8 @@ class moduleModel extends module
|
|||
if(is_array($permissions)) $permission_list = $permissions;
|
||||
else $permission_list[] = $permissions;
|
||||
|
||||
$buff[] = '$info->permission = new stdClass;';
|
||||
|
||||
$info->permission = new stdClass();
|
||||
foreach($permission_list as $permission)
|
||||
{
|
||||
|
|
@ -799,7 +812,7 @@ class moduleModel extends module
|
|||
|
||||
$info->permission->{$action} = $target;
|
||||
|
||||
$buff .= sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
||||
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
||||
}
|
||||
}
|
||||
// for admin menus
|
||||
|
|
@ -808,6 +821,7 @@ class moduleModel extends module
|
|||
if(is_array($menus)) $menu_list = $menus;
|
||||
else $menu_list[] = $menus;
|
||||
|
||||
$buff[] = '$info->menu = new stdClass;';
|
||||
$info->menu = new stdClass();
|
||||
foreach($menu_list as $menu)
|
||||
{
|
||||
|
|
@ -820,8 +834,9 @@ class moduleModel extends module
|
|||
$info->menu->{$menu_name}->acts = array();
|
||||
$info->menu->{$menu_name}->type = $menu_type;
|
||||
|
||||
$buff .= sprintf('$info->menu->%s->title=\'%s\';', $menu_name, $menu_title);
|
||||
$buff .= sprintf('$info->menu->%s->type=\'%s\';', $menu_name, $menu_type);
|
||||
$buff[] = sprintf('$info->menu->%s = new stdClass;', $menu_name);
|
||||
$buff[] = sprintf('$info->menu->%s->title=\'%s\';', $menu_name, $menu_title);
|
||||
$buff[] = sprintf('$info->menu->%s->type=\'%s\';', $menu_name, $menu_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -831,6 +846,7 @@ class moduleModel extends module
|
|||
if(is_array($actions)) $action_list = $actions;
|
||||
else $action_list[] = $actions;
|
||||
|
||||
$buff[] = '$info->action = new stdClass;';
|
||||
$info->action = new stdClass();
|
||||
foreach($action_list as $action)
|
||||
{
|
||||
|
|
@ -857,7 +873,7 @@ class moduleModel extends module
|
|||
if($menu_index == 'true')
|
||||
{
|
||||
$info->menu->{$action->attrs->menu_name}->index = $name;
|
||||
$buff .= sprintf('$info->menu->%s->index=\'%s\';', $action->attrs->menu_name, $name);
|
||||
$buff[] = sprintf('$info->menu->%s->index=\'%s\';', $action->attrs->menu_name, $name);
|
||||
}
|
||||
if(is_array($info->menu->{$action->attrs->menu_name}->acts))
|
||||
{
|
||||
|
|
@ -865,14 +881,15 @@ class moduleModel extends module
|
|||
$currentKey = @array_search($name, $info->menu->{$action->attrs->menu_name}->acts);
|
||||
}
|
||||
|
||||
$buff .= sprintf('$info->menu->%s->acts[%d]=\'%s\';', $action->attrs->menu_name, $currentKey, $name);
|
||||
$buff[] = sprintf('$info->menu->%s->acts[%d]=\'%s\';', $action->attrs->menu_name, $currentKey, $name);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$buff .= sprintf('$info->action->%s->type=\'%s\';', $name, $type);
|
||||
$buff .= sprintf('$info->action->%s->grant=\'%s\';', $name, $grant);
|
||||
$buff .= sprintf('$info->action->%s->ruleset=\'%s\';', $name, $ruleset);
|
||||
$buff .= sprintf('$info->action->%s->method=\'%s\';', $name, $method);
|
||||
$buff[] = sprintf('$info->action->%s = new stdClass;', $name);
|
||||
$buff[] = sprintf('$info->action->%s->type=\'%s\';', $name, $type);
|
||||
$buff[] = sprintf('$info->action->%s->grant=\'%s\';', $name, $grant);
|
||||
$buff[] = sprintf('$info->action->%s->ruleset=\'%s\';', $name, $ruleset);
|
||||
$buff[] = sprintf('$info->action->%s->method=\'%s\';', $name, $method);
|
||||
|
||||
if($index=='true')
|
||||
{
|
||||
|
|
@ -896,7 +913,12 @@ class moduleModel extends module
|
|||
}
|
||||
}
|
||||
}
|
||||
$buff = sprintf('<?php if(!defined("__XE__")) exit();$info->default_index_act = \'%s\';$info->setup_index_act=\'%s\';$info->simple_setup_index_act=\'%s\';$info->admin_index_act = \'%s\';%s?>', $default_index_act, $setup_index_act, $simple_setup_index_act, $admin_index_act, $buff);
|
||||
$buff['default_index_act'] = sprintf($buff['default_index_act'], $default_index_act);
|
||||
$buff['setup_index_act'] = sprintf($buff['setup_index_act'], $setup_index_act);
|
||||
$buff['simple_setup_index_act'] = sprintf($buff['simple_setup_index_act'], $simple_setup_index_act);
|
||||
$buff['admin_index_act'] = sprintf($buff['admin_index_act'], $admin_index_act);
|
||||
|
||||
$buff = implode(PHP_EOL, $buff);
|
||||
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue