| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | if(is_numeric($token[2]) && ($token[3] != 'newer' && $token[3] != 'popular')) |
|---|
| 27 | { |
|---|
| 28 | header('Location: /communities/category/'.$token[2].'/newer'); |
|---|
| 29 | exit(); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | if(is_numeric($token[2])) |
|---|
| 33 | { |
|---|
| 34 | $_SMARTY['Title'] = 'By category'; |
|---|
| 35 | |
|---|
| 36 | if($token[3] == 'newer') |
|---|
| 37 | $order = "ORDER BY date DESC"; |
|---|
| 38 | if($token[3] == 'popular') |
|---|
| 39 | $order = "ORDER BY nb_members DESC"; |
|---|
| 40 | |
|---|
| 41 | $category =& $db->getRow('SELECT name, description, nb_communities FROM community_cat WHERE id_cat=?', array($token[2])); |
|---|
| 42 | |
|---|
| 43 | $nb_page = ceil($category['nb_communities']/20); |
|---|
| 44 | $pages = @array_fill(1,$nb_page, NULL); |
|---|
| 45 | |
|---|
| 46 | if($category['nb_communities']>20 && is_numeric($token[4]) && $token[4]<= $nb_page ) |
|---|
| 47 | $limit_start = ($token[4]-1)*20; |
|---|
| 48 | else |
|---|
| 49 | $limit_start = 0; |
|---|
| 50 | |
|---|
| 51 | $community_r = $db->query('SELECT id, id_comm, name, description, nb_members FROM community WHERE id_cat=? ! LIMIT !,20', array($token[2], $order, $limit_start)); |
|---|
| 52 | while($community =& $community_r->fetchRow()) |
|---|
| 53 | { |
|---|
| 54 | $communities[$community['id_comm']] = $community; |
|---|
| 55 | $communities[$community['id_comm']]['logo'] = build_logo_thumb_url($community['id'], $community['id_comm']); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | $_SMARTY['cat'] = $category; |
|---|
| 59 | $_SMARTY['pages'] = $pages; |
|---|
| 60 | $_SMARTY['communities'] = $communities; |
|---|
| 61 | } |
|---|
| 62 | else |
|---|
| 63 | { |
|---|
| 64 | $categories_r = $db->query('SELECT id_cat, name, nb_communities FROM community_cat'); |
|---|
| 65 | while($category = $categories_r->fetchRow()) |
|---|
| 66 | { |
|---|
| 67 | $id_cat = $category['id_cat']; |
|---|
| 68 | settype($id_cat, 'string'); |
|---|
| 69 | $categories_list[$id_cat] = _($category['name']).' ('.$category['nb_communities'].')'; |
|---|
| 70 | $categories[$category['name']] = $category; |
|---|
| 71 | if($category['nb_communities']>0) |
|---|
| 72 | { |
|---|
| 73 | $communities_r = $db->query('SELECT id_comm, name, nb_members FROM community WHERE id_cat=? ORDER BY nb_members DESC LIMIT 6', array($category['id_cat'])); |
|---|
| 74 | while($communities = $communities_r->fetchRow()) |
|---|
| 75 | $categories[$category['name']]['list'][$communities['id_comm']] = $communities; |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | $_SMARTY['categories'] = $categories; |
|---|
| 80 | |
|---|
| 81 | array_unshift($categories_list, _('Everywhere')); |
|---|
| 82 | $_SMARTY['categories_list'] = $categories_list; |
|---|
| 83 | |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | ?> |
|---|