- Timestamp:
- Nov 17, 2013, 5:57:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_category.inc.php
r25425 r25508 23 23 24 24 /** 25 * Provides functions to handle categories. 26 * 27 * 28 */ 25 * @package functions\category 26 */ 27 28 29 /** 30 * Callback used for sorting by global_rank 31 */ 32 function global_rank_compare($a, $b) 33 { 34 return strnatcasecmp($a['global_rank'], $b['global_rank']); 35 } 36 37 /** 38 * Callback used for sorting by rank 39 */ 40 function rank_compare($a, $b) 41 { 42 return $a['rank'] - $b['rank']; 43 } 29 44 30 45 /** 31 46 * Is the category accessible to the connected user ? 32 * 33 * Note : if the user is not authorized to see this category, page creation 34 * ends (exit command in this function) 35 * 36 * @param int category id to verify 37 * @return void 47 * If the user is not authorized to see this category, script exits 48 * 49 * @param int $category_id 38 50 */ 39 51 function check_restrictions($category_id) … … 49 61 } 50 62 63 /** 64 * Returns template vars for main categories menu. 65 * 66 * @return array[] 67 */ 51 68 function get_categories_menu() 52 69 { … … 144 161 } 145 162 146 147 /** 148 * Retrieve informations about a category in the database 149 * 150 * Returns an array with following keys : 151 * 152 * - comment 153 * - dir : directory, might be empty for virtual categories 154 * - name : an array with indexes from 0 (lowest cat name) to n (most 155 * uppercat name findable) 156 * - nb_images 157 * - id_uppercat 158 * - site_id 159 * - 160 * 161 * @param int category id 163 /** 164 * Retrieves informations about a category. 165 * 166 * @param int $id 162 167 * @return array 163 168 */ 164 function get_cat_info( $id)169 function get_cat_info($id) 165 170 { 166 171 $query = ' … … 213 218 } 214 219 215 216 217 // returns an array of image orders available for users/visitors 220 /** 221 * Returns an array of image orders available for users/visitors. 222 * Each entry is an array containing 223 * 0: name 224 * 1: SQL ORDER command 225 * 2: visiblity (true or false) 226 * 227 * @return array[] 228 */ 218 229 function get_category_preferred_image_orders() 219 230 { … … 236 247 } 237 248 249 /** 250 * Assign a template var useable with {html_options} from a list of categories 251 * 252 * @param array[] $categories (at least id,name,global_rank,uppercats for each) 253 * @param int[] $selected ids of selected items 254 * @param string $blockname variable name in template 255 * @param bool $fullname full breadcrumb or not 256 */ 238 257 function display_select_categories($categories, 239 258 $selecteds, … … 275 294 } 276 295 277 function display_select_cat_wrapper($query, $selecteds, $blockname, 296 /** 297 * Same as display_select_categories but categories are ordered by rank 298 * @see display_select_categories() 299 */ 300 function display_select_cat_wrapper($query, 301 $selecteds, 302 $blockname, 278 303 $fullname = true) 279 304 { … … 284 309 285 310 /** 286 * returns all subcategory identifiers of given category ids287 * 288 * @param arrayids289 * @return array311 * Returns all subcategory identifiers of given category ids 312 * 313 * @param int[] $ids 314 * @return int[] 290 315 */ 291 316 function get_subcat_ids($ids) … … 314 339 } 315 340 316 /** finds a matching category id from a potential list of permalinks 317 * @param array permalinks example: holiday holiday/france holiday/france/paris 318 * @param int idx - output of the index in $permalinks that matches 319 * return category id or null if no match 320 */ 321 function get_cat_id_from_permalinks( $permalinks, &$idx ) 341 /** 342 * Finds a matching category id from a potential list of permalinks 343 * 344 * @param string[] $permalinks 345 * @param int $idx filled with the index in $permalinks that matches 346 * @return int|null 347 */ 348 function get_cat_id_from_permalinks($permalinks, &$idx) 322 349 { 323 350 $in = ''; … … 360 387 } 361 388 362 function global_rank_compare($a, $b) 363 { 364 return strnatcasecmp($a['global_rank'], $b['global_rank']); 365 } 366 367 function rank_compare($a, $b) 368 { 369 return $a['rank'] - $b['rank']; 370 } 371 372 /** 373 * returns display text for information images of category 374 * 375 * @param array categories 389 /** 390 * Returns display text for images counter of category 391 * 392 * @param int $cat_nb_images nb images directly in category 393 * @param int $cat_count_images nb images in category (including subcats) 394 * @param int $cat_count_categories nb subcats 395 * @param bool $short_message if true append " in this album" 396 * @param string $separator 376 397 * @return string 377 398 */ 378 function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true, $ Separator = '\n')399 function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true, $separator = '\n') 379 400 { 380 401 $display_text = ''; … … 384 405 if ($cat_nb_images > 0 and $cat_nb_images < $cat_count_images) 385 406 { 386 $display_text.= get_display_images_count($cat_nb_images, $cat_nb_images, 0, $short_message, $ Separator).$Separator;407 $display_text.= get_display_images_count($cat_nb_images, $cat_nb_images, 0, $short_message, $separator).$separator; 387 408 $cat_count_images-= $cat_nb_images; 388 409 $cat_nb_images = 0; … … 395 416 { 396 417 //no descendant categories or descendants do not contain images 397 if (! 418 if (!$short_message) 398 419 { 399 420 $display_text.= ' '.l10n('in this album'); … … 410 431 411 432 /** 412 * Find a random photo among all photos below a given album in the tree (not 413 * only photo directly associated to the album but also to sub-albums) 414 * 415 * we need $category['uppercats'], $category['id'], $category['count_images'] 433 * Find a random photo among all photos inside an album (including sub-albums) 434 * 435 * @param array $category (at least id,uppercats,count_images) 436 * @param bool $recursive 437 * @return int|null 416 438 */ 417 439 function get_random_image_in_category($category, $recursive=true) … … 459 481 } 460 482 461 462 483 ?>
Note: See TracChangeset
for help on using the changeset viewer.