aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2009-03-11 17:25:26 +0000
committerpatdenice <patdenice@piwigo.org>2009-03-11 17:25:26 +0000
commit36d0da30d307cd821413ccb8ea1ccc68de1d8538 (patch)
treee94b6f52d4657cecc5f7340526a467f095b684a3 /include/functions.inc.php
parent1516e8833f3a73b1dc4b73e7fa7d3c36bc25c0b4 (diff)
Move get_icon function.
git-svn-id: http://piwigo.org/svn/trunk@3188 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 2e72eb2cb..584933786 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1548,4 +1548,47 @@ function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $cle
}
return $navbar;
}
+
+/**
+ * return an array which will be sent to template to display recent icon
+ */
+function get_icon($date, $is_child_date = false)
+{
+ global $cache, $user;
+
+ if (empty($date))
+ {
+ return false;
+ }
+
+ if (!isset($cache['get_icon']['title']))
+ {
+ $cache['get_icon']['title'] = sprintf(
+ l10n('elements posted during the last %d days'),
+ $user['recent_period']
+ );
+ }
+
+ $icon = array(
+ 'TITLE' => $cache['get_icon']['title'],
+ 'IS_CHILD_DATE' => $is_child_date,
+ );
+
+ if (isset($cache['get_icon'][$date]))
+ {
+ return $cache['get_icon'][$date] ? $icon : array();
+ }
+
+ if (!isset($cache['get_icon']['sql_recent_date']))
+ {
+ // Use MySql date in order to standardize all recent "actions/queries"
+ list($cache['get_icon']['sql_recent_date']) =
+ mysql_fetch_array(pwg_query('select SUBDATE(
+ CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
+ }
+
+ $cache['get_icon'][$date] = $date > $cache['get_icon']['sql_recent_date'];
+
+ return $cache['get_icon'][$date] ? $icon : array();
+}
?> \ No newline at end of file