From eb37a4e5f19b5e3e8bdb08d45b8c6838aaf03e2a Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 10 Nov 2025 17:00:58 +0100 Subject: [PATCH] fixes #2423, fixes #1949, fixes #2401 render title/description and keep HTML in descriptions ... and in several API methods add new output fields name_raw and comment_raw that are ready for edition --- include/functions_tag.inc.php | 2 ++ include/ws_functions/pwg.categories.php | 37 +++++++++++++++---------- include/ws_functions/pwg.images.php | 28 +++++++++++++++++++ include/ws_functions/pwg.tags.php | 4 +++ 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php index fb54ec2f6..f3c395791 100644 --- a/include/functions_tag.inc.php +++ b/include/functions_tag.inc.php @@ -109,6 +109,7 @@ SELECT * if (isset($tag_counters[ $row['id'] ])) { $row['counter'] = intval($tag_counters[ $row['id'] ]); + $row['name_raw'] = $row['name']; $row['name'] = trigger_change('render_tag_name', $row['name'], $row); $tags[] = $row; } @@ -131,6 +132,7 @@ SELECT * $tags = array(); while ($row = pwg_db_fetch_assoc($result)) { + $row['name_raw'] = $row['name']; $row['name'] = trigger_change('render_tag_name', $row['name'], $row); $tags[] = $row; } diff --git a/include/ws_functions/pwg.categories.php b/include/ws_functions/pwg.categories.php index d1f6e9368..7fa4c36b2 100644 --- a/include/ws_functions/pwg.categories.php +++ b/include/ws_functions/pwg.categories.php @@ -131,6 +131,10 @@ SELECT SQL_CALC_FOUND_ROWS i.* { $image[$k] = $row[$k]; } + + $image['name'] = strip_tags(trigger_change('render_element_name', $image['name'], __FUNCTION__)); + $image['comment'] = trigger_change('render_element_description', $image['comment'], __FUNCTION__); + $image = array_merge($image, ws_std_get_urls($row)); $images[] = $image; @@ -369,6 +373,8 @@ SELECT SQL_CALC_FOUND_ROWS } else { + $row['name_raw'] = $row['name']; + $row['name'] = strip_tags( trigger_change( 'render_category_name', @@ -378,13 +384,13 @@ SELECT SQL_CALC_FOUND_ROWS ); } - $row['comment'] = strip_tags( - (string) trigger_change( - 'render_category_description', - $row['comment'], - 'ws_categories_getList' - ) - ); + $row['comment_raw'] = $row['comment']; + + $row['comment'] = (string) trigger_change( + 'render_category_description', + $row['comment'], + 'ws_categories_getList' + ); // management of the album thumbnail -- starts here // @@ -660,6 +666,8 @@ SELECT SQL_CALC_FOUND_ROWS id, name, comment, uppercats, global_rank, dir, statu 'admin.php?page=album-' ); + $row['name_raw'] = $row['name']; + $row['name'] = strip_tags( trigger_change( 'render_category_name', @@ -668,14 +676,13 @@ SELECT SQL_CALC_FOUND_ROWS id, name, comment, uppercats, global_rank, dir, statu ) ); $row['fullname'] = strip_tags($cat_display_name); - isset($row['comment']) ? false : $row['comment'] = ""; - $row['comment'] = strip_tags( - trigger_change( - 'render_category_description', - $row['comment'], - 'ws_categories_getAdminList' - ) - ); + + $row['comment_raw'] = $row['comment']; + $row['comment'] = trigger_change( + 'render_category_description', + $row['comment'] ?? '', + 'ws_categories_getAdminList' + ); if (empty($row['image_order'])) { diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index 3463f6d32..76176c962 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -390,6 +390,22 @@ LIMIT 1 $image_row = pwg_db_fetch_assoc($result); $image_row = array_merge($image_row, ws_std_get_urls($image_row)); + $image_row['name_raw'] = $image_row['name']; + $image_row['name'] = strip_tags( + trigger_change( + 'render_element_name', + $image_row['name'], + __FUNCTION__ + ) + ); + + $image_row['comment_raw'] = $image_row['comment']; + $image_row['comment'] = trigger_change( + 'render_element_description', + $image_row['comment'], + __FUNCTION__ + ); + //-------------------------------------------------------- related categories $query = ' SELECT id, name, permalink, uppercats, global_rank, commentable @@ -428,6 +444,15 @@ SELECT id, name, permalink, uppercats, global_rank, commentable ); $row['id']=(int)$row['id']; + + $row['name'] = strip_tags( + trigger_change( + 'render_category_name', + $row['name'], + __FUNCTION__ + ) + ); + $related_categories[] = $row; } usort($related_categories, 'global_rank_compare'); @@ -692,6 +717,9 @@ SELECT * $image[$k] = $row[$k]; } + $image['name'] = strip_tags(trigger_change('render_element_name', $image['name'], __FUNCTION__)); + $image['comment'] = trigger_change('render_element_description', $image['comment'], __FUNCTION__); + $image = array_merge($image, ws_std_get_urls($row)); $images[ $image_ids[ $image['id'] ] ] = $image; } diff --git a/include/ws_functions/pwg.tags.php b/include/ws_functions/pwg.tags.php index 1d6539669..6ca23bb9a 100644 --- a/include/ws_functions/pwg.tags.php +++ b/include/ws_functions/pwg.tags.php @@ -160,6 +160,10 @@ SELECT * { $image[$k] = $row[$k]; } + + $image['name'] = strip_tags(trigger_change('render_element_name', $image['name'], __FUNCTION__)); + $image['comment'] = trigger_change('render_element_description', $image['comment'], __FUNCTION__); + $image = array_merge( $image, ws_std_get_urls($row) ); $image_tag_ids = ($params['tag_mode_and']) ? $tag_ids : $image_tag_map[$image['id']];