adding read more
This commit is contained in:
parent
39610613f2
commit
a4dccb579a
12
index.php
12
index.php
@ -128,7 +128,15 @@ $cases = $stmt->fetchAll();
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? $t['subtitle'];
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
|
||||
// Helper for safe truncation
|
||||
// Helpers for safe string operations
|
||||
function safe_strlen($text) {
|
||||
if (empty($text)) return 0;
|
||||
if (function_exists('mb_strlen')) {
|
||||
return mb_strlen($text);
|
||||
}
|
||||
return strlen($text);
|
||||
}
|
||||
|
||||
function safe_truncate($text, $limit = 120) {
|
||||
if (empty($text)) return '';
|
||||
if (function_exists('mb_strimwidth')) {
|
||||
@ -664,7 +672,7 @@ function safe_truncate($text, $limit = 120) {
|
||||
<?php
|
||||
$pct = min(100, round(($case['raised'] / $case['goal']) * 100));
|
||||
$full_desc = $lang === 'en' ? $case['desc_en'] : $case['desc_ar'];
|
||||
$is_long = mb_strlen($full_desc) > 120;
|
||||
$is_long = safe_strlen($full_desc) > 120;
|
||||
$truncated_desc = safe_truncate($full_desc, 120);
|
||||
?>
|
||||
<div class="col-md-6 col-lg-4" id="case-<?= $case['id'] ?>">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user