0) { list($image_id) = mysql_fetch_row($subresult); } } else { // searching a random representant among representant of sub-categories $query = ' SELECT representative_picture_id FROM '.CATEGORIES_TABLE.' WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' AND id NOT IN ('.$user['forbidden_categories'].') AND representative_picture_id IS NOT NULL ORDER BY RAND() LIMIT 0,1 ;'; $subresult = pwg_query($query); if (mysql_num_rows($subresult) > 0) { list($image_id) = mysql_fetch_row($subresult); } } $comment = null; if ( isset($row['comment']) ) { $comment = strip_tags( $row['comment'] ); } if (isset($image_id)) { array_push( $cat_thumbnails, array( 'category' => $row['id'], 'picture' => $image_id, 'name' => $row['name'], 'date_last' => @$row['date_last'], 'comment' => $comment, 'nb_images' => $row['nb_images'], ) ); } unset($image_id); } if (count($cat_thumbnails) > 0) { $images = array(); foreach ($cat_thumbnails as $item) { $images[$item['picture']] = ''; } $query = ' SELECT id, path, tn_ext FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', array_keys($images)).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_array($result)) { $images[$row['id']] = get_thumbnail_src($row['path'], @$row['tn_ext']); } $template->assign_block_vars('categories', array()); foreach ($cat_thumbnails as $item) { $template->assign_block_vars( 'categories.category', array( 'SRC' => $images[$item['picture']], 'ALT' => $item['name'], 'TITLE' => $lang['hint_category'], 'ICON' => get_icon(@$item['date_last']), 'URL' => make_index_url( array( 'category' => $item['category'], 'cat_name' => $item['name'], ) ), 'NAME' => $item['name'], 'NB_IMAGES' => $item['nb_images'], 'DESCRIPTION' => @$item['comment'], ) ); } } ?>