mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-09 18:05:56 +03:00
Move get_icon function.
git-svn-id: http://piwigo.org/svn/trunk@3188 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
1516e8833f
commit
36d0da30d3
8 changed files with 55 additions and 58 deletions
|
@ -244,7 +244,7 @@ if (count($categories) > 0)
|
||||||
'ID' => $category['id'],
|
'ID' => $category['id'],
|
||||||
'TN_SRC' => $thumbnail_src_of[$category['representative_picture_id']],
|
'TN_SRC' => $thumbnail_src_of[$category['representative_picture_id']],
|
||||||
'TN_ALT' => strip_tags($category['name']),
|
'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(
|
'URL' => make_index_url(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -110,7 +110,7 @@ foreach ($pictures as $row)
|
||||||
'TN_SRC' => get_thumbnail_url($row),
|
'TN_SRC' => get_thumbnail_url($row),
|
||||||
'TN_ALT' => $row['file'],
|
'TN_ALT' => $row['file'],
|
||||||
'TN_TITLE' => get_thumbnail_title($row),
|
'TN_TITLE' => get_thumbnail_title($row),
|
||||||
'ICON_TS' => get_icon($row['date_available']),
|
'icon_ts' => get_icon($row['date_available']),
|
||||||
'URL' => $url,
|
'URL' => $url,
|
||||||
|
|
||||||
/* Fields for template-extension usage */
|
/* Fields for template-extension usage */
|
||||||
|
|
|
@ -1548,4 +1548,47 @@ function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $cle
|
||||||
}
|
}
|
||||||
return $navbar;
|
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();
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -120,7 +120,7 @@ WHERE '.$where.'
|
||||||
),
|
),
|
||||||
'URL' => make_index_url(array('category' => $row)),
|
'URL' => make_index_url(array('category' => $row)),
|
||||||
'LEVEL' => substr_count($row['global_rank'], '.') + 1,
|
'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,
|
'SELECTED' => $selected_category['id'] == $row['id'] ? true : false,
|
||||||
'IS_UPPERCAT' => $selected_category['id_uppercat'] == $row['id'] ? true : false,
|
'IS_UPPERCAT' => $selected_category['id_uppercat'] == $row['id'] ? true : false,
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,58 +21,6 @@
|
||||||
// | USA. |
|
// | 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
|
* returns the list of categories as a HTML string
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="{$cat.URL}">{$cat.NAME}</a>
|
<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>
|
</h3>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
{if isset($cat.INFO_DATES) }
|
{if isset($cat.INFO_DATES) }
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
{if $cat.count_images > 0}
|
{if $cat.count_images > 0}
|
||||||
<span class="{if $cat.nb_images > 0}menuInfoCat{else}menuInfoCatByChild{/if}" title="{$cat.TITLE}">[{$cat.count_images}]</span>
|
<span class="{if $cat.nb_images > 0}menuInfoCat{else}menuInfoCatByChild{/if}" title="{$cat.TITLE}">[{$cat.count_images}]</span>
|
||||||
{/if}
|
{/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}
|
{assign var='ref_level' value=$cat.LEVEL}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{'</li></ul>'|@str_repeat:$ref_level}
|
{'</li></ul>'|@str_repeat:$ref_level}
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="thumbLegend">
|
<span class="thumbLegend">
|
||||||
{if isset($thumbnail.NAME)}{$thumbnail.NAME}{/if}
|
{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)}
|
{if isset($thumbnail.NB_COMMENTS)}
|
||||||
<span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments">
|
<span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments">
|
||||||
<br>
|
<br>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue