mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +09:00
moduleModel::getModuleActionXmlInfo()를 memcache나 apc로 캐싱할 수 있도록 개선
This commit is contained in:
parent
f120f4c8da
commit
95322d2b5d
1 changed files with 240 additions and 181 deletions
|
|
@ -817,13 +817,29 @@ class moduleModel extends module
|
||||||
$xml_file = sprintf("%sconf/module.xml", $class_path);
|
$xml_file = sprintf("%sconf/module.xml", $class_path);
|
||||||
if(!file_exists($xml_file)) return;
|
if(!file_exists($xml_file)) return;
|
||||||
|
|
||||||
|
$oCacheHandler = CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$object_key = 'module:' . $module . '_' . Context::getLangType() . '_' . __XE_VERSION__;
|
||||||
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
|
||||||
|
$info = $oCacheHandler->get($cache_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($info)
|
||||||
|
{
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Check if cached file exists
|
// Check if cached file exists
|
||||||
$cache_file = sprintf(_XE_PATH_ . "files/cache/module_info/%s.%s.%s.php", $module, Context::getLangType(), __XE_VERSION__);
|
$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
|
// Update if no cache file exists or it is older than xml file
|
||||||
if(!file_exists($cache_file) || filemtime($cache_file) < filemtime($xml_file) || $re_cache)
|
if($oCacheHandler->isSupport() || (!file_exists($cache_file) || filemtime($cache_file) < filemtime($xml_file) || $re_cache))
|
||||||
{
|
{
|
||||||
$info = new stdClass();
|
$info = new stdClass();
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff = array(); // /< 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[] = '<?php if(!defined("__XE__")) exit();';
|
||||||
$buff[] = '$info = new stdClass;';
|
$buff[] = '$info = new stdClass;';
|
||||||
|
|
@ -831,6 +847,7 @@ class moduleModel extends module
|
||||||
$buff['setup_index_act'] = '$info->setup_index_act=\'%s\';';
|
$buff['setup_index_act'] = '$info->setup_index_act=\'%s\';';
|
||||||
$buff['simple_setup_index_act'] = '$info->simple_setup_index_act=\'%s\';';
|
$buff['simple_setup_index_act'] = '$info->simple_setup_index_act=\'%s\';';
|
||||||
$buff['admin_index_act'] = '$info->admin_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
|
$xml_obj = XmlParser::loadXmlFile($xml_file); // /< Read xml file and convert it to xml object
|
||||||
|
|
||||||
|
|
@ -850,7 +867,10 @@ class moduleModel extends module
|
||||||
else $grant_list[] = $grants;
|
else $grant_list[] = $grants;
|
||||||
|
|
||||||
$info->grant = new stdClass();
|
$info->grant = new stdClass();
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = '$info->grant = new stdClass;';
|
$buff[] = '$info->grant = new stdClass;';
|
||||||
|
}
|
||||||
foreach($grant_list as $grant)
|
foreach($grant_list as $grant)
|
||||||
{
|
{
|
||||||
$name = $grant->attrs->name;
|
$name = $grant->attrs->name;
|
||||||
|
|
@ -861,11 +881,14 @@ class moduleModel extends module
|
||||||
$info->grant->{$name}->title = $title;
|
$info->grant->{$name}->title = $title;
|
||||||
$info->grant->{$name}->default = $default;
|
$info->grant->{$name}->default = $default;
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = sprintf('$info->grant->%s = new stdClass;', $name);
|
$buff[] = sprintf('$info->grant->%s = new stdClass;', $name);
|
||||||
$buff[] = sprintf('$info->grant->%s->title=\'%s\';', $name, $title);
|
$buff[] = sprintf('$info->grant->%s->title=\'%s\';', $name, $title);
|
||||||
$buff[] = sprintf('$info->grant->%s->default=\'%s\';', $name, $default);
|
$buff[] = sprintf('$info->grant->%s->default=\'%s\';', $name, $default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Permissions to grant
|
// Permissions to grant
|
||||||
if($permissions)
|
if($permissions)
|
||||||
{
|
{
|
||||||
|
|
@ -882,16 +905,22 @@ class moduleModel extends module
|
||||||
|
|
||||||
$info->permission->{$action} = $target;
|
$info->permission->{$action} = $target;
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// for admin menus
|
// for admin menus
|
||||||
if($menus)
|
if($menus)
|
||||||
{
|
{
|
||||||
if(is_array($menus)) $menu_list = $menus;
|
if(is_array($menus)) $menu_list = $menus;
|
||||||
else $menu_list[] = $menus;
|
else $menu_list[] = $menus;
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = '$info->menu = new stdClass;';
|
$buff[] = '$info->menu = new stdClass;';
|
||||||
|
}
|
||||||
$info->menu = new stdClass();
|
$info->menu = new stdClass();
|
||||||
foreach($menu_list as $menu)
|
foreach($menu_list as $menu)
|
||||||
{
|
{
|
||||||
|
|
@ -904,11 +933,14 @@ class moduleModel extends module
|
||||||
$info->menu->{$menu_name}->acts = array();
|
$info->menu->{$menu_name}->acts = array();
|
||||||
$info->menu->{$menu_name}->type = $menu_type;
|
$info->menu->{$menu_name}->type = $menu_type;
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = sprintf('$info->menu->%s = new stdClass;', $menu_name);
|
$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->title=\'%s\';', $menu_name, $menu_title);
|
||||||
$buff[] = sprintf('$info->menu->%s->type=\'%s\';', $menu_name, $menu_type);
|
$buff[] = sprintf('$info->menu->%s->type=\'%s\';', $menu_name, $menu_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
if($actions)
|
if($actions)
|
||||||
|
|
@ -916,7 +948,10 @@ class moduleModel extends module
|
||||||
if(is_array($actions)) $action_list = $actions;
|
if(is_array($actions)) $action_list = $actions;
|
||||||
else $action_list[] = $actions;
|
else $action_list[] = $actions;
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = '$info->action = new stdClass;';
|
$buff[] = '$info->action = new stdClass;';
|
||||||
|
}
|
||||||
$info->action = new stdClass();
|
$info->action = new stdClass();
|
||||||
foreach($action_list as $action)
|
foreach($action_list as $action)
|
||||||
{
|
{
|
||||||
|
|
@ -945,24 +980,33 @@ class moduleModel extends module
|
||||||
if($menu_index == 'true')
|
if($menu_index == 'true')
|
||||||
{
|
{
|
||||||
$info->menu->{$action->attrs->menu_name}->index = $name;
|
$info->menu->{$action->attrs->menu_name}->index = $name;
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$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))
|
if(is_array($info->menu->{$action->attrs->menu_name}->acts))
|
||||||
{
|
{
|
||||||
$info->menu->{$action->attrs->menu_name}->acts[] = $name;
|
$info->menu->{$action->attrs->menu_name}->acts[] = $name;
|
||||||
$currentKey = array_search($name, $info->menu->{$action->attrs->menu_name}->acts);
|
$currentKey = array_search($name, $info->menu->{$action->attrs->menu_name}->acts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$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++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff[] = sprintf('$info->action->%s = new stdClass;', $name);
|
$buff[] = sprintf('$info->action->%s = new stdClass;', $name);
|
||||||
$buff[] = sprintf('$info->action->%s->type=\'%s\';', $name, $type);
|
$buff[] = sprintf('$info->action->%s->type=\'%s\';', $name, $type);
|
||||||
$buff[] = sprintf('$info->action->%s->grant=\'%s\';', $name, $grant);
|
$buff[] = sprintf('$info->action->%s->grant=\'%s\';', $name, $grant);
|
||||||
$buff[] = sprintf('$info->action->%s->standalone=\'%s\';', $name, $standalone);
|
$buff[] = sprintf('$info->action->%s->standalone=\'%s\';', $name, $standalone);
|
||||||
$buff[] = sprintf('$info->action->%s->ruleset=\'%s\';', $name, $ruleset);
|
$buff[] = sprintf('$info->action->%s->ruleset=\'%s\';', $name, $ruleset);
|
||||||
$buff[] = sprintf('$info->action->%s->method=\'%s\';', $name, $method);
|
$buff[] = sprintf('$info->action->%s->method=\'%s\';', $name, $method);
|
||||||
|
}
|
||||||
|
|
||||||
if($index=='true')
|
if($index=='true')
|
||||||
{
|
{
|
||||||
|
|
@ -986,21 +1030,36 @@ class moduleModel extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!$oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
$buff['default_index_act'] = sprintf($buff['default_index_act'], $default_index_act);
|
$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['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['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['admin_index_act'] = sprintf($buff['admin_index_act'], $admin_index_act);
|
||||||
|
|
||||||
$buff[] = 'return $info;';
|
$buff[] = 'return $info;';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
|
||||||
|
$oCacheHandler->put($cache_key, $info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$buff = implode(PHP_EOL, $buff);
|
$buff = implode(PHP_EOL, $buff);
|
||||||
|
|
||||||
FileHandler::writeFile($cache_file, $buff);
|
FileHandler::writeFile($cache_file, $buff);
|
||||||
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($cache_file)) return include($cache_file);
|
if(!$oCacheHandler->isSupport() && file_exists($cache_file))
|
||||||
|
{
|
||||||
|
return include($cache_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue