Base Directory:
/home/ecedu/public_html/new/Views/layouts
$html = '
$title = htmlspecialchars($item['title'] ?? '', ENT_QUOTES, 'UTF-8');
$href = htmlspecialchars($item['link'] ?? '#', ENT_QUOTES, 'UTF-8');
$html .= ''.$title.'';
// الأطفال: dropdown عادي
if ($hasChildren && $isDropdown) {
$html .= '';
}
// الأطفال: mega
if ($hasChildren && $isMega) {
if ($layout === 'list') {
$html .= '';
} else {
// layout = grid (شبكة بطاقات المقالات)
$html .= '';
$html .= '
';
foreach (array_slice($item['items'], 0, 4) as $news) {
$titleNews = htmlspecialchars(getLocalizedTitle($news, $lang), ENT_QUOTES, 'UTF-8');
$imagePath = htmlspecialchars(getImagePath($news, $type_id), ENT_QUOTES, 'UTF-8');
$dateStr = htmlspecialchars(formatNewsDate($news), ENT_QUOTES, 'UTF-8');
$newsId = (int)($news['news_id'] ?? 0);
$html .= '
';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
'.$dateStr.'
';
$html .= '
';
$html .= '
';
$html .= '';
}
$html .= '
';
$html .= '
';
}
}
$html .= '';
return $html;
}
function renderNewMenu(array $items, string $lang = "ar", bool $isMobile = false, int $level = 0, bool $st = false): string
{
$html = '';
$m = '';
$currentId = $_GET['i'] ?? 1;
foreach ($items as $item) {
$title = getItemTitle($item['title'], $lang);
$id = $item['id']?? -1;
$icon = $item['icon'] ?? '';
$hasChildren = !empty($item['children']);
$link = $id == -1 ? '' : (($id == 0) ? 'index.php?lang=' . $lang : 'list-news.php?i=' . $id . '&lang=' . $lang);
$iconHtml = $icon ? "
" : '';
$isActive = ($id == $currentId) ? ' active-text' : '';
$edit = ($id > 1) ? edit_news($id) : '';
// إنشاء IDs فريدة لكل عنصر أكورديون
$parentId = 'parent-' . ($item['parent_id'] ?? 'root');
$accordionId = 'accordion-' . $id . '-' . uniqid();
$headingId = 'heading-' . $accordionId;
$collapseId = 'collapse-' . $accordionId;
// إضافة كلاس بناءً على وجود أبناء
$itemClass = $hasChildren ? 'has-children' : 'no-children';
/* ---------------------------------------------------
* فرع الموبايل (أكورديون)
* --------------------------------------------------*/
if ($isMobile) {
if ($hasChildren) {
$html .= "
" . renderNewMenu($item['children'], $lang, true, $level + 1, true, $accordionId) . "
";
} else {
if (!$st) {
$html .= "
";
} else {
$html .= "
";
}
}
} else {
// ↓↓ التعديل الرئيسى على المسافات ↓↓
$dropdownClass = $hasChildren ? 'dropdown' : '';
$aBaseClass = $hasChildren ? 'nav-link dropdown-toggle' : 'nav-link';
$aClass = $aBaseClass . ' py-2 px-2';
$aAttrs = $hasChildren
? "href='#' role='button' data-bs-toggle='dropdown' aria-expanded='false'"
: "href='$link'";
$edit = (!$hasChildren && $id > 1) ? edit_details($id) : '';
$html .= "
$iconHtml$title $edit";
if ($hasChildren) {
$html .= "
";
}
$html .= " ";
}
}
return $html;
}
// ——— الآن نبدأ الشرط ———
if ($showHeaderType == 1): ?>