aboutsummaryrefslogtreecommitdiffstats
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
parent1516e8833f3a73b1dc4b73e7fa7d3c36bc25c0b4 (diff)
Move get_icon function.
git-svn-id: http://piwigo.org/svn/trunk@3188 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/category_cats.inc.php2
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/functions.inc.php43
-rw-r--r--include/functions_category.inc.php2
-rw-r--r--include/functions_html.inc.php52
-rw-r--r--template/yoga/mainpage_categories.tpl4
-rw-r--r--template/yoga/menubar_categories.tpl4
-rw-r--r--template/yoga/thumbnails.tpl4
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 = '<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
*
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 @@
<div class="description">
<h3>
<a href="{$cat.URL}">{$cat.NAME}</a>
- {$cat.ICON_TS}
+ {if !empty($cat.icon_ts)}
+ <img title="{$cat.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent{if $cat.icon_ts.IS_CHILD_DATE}_by_child{/if}.png" class="icon" alt="(!)" />
+ {/if}
</h3>
<div class="text">
{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}
<span class="{if $cat.nb_images > 0}menuInfoCat{else}menuInfoCatByChild{/if}" title="{$cat.TITLE}">[{$cat.count_images}]</span>
{/if}
- {$cat.ICON_TS}
+ {if !empty($cat.icon_ts)}
+ <img title="{$cat.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent{if $cat.icon_ts.IS_CHILD_DATE}_by_child{/if}.png" class="icon" alt="(!)" />
+ {/if}
{assign var='ref_level' value=$cat.LEVEL}
{/foreach}
{'</li></ul>'|@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 @@
</span>
<span class="thumbLegend">
{if isset($thumbnail.NAME)}{$thumbnail.NAME}{/if}
- {$thumbnail.ICON_TS}
+ {if !empty($thumbnail.icon_ts)}
+ <img title="{$thumbnail.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent.png" class="icon" alt="(!)" />
+ {/if}
{if isset($thumbnail.NB_COMMENTS)}
<span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments">
<br>