source: extensions/nbc_ThemeChanger/include/functions_ThemeChanger.inc.php @ 6642

Last change on this file since 6642 was 6642, checked in by datajulien, 14 years ago

theme changer :
Correction du bug sur la suppression du thème présent sur une association active.
Utilisation unique des id des thèmes.
Mise en place jquery et tableSorter pour la gestion des tris.

File size: 3.4 KB
Line 
1<?php
2function get_My_categories_menu($id_niveau_parent)
3{
4  global $page, $user, $filter;
5
6  $query = '
7SELECT ';
8  // From CATEGORIES_TABLE
9  $query.= '
10  id, name, permalink, nb_images, global_rank,';
11  // From USER_CACHE_CATEGORIES_TABLE
12  $query.= '
13  date_last, max_date_last, count_images, count_categories, uppercats';
14
15  // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
16  $query.= '
17FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
18  ON id = cat_id and user_id = '.$user['id'];
19
20  // Always expand when filter is activated
21  if (!$user['expand'] and !$filter['enabled'])
22  {
23    $where = '
24(id_uppercat is NULL';
25    if (isset($page['category']))
26    {
27      $where .= ' OR id_uppercat IN ('.$page['category']['uppercats'].')';
28    }
29    $where .= ')';
30  }
31  else
32  {
33    $where = '
34  '.get_sql_condition_FandF
35    (
36      array
37        (
38          'visible_categories' => 'id',
39        ),
40      null,
41      true
42    );
43  }
44
45  $where = trigger_event('get_categories_menu_sql_where',
46    $where, $user['expand'], $filter['enabled'] );
47
48  $query.= '
49WHERE '.$where.'
50;';
51
52  $result = pwg_query($query);
53  $cats = array();
54  while ($row = mysql_fetch_assoc($result))
55  {
56        $tmp = explode("," , $row['uppercats']);
57        if (in_array ($id_niveau_parent, $tmp))
58                array_push($cats, $row);
59    if ($row['id']==@$page['category']['id']) //save the number of subcats for later optim
60      $page['category']['count_categories'] = $row['count_categories'];
61  }
62  usort($cats, 'global_rank_compare');
63
64  // Update filtered data
65  if (function_exists('update_cats_with_filtered_data'))
66  {
67    update_cats_with_filtered_data($cats);
68  }
69
70  return get_html_menu_category($cats, @$page['category'] );
71}
72
73/*
74function my_existe_theme ($themeId)
75{
76        return -1;
77}
78
79
80function my_get_pwg_themeName ($themeId)
81{
82        $themes = my_get_pwg_themes();
83        $i_themeName = 0;
84        while (($tmp = $themes[$i_themeName]['id'])<> $themeId)
85        {$i_themeName++;}
86       
87        if (ISSET($themes[$i_themeName]))
88                return $themes[$i_themeName]['name'];
89                else return  '0';
90}*/
91
92
93function my_get_pwg_themes()
94{
95  global $conf;
96
97  $themes = array();
98
99  $query = '
100SELECT
101    id,
102    name
103  FROM '.THEMES_TABLE.'
104  ORDER BY name ASC
105;';
106  $result = pwg_query($query);
107  $i_themes = 0;
108  while ($row = pwg_db_fetch_assoc($result))
109  {
110    if (check_theme_installed($row['id']))
111    {
112                $themes[$i_themes]['id'] =  $row['id'] ;
113                $themes[$i_themes]['name'] = $row['name'];
114               
115                  $i_themes =$i_themes + 1;
116    }
117  }
118  return $themes;
119}
120
121function  my_get_pwg_categories()
122{
123$cat=array();
124$categories = array();
125
126
127//chargement des catégories
128 $query = '
129    SELECT id, name, uppercats, global_rank
130    FROM '.CATEGORIES_TABLE.' ;
131  ';
132   $result = pwg_query($query);
133
134   while (($cat = mysql_fetch_array($result)) <> null)
135   {
136   array_push($categories , array("id" => $cat['id'],
137                                "name" => $cat['name'],
138                                "uppercats" =>$cat['uppercats'],
139                                "longName" => get_cat_display_name_cache($cat['uppercats'], null, false),
140                                "global_rank" => $cat['global_rank'],
141                                ));
142                }
143return $categories;
144}
145
146function get_long_categorie_name($id_cat)
147{
148        $categories = my_get_pwg_categories();
149       
150        $cat=array();
151       
152           while ($cat = array_shift($categories ))
153           {
154                        if ($cat['id'] == $id_cat)
155                        {
156                                return $cat['longName'];
157                        }
158           }
159       
160return 'Failed';
161}
162
163?>
Note: See TracBrowser for help on using the repository browser.