diff options
author | plegall <plg@piwigo.org> | 2007-04-22 13:11:56 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2007-04-22 13:11:56 +0000 |
commit | 4d7cc8e7f176c28fa603ba93094948f635582078 (patch) | |
tree | e9a077270c41130440bb89c37c5c9263bcba9a37 /include/category_cats.inc.php | |
parent | 6c888182b977beed4374bfa0dab644281ecc2aaf (diff) |
Feature 660 added: creation date of tthe category images can be displayed
next to category title in subcatify mode. The feature was implemented in a
very simple way that must be improved in display, performance and
recursivity.
git-svn-id: http://piwigo.org/svn/trunk@1970 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/category_cats.inc.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index f50f9ff77..a8c6c49ca 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -77,6 +77,7 @@ SELECT $result = pwg_query($query); $categories = array(); +$category_ids = array(); $image_ids = array(); while ($row = mysql_fetch_assoc($result)) @@ -146,10 +147,38 @@ SELECT representative_picture_id $row['representative_picture_id'] = $image_id; array_push($image_ids, $image_id); array_push($categories, $row); + array_push($category_ids, $row['id']); } unset($image_id); } +if ($conf['display_fromto']) +{ + $dates_of_category = array(); + if (count($category_ids) > 0) + { + $query = ' +SELECT + category_id, + MIN(date_creation) AS date_creation_min, + MAX(date_creation) AS date_creation_max + FROM '.IMAGE_CATEGORY_TABLE.' + INNER JOIN '.IMAGES_TABLE.' ON image_id = id + WHERE category_id IN ('.implode(',', $category_ids).') + GROUP BY category_id +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $dates_of_category[ $row['category_id'] ] = array( + 'from' => $row['date_creation_min'], + 'to' => $row['date_creation_max'], + ); + } + // echo '<pre>'; print_r($dates_of_category); echo '</pre>'; + } +} + if ($page['section']=='recent_cats') { usort($categories, 'global_rank_compare'); @@ -221,7 +250,41 @@ if (count($categories) > 0) 'NAME' => $name, ) ); + + if ($conf['display_fromto']) + { + if (isset($dates_of_category[ $category['id'] ])) + { + $from = $dates_of_category[ $category['id'] ]['from']; + $to = $dates_of_category[ $category['id'] ]['to']; + if (!empty($from)) + { + $info = ''; + + if ($from == $to) + { + $info = format_date($from); + } + else + { + $info = sprintf( + l10n('from %s to %s'), + format_date($from), + format_date($to) + ); + } + + $template->assign_block_vars( + 'categories.category.dates', + array( + 'INFO' => $info, + ) + ); + } + } + } + //plugins need to add/modify sth in this loop ? trigger_action('loc_index_category_thumbnail', $category, 'categories.category' ); |