From 36d0da30d307cd821413ccb8ea1ccc68de1d8538 Mon Sep 17 00:00:00 2001 From: patdenice Date: Wed, 11 Mar 2009 17:25:26 +0000 Subject: Move get_icon function. git-svn-id: http://piwigo.org/svn/trunk@3188 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/category_cats.inc.php | 2 +- include/category_default.inc.php | 2 +- include/functions.inc.php | 43 +++++++++++++++++++++++++++++ include/functions_category.inc.php | 2 +- include/functions_html.inc.php | 52 ----------------------------------- template/yoga/mainpage_categories.tpl | 4 ++- template/yoga/menubar_categories.tpl | 4 ++- template/yoga/thumbnails.tpl | 4 ++- 8 files changed, 55 insertions(+), 58 deletions(-) diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index 635b5efed..43f4776fc 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -244,7 +244,7 @@ if (count($categories) > 0) 'ID' => $category['id'], 'TN_SRC' => $thumbnail_src_of[$category['representative_picture_id']], 'TN_ALT' => strip_tags($category['name']), - 'ICON_TS' => get_icon($category['max_date_last'], $category['is_child_date_last']), + 'icon_ts' => get_icon($category['max_date_last'], $category['is_child_date_last']), 'URL' => make_index_url( array( diff --git a/include/category_default.inc.php b/include/category_default.inc.php index 98e6250f1..ae24adec1 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -110,7 +110,7 @@ foreach ($pictures as $row) 'TN_SRC' => get_thumbnail_url($row), 'TN_ALT' => $row['file'], 'TN_TITLE' => get_thumbnail_title($row), - 'ICON_TS' => get_icon($row['date_available']), + 'icon_ts' => get_icon($row['date_available']), 'URL' => $url, /* Fields for template-extension usage */ 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 diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 8d05a6c2a..a96347258 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -120,7 +120,7 @@ WHERE '.$where.' ), 'URL' => make_index_url(array('category' => $row)), 'LEVEL' => substr_count($row['global_rank'], '.') + 1, - 'ICON_TS' => get_icon($row['max_date_last'], $child_date_last), + 'icon_ts' => get_icon($row['max_date_last'], $child_date_last), 'SELECTED' => $selected_category['id'] == $row['id'] ? true : false, 'IS_UPPERCAT' => $selected_category['id_uppercat'] == $row['id'] ? true : false, ) diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 4dac9cb88..4be5ef077 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -21,58 +21,6 @@ // | USA. | // +-----------------------------------------------------------------------+ -function get_icon($date, $is_child_date = false) -{ - global $cache, $user; - - if (empty($date)) - { - return ''; - } - - if (isset($cache['get_icon'][$date])) - { - if (! $cache['get_icon'][$date] ) - return ''; - return $cache['get_icon']['_icons_'][$is_child_date]; - } - - 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] = false; - if ( $date > $cache['get_icon']['sql_recent_date'] ) - { - if ( !isset($cache['get_icon']['_icons_'] ) ) - { - $icons = array(false => 'recent', true => 'recent_by_child' ); - $title = sprintf( - l10n('elements posted during the last %d days'), - $user['recent_period'] - ); - foreach ($icons as $key => $icon) - { - $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png'; - $size = getimagesize( PHPWG_ROOT_PATH.$icon_url ); - $icon_url = get_root_url().$icon_url; - $output = '(!)'; - $cache['get_icon']['_icons_'][$key] = $output; - } - } - $cache['get_icon'][$date] = true; - } - - if (! $cache['get_icon'][$date] ) - return ''; - return $cache['get_icon']['_icons_'][$is_child_date]; -} - /** * returns the list of categories as a HTML string * diff --git a/template/yoga/mainpage_categories.tpl b/template/yoga/mainpage_categories.tpl index e1cc953ff..6b96167e5 100644 --- a/template/yoga/mainpage_categories.tpl +++ b/template/yoga/mainpage_categories.tpl @@ -12,7 +12,9 @@

{$cat.NAME} - {$cat.ICON_TS} + {if !empty($cat.icon_ts)} + (!) + {/if}

{if isset($cat.INFO_DATES) } diff --git a/template/yoga/menubar_categories.tpl b/template/yoga/menubar_categories.tpl index d650c49b9..0dbb22b77 100644 --- a/template/yoga/menubar_categories.tpl +++ b/template/yoga/menubar_categories.tpl @@ -21,7 +21,9 @@ {if $cat.count_images > 0} [{$cat.count_images}] {/if} - {$cat.ICON_TS} + {if !empty($cat.icon_ts)} + (!) + {/if} {assign var='ref_level' value=$cat.LEVEL} {/foreach} {''|@str_repeat:$ref_level} diff --git a/template/yoga/thumbnails.tpl b/template/yoga/thumbnails.tpl index 01068dee8..31d6cb890 100644 --- a/template/yoga/thumbnails.tpl +++ b/template/yoga/thumbnails.tpl @@ -12,7 +12,9 @@ {if isset($thumbnail.NAME)}{$thumbnail.NAME}{/if} - {$thumbnail.ICON_TS} + {if !empty($thumbnail.icon_ts)} + (!) + {/if} {if isset($thumbnail.NB_COMMENTS)}
-- cgit v1.2.3