Skip to content

Commit

Permalink
Feature 660 added: creation date of tthe category images can be displ…
Browse files Browse the repository at this point in the history
…ayed

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
  • Loading branch information
plegall committed Apr 22, 2007
1 parent 6c88818 commit 4d7cc8e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
63 changes: 63 additions & 0 deletions include/category_cats.inc.php
Expand Up @@ -77,6 +77,7 @@

$result = pwg_query($query);
$categories = array();
$category_ids = array();
$image_ids = array();

while ($row = mysql_fetch_assoc($result))
Expand Down Expand Up @@ -146,10 +147,38 @@
$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');
Expand Down Expand Up @@ -221,7 +250,41 @@
'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' );
Expand Down
4 changes: 4 additions & 0 deletions include/config_default.inc.php
Expand Up @@ -234,6 +234,10 @@
// 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 ?
//
Expand Down
3 changes: 3 additions & 0 deletions template/yoga/mainpage_categories.tpl
Expand Up @@ -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>
Expand Down

0 comments on commit 4d7cc8e

Please sign in to comment.