Changeset 1970


Ignore:
Timestamp:
Apr 22, 2007, 3:11:56 PM (17 years ago)
Author:
plg
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r1900 r1970  
    7878$result = pwg_query($query);
    7979$categories = array();
     80$category_ids = array();
    8081$image_ids = array();
    8182
     
    147148    array_push($image_ids, $image_id);
    148149    array_push($categories, $row);
     150    array_push($category_ids, $row['id']);
    149151  }
    150152  unset($image_id);
     153}
     154
     155if ($conf['display_fromto'])
     156{
     157  $dates_of_category = array();
     158  if (count($category_ids) > 0)
     159  {
     160    $query = '
     161SELECT
     162    category_id,
     163    MIN(date_creation) AS date_creation_min,
     164    MAX(date_creation) AS date_creation_max
     165  FROM '.IMAGE_CATEGORY_TABLE.'
     166    INNER JOIN '.IMAGES_TABLE.' ON image_id = id
     167  WHERE category_id IN ('.implode(',', $category_ids).')
     168  GROUP BY category_id
     169;';
     170    $result = pwg_query($query);
     171    while ($row = mysql_fetch_array($result))
     172    {
     173      $dates_of_category[ $row['category_id'] ] = array(
     174        'from' => $row['date_creation_min'],
     175        'to'   => $row['date_creation_max'],
     176        );
     177    }
     178    // echo '<pre>'; print_r($dates_of_category); echo '</pre>';
     179  }
    151180}
    152181
     
    222251          )
    223252        );
     253
     254      if ($conf['display_fromto'])
     255      {
     256        if (isset($dates_of_category[ $category['id'] ]))
     257        {
     258          $from = $dates_of_category[ $category['id'] ]['from'];
     259          $to   = $dates_of_category[ $category['id'] ]['to'];
    224260       
     261          if (!empty($from))
     262          {
     263            $info = '';
     264         
     265            if ($from == $to)
     266            {
     267              $info = format_date($from);
     268            }
     269            else
     270            {
     271              $info = sprintf(
     272                l10n('from %s to %s'),
     273                format_date($from),
     274                format_date($to)
     275                );
     276            }
     277
     278            $template->assign_block_vars(
     279              'categories.category.dates',
     280              array(
     281                'INFO' => $info,
     282                )
     283              );
     284          }
     285        }
     286      }
     287
    225288      //plugins need to add/modify sth in this loop ?
    226289      trigger_action('loc_index_category_thumbnail',
  • trunk/include/config_default.inc.php

    r1926 r1970  
    234234// than thumbnails representing a picture.
    235235$conf['subcatify'] = true;
     236
     237// display_fromto: in subcatify mode, display the date creation bounds of a
     238// category.
     239$conf['display_fromto'] = false;
    236240
    237241// allow_random_representative : do you wish PhpWebGallery to search among
  • trunk/template/yoga/mainpage_categories.tpl

    r1900 r1970  
    1515          {categories.category.ICON}
    1616        </h3>
     17        <!-- BEGIN dates -->
     18        <p>{categories.category.dates.INFO}</p>
     19        <!-- END dates -->
    1720        <p>{categories.category.CAPTION_NB_IMAGES}</p>
    1821        <p>{categories.category.DESCRIPTION}&nbsp;</p>
Note: See TracChangeset for help on using the changeset viewer.