Changeset 12954 for trunk/include/functions_category.inc.php
- Timestamp:
- Jan 24, 2012, 8:24:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_category.inc.php
r12922 r12954 214 214 } 215 215 216 // get_complete_dir returns the concatenation of get_site_url and 217 // get_local_dir 218 // Example : "pets > rex > 1_year_old" is on the the same site as the 219 // Piwigo files and this category has 22 for identifier 220 // get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/" 221 function get_complete_dir( $category_id ) 222 { 223 return get_site_url($category_id).get_local_dir($category_id); 224 } 225 226 // get_local_dir returns an array with complete path without the site url 227 // Example : "pets > rex > 1_year_old" is on the the same site as the 228 // Piwigo files and this category has 22 for identifier 229 // get_local_dir(22) returns "pets/rex/1_year_old/" 230 function get_local_dir( $category_id ) 231 { 232 global $page; 233 234 $uppercats = ''; 235 $local_dir = ''; 236 237 if ( isset( $page['plain_structure'][$category_id]['uppercats'] ) ) 238 { 239 $uppercats = $page['plain_structure'][$category_id]['uppercats']; 240 } 241 else 242 { 243 $query = 'SELECT uppercats'; 244 $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id; 245 $query.= ';'; 246 $row = pwg_db_fetch_assoc( pwg_query( $query ) ); 247 $uppercats = $row['uppercats']; 248 } 249 250 $upper_array = explode( ',', $uppercats ); 251 252 $database_dirs = array(); 253 $query = 'SELECT id,dir'; 254 $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')'; 255 $query.= ';'; 256 $result = pwg_query( $query ); 257 while( $row = pwg_db_fetch_assoc( $result ) ) 258 { 259 $database_dirs[$row['id']] = $row['dir']; 260 } 261 foreach ($upper_array as $id) 262 { 263 $local_dir.= $database_dirs[$id].'/'; 264 } 265 266 return $local_dir; 267 } 268 269 // retrieving the site url : "http://domain.com/gallery/" or 270 // simply "./galleries/" 271 function get_site_url($category_id) 272 { 273 global $page; 274 275 $query = ' 276 SELECT galleries_url 277 FROM '.SITES_TABLE.' AS s,'.CATEGORIES_TABLE.' AS c 278 WHERE s.id = c.site_id 279 AND c.id = '.$category_id.' 280 ;'; 281 $row = pwg_db_fetch_assoc(pwg_query($query)); 282 return $row['galleries_url']; 283 } 216 284 217 285 218 // returns an array of image orders available for users/visitors
Note: See TracChangeset
for help on using the changeset viewer.