mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Allow more units in widget cache settings
This commit is contained in:
parent
f40ea2e05d
commit
145bdab6c6
2 changed files with 25 additions and 4 deletions
|
|
@ -25,7 +25,14 @@
|
|||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="widget_cache">{$lang->widget_cache}</label>
|
||||
<div class="x_controls">
|
||||
<input type="number" name="widget_cache" id="widget_cache" value="0" size="2" /> {$lang->unit_min}
|
||||
<input type="number" name="widget_cache" id="widget_cache" value="0" size="5" />
|
||||
<select name="widget_cache_unit" id="widget_cache_unit" style="width:60px;min-width:60px">
|
||||
<option value="s">{$lang->unit_sec}</option>
|
||||
<option value="m" selected="selected">{$lang->unit_min}</option>
|
||||
<option value="h">{$lang->unit_hour}</option>
|
||||
<option value="d">{$lang->unit_day}</option>
|
||||
</select>
|
||||
<br />
|
||||
<p class="x_help-inline">{$lang->about_widget_cache}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -359,6 +359,16 @@ class widgetController extends widget
|
|||
// widget, the cache number and cache values are set
|
||||
$widget_sequence = $args->widget_sequence;
|
||||
$widget_cache = $args->widget_cache;
|
||||
if (preg_match('/^([0-9\.]+)([smhd])$/i', $widget_cache, $matches))
|
||||
{
|
||||
$multipliers = array('s' => 1, 'm' => 60, 'h' => 3600, 'd' => 86400);
|
||||
$widget_cache = intval(floatval($matches[1]) * $multipliers[strtolower($matches[2])]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$widget_cache = intval(floatval($widget_cache) * 60);
|
||||
}
|
||||
debugPrint($widget_cache);
|
||||
|
||||
/**
|
||||
* Even if the cache number and value of the cache and return it to extract data
|
||||
|
|
@ -400,7 +410,7 @@ class widgetController extends widget
|
|||
{
|
||||
$filemtime = filemtime($cache_file);
|
||||
// Should be modified compared to the time of the cache or in the future if creating more than widget.controller.php file a return value of the cache
|
||||
if($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php'))
|
||||
if($filemtime + $widget_cache > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php'))
|
||||
{
|
||||
$cache_body = FileHandler::readFile($cache_file);
|
||||
$cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body);
|
||||
|
|
@ -411,7 +421,7 @@ class widgetController extends widget
|
|||
// cache update and cache renewal of the file mtime
|
||||
if(!$oCacheHandler->isSupport())
|
||||
{
|
||||
touch($cache_file);
|
||||
touch($cache_file);
|
||||
}
|
||||
|
||||
$oWidget = $this->getWidgetObject($widget);
|
||||
|
|
@ -422,7 +432,7 @@ class widgetController extends widget
|
|||
$oModuleController->replaceDefinedLangCode($widget_content);
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$oCacheHandler->put($key, $widget_content, $widget_cache * 60);
|
||||
$oCacheHandler->put($key, $widget_content, $widget_cache);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -751,6 +761,10 @@ class widgetController extends widget
|
|||
$vars->colorset = trim($request_vars->colorset);
|
||||
$vars->widget_sequence = (int)($request_vars->widget_sequence);
|
||||
$vars->widget_cache = (int)($request_vars->widget_cache);
|
||||
if($request_vars->widget_cache_unit && in_array($request_vars->widget_cache_unit, array('s', 'm', 'h', 'd')))
|
||||
{
|
||||
$vars->widget_cache .= $request_vars->widget_cache_unit;
|
||||
}
|
||||
$vars->style = trim($request_vars->style);
|
||||
$vars->widget_padding_left = trim($request_vars->widget_padding_left);
|
||||
$vars->widget_padding_right = trim($request_vars->widget_padding_right);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue