root/trunk/inc/communities/category.inc.php

Revision 15, 3.1 KB (checked in by alexx, 7 years ago)
  • fix last bug in communities (see [14])
  • execute a "conversion smarty style" script ;) : for i in find . -type f | grep "\.php$" | grep -v "\.svn"; do perl -pi -e "s/\\\$smarty->assign\((.*),(.*)\);/\\\$_SMARTY\[\$1\] = \$2;/" $i; done
Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25
26if(is_numeric($token[2]) && ($token[3] != 'newer' && $token[3] != 'popular'))
27{
28    header('Location: /communities/category/'.$token[2].'/newer');
29    exit();
30}
31
32if(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}
62else
63{
64    $categories_r = $db->query('SELECT id_cat, name, nb_communities FROM community_cat');
65while($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
81array_unshift($categories_list, _('Everywhere'));
82$_SMARTY['categories_list'] =  $categories_list;
83
84}
85
86?>
Note: See TracBrowser for help on using the browser.