39496-vm/patch_index.py
2026-04-07 07:11:44 +00:00

161 lines
9.4 KiB
Python

with open('index.php', 'r', encoding='utf-8') as f:
content = f.read()
# 1. Hero Section
# find the panel-card div and everything inside it up to </section>
# It starts with:
# <div class="col-lg-5">
# <div class="panel-card">
old_hero_col = """ <div class="col-lg-5">
<div class="panel-card">"""
new_hero_col = """ <div class="col-lg-5">
<?php if ($hero_img = landing_setting('hero_image', '')): ?>
<img src="<?= h($hero_img) ?>" class="img-fluid rounded shadow-lg w-100" style="object-fit: cover; max-height: 500px;" alt="Hero Image">
<?php else: ?>
<div class="panel-card">"""
content = content.replace(old_hero_col, new_hero_col)
old_hero_end = """ <a class="btn btn-outline-dark w-100 mt-3" href="<?= h(app_url('dashboard.php')) ?>"><?= h(t('Open student dashboard', 'افتح لوحة الطالب')) ?></a>
</div>
</div>
</div>
</div>
</section>"""
new_hero_end = """ <a class="btn btn-outline-dark w-100 mt-3" href="<?= h(app_url('dashboard.php')) ?>"><?= h(t('Open student dashboard', 'افتح لوحة الطالب')) ?></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
</section>"""
content = content.replace(old_hero_end, new_hero_end)
# 2. Courses Section
old_courses = """ <div class="section-header">
<div>
<span class="eyebrow"><?= h(landing_setting('courses_eyebrow', 'Featured Courses', 'الدورات المميزة')) ?></span>
<h2 class="section-title"><?= h(landing_setting('courses_title', 'Enroll in specialized short courses designed to accelerate your skills.', 'سجل في دورات قصيرة متخصصة لتسريع تطوير مهاراتك.')) ?></h2>
</div>
</div>"""
new_courses = """ <?php if ($courses_img = landing_setting('courses_image', '')): ?>
<div class="row align-items-center mb-4">
<div class="col-lg-7">
<span class="eyebrow"><?= h(landing_setting('courses_eyebrow', 'Featured Courses', 'الدورات المميزة')) ?></span>
<h2 class="section-title mb-0"><?= h(landing_setting('courses_title', 'Enroll in specialized short courses designed to accelerate your skills.', 'سجل في دورات قصيرة متخصصة لتسريع تطوير مهاراتك.')) ?></h2>
</div>
<div class="col-lg-5 text-lg-end mt-3 mt-lg-0">
<img src="<?= h($courses_img) ?>" class="img-fluid rounded shadow-sm" alt="Courses" style="max-height: 150px; object-fit: cover;">
</div>
</div>
<?php else: ?>
<div class="section-header">
<div>
<span class="eyebrow"><?= h(landing_setting('courses_eyebrow', 'Featured Courses', 'الدورات المميزة')) ?></span>
<h2 class="section-title"><?= h(landing_setting('courses_title', 'Enroll in specialized short courses designed to accelerate your skills.', 'سجل في دورات قصيرة متخصصة لتسريع تطوير مهاراتك.')) ?></h2>
</div>
</div>
<?php endif; ?>"""
content = content.replace(old_courses, new_courses)
# 3. Subjects Section
old_subjects = """ <div class="section-header">
<div>
<span class="eyebrow"><?= h(landing_setting('subjects_eyebrow', 'Featured subjects', 'المواد المميزة')) ?></span>
<h2 class="section-title"><?= h(landing_setting('subjects_title', 'Separate pages for catalog, detail, checkout, and dashboards.', 'صفحات منفصلة للكتالوج والتفاصيل والدفع ولوحات التحكم.')) ?></h2>
</div>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('catalog.php')) ?>"><?= h(t('See all subjects', 'عرض جميع المواد')) ?></a>
</div>"""
new_subjects = """ <?php if ($subjects_img = landing_setting('subjects_image', '')): ?>
<div class="row align-items-center mb-4">
<div class="col-lg-7">
<span class="eyebrow"><?= h(landing_setting('subjects_eyebrow', 'Featured subjects', 'المواد المميزة')) ?></span>
<h2 class="section-title mb-2"><?= h(landing_setting('subjects_title', 'Separate pages for catalog, detail, checkout, and dashboards.', 'صفحات منفصلة للكتالوج والتفاصيل والدفع ولوحات التحكم.')) ?></h2>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('catalog.php')) ?>"><?= h(t('See all subjects', 'عرض جميع المواد')) ?></a>
</div>
<div class="col-lg-5 text-lg-end mt-3 mt-lg-0">
<img src="<?= h($subjects_img) ?>" class="img-fluid rounded shadow-sm" alt="Subjects" style="max-height: 150px; object-fit: cover;">
</div>
</div>
<?php else: ?>
<div class="section-header">
<div>
<span class="eyebrow"><?= h(landing_setting('subjects_eyebrow', 'Featured subjects', 'المواد المميزة')) ?></span>
<h2 class="section-title"><?= h(landing_setting('subjects_title', 'Separate pages for catalog, detail, checkout, and dashboards.', 'صفحات منفصلة للكتالوج والتفاصيل والدفع ولوحات التحكم.')) ?></h2>
</div>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('catalog.php')) ?>"><?= h(t('See all subjects', 'عرض جميع المواد')) ?></a>
</div>
<?php endif; ?>"""
content = content.replace(old_subjects, new_subjects)
# 4. Flow Section
old_flow = """ <div class="section-header mb-4">
<div>
<span class="eyebrow"><?= h(landing_setting('flow_eyebrow', 'Delivery flow', 'مسار التسليم')) ?></span>
<h2 class="section-title"><?= h(landing_setting('flow_title', 'One thin slice from discovery to live access.', 'شريحة رشيقة من الاكتشاف حتى الوصول المباشر.')) ?></h2>
</div>
</div>"""
new_flow = """ <?php if ($flow_img = landing_setting('flow_image', '')): ?>
<div class="row align-items-center mb-4">
<div class="col-lg-7">
<span class="eyebrow"><?= h(landing_setting('flow_eyebrow', 'Delivery flow', 'مسار التسليم')) ?></span>
<h2 class="section-title mb-0"><?= h(landing_setting('flow_title', 'One thin slice from discovery to live access.', 'شريحة رشيقة من الاكتشاف حتى الوصول المباشر.')) ?></h2>
</div>
<div class="col-lg-5 text-lg-end mt-3 mt-lg-0">
<img src="<?= h($flow_img) ?>" class="img-fluid rounded shadow-sm" alt="Delivery Flow" style="max-height: 150px; object-fit: cover;">
</div>
</div>
<?php else: ?>
<div class="section-header mb-4">
<div>
<span class="eyebrow"><?= h(landing_setting('flow_eyebrow', 'Delivery flow', 'مسار التسليم')) ?></span>
<h2 class="section-title"><?= h(landing_setting('flow_title', 'One thin slice from discovery to live access.', 'شريحة رشيقة من الاكتشاف حتى الوصول المباشر.')) ?></h2>
</div>
</div>
<?php endif; ?>"""
content = content.replace(old_flow, new_flow)
# 5. Plans Section
old_plans = """ <div class="section-header mb-4">
<div>
<span class="eyebrow"><?= h(landing_setting('plans_eyebrow', 'Plans', 'الخطط')) ?></span>
<h2 class="section-title"><?= h(landing_setting('plans_title', 'Plan-based access for a shared marketplace.', 'وصول قائم على الخطط لمنصة مشتركة.')) ?></h2>
</div>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('pricing.php')) ?>"><?= h(t('Open pricing', 'افتح التسعير')) ?></a>
</div>"""
new_plans = """ <?php if ($plans_img = landing_setting('plans_image', '')): ?>
<div class="row align-items-center mb-4">
<div class="col-lg-7">
<span class="eyebrow"><?= h(landing_setting('plans_eyebrow', 'Plans', 'الخطط')) ?></span>
<h2 class="section-title mb-2"><?= h(landing_setting('plans_title', 'Plan-based access for a shared marketplace.', 'وصول قائم على الخطط لمنصة مشتركة.')) ?></h2>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('pricing.php')) ?>"><?= h(t('Open pricing', 'افتح التسعير')) ?></a>
</div>
<div class="col-lg-5 text-lg-end mt-3 mt-lg-0">
<img src="<?= h($plans_img) ?>" class="img-fluid rounded shadow-sm" alt="Plans" style="max-height: 150px; object-fit: cover;">
</div>
</div>
<?php else: ?>
<div class="section-header mb-4">
<div>
<span class="eyebrow"><?= h(landing_setting('plans_eyebrow', 'Plans', 'الخطط')) ?></span>
<h2 class="section-title"><?= h(landing_setting('plans_title', 'Plan-based access for a shared marketplace.', 'وصول قائم على الخطط لمنصة مشتركة.')) ?></h2>
</div>
<a class="link-dark fw-semibold text-decoration-none" href="<?= h(app_url('pricing.php')) ?>"><?= h(t('Open pricing', 'افتح التسعير')) ?></a>
</div>
<?php endif; ?>"""
content = content.replace(old_plans, new_plans)
with open('index.php', 'w', encoding='utf-8') as f:
f.write(content)