From 145bdab6c62c22747b13fdabbff3a05db0e05b7a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 7 Mar 2016 10:27:27 +0900 Subject: [PATCH] Allow more units in widget cache settings --- .../tpl/widget_generate_code.include.html | 9 ++++++++- modules/widget/widget.controller.php | 20 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/modules/widget/tpl/widget_generate_code.include.html b/modules/widget/tpl/widget_generate_code.include.html index 8d931af62..07e1daec0 100644 --- a/modules/widget/tpl/widget_generate_code.include.html +++ b/modules/widget/tpl/widget_generate_code.include.html @@ -25,7 +25,14 @@
- {$lang->unit_min} + + +

{$lang->about_widget_cache}

diff --git a/modules/widget/widget.controller.php b/modules/widget/widget.controller.php index bc0154136..623c534ad 100644 --- a/modules/widget/widget.controller.php +++ b/modules/widget/widget.controller.php @@ -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:@', '