Changeset 25548 for trunk/include
- Timestamp:
- Nov 18, 2013, 11:02:17 AM (10 years ago)
- Location:
- trunk/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_comment.inc.php
r25360 r25548 22 22 // +-----------------------------------------------------------------------+ 23 23 24 //returns string action to perform on a new comment: validate, moderate, reject 24 /** 25 * @package functions\comment 26 */ 27 28 29 add_event_handler('user_comment_check', 'user_comment_check', 30 EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 31 32 /** 33 * Does basic check on comment and returns action to perform. 34 * This method is called by a trigger_event() 35 * 36 * @param string $action before check 37 * @param array $comment 38 * @return string validate, moderate, reject 39 */ 25 40 function user_comment_check($action, $comment) 26 41 { … … 55 70 } 56 71 57 58 add_event_handler('user_comment_check', 'user_comment_check', 59 EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 60 61 /** 62 * Tries to insert a user comment in the database and returns one of : 63 * validate, moderate, reject 64 * @param array comm contains author, content, image_id 65 * @param string key secret key sent back to the browser 66 * @param array infos out array of messages 67 */ 68 function insert_user_comment( &$comm, $key, &$infos ) 72 /** 73 * Tries to insert a user comment and returns action to perform. 74 * 75 * @param array $comm 76 * @param string $key secret key sent back to the browser 77 * @param array $infos output array of error messages 78 * @return string validate, moderate, reject 79 */ 80 function insert_user_comment(&$comm, $key, &$infos) 69 81 { 70 82 global $conf, $user; … … 252 264 } 253 265 } 266 254 267 return $comment_action; 255 268 } 256 269 257 270 /** 258 * Tries to delete a user comment in the database259 * only admin can delete all comments260 * other users can delete their own comments261 * so to avoid a new sql request we add author in where clause262 * 263 * @ param int or array of int comment_id271 * Tries to delete a (or more) user comment. 272 * only admin can delete all comments 273 * other users can delete their own comments 274 * 275 * @param int|int[] $comment_id 276 * @return bool false if nothing deleted 264 277 */ 265 278 function delete_user_comment($comment_id) … … 291 304 )); 292 305 trigger_action('user_comment_deletion', $comment_id); 293 } 294 } 295 296 /** 297 * Tries to update a user comment in the database 298 * only admin can update all comments 299 * users can edit their own comments if admin allow them 300 * so to avoid a new sql request we add author in where clause 301 * 302 * @param comment_id 303 * @param post_key 304 * @param content 306 307 return true; 308 } 309 310 return false; 311 } 312 313 /** 314 * Tries to update a user comment 315 * only admin can update all comments 316 * users can edit their own comments if admin allow them 317 * 318 * @param array $comment 319 * @param string $post_key secret key sent back to the browser 320 * @return string validate, moderate, reject 305 321 */ 306 322 … … 398 414 } 399 415 416 /** 417 * Notifies admins about updated or deleted comment. 418 * Only used when no validation is needed, otherwise pwg_mail_notification_admins() is used. 419 * 420 * @param string $action edit, delete 421 * @param array $comment 422 */ 400 423 function email_admin($action, $comment) 401 424 { … … 431 454 } 432 455 456 /** 457 * Returns the author id of a comment 458 * 459 * @param int $comment_id 460 * @param bool $die_on_error 461 * @return int 462 */ 433 463 function get_comment_author_id($comment_id, $die_on_error=true) 434 464 { … … 458 488 459 489 /** 460 * Tries to validate a user comment in the database 461 * @param int or array of int comment_id 490 * Tries to validate a user comment. 491 * 492 * @param int|int[] $comment_id 462 493 */ 463 494 function validate_user_comment($comment_id) … … 480 511 } 481 512 482 513 /** 514 * Clears cache of nb comments for all users 515 */ 483 516 function invalidate_user_cache_nb_comments() 484 517 { 485 518 global $user; 519 486 520 unset($user['nb_available_comments']); 521 487 522 $query = ' 488 523 UPDATE '.USER_CACHE_TABLE.' 489 SET nb_available_comments = NULL'; 524 SET nb_available_comments = NULL 525 ;'; 490 526 pwg_query($query); 491 527 } -
trunk/include/functions_cookie.inc.php
r19703 r25548 22 22 // +-----------------------------------------------------------------------+ 23 23 24 // cookie_path returns the path to use for the Piwigo cookie. 25 // If Piwigo is installed on : 26 // http://domain.org/meeting/gallery/category.php 27 // cookie_path will return : "/meeting/gallery" 24 /** 25 * @package functions\cookie 26 */ 27 28 29 /** 30 * Returns the path to use for the Piwigo cookie. 31 * If Piwigo is installed on : 32 * http://domain.org/meeting/gallery/ 33 * it will return : "/meeting/gallery" 34 * 35 * @return string 36 */ 28 37 function cookie_path() 29 38 { … … 84 93 85 94 /** 86 * persistently stores a variable in pwg cookie 87 * @return boolean true on success 88 * @see pwg_get_cookie_var 95 * Persistently stores a variable in pwg cookie. 96 * Set $value to null to delete the cookie. 97 * 98 * @param string $car 99 * @param mixed $value 100 * @param int|null $expire 101 * @return bool 89 102 */ 90 103 function pwg_set_cookie_var($var, $value, $expire=null) … … 105 118 106 119 /** 107 * retrieves the value of a persistent variable in pwg cookie 120 * Retrieves the value of a persistent variable in pwg cookie 121 * @see pwg_set_cookie_var 122 * 123 * @param string $var 124 * @param mixed $default 108 125 * @return mixed 109 * @see pwg_set_cookie_var110 126 */ 111 127 function pwg_get_cookie_var($var, $default = null) -
trunk/include/functions_filter.inc.php
r19703 r25548 22 22 // +-----------------------------------------------------------------------+ 23 23 24 /** 25 * @package functions\filter 26 */ 24 27 25 28 26 29 /** 27 * updatedata of categories with filtered values30 * Updates data of categories with filtered values 28 31 * 29 * @param array list of categories 30 * @return null 32 * @param array $cats 31 33 */ 32 34 function update_cats_with_filtered_data(&$cats) -
trunk/include/functions_html.inc.php
r25425 r25548 23 23 24 24 /** 25 * returns the list of categories as a HTML string 26 * 27 * categories string returned contains categories as given in the input 25 * @package functions\html 26 */ 27 28 29 /** 30 * Generates breadcrumb from categories list. 31 * Categories string returned contains categories as given in the input 28 32 * array $cat_informations. $cat_informations array must be an array 29 33 * of array( id=>?, name=>?, permalink=>?). If url input parameter is null, 30 34 * returns only the categories name without links. 31 35 * 32 * @param array cat_informations33 * @param string 34 * @return string 35 */ 36 function get_cat_display_name($cat_informations, $url ='')36 * @param array $cat_informations 37 * @param string|null $url 38 * @return string 39 */ 40 function get_cat_display_name($cat_informations, $url='') 37 41 { 38 42 global $conf; … … 88 92 89 93 /** 90 * returns the list of categories as a HTML string, with cache of names 91 * 92 * categories string returned contains categories as given in the input 93 * array $cat_informations. $uppercats is the list of category ids to 94 * display in the right order. If url input parameter is empty, returns only 95 * the categories name without links. 96 * 97 * @param string uppercats 98 * @param string url 94 * Generates breadcrumb from categories list using a cache. 95 * @see get_cat_display_name() 96 * 97 * @param string $uppercats 98 * @param string|null $url 99 * @param bool $single_link 100 * @param string|null $link_class 99 101 * @return string 100 102 */ … … 177 179 178 180 /** 179 * returns HTMLized comment contents retrieved from database 180 * 181 * newlines becomes br tags, _word_ becomes underline, /word/ becomes 182 * italic, *word* becomes bolded 183 * 184 * @param string content 181 * Generates breadcrumb for a category. 182 * @see get_cat_display_name() 183 * 184 * @param int $cat_id 185 * @param string|null $url 186 * @return string 187 */ 188 function get_cat_display_name_from_id($cat_id, $url = '') 189 { 190 $cat_info = get_cat_info($cat_id); 191 return get_cat_display_name($cat_info['upper_names'], $url); 192 } 193 194 /** 195 * Apply basic markdown transformations to a text. 196 * newlines becomes br tags 197 * _word_ becomes underline 198 * /word/ becomes italic 199 * *word* becomes bolded 200 * urls becomes a tags 201 * 202 * @param string $content 185 203 * @return string 186 204 */ … … 209 227 $content = preg_replace($pattern, $replacement, $content); 210 228 229 // TODO : add a trigger 230 211 231 return $content; 212 }213 214 function get_cat_display_name_from_id($cat_id, $url = '')215 {216 $cat_info = get_cat_info($cat_id);217 return get_cat_display_name($cat_info['upper_names'], $url);218 232 } 219 233 … … 267 281 } 268 282 283 /** 284 * Callback used for sorting by name. 285 */ 269 286 function name_compare($a, $b) 270 287 { … … 272 289 } 273 290 291 /** 292 * Callback used for sorting by name (slug) with cache. 293 */ 274 294 function tag_alpha_compare($a, $b) 275 295 { … … 288 308 289 309 /** 290 * exits the current script (either exit or redirect)310 * Exits the current script (or redirect to login page if not logged). 291 311 */ 292 312 function access_denied() … … 315 335 316 336 /** 317 * exits the current script with 403 code 318 * @param string msg a message to display 319 * @param string alternate_url redirect to this url 337 * Exits the current script with 403 code. 338 * TODO : nice display if $template loaded 339 * 340 * @param string $msg 341 * @param string|null $alternate_url redirect to this url 320 342 */ 321 343 function page_forbidden($msg, $alternate_url=null) … … 332 354 333 355 /** 334 * exits the current script with 400 code 335 * @param string msg a message to display 336 * @param string alternate_url redirect to this url 356 * Exits the current script with 400 code. 357 * TODO : nice display if $template loaded 358 * 359 * @param string $msg 360 * @param string|null $alternate_url redirect to this url 337 361 */ 338 362 function bad_request($msg, $alternate_url=null) … … 349 373 350 374 /** 351 * exits the current script with 404 code when a page cannot be found 352 * @param string msg a message to display 353 * @param string alternate_url redirect to this url 375 * Exits the current script with 404 code. 376 * TODO : nice display if $template loaded 377 * 378 * @param string $msg 379 * @param string|null $alternate_url redirect to this url 354 380 */ 355 381 function page_not_found($msg, $alternate_url=null) … … 366 392 367 393 /** 368 * exits the current script with 500 http code 369 * this method can be called at any time (does not use template/language/user etc...) 370 * @param string msg a message to display 394 * Exits the current script with 500 code. 395 * TODO : nice display if $template loaded 396 * 397 * @param string $msg 398 * @param string|null $title 399 * @param bool $show_trace 371 400 */ 372 401 function fatal_error($msg, $title=null, $show_trace=true) … … 409 438 } 410 439 411 /* returns the title to be displayed above thumbnails on tag page 440 /** 441 * Returns the breadcrumb to be displayed above thumbnails on tag page. 442 * 443 * @return string 412 444 */ 413 445 function get_tags_content_title() … … 458 490 459 491 /** 460 Sets the http status header (200,401,...) 492 * Sets the http status header (200,401,...) 493 * @param int $code 494 * @param string $text for exotic http codes 461 495 */ 462 496 function set_status_header($code, $text='') … … 487 521 } 488 522 489 /** returns the category comment for rendering in html textual mode (subcatify) 490 * this is an event handler. don't call directly 523 /** 524 * Returns the category comment for rendering in html textual mode (subcatify) 525 * This method is called by a trigger_action() 526 * 527 * @param string $desc 528 * @return string 491 529 */ 492 530 function render_category_literal_description($desc) … … 495 533 } 496 534 497 /*event handler for menu*/ 498 function register_default_menubar_blocks( $menu_ref_arr ) 535 /** 536 * Add known menubar blocks. 537 * This method is called by a trigger_event() 538 * 539 * @param BlockManager[] $menu_ref_arr 540 */ 541 function register_default_menubar_blocks($menu_ref_arr) 499 542 { 500 543 $menu = & $menu_ref_arr[0]; … … 510 553 511 554 /** 555 * Returns display name for an element. 556 * Returns 'name' if exists of name from 'file'. 557 * 558 * @param array $info at least file or name 559 * @return string 512 560 */ 513 561 function render_element_name($info) 514 562 { 515 $name = $info['name']; 516 if (!empty($name)) 517 { 518 $name = trigger_event('render_element_name', $name); 519 return $name; 520 } 521 563 if (!empty($info['name'])) 564 { 565 return trigger_event('render_element_name', $info['name']); 566 } 522 567 return get_name_from_file($info['file']); 523 568 } 524 569 570 /** 571 * Returns display description for an element. 572 * 573 * @param array $info at least comment 574 * @param string $param used to identify the trigger 575 * @return string 576 */ 525 577 function render_element_description($info, $param='') 526 578 { 527 $comment = $info['comment']; 528 if (!empty($comment)) 529 { 530 $comment = trigger_event('render_element_description', $comment, $param); 531 return $comment; 579 if (!empty($info['comment'])) 580 { 581 return trigger_event('render_element_description', $info['comment'], $param); 532 582 } 533 583 return ''; … … 535 585 536 586 /** 537 * returns the title of the thumbnail based on photo properties 538 */ 539 function get_thumbnail_title($info, $title, $comment) 587 * Add info to the title of the thumbnail based on photo properties. 588 * 589 * @param array $info hit, rating_score, nb_comments 590 * @param string $title 591 * @param string $comment 592 * @return string 593 */ 594 function get_thumbnail_title($info, $title, $comment='') 540 595 { 541 596 global $conf, $user; … … 571 626 $title = htmlspecialchars(strip_tags($title)); 572 627 $title = trigger_event('get_thumbnail_title', $title, $info); 628 573 629 return $title; 574 630 } 575 631 576 /** optional event handler to protect src image urls */ 632 /** 633 * Event handler to protect src image urls. 634 * 635 * @param string $url 636 * @param SrcImage $src_image 637 * @return string 638 */ 577 639 function get_src_image_url_protection_handler($url, $src_image) 578 640 { … … 580 642 } 581 643 582 /** optional event handler to protect element urls */ 644 /** 645 * Event handler to protect element urls. 646 * 647 * @param string $url 648 * @param array $infos id, path 649 * @return string 650 */ 583 651 function get_element_url_protection_handler($url, $infos) 584 652 { … … 595 663 } 596 664 597 665 /** 666 * Sends to the template all messages stored in $page and in the session. 667 */ 598 668 function flush_page_messages() 599 669 {
Note: See TracChangeset
for help on using the changeset viewer.