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

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

theme changer
Amélioration de la gestion des thèmes désactivés ou supprimés par l'ajout d'un indicateur de l'état de l'association.

File size: 3.8 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_exist_pwg_theme ($themeId)
75{
76        return realpath(PHPWG_ROOT_PATH.'themes'.'/'.$themeId);
77}
78
79
80function my_get_pwg_theme_status($themeId)
81{
82        if (!my_exist_pwg_theme($themeId))
83                return 'Delete';
84        else 
85        {
86                $themes = my_get_pwg_themes();
87                $i_themeName = 0;
88                while (ISSET($themes[$i_themeName])){
89                        if ($themes[$i_themeName]['id'] == $themeId)
90                                return 'Active';
91                        $i_themeName++; 
92                }
93        }
94        return 'Inactive';
95}
96
97/*
98function my_get_pwg_themeName ($themeId)
99{
100        $themes = my_get_pwg_themes();
101        $i_themeName = 0;
102        while (($tmp = $themes[$i_themeName]['id'])<> $themeId)
103        {$i_themeName++;}
104       
105        if (ISSET($themes[$i_themeName]))
106                return $themes[$i_themeName]['name'];
107                else return  '0';
108}*/
109
110
111function my_get_pwg_themes()
112{
113  global $conf;
114
115  $themes = array();
116
117  $query = '
118SELECT
119    id,
120    name
121  FROM '.THEMES_TABLE.'
122  ORDER BY name ASC
123;';
124  $result = pwg_query($query);
125  $i_themes = 0;
126  while ($row = pwg_db_fetch_assoc($result))
127  {
128    if (check_theme_installed($row['id']))
129    {
130                $themes[$i_themes]['id'] =  $row['id'] ;
131                $themes[$i_themes]['name'] = $row['name'];
132               
133                  $i_themes =$i_themes + 1;
134    }
135  }
136  return $themes;
137}
138
139function  my_get_pwg_categories()
140{
141$cat=array();
142$categories = array();
143
144
145//chargement des catégories
146 $query = '
147    SELECT id, name, uppercats, global_rank
148    FROM '.CATEGORIES_TABLE.' ;
149  ';
150   $result = pwg_query($query);
151
152   while (($cat = mysql_fetch_array($result)) <> null)
153   {
154   array_push($categories , array("id" => $cat['id'],
155                                "name" => $cat['name'],
156                                "uppercats" =>$cat['uppercats'],
157                                "longName" => get_cat_display_name_cache($cat['uppercats'], null, false),
158                                "global_rank" => $cat['global_rank'],
159                                ));
160                }
161return $categories;
162}
163
164function get_long_categorie_name($id_cat)
165{
166        $categories = my_get_pwg_categories();
167       
168        $cat=array();
169       
170           while ($cat = array_shift($categories ))
171           {
172                        if ($cat['id'] == $id_cat)
173                        {
174                                return $cat['longName'];
175                        }
176           }
177       
178return 'Failed';
179}
180
181?>
Note: See TracBrowser for help on using the repository browser.