aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_cats.inc.php143
-rw-r--r--include/category_default.inc.php62
-rw-r--r--include/config_default.inc.php4
-rw-r--r--template/yoga/thumbnails.tpl23
4 files changed, 80 insertions, 152 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 7f3c2ace6..3b324097c 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -215,25 +215,24 @@ if (count($categories) > 0)
update_cats_with_filtered_data($categories);
}
+ $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl');
+
trigger_action('loc_begin_index_category_thumbnails', $categories);
- if ($conf['subcatify'])
- {
- $template->set_filename('mainpage_categories', 'mainpage_categories.tpl');
- foreach ($categories as $category)
+ foreach ($categories as $category)
+ {
+ if ($page['section']=='recent_cats')
{
- if ($page['section']=='recent_cats')
- {
- $name = get_cat_display_name_cache($category['uppercats'], null, false);
- }
- else
- {
- $name = $category['name'];
- }
+ $name = get_cat_display_name_cache($category['uppercats'], null, false);
+ }
+ else
+ {
+ $name = $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']);
- $tpl_var =
+ $tpl_var =
array(
'ID' => $category['id'],
'TN_SRC' => $thumbnail_src_of[$category['representative_picture_id']],
@@ -259,104 +258,44 @@ if (count($categories) > 0)
@$category['comment'],
'subcatify_category_description')),
'NAME' => $name,
- );
+ );
- if ($conf['display_fromto'])
+ if ($conf['display_fromto'])
+ {
+ if (isset($dates_of_category[ $category['id'] ]))
{
- if (isset($dates_of_category[ $category['id'] ]))
+ $from = $dates_of_category[ $category['id'] ]['from'];
+ $to = $dates_of_category[ $category['id'] ]['to'];
+
+ if (!empty($from))
{
- $from = $dates_of_category[ $category['id'] ]['from'];
- $to = $dates_of_category[ $category['id'] ]['to'];
+ $info = '';
- if (!empty($from))
+ if ($from == $to)
{
- $info = '';
-
- if ($from == $to)
- {
- $info = format_date($from);
- }
- else
- {
- $info = sprintf(
- l10n('from %s to %s'),
- format_date($from),
- format_date($to)
- );
- }
- $tpl_var['INFO_DATES'] = $info;
+ $info = format_date($from);
+ }
+ else
+ {
+ $info = sprintf(
+ l10n('from %s to %s'),
+ format_date($from),
+ format_date($to)
+ );
}
+ $tpl_var['INFO_DATES'] = $info;
}
- }//fromto
-
- $template->append( 'category_thumbnails', $tpl_var);
-
-
- //plugins need to add/modify sth in this loop ?
- trigger_action('loc_index_category_thumbnail',
- $category, 'categories.category' );
- }
-
- $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
- }
- else
- {
- $template->set_filename( 'thumbnails', 'thumbnails.tpl');
-
- if ($page['section']=='recent_cats')
- {
- $old_level_separator = $conf['level_separator'];
- $conf['level_separator'] = '<br />';
- }
-
- foreach ($categories as $category)
- {
- $tpl_var =
- array(
- 'IMAGE' => $thumbnail_src_of[ $category['representative_picture_id'] ],
- 'IMAGE_ALT' => $category['name'],
- 'IMAGE_TITLE' => get_display_images_count
- (
- $category['nb_images'],
- $category['count_images'],
- $category['count_categories'],
- true,
- ' / '
- ),
-
- 'U_IMG_LINK' => make_index_url(
- array(
- 'category' => $category
- )
- ),
- 'CLASS' => 'thumbCat',
- );
- if ($page['section']=='recent_cats')
- {
- $name = get_cat_display_name_cache($category['uppercats'], null, false);
}
- else
- {
- $name = $category['name'];
- $tpl_var['IMAGE_TS'] = get_icon($category['max_date_last'], $category['is_child_date_last']);
- }
- $tpl_var['CATEGORY_NAME']=$name;
-
- $template->append('thumbnails', $tpl_var);
+ }//fromto
- //plugins need to add/modify sth in this loop ?
- trigger_action('loc_index_category_thumbnail',
- $category, 'thumbnails' );
+ //plugins need to add/modify sth in this loop ?
+ $tpl_var = trigger_event('loc_index_category_thumbnail',
+ $tpl_var, $category );
- }
-
- if ( isset($old_level_separator) )
- {
- $conf['level_separator']=$old_level_separator;
- }
-
- $template->assign_var_from_handle('CATEGORIES', 'thumbnails');
+ $template->append( 'category_thumbnails', $tpl_var);
}
+
trigger_action('loc_end_index_category_thumbnails', $categories);
+ $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
}
-?> \ No newline at end of file
+?>
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 365eedff6..bbfb35a6f 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -58,8 +58,6 @@ SELECT *
usort($pictures, 'rank_compare');
}
-// template thumbnail initialization
-$template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
if (count($pictures) > 0)
{
// define category slideshow url
@@ -78,9 +76,22 @@ if (count($pictures) > 0)
: '' ))
);
- $template->clear_assign('thumbnails'); // category_default reuse them
+ if ($user['show_nb_comments'])
+ {
+ $query = '
+SELECT image_id, COUNT(*) AS nb_comments
+ FROM '.COMMENTS_TABLE.'
+ WHERE validated = \'true\'
+ AND image_id IN ('.implode(',', $selection).')
+ GROUP BY image_id
+;';
+ $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments');
+ }
}
+// template thumbnail initialization
+$template->set_filenames( array( 'index_thumbnails' => 'thumbnails.tpl',));
+
trigger_action('loc_begin_index_thumbnails', $pictures);
foreach ($pictures as $row)
@@ -98,23 +109,17 @@ foreach ($pictures as $row)
$tpl_var =
array(
- 'IMAGE' => $thumbnail_url,
- 'IMAGE_ALT' => $row['file'],
- 'IMAGE_TITLE' => get_thumbnail_title($row),
- 'IMAGE_TS' => get_icon($row['date_available']),
-
- 'U_IMG_LINK' => $url,
-
- 'CLASS' => 'thumbElmt',
+ 'ID' => $row['id'],
+ 'IMAGE' => $thumbnail_url,
+ 'IMAGE_ALT' => $row['file'],
+ 'IMAGE_TITLE' => get_thumbnail_title($row),
+ 'IMAGE_TS' => get_icon($row['date_available']),
+ 'U_IMG_LINK' => $url,
);
if ($user['show_nb_hits'])
{
- $tpl_var['nb_hits'] =
- array(
- 'HITS'=> $row['hit'],
- 'CLASS'=> set_span_class($row['hit']),
- );
+ $tpl_var['NB_HITS'] = $row['hit'];
}
if ($conf['show_thumbnail_caption'])
@@ -148,30 +153,21 @@ foreach ($pictures as $row)
$tpl_var['ELEMENT_NAME'] = $name;
}
- if ($user['show_nb_comments'])
+ if ( isset($nb_comments_of) )
{
- $query = '
-SELECT COUNT(*) AS nb_comments
- FROM '.COMMENTS_TABLE.'
- WHERE image_id = '.$row['id'].'
- AND validated = \'true\'
-;';
- list($row['nb_comments']) = mysql_fetch_array(pwg_query($query));
- $tpl_var['nb_comments'] =
- array(
- 'NB_COMMENTS'=> $row['nb_comments'],
- 'CLASS'=> set_span_class($row['nb_comments']),
- );
+ $row['nb_comments'] = isset($nb_comments_of[$row['id']])
+ ? (int)$nb_comments_of[$row['id']] : 0;
+ $tpl_var['NB_COMMENTS'] = $row['nb_comments'];
}
- $template->append('thumbnails', $tpl_var);
-
//plugins need to add/modify sth in this loop ?
- trigger_action('loc_index_thumbnail', $row, 'thumbnails' );
+ $tpl_var = trigger_event('loc_index_thumbnail', $tpl_var, $row);
+
+ $template->append('thumbnails', $tpl_var);
}
trigger_action('loc_end_index_thumbnails', $pictures);
-$template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
+$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
pwg_debug('end include/category_default.inc.php');
?>
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 67369119e..addb5a1f9 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -222,10 +222,6 @@ $conf['show_thumbnail_caption'] = true;
// name ?
$conf['show_picture_name_on_title'] = true;
-// subcatify: display thumbnails representing a category a different way
-// than thumbnails representing a picture.
-$conf['subcatify'] = true;
-
// display_fromto: in subcatify mode, display the date creation bounds of a
// category.
$conf['display_fromto'] = false;
diff --git a/template/yoga/thumbnails.tpl b/template/yoga/thumbnails.tpl
index 106a20847..2fd37f649 100644
--- a/template/yoga/thumbnails.tpl
+++ b/template/yoga/thumbnails.tpl
@@ -3,32 +3,29 @@
{if !empty($thumbnails)}
<ul class="thumbnails">
{foreach from=$thumbnails item=thumbnail}
- <li class="{$thumbnail.CLASS}">
+ <li>
<span class="wrap1">
<span class="wrap2">
<a href="{$thumbnail.U_IMG_LINK}">
- <img class="thumbnail" src="{$thumbnail.IMAGE}"
- alt="{$thumbnail.IMAGE_ALT}"
- title="{$thumbnail.IMAGE_TITLE}">
+ <img class="thumbnail" src="{$thumbnail.IMAGE}" alt="{$thumbnail.IMAGE_ALT}" title="{$thumbnail.IMAGE_TITLE}" />
</a>
</span>
<span class="thumbLegend">
{if !empty($thumbnail.ELEMENT_NAME)}{$thumbnail.ELEMENT_NAME}{/if}
- {if !empty($thumbnail.CATEGORY_NAME)}{$thumbnail.CATEGORY_NAME}{/if}
{if !empty($thumbnail.IMAGE_TS)}{$thumbnail.IMAGE_TS}{/if}
-
- {if !empty($thumbnail.nb_comments)}
- <span class="{$thumbnail.nb_comments.CLASS} nb-comments">
+
+ {if isset($thumbnail.NB_COMMENTS)}
+ <span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments">
<br />
- {$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.nb_comments.NB_COMMENTS)}
+ {$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.NB_COMMENTS)}
</span>
{/if}
-
- {if !empty($thumbnail.nb_hits)}
- <span class="{$thumbnail.nb_hits.CLASS} nb-hits">
+
+ {if isset($thumbnail.NB_HITS)}
+ <span class="{if 0==$thumbnail.NB_HITS}zero {/if}nb-hits">
<br />
- {$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.nb_hits.HITS)}
+ {$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.NB_HITS)}
</span>
{/if}
</span>