Update Layout.php and Editing.php

This commit is contained in:
gtbu 2025-04-02 18:32:40 +02:00
parent 40573163db
commit 170af7327a
2 changed files with 32 additions and 23 deletions

View file

@ -1979,17 +1979,17 @@ class Layout extends \gp\admin\Addon\Install{
return $theme;
}
public function TitlesCount($layout) {
$titles_count = 0;
public function TitlesCount($layout){
$titles_count = 0;
foreach($this->LayoutArray as $layout_comparison){
if( $layout == $layout_comparison ){
$titles_count++;
}
}
return $titles_count;
}
foreach ($this->LayoutArray ?? [] as $layout_comparison) {
if ($layout == $layout_comparison) {
$titles_count++;
}
}
return $titles_count;
}
/**
* Restore a layout to it's default content arrangement

View file

@ -1000,22 +1000,31 @@ namespace gp\tool{
echo '<ul class="gp_gallery">';
foreach($_POST['images'] as $i => $image ){
foreach ($_POST['images'] as $i => $image) {
// Sanitize and escape the image path
$image = htmlspecialchars($image, ENT_QUOTES, 'UTF-8');
$thumb_path = \gp\tool::ThumbnailPath($image);
$caption = $_POST['captions'][$i];
\gp\tool\Files::cleanText($caption);
$img_alt = str_replace('_', ' ', basename(pathinfo($image, PATHINFO_FILENAME)));
// Generate a thumbnail path (assumes this function is safe)
$thumb_path = \gp\tool::ThumbnailPath($image);
$thumb_path = htmlspecialchars($thumb_path, ENT_QUOTES, 'UTF-8');
echo '<li>';
// echo '<a class="gallery_gallery" data-arg="gallery_gallery" href="'.$image.'" data-cmd="gallery" rel="'.$rel_id.'">'; // title="'.htmlspecialchars($caption).'"
echo '<a class="gallery_gallery" data-arg="gallery_gallery" href="'.htmlspecialchars(urlencode($image), ENT_QUOTES, 'UTF-8').'" data-cmd="gallery" rel="'.htmlspecialchars($rel_id, ENT_QUOTES, 'UTF-8').'">';
echo '<img src="'.$thumb_path.'" alt="'.$img_alt.'" />';
echo '<span class="caption">'.$caption.'</span>';
echo '</a>';
echo '</li>';
}
echo '</ul>';
// Get and escape captions
$caption = isset($_POST['captions'][$i]) ? $_POST['captions'][$i] : '';
\gp\tool\Files::cleanText($caption); // Assuming this cleans text correctly
$caption = htmlspecialchars($caption, ENT_QUOTES, 'UTF-8');
// Sanitize the alt text
$img_alt = htmlspecialchars(str_replace('_', ' ', basename(pathinfo($image, PATHINFO_FILENAME))), ENT_QUOTES, 'UTF-8');
echo '<li>';
echo '<a class="gallery_gallery" data-arg="gallery_gallery" href="' . $image . '" data-cmd="gallery" rel="' . htmlspecialchars($rel_id, ENT_QUOTES, 'UTF-8') . '">';
echo '<img src="' . $thumb_path . '" alt="' . $img_alt . '" />';
echo '<span class="caption">' . $caption . '</span>';
echo '</a>';
echo '</li>';
}
echo '</ul>';
$section['content'] = ob_get_clean();
$section['images'] = $_POST['images'];