Changeset 1132 for trunk


Ignore:
Timestamp:
Apr 6, 2006, 10:28:37 PM (18 years ago)
Author:
plg
Message:

modification: "subcatify" becomes optionnal. Enabled by default, easy to
revert to previous display.

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r1130 r1132  
    6161$result = pwg_query( $query );
    6262
    63 // template thumbnail initialization
    64 if (mysql_num_rows($result) > 0)
     63if ($conf['subcatify'])
    6564{
    66   $template->assign_block_vars('categories', array());
    67 }
    68 
    69 // for each category, we have to search a recent picture to display and
    70 // the name to display
    71 while ( $row = mysql_fetch_array( $result ) )
    72 {
    73   $template->assign_block_vars(
    74     'categories.category',
     65  $template->set_filenames(
    7566    array(
    76       'SRC'       => get_thumbnail_src($row['path'], @$row['tn_ext']),
    77       'ALT'   => $row['file'],
    78       'TITLE' => $lang['hint_category'],
    79 
    80       'URL'  => make_index_url(
    81         array(
    82           'category' => $row['category_id'],
    83           )
    84         ),
    85       'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
    86       'NB_IMAGES' => $row['nb_images'],
    87       'DESCRIPTION' => @$row['comment'],
     67      'mainpage_categories' => 'mainpage_categories.tpl',
    8868      )
    8969    );
     70 
     71  // template thumbnail initialization
     72  if (mysql_num_rows($result) > 0)
     73  {
     74    $template->assign_block_vars('categories', array());
     75  }
     76
     77  // for each category, we have to search a recent picture to display and
     78  // the name to display
     79  while ( $row = mysql_fetch_array( $result ) )
     80  {
     81    $template->assign_block_vars(
     82      'categories.category',
     83      array(
     84        'SRC'       => get_thumbnail_src($row['path'], @$row['tn_ext']),
     85        'ALT'   => $row['file'],
     86        'TITLE' => $lang['hint_category'],
     87       
     88        'URL'  => make_index_url(
     89          array(
     90            'category' => $row['category_id'],
     91            )
     92          ),
     93        'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
     94        'NB_IMAGES' => $row['nb_images'],
     95        'DESCRIPTION' => @$row['comment'],
     96        )
     97      );
     98  }
     99
     100  $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
     101}
     102else
     103{
     104  // template thumbnail initialization
     105  if (mysql_num_rows($result) > 0)
     106  {
     107    $template->assign_block_vars('thumbnails', array());
     108    // first line
     109    $template->assign_block_vars('thumbnails.line', array());
     110    // current row displayed
     111    $row_number = 0;
     112  }
     113 
     114  $old_level_separator = $conf['level_separator'];
     115  $conf['level_separator'] = '<br />';
     116  // for each category, we have to search a recent picture to display and
     117  // the name to display
     118  while ( $row = mysql_fetch_array( $result ) )
     119  {
     120    $template->assign_block_vars(
     121      'thumbnails.line.thumbnail',
     122      array(
     123        'IMAGE'       => get_thumbnail_src($row['path'], @$row['tn_ext']),
     124        'IMAGE_ALT'   => $row['file'],
     125        'IMAGE_TITLE' => $lang['hint_category'],
     126       
     127        'U_IMG_LINK'  => make_index_url(
     128          array(
     129            'category' => $row['category_id'],
     130            )
     131          ),
     132        )
     133      );
     134
     135    $template->assign_block_vars(
     136      'thumbnails.line.thumbnail.category_name',
     137      array(
     138        'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
     139        )
     140      );
     141
     142    // create a new line ?
     143    if (++$row_number == $user['nb_image_line'])
     144    {
     145      $template->assign_block_vars('thumbnails.line', array());
     146      $row_number = 0;
     147    }
     148  }
     149  $conf['level_separator'] = $old_level_separator;
    90150}
    91151?>
  • trunk/include/category_subcats.inc.php

    r1131 r1132  
    4444// $conf['allow_random_representative']
    4545
    46 $cat_thumbnails = array();
     46$categories = array();
     47$image_ids = array();
    4748
    4849while ($row = mysql_fetch_array($result))
     
    9293
    9394  $comment = null;
    94   if ( isset($row['comment']) )
    95   {
    96     $comment = strip_tags( $row['comment'] );
     95  if (isset($row['comment']))
     96  {
     97    $comment = strip_tags($row['comment']);
    9798  }
    9899
     
    100101  {
    101102    array_push(
    102       $cat_thumbnails,
     103      $categories,
    103104      array(
    104         'category' => $row['id'],
    105         'picture' => $image_id,
    106         'name' => $row['name'],
    107         'date_last' => @$row['date_last'],
    108         'comment' => $comment,
    109         'nb_images' => $row['nb_images'],
     105        'category'    => $row['id'],
     106        'picture'     => $image_id,
     107        'name'        => $row['name'],
     108        'date_last'   => @$row['date_last'],
     109        'comment'     => $comment,
     110        'nb_images'   => $row['nb_images'],
    110111        )
    111112      );
     113
     114    array_push($image_ids, $image_id);
    112115  }
    113116
     
    115118}
    116119
    117 if (count($cat_thumbnails) > 0)
     120if (count($image_ids) > 0)
    118121{
    119   $images = array();
    120 
    121   foreach ($cat_thumbnails as $item)
    122   {
    123     $images[$item['picture']] = '';
    124   }
     122  $thumbnail_src_of = array();
    125123
    126124  $query = '
    127125SELECT id, path, tn_ext
    128126  FROM '.IMAGES_TABLE.'
    129   WHERE id IN ('.implode(',', array_keys($images)).')
     127  WHERE id IN ('.implode(',', $image_ids).')
    130128;';
    131129  $result = pwg_query($query);
    132130  while ($row = mysql_fetch_array($result))
    133131  {
    134     $images[$row['id']] = get_thumbnail_src($row['path'], @$row['tn_ext']);
    135   }
    136 
    137   $template->assign_block_vars('categories', array());
    138 
    139   foreach ($cat_thumbnails as $item)
    140   {
    141     $template->assign_block_vars(
    142       'categories.category',
     132    $thumbnail_src_of[$row['id']] =
     133      get_thumbnail_src($row['path'], @$row['tn_ext']);
     134  }
     135 
     136  if ($conf['subcatify'])
     137  {
     138    $template->set_filenames(
    143139      array(
    144         'SRC'   => $images[$item['picture']],
    145         'ALT'   => $item['name'],
    146         'TITLE' => $lang['hint_category'],
    147         'ICON'  => get_icon(@$item['date_last']),
    148 
    149         'URL' => make_index_url(
    150           array(
    151             'category' => $item['category'],
    152             'cat_name' => $item['name'],
    153             )
    154           ),
    155         'NAME' => $item['name'],
    156         'NB_IMAGES' => $item['nb_images'],
    157         'DESCRIPTION' => @$item['comment'],
     140        'mainpage_categories' => 'mainpage_categories.tpl',
    158141        )
    159142      );
     143
     144    $template->assign_block_vars('categories', array());
     145   
     146    foreach ($categories as $category)
     147    {
     148      $template->assign_block_vars(
     149        'categories.category',
     150        array(
     151          'SRC'   => $thumbnail_src_of[ $category['picture'] ],
     152          'ALT'   => $category['name'],
     153          'TITLE' => $lang['hint_category'],
     154          'ICON'  => get_icon(@$category['date_last']),
     155         
     156          'URL' => make_index_url(
     157            array(
     158              'category' => $category['category'],
     159              'cat_name' => $category['name'],
     160              )
     161            ),
     162          'NAME' => $category['name'],
     163          'NB_IMAGES' => $category['nb_images'],
     164          'DESCRIPTION' => @$category['comment'],
     165          )
     166        );
     167    }
     168 
     169    $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
     170  }
     171  else
     172  {
     173    $template->assign_block_vars('thumbnails', array());
     174    // first line
     175    $template->assign_block_vars('thumbnails.line', array());
     176    // current row displayed
     177    $row_number = 0;
     178   
     179    foreach ($categories as $category)
     180    {
     181      $template->assign_block_vars(
     182        'thumbnails.line.thumbnail',
     183        array(
     184          'IMAGE'       => $thumbnail_src_of[ $category['picture'] ],
     185          'IMAGE_ALT'   => $category['name'],
     186          'IMAGE_TITLE' => $lang['hint_category'],
     187          'IMAGE_TS'    => get_icon(@$category['date_last']),
     188         
     189          'U_IMG_LINK'  => make_index_url(
     190            array(
     191              'category' => $category['category'],
     192              )
     193            ),
     194          'CLASS'       => 'thumbCat',
     195          )
     196        );
     197
     198      $template->assign_block_vars(
     199        'thumbnails.line.thumbnail.category_name',
     200        array(
     201          'NAME' => $category['name']
     202          )
     203        );
     204     
     205      // create a new line ?
     206      if (++$row_number == $user['nb_image_line'])
     207      {
     208        $template->assign_block_vars('thumbnails.line', array());
     209        $row_number = 0;
     210      }
     211    }
    160212  }
    161213}
  • trunk/include/config_default.inc.php

    r1131 r1132  
    169169$conf['show_picture_name_on_title'] = true;
    170170
     171// subcatify: display thumbnails representing a category a different way
     172// than thumbnails representing a picture.
     173$conf['subcatify'] = true;
     174
    171175// allow_random_representative : do you wish PhpWebGallery to search among
    172176// categories elements a new representative at each reload ?
  • trunk/template/yoga/index.tpl

    r1131 r1132  
    232232<!-- END thumbnails -->
    233233
    234 <!-- BEGIN categories -->
    235 <ul class="thumbnailCategories">
    236   <!-- BEGIN category -->
    237   <li>
    238     <div class="thumbnailCategory">
    239       <div class="illustration">
    240         <a href="{categories.category.URL}">
    241           <img src="{categories.category.SRC}"
    242                alt="{categories.category.ALT}"
    243              title="{categories.category.TITLE}">
    244         </a>
    245       </div>
    246       <div class="description">
    247         <h3>
    248           {categories.category.ICON}
    249           <a href="{categories.category.URL}">{categories.category.NAME}</a>
    250         </h3>
    251         <p>{categories.category.NB_IMAGES} {lang:pictures}</p>
    252         <p>{categories.category.DESCRIPTION}</p>
    253       </div>
    254       <hr class="separation" />
    255     </div>
    256   </li>
    257   <!-- END category -->
    258 </ul>
    259 <hr class="separation" />
    260 <!-- END categories -->
     234{CATEGORIES}
    261235
    262236<!-- BEGIN cat_infos -->
Note: See TracChangeset for help on using the changeset viewer.