mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
feature 2999: documentation of functions\comment|cookie|filter|html
git-svn-id: http://piwigo.org/svn/trunk@25548 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -21,7 +21,22 @@
|
|||||||
// | USA. |
|
// | USA. |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
//returns string action to perform on a new comment: validate, moderate, reject
|
/**
|
||||||
|
* @package functions\comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
add_event_handler('user_comment_check', 'user_comment_check',
|
||||||
|
EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does basic check on comment and returns action to perform.
|
||||||
|
* This method is called by a trigger_event()
|
||||||
|
*
|
||||||
|
* @param string $action before check
|
||||||
|
* @param array $comment
|
||||||
|
* @return string validate, moderate, reject
|
||||||
|
*/
|
||||||
function user_comment_check($action, $comment)
|
function user_comment_check($action, $comment)
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
global $conf,$user;
|
||||||
@@ -54,18 +69,15 @@ function user_comment_check($action, $comment)
|
|||||||
return $action;
|
return $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
add_event_handler('user_comment_check', 'user_comment_check',
|
|
||||||
EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to insert a user comment in the database and returns one of :
|
* Tries to insert a user comment and returns action to perform.
|
||||||
* validate, moderate, reject
|
*
|
||||||
* @param array comm contains author, content, image_id
|
* @param array $comm
|
||||||
* @param string key secret key sent back to the browser
|
* @param string $key secret key sent back to the browser
|
||||||
* @param array infos out array of messages
|
* @param array $infos output array of error messages
|
||||||
|
* @return string validate, moderate, reject
|
||||||
*/
|
*/
|
||||||
function insert_user_comment( &$comm, $key, &$infos )
|
function insert_user_comment(&$comm, $key, &$infos)
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
@@ -251,16 +263,17 @@ INSERT INTO '.COMMENTS_TABLE.'
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $comment_action;
|
return $comment_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to delete a user comment in the database
|
* Tries to delete a (or more) user comment.
|
||||||
* only admin can delete all comments
|
* only admin can delete all comments
|
||||||
* other users can delete their own comments
|
* other users can delete their own comments
|
||||||
* so to avoid a new sql request we add author in where clause
|
|
||||||
*
|
*
|
||||||
* @param int or array of int comment_id
|
* @param int|int[] $comment_id
|
||||||
|
* @return bool false if nothing deleted
|
||||||
*/
|
*/
|
||||||
function delete_user_comment($comment_id)
|
function delete_user_comment($comment_id)
|
||||||
{
|
{
|
||||||
@@ -290,18 +303,21 @@ $user_where_clause.'
|
|||||||
'comment_id' => $comment_id
|
'comment_id' => $comment_id
|
||||||
));
|
));
|
||||||
trigger_action('user_comment_deletion', $comment_id);
|
trigger_action('user_comment_deletion', $comment_id);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to update a user comment in the database
|
* Tries to update a user comment
|
||||||
* only admin can update all comments
|
* only admin can update all comments
|
||||||
* users can edit their own comments if admin allow them
|
* users can edit their own comments if admin allow them
|
||||||
* so to avoid a new sql request we add author in where clause
|
|
||||||
*
|
*
|
||||||
* @param comment_id
|
* @param array $comment
|
||||||
* @param post_key
|
* @param string $post_key secret key sent back to the browser
|
||||||
* @param content
|
* @return string validate, moderate, reject
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function update_user_comment($comment, $post_key)
|
function update_user_comment($comment, $post_key)
|
||||||
@@ -397,6 +413,13 @@ $user_where_clause.'
|
|||||||
return $comment_action;
|
return $comment_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies admins about updated or deleted comment.
|
||||||
|
* Only used when no validation is needed, otherwise pwg_mail_notification_admins() is used.
|
||||||
|
*
|
||||||
|
* @param string $action edit, delete
|
||||||
|
* @param array $comment
|
||||||
|
*/
|
||||||
function email_admin($action, $comment)
|
function email_admin($action, $comment)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
@@ -430,6 +453,13 @@ function email_admin($action, $comment)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the author id of a comment
|
||||||
|
*
|
||||||
|
* @param int $comment_id
|
||||||
|
* @param bool $die_on_error
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function get_comment_author_id($comment_id, $die_on_error=true)
|
function get_comment_author_id($comment_id, $die_on_error=true)
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
@@ -457,8 +487,9 @@ SELECT
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to validate a user comment in the database
|
* Tries to validate a user comment.
|
||||||
* @param int or array of int comment_id
|
*
|
||||||
|
* @param int|int[] $comment_id
|
||||||
*/
|
*/
|
||||||
function validate_user_comment($comment_id)
|
function validate_user_comment($comment_id)
|
||||||
{
|
{
|
||||||
@@ -479,14 +510,19 @@ UPDATE '.COMMENTS_TABLE.'
|
|||||||
trigger_action('user_comment_validation', $comment_id);
|
trigger_action('user_comment_validation', $comment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears cache of nb comments for all users
|
||||||
|
*/
|
||||||
function invalidate_user_cache_nb_comments()
|
function invalidate_user_cache_nb_comments()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
unset($user['nb_available_comments']);
|
unset($user['nb_available_comments']);
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
UPDATE '.USER_CACHE_TABLE.'
|
UPDATE '.USER_CACHE_TABLE.'
|
||||||
SET nb_available_comments = NULL';
|
SET nb_available_comments = NULL
|
||||||
|
;';
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,19 @@
|
|||||||
// | USA. |
|
// | USA. |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
// cookie_path returns the path to use for the Piwigo cookie.
|
/**
|
||||||
// If Piwigo is installed on :
|
* @package functions\cookie
|
||||||
// http://domain.org/meeting/gallery/category.php
|
*/
|
||||||
// cookie_path will return : "/meeting/gallery"
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to use for the Piwigo cookie.
|
||||||
|
* If Piwigo is installed on :
|
||||||
|
* http://domain.org/meeting/gallery/
|
||||||
|
* it will return : "/meeting/gallery"
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function cookie_path()
|
function cookie_path()
|
||||||
{
|
{
|
||||||
if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and
|
if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and
|
||||||
@@ -83,9 +92,13 @@ function cookie_path()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* persistently stores a variable in pwg cookie
|
* Persistently stores a variable in pwg cookie.
|
||||||
* @return boolean true on success
|
* Set $value to null to delete the cookie.
|
||||||
* @see pwg_get_cookie_var
|
*
|
||||||
|
* @param string $car
|
||||||
|
* @param mixed $value
|
||||||
|
* @param int|null $expire
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function pwg_set_cookie_var($var, $value, $expire=null)
|
function pwg_set_cookie_var($var, $value, $expire=null)
|
||||||
{
|
{
|
||||||
@@ -104,9 +117,12 @@ function pwg_set_cookie_var($var, $value, $expire=null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves the value of a persistent variable in pwg cookie
|
* Retrieves the value of a persistent variable in pwg cookie
|
||||||
* @return mixed
|
|
||||||
* @see pwg_set_cookie_var
|
* @see pwg_set_cookie_var
|
||||||
|
*
|
||||||
|
* @param string $var
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function pwg_get_cookie_var($var, $default = null)
|
function pwg_get_cookie_var($var, $default = null)
|
||||||
{
|
{
|
||||||
@@ -120,4 +136,4 @@ function pwg_get_cookie_var($var, $default = null)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -21,13 +21,15 @@
|
|||||||
// | USA. |
|
// | USA. |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package functions\filter
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update data of categories with filtered values
|
* Updates data of categories with filtered values
|
||||||
*
|
*
|
||||||
* @param array list of categories
|
* @param array $cats
|
||||||
* @return null
|
|
||||||
*/
|
*/
|
||||||
function update_cats_with_filtered_data(&$cats)
|
function update_cats_with_filtered_data(&$cats)
|
||||||
{
|
{
|
||||||
@@ -47,4 +49,4 @@ function update_cats_with_filtered_data(&$cats)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
+127
-57
@@ -22,18 +22,22 @@
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the list of categories as a HTML string
|
* @package functions\html
|
||||||
*
|
*/
|
||||||
* categories string returned contains categories as given in the input
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates breadcrumb from categories list.
|
||||||
|
* Categories string returned contains categories as given in the input
|
||||||
* array $cat_informations. $cat_informations array must be an array
|
* array $cat_informations. $cat_informations array must be an array
|
||||||
* of array( id=>?, name=>?, permalink=>?). If url input parameter is null,
|
* of array( id=>?, name=>?, permalink=>?). If url input parameter is null,
|
||||||
* returns only the categories name without links.
|
* returns only the categories name without links.
|
||||||
*
|
*
|
||||||
* @param array cat_informations
|
* @param array $cat_informations
|
||||||
* @param string url
|
* @param string|null $url
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_cat_display_name($cat_informations, $url = '')
|
function get_cat_display_name($cat_informations, $url='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@@ -87,15 +91,13 @@ function get_cat_display_name($cat_informations, $url = '')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the list of categories as a HTML string, with cache of names
|
* Generates breadcrumb from categories list using a cache.
|
||||||
|
* @see get_cat_display_name()
|
||||||
*
|
*
|
||||||
* categories string returned contains categories as given in the input
|
* @param string $uppercats
|
||||||
* array $cat_informations. $uppercats is the list of category ids to
|
* @param string|null $url
|
||||||
* display in the right order. If url input parameter is empty, returns only
|
* @param bool $single_link
|
||||||
* the categories name without links.
|
* @param string|null $link_class
|
||||||
*
|
|
||||||
* @param string uppercats
|
|
||||||
* @param string url
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_cat_display_name_cache($uppercats,
|
function get_cat_display_name_cache($uppercats,
|
||||||
@@ -176,12 +178,28 @@ SELECT id, name, permalink
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns HTMLized comment contents retrieved from database
|
* Generates breadcrumb for a category.
|
||||||
|
* @see get_cat_display_name()
|
||||||
*
|
*
|
||||||
* newlines becomes br tags, _word_ becomes underline, /word/ becomes
|
* @param int $cat_id
|
||||||
* italic, *word* becomes bolded
|
* @param string|null $url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_cat_display_name_from_id($cat_id, $url = '')
|
||||||
|
{
|
||||||
|
$cat_info = get_cat_info($cat_id);
|
||||||
|
return get_cat_display_name($cat_info['upper_names'], $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply basic markdown transformations to a text.
|
||||||
|
* newlines becomes br tags
|
||||||
|
* _word_ becomes underline
|
||||||
|
* /word/ becomes italic
|
||||||
|
* *word* becomes bolded
|
||||||
|
* urls becomes a tags
|
||||||
*
|
*
|
||||||
* @param string content
|
* @param string $content
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function render_comment_content($content)
|
function render_comment_content($content)
|
||||||
@@ -208,13 +226,9 @@ function render_comment_content($content)
|
|||||||
$replacement = '<span style="font-style:italic;">$1$2</span>';
|
$replacement = '<span style="font-style:italic;">$1$2</span>';
|
||||||
$content = preg_replace($pattern, $replacement, $content);
|
$content = preg_replace($pattern, $replacement, $content);
|
||||||
|
|
||||||
return $content;
|
// TODO : add a trigger
|
||||||
}
|
|
||||||
|
|
||||||
function get_cat_display_name_from_id($cat_id, $url = '')
|
return $content;
|
||||||
{
|
|
||||||
$cat_info = get_cat_info($cat_id);
|
|
||||||
return get_cat_display_name($cat_info['upper_names'], $url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,11 +280,17 @@ function get_html_tag_selection(
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used for sorting by name.
|
||||||
|
*/
|
||||||
function name_compare($a, $b)
|
function name_compare($a, $b)
|
||||||
{
|
{
|
||||||
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used for sorting by name (slug) with cache.
|
||||||
|
*/
|
||||||
function tag_alpha_compare($a, $b)
|
function tag_alpha_compare($a, $b)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
@@ -287,7 +307,7 @@ function tag_alpha_compare($a, $b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exits the current script (either exit or redirect)
|
* Exits the current script (or redirect to login page if not logged).
|
||||||
*/
|
*/
|
||||||
function access_denied()
|
function access_denied()
|
||||||
{
|
{
|
||||||
@@ -314,9 +334,11 @@ function access_denied()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exits the current script with 403 code
|
* Exits the current script with 403 code.
|
||||||
* @param string msg a message to display
|
* TODO : nice display if $template loaded
|
||||||
* @param string alternate_url redirect to this url
|
*
|
||||||
|
* @param string $msg
|
||||||
|
* @param string|null $alternate_url redirect to this url
|
||||||
*/
|
*/
|
||||||
function page_forbidden($msg, $alternate_url=null)
|
function page_forbidden($msg, $alternate_url=null)
|
||||||
{
|
{
|
||||||
@@ -331,9 +353,11 @@ function page_forbidden($msg, $alternate_url=null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exits the current script with 400 code
|
* Exits the current script with 400 code.
|
||||||
* @param string msg a message to display
|
* TODO : nice display if $template loaded
|
||||||
* @param string alternate_url redirect to this url
|
*
|
||||||
|
* @param string $msg
|
||||||
|
* @param string|null $alternate_url redirect to this url
|
||||||
*/
|
*/
|
||||||
function bad_request($msg, $alternate_url=null)
|
function bad_request($msg, $alternate_url=null)
|
||||||
{
|
{
|
||||||
@@ -348,9 +372,11 @@ function bad_request($msg, $alternate_url=null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exits the current script with 404 code when a page cannot be found
|
* Exits the current script with 404 code.
|
||||||
* @param string msg a message to display
|
* TODO : nice display if $template loaded
|
||||||
* @param string alternate_url redirect to this url
|
*
|
||||||
|
* @param string $msg
|
||||||
|
* @param string|null $alternate_url redirect to this url
|
||||||
*/
|
*/
|
||||||
function page_not_found($msg, $alternate_url=null)
|
function page_not_found($msg, $alternate_url=null)
|
||||||
{
|
{
|
||||||
@@ -365,9 +391,12 @@ function page_not_found($msg, $alternate_url=null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exits the current script with 500 http code
|
* Exits the current script with 500 code.
|
||||||
* this method can be called at any time (does not use template/language/user etc...)
|
* TODO : nice display if $template loaded
|
||||||
* @param string msg a message to display
|
*
|
||||||
|
* @param string $msg
|
||||||
|
* @param string|null $title
|
||||||
|
* @param bool $show_trace
|
||||||
*/
|
*/
|
||||||
function fatal_error($msg, $title=null, $show_trace=true)
|
function fatal_error($msg, $title=null, $show_trace=true)
|
||||||
{
|
{
|
||||||
@@ -408,7 +437,10 @@ $btrace_msg
|
|||||||
die(0); // just in case
|
die(0); // just in case
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns the title to be displayed above thumbnails on tag page
|
/**
|
||||||
|
* Returns the breadcrumb to be displayed above thumbnails on tag page.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_tags_content_title()
|
function get_tags_content_title()
|
||||||
{
|
{
|
||||||
@@ -457,7 +489,9 @@ function get_tags_content_title()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the http status header (200,401,...)
|
* Sets the http status header (200,401,...)
|
||||||
|
* @param int $code
|
||||||
|
* @param string $text for exotic http codes
|
||||||
*/
|
*/
|
||||||
function set_status_header($code, $text='')
|
function set_status_header($code, $text='')
|
||||||
{
|
{
|
||||||
@@ -486,16 +520,25 @@ function set_status_header($code, $text='')
|
|||||||
trigger_action('set_status_header', $code, $text);
|
trigger_action('set_status_header', $code, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** returns the category comment for rendering in html textual mode (subcatify)
|
/**
|
||||||
* this is an event handler. don't call directly
|
* Returns the category comment for rendering in html textual mode (subcatify)
|
||||||
|
* This method is called by a trigger_action()
|
||||||
|
*
|
||||||
|
* @param string $desc
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function render_category_literal_description($desc)
|
function render_category_literal_description($desc)
|
||||||
{
|
{
|
||||||
return strip_tags($desc, '<span><p><a><br><b><i><small><big><strong><em>');
|
return strip_tags($desc, '<span><p><a><br><b><i><small><big><strong><em>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*event handler for menu*/
|
/**
|
||||||
function register_default_menubar_blocks( $menu_ref_arr )
|
* Add known menubar blocks.
|
||||||
|
* This method is called by a trigger_event()
|
||||||
|
*
|
||||||
|
* @param BlockManager[] $menu_ref_arr
|
||||||
|
*/
|
||||||
|
function register_default_menubar_blocks($menu_ref_arr)
|
||||||
{
|
{
|
||||||
$menu = & $menu_ref_arr[0];
|
$menu = & $menu_ref_arr[0];
|
||||||
if ($menu->get_id() != 'menubar')
|
if ($menu->get_id() != 'menubar')
|
||||||
@@ -509,34 +552,46 @@ function register_default_menubar_blocks( $menu_ref_arr )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns display name for an element.
|
||||||
|
* Returns 'name' if exists of name from 'file'.
|
||||||
|
*
|
||||||
|
* @param array $info at least file or name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function render_element_name($info)
|
function render_element_name($info)
|
||||||
{
|
{
|
||||||
$name = $info['name'];
|
if (!empty($info['name']))
|
||||||
if (!empty($name))
|
|
||||||
{
|
{
|
||||||
$name = trigger_event('render_element_name', $name);
|
return trigger_event('render_element_name', $info['name']);
|
||||||
return $name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_name_from_file($info['file']);
|
return get_name_from_file($info['file']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns display description for an element.
|
||||||
|
*
|
||||||
|
* @param array $info at least comment
|
||||||
|
* @param string $param used to identify the trigger
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function render_element_description($info, $param='')
|
function render_element_description($info, $param='')
|
||||||
{
|
{
|
||||||
$comment = $info['comment'];
|
if (!empty($info['comment']))
|
||||||
if (!empty($comment))
|
|
||||||
{
|
{
|
||||||
$comment = trigger_event('render_element_description', $comment, $param);
|
return trigger_event('render_element_description', $info['comment'], $param);
|
||||||
return $comment;
|
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the title of the thumbnail based on photo properties
|
* Add info to the title of the thumbnail based on photo properties.
|
||||||
|
*
|
||||||
|
* @param array $info hit, rating_score, nb_comments
|
||||||
|
* @param string $title
|
||||||
|
* @param string $comment
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_thumbnail_title($info, $title, $comment)
|
function get_thumbnail_title($info, $title, $comment='')
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
@@ -570,16 +625,29 @@ function get_thumbnail_title($info, $title, $comment)
|
|||||||
|
|
||||||
$title = htmlspecialchars(strip_tags($title));
|
$title = htmlspecialchars(strip_tags($title));
|
||||||
$title = trigger_event('get_thumbnail_title', $title, $info);
|
$title = trigger_event('get_thumbnail_title', $title, $info);
|
||||||
|
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** optional event handler to protect src image urls */
|
/**
|
||||||
|
* Event handler to protect src image urls.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param SrcImage $src_image
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_src_image_url_protection_handler($url, $src_image)
|
function get_src_image_url_protection_handler($url, $src_image)
|
||||||
{
|
{
|
||||||
return get_action_url($src_image->id, $src_image->is_original() ? 'e' : 'r', false);
|
return get_action_url($src_image->id, $src_image->is_original() ? 'e' : 'r', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** optional event handler to protect element urls */
|
/**
|
||||||
|
* Event handler to protect element urls.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param array $infos id, path
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_element_url_protection_handler($url, $infos)
|
function get_element_url_protection_handler($url, $infos)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
@@ -594,7 +662,9 @@ function get_element_url_protection_handler($url, $infos)
|
|||||||
return get_action_url($infos['id'], 'e', false);
|
return get_action_url($infos['id'], 'e', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends to the template all messages stored in $page and in the session.
|
||||||
|
*/
|
||||||
function flush_page_messages()
|
function flush_page_messages()
|
||||||
{
|
{
|
||||||
global $template, $page;
|
global $template, $page;
|
||||||
|
|||||||
Reference in New Issue
Block a user