Base Directory:
/home/ecedu/public_html/new/Views/layouts
'عربي',
'ku' => 'کوردی',
'en' => 'English',
];
$tables = getTables();
$currentLangName = isset($langNames[$lang]) ? $langNames[$lang] : 'English';
// -------------------------------------
// 2) توليد أسماء الجداول تلقائياً
// -------------------------------------
// ———– طريقة 1: إذا كنت تعرف عدد الجداول الثابت مسبقاً
// -------------------------------------
// 2) تعريف باقي المتغيرات والمصفوفات
// -------------------------------------
// نص من نحن - افتراضياً فارغ، قد يعبأ من قاعدة البيانات.
// تهيئة المتغيرات الافتراضية
$type_id = 0;
$_aboutus = '';
$aboutus = '';
$aboutus1 = '';
$aboutus2 = '';
$_contactus = '';
$contactus = '';
$contactus1 = '';
$contactus2 = '';
$address = '';
$social = array_fill(1, 4, ''); // للمواقع الاجتماعية
$logo = []; // للشعارات
$ads_url1 = '';
$ads_img1 = '';
$details_title = '';
$details1_title = '';
$details2_title = '';
$details_description = '';
$details1_description = '';
$details2_description = '';
$news_path = "service/images/news/";
// 1) محتوى "من نحن"
if (!empty($editorialData) && is_array($editorialData)) {
$aboutus = $editorialData['text_description'] ?? '';
$aboutus1 = $editorialData['text_description1'] ?? '';
$aboutus2 = $editorialData['text_description2'] ?? '';
switch ($lang) {
case 'ku':
$_aboutus = $aboutus1 !== '' ? $aboutus1 : $aboutus;
break;
case 'en':
$_aboutus = $aboutus2 !== '' ? $aboutus2 : $aboutus;
break;
default:
$_aboutus = $aboutus;
}
}
// 2) محتوى "اتصل بنا"
if (!empty($contactusData) && is_array($contactusData)) {
$contactus = $contactusData['text_description'] ?? '';
$contactus1 = $contactusData['text_description1'] ?? '';
$contactus2 = $contactusData['text_description2'] ?? '';
switch ($lang) {
case 'ku':
$_contactus = $contactus1 !== '' ? $contactus1 : $contactus;
break;
case 'en':
$_contactus = $contactus2 !== '' ? $contactus2 : $contactus;
break;
default:
$_contactus = $contactus;
}
}
// 3) بيانات التواصل الاجتماعي
if (!empty($socialData) && is_array($socialData)) {
foreach ($socialData as $idx => $item) {
$key = $idx + 1;
if ($key >= 1 && $key <= 4) {
$social[$key] = $item['text_description'] ?? '';
}
}
}
$social1 = $social[1];
$social2 = $social[2];
$social3 = $social[3];
$social4 = $social[4];
// 4) الشعارات
if (!empty($imageData) && is_array($imageData)) {
foreach ($imageData as $img) {
$tid = $img['type_id'] ?? null;
$id = $img['img_id'] ?? '';
$ext = $img['img_ext'] ?? '';
if ($tid && $id && $ext) {
$logo[$tid] = "service/images/header/img_{$id}.{$ext}";
}
}
}
$logo1 = $logo[1] ?? '';
$logo2 = $logo[2] ?? '';
$logo3 = $logo[3] ?? '';
$logo4 = $logo[4] ?? '';
// 5) إعلانات
if (!empty($adsData) && is_array($adsData)) {
foreach ($adsData as $ad) {
if (($ad['type_id'] ?? null) == 1) {
$ads_url1 = !empty($ad['img_url']) ? $ad['img_url'] : '#';
$id = $ad['img_id'] ?? '';
$ext = $ad['img_ext'] ?? '';
$ads_img1 = "service/images/ads/img_{$id}.{$ext}";
}
}
}
$site_title=$L['site_title'];
// معلومات عامة عن الموقع
$siteInfo = [
'logo' => $logo1,
'address' => 'العراق – بغداد – الوزيرية – قرب المعهد القضائي',
'address1' => 'عێراق – بەغداد – الوزیریە – نزیک ئەنجومەنی دادوەری',
'address2' => 'Iraq – Baghdad – Al-Waziriyah – Near the Judicial Institute',
'phone' => '',//'+(123) 456-7890',
'email' => 'ec@ec.edu.iq',
];
$address= $siteInfo['address'];
if($lang=="ku") $address= $siteInfo['address1'];
if($lang=="en") $address= $siteInfo['address2'];
// روابط الصفحات الثابتة في شريط الحقوق
$footerPages = [
['aboutus.php', $L['about_us']],
['contactus.php', $L['contact_us']],
['term-of-use.html', $L['term_of_use'] ],
['privacy-policy.html',$L['privacy'] ],
];
$socialPlatforms = [
11 => [
'url' => !empty($social1) ? $social1 : 'https://facebook.com',
'icon' => 'facebook',
'name' => !empty($L['facebook']) ? $L['facebook'] : 'Facebook'
],
12 => [
'url' => !empty($social2) ? $social2 : 'https://x.com/',
'icon' => 'twitter',
'name' => !empty($L['twitter']) ? $L['twitter'] : 'Twitter'
],
13 => [
'url' => !empty($social3) ? $social3 : 'https://youtube.com',
'icon' => 'youtube',
'name' => !empty($L['youtube']) ? $L['youtube'] : 'YouTube'
],
14 => [
'url' => !empty($social4) ? $social4 : 'https://instagram.com',
'icon' => 'instagram',
'name' => !empty($L['instagram']) ? $L['instagram'] : 'Instagram'
],
];
// نفترض وجود كائن $functions مسبقاً
$today = $functions->getDate($lang);
// -------------------------------------
// القائمة الجديدة
// -------------------------------------
$showHeaderType=2;
$menu =$M;
/**
* دالة للمساعدة في إرجاع العنوان المناسب حسب اللغة
*/
function getItemTitle(array $items, string $lang): string {
// إذا كان العنوان مصفوفة لغات
if (is_array($items ?? null)) {
return $items[$lang] ?? '';
}
// دعم قديم في حال كان العنوان نصا مفردا
return $items ?? '';
}
function renderMenu(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) : '';
/* ---------------------------------------------------
* فرع الموبايل (أكورديون)
* --------------------------------------------------*/
if ($isMobile) {
if ($hasChildren) {
$html .= "
" . renderMenu($item['children'], $lang, true, $level + 1, true) . "
";
} else {
if (!$st) {
$html .= "
";
} else {
$html .= "
";
}
}
/* ---------------------------------------------------
* فرع الدسكتوب (Dropdown)
* --------------------------------------------------*/
} else {
// ↓↓ التعديل الرئيسى على المسافات ↓↓
$dropdownClass = $hasChildren ? 'dropdown' : '';
$aBaseClass = $hasChildren ? 'nav-link dropdown-toggle' : 'nav-link';
$aClass = $aBaseClass . ' py-1 px-2'; // Padding أصغر
$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;
}
// Define readMenu function
function readMenu(array $items, int $id, string $lang): string {
foreach ($items as $item) {
$id1 = $item['id'] ?? -1;
if ($id == $id1) {
return getItemTitle($item['title'], $lang);
}
if (!empty($item['children'])) {
$result = readMenu($item['children'], $id, $lang);
if (!empty($result)) {
return $result;
}
}
}
return '';
}
// دالة السلايدر الرئيسي (يسار كبير)
function renderMainSlider(array $newsList, string $lang, int $type = 2): string {
ob_start(); ?>
0) {
$repeatedNews = [];
for ($i = 0; $i < $requiredCount; $i++) {
$repeatedNews[] = $newsList[$i % $currentCount];
}
} else {
$repeatedNews = array_slice($newsList, 0, $requiredCount);
}
$padLeft = '4px';
?>
= playIcon($news,$lang,$type); ?>
= htmlspecialchars($description) ?>
= htmlspecialchars($description) ?>
= htmlspecialchars($description) ?>
';
}
$news = $newsList[0];
$title = htmlspecialchars(getLocalizedTitle($news, $lang));
$description = htmlspecialchars(getShortDescription($news, $lang, $functions, $limit));
$imagePath = htmlspecialchars(getImagePath($news, $type));
$author = htmlspecialchars(getAuthor($news));
$dateStr = formatNewsDate($news, 'd F Y');
$newsId = (int)$news['news_id'];
return '
'
. playIcon($news,$lang,$type) .
'
' . $author . '
' . $description . '
';
}
function renderSidePostsBlock(array $newsList, string $lang, int $type, $l, int $limit = 4): string {
if (empty($newsList) || count($newsList) <= 1) return '';
$output = '
';
$side_posts = array_slice($newsList, 1);
$count = 0;
foreach ($side_posts as $news) {
if ($count++ >= $limit) break;
$title = htmlspecialchars(getLocalizedTitle($news, $lang));
$imagePath = htmlspecialchars(getImagePath($news, $type));
$dateStr = formatNewsDate($news);
$newsId = (int)$news['news_id'];
$output .= '
'
. playIcon($news,$lang,$type) .
'
';
}
$output .= readMore($newsList, $type, $lang ,$l);
$output .= '
';
return $output;
}
function renderNewsBlockSection(array $newsList, string $lang, int $type, string $sectionTitle, $functions, $l): string {
ob_start();
?>
= playIcon($news,$lang,$type); ?>
= $description ?>
= readMore($newsList, $type, $lang ,$l) ?>
= playIcon($news,$lang,$type); ?>
= readMore($newsList, $type, $lang , $l) ?>
= playIcon($news, $lang, $type); ?>
= htmlspecialchars($description) ?>
= readMore($newsList, $type, $lang , $l) ?>
= playIcon($news,$lang,$type); ?>
= $description ?>
= readMore($newsList, $type, $lang , $l) ?>
' . htmlspecialchars($L['no_last_news'] ?? 'No news available') . '';
}
$table = $tables[$tableId];
$img_path = "service/images/news/$table/";
ob_start();
?>
= playIcon($news,$lang,$type); ?>
' . htmlspecialchars($L['no_last_news'] ?? 'No news available') . '';
}
$table = $tables[$tableId];
$img_path = "service/images/news/$table/";
ob_start(); ?>
= $maxCount) break;
$newsId = (int)$news['news_id'];
$title = getLocalizedTitle($news, $lang);
$imagePath = $img_path . "img_" . $newsId . '.' . $news['img_ext'];
?>
= 5) {
return '
' . htmlspecialchars($L['read_more']) . '
';
}
return '';
}
function playIcon($news, $lang, $type){
$id=$news['news_id'];
$url=$news['news_link'];
if($url)
return '
';
else
return '';
}
/**
* إرجاع كود SVG لشبكات التواصل مع إمكانية مضاعفة الحجم.
*
* @param string $name اسم الشبكة: facebook | twitter | youtube | instagram
* @param float $scale عامل التكبير (1 = الحجم الأصلي؛ 2 = ضعف الحجم؛ …)
* @return string كود SVG جاهز للإدراج
*/
function getSocialIconSvg(string $name, float $scale = 1): string
{
$base = 1 * $scale . 'rem';
$icons = [
'facebook' => '
',
'twitter' => '',
'youtube' => '
',
'instagram' => '
'
];
if (isset($icons[$name])) {
return preg_replace('/