1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | global $user, $conf, $template; |
---|
6 | |
---|
7 | |
---|
8 | if (isset($home)) |
---|
9 | { |
---|
10 | $page['section'] = 'categories'; |
---|
11 | } |
---|
12 | elseif (isset($catid)) |
---|
13 | { |
---|
14 | $page['section'] = 'categories'; |
---|
15 | $page['category']['id'] = $catid; |
---|
16 | } |
---|
17 | elseif (isset($permalink)) |
---|
18 | { |
---|
19 | $page['section'] = 'categories'; |
---|
20 | $page['category']['id'] = $permalink; |
---|
21 | } |
---|
22 | |
---|
23 | // Vérification d'activation du plugin (page administration) OU activation de piclensWall |
---|
24 | if (isset($page['section'])) |
---|
25 | { |
---|
26 | $cat = array(); |
---|
27 | $pictures = array(); |
---|
28 | |
---|
29 | $forbidden = get_sql_condition_FandF( |
---|
30 | array |
---|
31 | ( |
---|
32 | 'forbidden_categories' => 'category_id', |
---|
33 | 'visible_categories' => 'category_id', |
---|
34 | 'visible_images' => 'id' |
---|
35 | ), |
---|
36 | 'AND' |
---|
37 | ); |
---|
38 | |
---|
39 | if (($page['section']) == 'categories') |
---|
40 | { |
---|
41 | // Accueil |
---|
42 | if(empty($page['category']) and $module['on_home']) |
---|
43 | { |
---|
44 | // Page accueil |
---|
45 | // actif sur page accueil |
---|
46 | |
---|
47 | // Categories de premier niveau |
---|
48 | $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE |
---|
49 | .' WHERE id_uppercat is NULL'; |
---|
50 | |
---|
51 | $result = pwg_query($query); |
---|
52 | |
---|
53 | while ($row = mysql_fetch_assoc($result)) |
---|
54 | { |
---|
55 | if (!(in_array($row['id'], explode(',', $user['forbidden_categories'])))) |
---|
56 | { |
---|
57 | array_push($cat, $row['id']); |
---|
58 | |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | // Affichage sur l'accueil uniquement des categories selectionnees |
---|
63 | if ($module['on_home_global'] == 'selective') |
---|
64 | { |
---|
65 | $cats_selected = $module['cats'];//(!empty($module['cats']) ? unserialize($module['cats']) : array()); |
---|
66 | |
---|
67 | foreach($cat as $i => $wcat) |
---|
68 | { |
---|
69 | if (!in_array($wcat, $cats_selected)) |
---|
70 | unset($cat[$i]); |
---|
71 | } |
---|
72 | } |
---|
73 | // avec recursiite |
---|
74 | elseif ($module['recurs_cats'] == 'true') |
---|
75 | { |
---|
76 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
77 | $subcat= get_subcat_ids($cat); |
---|
78 | |
---|
79 | // Verification droits des sous-categories |
---|
80 | foreach($subcat as $sscat) |
---|
81 | { |
---|
82 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
83 | array_push($cat, $sscat); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | $query = 'SELECT DISTINCT(img.id) AS IMGID, img.file AS IMGFILE, |
---|
88 | img.tn_ext, img.path, img.has_high, |
---|
89 | img.width AS IMGWIDTH, img.height AS IMGHEIGHT, |
---|
90 | img.name AS IMGNAME, img.comment AS IMGDESC, |
---|
91 | img.author AS IMGAUTHOR, img.path AS IMGPATH, |
---|
92 | cat.id AS CATID, cat.name AS CATNAME, |
---|
93 | cat.comment AS CATDESC, cat.dir AS CATDIR' |
---|
94 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
95 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
96 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
97 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
98 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
99 | .' AND img.level <='.$user['level'].' ' |
---|
100 | // Choix du critere de tri d'affichage |
---|
101 | .(isset($module_data['Order']) ? $module_data['Order'] : |
---|
102 | str_replace(' id', ' IMGID', $conf['order_by_inside_category'])) |
---|
103 | .''; |
---|
104 | |
---|
105 | } |
---|
106 | |
---|
107 | // Page category et actif sur categories |
---|
108 | elseif (isset($page['category']) and $module['on_cats']) |
---|
109 | { |
---|
110 | check_restrictions($page['category']['id']); |
---|
111 | |
---|
112 | // recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire) |
---|
113 | $selectionID = $page['category']['id']; |
---|
114 | |
---|
115 | |
---|
116 | array_push($cat, $selectionID); |
---|
117 | |
---|
118 | |
---|
119 | // Si recursivite activee |
---|
120 | if ($module['recurs_cats'] == 'true') |
---|
121 | { |
---|
122 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
123 | $subcat= get_subcat_ids(array($selectionID)); |
---|
124 | |
---|
125 | // Verification droits des sous-categories |
---|
126 | foreach($subcat as $sscat) |
---|
127 | { |
---|
128 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
129 | array_push($cat, $sscat); |
---|
130 | } |
---|
131 | |
---|
132 | } |
---|
133 | |
---|
134 | $query = 'SELECT DISTINCT(img.id) AS IMGID, img.file AS IMGFILE, |
---|
135 | img.tn_ext, img.path, img.has_high, |
---|
136 | img.width AS IMGWIDTH, img.height AS IMGHEIGHT, |
---|
137 | img.name AS IMGNAME, img.comment AS IMGDESC, |
---|
138 | img.author AS IMGAUTHOR, img.path AS IMGPATH, |
---|
139 | cat.id AS CATID, cat.name AS CATNAME, |
---|
140 | cat.comment AS CATDESC, cat.dir AS CATDIR' |
---|
141 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
142 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
143 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
144 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
145 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
146 | .' AND img.level <='.$user['level'].' ' |
---|
147 | // Choix du critere de tri d'affichage |
---|
148 | .(isset($module_data['Order']) ? $module_data['Order'] : |
---|
149 | str_replace(' id', ' IMGID', $conf['order_by_inside_category'])) |
---|
150 | .''; |
---|
151 | |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | $flashgal_extdesc_hidden = '<!--hidden-->'; |
---|
157 | // Si au moins une image récupérée (une catégorie ou une image présente) |
---|
158 | if (count($cat)!=0) |
---|
159 | { |
---|
160 | $result = pwg_query($query); |
---|
161 | while ($row = mysql_fetch_assoc($result)) |
---|
162 | { |
---|
163 | // Prise en compte images et galeries en hidden |
---|
164 | if ( !(substr_count($row['IMGNAME'], $flashgal_extdesc_hidden)) |
---|
165 | && ((isset($row['CATNAME']) ? !(substr_count($row['CATNAME'], $flashgal_extdesc_hidden)) : true)) |
---|
166 | ) |
---|
167 | |
---|
168 | array_push($pictures, $row); |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | // Fin requetes recherches photos dans $pictures |
---|
173 | $module['datas'] = (!empty($module['datas']) ? unserialize($module['datas']) : array('')); |
---|
174 | |
---|
175 | foreach ($pictures as $row) |
---|
176 | { |
---|
177 | |
---|
178 | |
---|
179 | foreach ($module_data['datas'] as $keydata => $valuedata) |
---|
180 | { |
---|
181 | if ($valuedata) |
---|
182 | { |
---|
183 | include (FLASHGAL_PATH.'include/config_param.inc.php'); |
---|
184 | |
---|
185 | $patterns = array(); |
---|
186 | $replacements = array(); |
---|
187 | foreach ($flashgal_parse as $key => $value) |
---|
188 | { |
---|
189 | array_push($patterns, $key); |
---|
190 | array_push($replacements, $value); |
---|
191 | } |
---|
192 | |
---|
193 | // echo "module".$module['datas'][$keydata]; |
---|
194 | $picture[$keydata] = str_replace($patterns, $replacements, $module['datas'][$keydata]); |
---|
195 | // $picture[$keydata] = parse($module['datas'][$keydata], $row); |
---|
196 | } |
---|
197 | else |
---|
198 | $picture[$keydata] = ''; |
---|
199 | } |
---|
200 | $template->append('ImageNode',array('url' => $picture['img_URLNormal'],'name' => $picture['img_name'])); |
---|
201 | |
---|
202 | } |
---|
203 | |
---|
204 | $template->assign(array('OTHERS_SCRIPT' => |
---|
205 | '<script type="text/javascript" src="'.FLASHGAL_PATH.'modules/prometeus/js/prometeus.js"></script>')); |
---|
206 | |
---|
207 | |
---|
208 | } |
---|
209 | ?> |
---|