1 | <?php |
---|
2 | function get_My_categories_menu($id_niveau_parent) |
---|
3 | { |
---|
4 | global $page, $user, $filter; |
---|
5 | |
---|
6 | $query = ' |
---|
7 | SELECT '; |
---|
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.= ' |
---|
17 | FROM '.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.= ' |
---|
49 | WHERE '.$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 | |
---|
74 | function my_get_pwg_themeName ($themeId) |
---|
75 | { |
---|
76 | $themes = my_get_pwg_themes(); |
---|
77 | $i_themeName = 0; |
---|
78 | while (($tmp = $themes[$i_themeName]['id'])<> $themeId) |
---|
79 | {$i_themeName++;} |
---|
80 | |
---|
81 | if (ISSET($themes[$i_themeName])) |
---|
82 | return $themes[$i_themeName]['name']; |
---|
83 | else return '0'; |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | function my_get_pwg_themes() |
---|
89 | { |
---|
90 | global $conf; |
---|
91 | |
---|
92 | $themes = array(); |
---|
93 | |
---|
94 | $query = ' |
---|
95 | SELECT |
---|
96 | id, |
---|
97 | name |
---|
98 | FROM '.THEMES_TABLE.' |
---|
99 | ORDER BY name ASC |
---|
100 | ;'; |
---|
101 | $result = pwg_query($query); |
---|
102 | $i_themes = 0; |
---|
103 | while ($row = pwg_db_fetch_assoc($result)) |
---|
104 | { |
---|
105 | if (check_theme_installed($row['id'])) |
---|
106 | { |
---|
107 | $themes[$i_themes]['id'] = $row['id'] ; |
---|
108 | $themes[$i_themes]['name'] = $row['name']; |
---|
109 | |
---|
110 | $i_themes =$i_themes + 1; |
---|
111 | } |
---|
112 | } |
---|
113 | return $themes; |
---|
114 | } |
---|
115 | |
---|
116 | function my_get_pwg_categories() |
---|
117 | { |
---|
118 | $cat=array(); |
---|
119 | $categories = array(); |
---|
120 | |
---|
121 | |
---|
122 | //chargement des catégories |
---|
123 | $query = ' |
---|
124 | SELECT id, name, uppercats, global_rank |
---|
125 | FROM '.CATEGORIES_TABLE.' ; |
---|
126 | '; |
---|
127 | $result = pwg_query($query); |
---|
128 | |
---|
129 | while (($cat = mysql_fetch_array($result)) <> null) |
---|
130 | { |
---|
131 | array_push($categories , array("id" => $cat['id'], |
---|
132 | "name" => $cat['name'], |
---|
133 | "uppercats" =>$cat['uppercats'], |
---|
134 | "longName" => get_cat_display_name_cache($cat['uppercats'], null, false), |
---|
135 | "global_rank" => $cat['global_rank'], |
---|
136 | )); |
---|
137 | } |
---|
138 | return $categories; |
---|
139 | } |
---|
140 | |
---|
141 | function get_long_categorie_name($id_cat) |
---|
142 | { |
---|
143 | $categories = my_get_pwg_categories(); |
---|
144 | |
---|
145 | $cat=array(); |
---|
146 | |
---|
147 | while ($cat = array_shift($categories )) |
---|
148 | { |
---|
149 | if ($cat['id'] == $id_cat) |
---|
150 | { |
---|
151 | return $cat['longName']; |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | return 'Failed'; |
---|
156 | } |
---|
157 | |
---|
158 | ?> |
---|