Changeset 436 for trunk


Ignore:
Timestamp:
Jun 19, 2004, 1:23:29 AM (20 years ago)
Author:
z0rglub
Message:
  • new category added : recent_cats
  • calculates icon_short only once
  • get_icon function takes a date in YYY-MM-DD format
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r435 r436  
    161161}
    162162
     163$icon_short = get_icon( date( 'Y-m-d' ) );
     164
    163165$template->assign_vars(array(
    164166  'NB_PICTURE' => count_user_total_images(),
     
    179181  'L_RECENT_PICS_HINT' => $lang['recent_pics_cat_hint'],
    180182  'L_RECENT_PICS' => $lang['recent_pics_cat'],
     183  'L_RECENT_CATS_HINT' => $lang['recent_cats_cat_hint'],
     184  'L_RECENT_CATS' => $lang['recent_cats_cat'],
    181185  'L_CALENDAR' => $lang['calendar'],
    182186  'L_CALENDAR_HINT' => $lang['calendar_hint'],
     
    198202 
    199203  'T_COLLAPSED' => $user['lien_collapsed'],
    200   'T_SHORT'=>get_icon( time() ),
    201   'T_LONG'=>get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ),
     204  'T_SHORT' => $icon_short,
     205  'T_LONG'=>get_icon(date( 'Y-m-d',time()-($user['short_period']*24*60*60+1))),
    202206
    203207  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
     
    205209  'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited' ),
    206210  'U_RECENT_PICS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_pics' ),
     211  'U_RECENT_CATS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_cats' ),
    207212  'U_CALENDAR'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=calendar' ),
    208213  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
     
    328333      $url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
    329334    }
    330     // date of availability for creation icon
    331     list( $year,$month,$day ) = explode( '-', $row['date_available'] );
    332     $date = mktime( 0, 0, 0, $month, $day, $year );
    333 
    334335    // create a new line ?
    335336    if ( (!$line_opened or $row_number++ == $user['nb_image_line'] )
     
    348349        'IMAGE_TITLE'=>$thumbnail_title,
    349350        'IMAGE_NAME'=>$name,
    350         'IMAGE_TS'=>get_icon( $date ),
     351        'IMAGE_TS'=>get_icon( $row['date_available'] ),
    351352       
    352353        'U_IMG_LINK'=>add_session_id( $url_link )
     
    588589      // create a new line ?
    589590      if ( ( !$line_opened or $row_number++ == $user['nb_image_line'] )
    590            and $displayed_pics++ < count( $calendar_months ) )
     591           and $displayed_pics++ <= count( $calendar_months ) )
    591592      {
    592593        $template->assign_block_vars('thumbnails.line', array());
     
    607608        );
    608609    }
     610  }
     611}
     612//------------------------------------------------- recently updated categories
     613elseif ( isset( $page['cat'] ) and $page['cat'] == 'recent_cats' )
     614{
     615  // retrieving categories recently update, ie containing pictures added
     616  // recently. The calculated table field categories.date_last will be
     617  // easier to use
     618  $query = 'SELECT id AS category_id';
     619  $query.= ' FROM '.CATEGORIES_TABLE;
     620  $query.= ' WHERE date_last > ';
     621  $query.= '   SUBDATE(CURRENT_DATE,INTERVAL '.$user['short_period'].' DAY)';
     622  if ( $user['forbidden_categories'] != '' )
     623  {
     624    $query.= ' AND id NOT IN ('.$user['forbidden_categories'].')';
     625  }
     626  $query.= ';';
     627  $result = mysql_query( $query );
     628
     629  $row_number  = 1;
     630  $line_opened = false;
     631  $displayed_pics = 0;
     632  $cat_nb_images = mysql_num_rows( $result );
     633  $template->assign_block_vars('thumbnails', array());
     634 
     635  // for each category, we have to search a recent picture to display and
     636  // the name to display
     637  while ( $row = mysql_fetch_array( $result ) )
     638  {
     639    $cat_infos = get_cat_info( $row['category_id'] );
     640    $name = '['.get_cat_display_name($cat_infos['name'],'<br />','',false).']';
     641   
     642    $query = 'SELECT id,file,tn_ext,storage_category_id';
     643    $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE;
     644    $query.= ' WHERE category_id = '.$row['category_id'];
     645    $query.= ' AND date_available > ';
     646    $query.= '   SUBDATE(CURRENT_DATE,INTERVAL '.$user['short_period'].' DAY)';
     647    $query.= ' AND id = image_id';
     648    $query.= ' ORDER BY RAND()';
     649    $query.= ' LIMIT 0,1';
     650    $query.= ';';
     651    $subrow = mysql_fetch_array( mysql_query( $query ) );
     652
     653    $file = get_filename_wo_extension( $subrow['file'] );
     654   
     655    // creating links for thumbnail and associated category
     656    $thumbnail_link = get_complete_dir( $subrow['storage_category_id'] );
     657    $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
     658    $thumbnail_link.= $file.'.'.$subrow['tn_ext'];
     659   
     660    $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
     661   
     662    // create a new line ?
     663    if ( ( !$line_opened or $row_number++ == $user['nb_image_line'] )
     664         and $displayed_pics++ < $cat_nb_images )
     665    {
     666      $template->assign_block_vars('thumbnails.line', array());
     667      $row_number = 1;
     668      $line_opened = true;
     669    }
     670   
     671    $template->assign_block_vars(
     672      'thumbnails.line.thumbnail',
     673      array(
     674        'IMAGE' => $thumbnail_link,
     675        'IMAGE_ALT' => $subrow['file'],
     676        'IMAGE_TITLE' => $lang['hint_category'],
     677        'IMAGE_NAME' => $name,
     678       
     679        'U_IMG_LINK'=>add_session_id( $url_link )
     680        )
     681      );   
    609682  }
    610683}
Note: See TracChangeset for help on using the changeset viewer.