diff options
Diffstat (limited to '')
-rw-r--r-- | include/category_cats.inc.php | 2 | ||||
-rw-r--r-- | include/category_default.inc.php | 2 | ||||
-rw-r--r-- | include/functions.inc.php | 43 | ||||
-rw-r--r-- | include/functions_category.inc.php | 2 | ||||
-rw-r--r-- | include/functions_html.inc.php | 52 |
5 files changed, 46 insertions, 55 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 = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;'; - $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)">'; - $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 * |