aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_cats.inc.php63
-rw-r--r--include/config_default.inc.php4
-rw-r--r--template/yoga/mainpage_categories.tpl3
3 files changed, 70 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' );
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index cc949f7b2..0ac388e33 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -234,6 +234,10 @@ $conf['show_picture_name_on_title'] = true;
// 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;
+
// allow_random_representative : do you wish PhpWebGallery to search among
// categories elements a new representative at each reload ?
//
diff --git a/template/yoga/mainpage_categories.tpl b/template/yoga/mainpage_categories.tpl
index 4d8efdd93..8708aa5c3 100644
--- a/template/yoga/mainpage_categories.tpl
+++ b/template/yoga/mainpage_categories.tpl
@@ -14,6 +14,9 @@
<a href="{categories.category.URL}">{categories.category.NAME}</a>
{categories.category.ICON}
</h3>
+ <!-- BEGIN dates -->
+ <p>{categories.category.dates.INFO}</p>
+ <!-- END dates -->
<p>{categories.category.CAPTION_NB_IMAGES}</p>
<p>{categories.category.DESCRIPTION}&nbsp;</p>
</div>