root/trunk/inc/communities/search.inc.php

Revision 15, 2.5 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$_SMARTY['Title'] =  'Community';
26
27$array = explode(' ', $_GET['q']);
28error_log('comm_search: '.$_GET['q']);
29$result = array();
30$comm = array();
31$idx=0;
32
33$nb_elemt = 0;
34
35foreach($array as $elemt)
36{
37    $elemt = ereg_replace("(.*)s$", "\\1", $elemt);
38   
39    if(strlen($elemt)>2)
40    {
41        if(is_numeric($_GET['cat']) && $_GET['cat']>0)
42            $s_r = $db->query('SELECT id_comm, id_cat FROM community_keyword WHERE key_sndx=SOUNDEX(?) AND id_cat=?', array($elemt, $_GET['cat']));
43        else
44            $s_r = $db->query('SELECT id_comm, id_cat FROM community_keyword WHERE key_sndx=SOUNDEX(?)', array($elemt));
45        while($s = $s_r->fetchRow())
46            $result[$s['id_comm']]++;
47        $nb_elemt++;
48    }
49}
50asort($result);
51
52foreach($result as $key=>$value)
53{
54    if($value==$nb_elemt)
55    {
56        $comm[$key] = $db->getRow('SELECT community.id AS id, community.id_comm AS id_comm, community.name AS name, community.description AS description, nb_members, community_cat.name AS cat_name FROM community LEFT JOIN community_cat USING (id_cat) WHERE community.id_comm=?', array($key));
57        $comm[$key]['logo'] = build_logo_thumb_url($comm[$key]['id'], $comm[$key]['id_comm']);
58        $comm[$key]['weight'] = $value;
59    }
60}
61
62$categories_r = $db->query('SELECT id_cat, name, nb_communities FROM community_cat');
63while($category = $categories_r->fetchRow())
64{
65        $id_cat = $category['id_cat'];
66        $categories_list[$id_cat] = tr($category['name']).' ('.$category['nb_communities'].')';
67}
68
69array_unshift($categories_list, _('Everywhere'));
70$_SMARTY['categories_list'] =  $categories_list;
71$_SMARTY['comm'] =  $comm;
72
73
74?>
Note: See TracBrowser for help on using the browser.