Cleanup: Remove temporary batch update helper script
This commit is contained in:
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BATCH UPDATE BANNER COMPONENTS - ROBUST
|
|
||||||
* Updates pages using the page-banner-area pattern to use the reusable banner component
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Configuration for each file: filename => ['pageTitle', [breadcrumbs]]
|
|
||||||
$filesToUpdate = [
|
|
||||||
'blog.php' => ['Blogs', [['Home' => 'index.php']]],
|
|
||||||
'blog_details.php' => ['Blog Details', [['Home' => 'index.php'], ['Blogs' => 'blog.php']]],
|
|
||||||
'bookings.php' => ['Bookings', [['Home' => 'index.php']]],
|
|
||||||
'campsites.php' => ['Campsites', [['Home' => 'index.php']]],
|
|
||||||
'contact.php' => ['Contact Us', [['Home' => 'index.php']]],
|
|
||||||
'driver_training.php' => ['Driver Training', [['Home' => 'index.php']]],
|
|
||||||
'events.php' => ['Events', [['Home' => 'index.php']]],
|
|
||||||
'membership.php' => ['Membership', [['Home' => 'index.php']]],
|
|
||||||
'membership_application.php' => ['Membership Application', [['Home' => 'index.php'], ['Membership' => 'membership.php']]],
|
|
||||||
'membership_payment.php' => ['Membership Payment', [['Home' => 'index.php'], ['Membership' => 'membership.php']]],
|
|
||||||
'trips.php' => ['Trips', [['Home' => 'index.php']]],
|
|
||||||
'bush_mechanics.php' => ['Bush Mechanics', [['Home' => 'index.php']]],
|
|
||||||
'rescue_recovery.php' => ['Rescue & Recovery', [['Home' => 'index.php']]],
|
|
||||||
'best_of_the_eastern_cape_2024.php' => ['Best of Eastern Cape 2024', [['Home' => 'index.php']]],
|
|
||||||
'2025_agm_minutes.php' => ['2025 AGM Minutes', [['Home' => 'index.php']]],
|
|
||||||
];
|
|
||||||
|
|
||||||
$updated = 0;
|
|
||||||
$skipped = 0;
|
|
||||||
$failed = 0;
|
|
||||||
|
|
||||||
foreach ($filesToUpdate as $filename => $config) {
|
|
||||||
$filepath = __DIR__ . '/' . $filename;
|
|
||||||
|
|
||||||
if (!file_exists($filepath)) {
|
|
||||||
echo "[MISSING] $filename\n";
|
|
||||||
$failed++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = file_get_contents($filepath);
|
|
||||||
|
|
||||||
// Check if already uses banner component
|
|
||||||
if (strpos($content, 'components/banner.php') !== false) {
|
|
||||||
echo "[SKIP] $filename - Already uses banner component\n";
|
|
||||||
$skipped++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if file has page-banner-area
|
|
||||||
if (strpos($content, 'page-banner-area') === false) {
|
|
||||||
echo "[SKIP] $filename - No page-banner-area found\n";
|
|
||||||
$skipped++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list($pageTitle, $breadcrumbs) = $config;
|
|
||||||
|
|
||||||
// Format breadcrumbs array for PHP code
|
|
||||||
$breadcrumbStr = '[';
|
|
||||||
foreach ($breadcrumbs as $item) {
|
|
||||||
$breadcrumbStr .= '[';
|
|
||||||
foreach ($item as $label => $url) {
|
|
||||||
$breadcrumbStr .= "'{$label}' => '{$url}', ";
|
|
||||||
}
|
|
||||||
$breadcrumbStr = rtrim($breadcrumbStr, ', ') . '], ';
|
|
||||||
}
|
|
||||||
$breadcrumbStr = rtrim($breadcrumbStr, ', ') . ']';
|
|
||||||
|
|
||||||
// Build replacement code
|
|
||||||
$replacement = "<?php\n \$pageTitle = '{$pageTitle}';\n \$breadcrumbs = {$breadcrumbStr};\n require_once('components/banner.php');\n?>";
|
|
||||||
|
|
||||||
// Pattern: Match from "<?php $bannerFolder" through entire banner section including "<!-- Page Banner End -->"
|
|
||||||
// This handles the PHP setup code + HTML section + closing comment
|
|
||||||
$pattern = '/[\s]*<\?php\s*\$bannerFolder\s*=\s*[\'"]assets\/images\/banners\/[\'"];[\s\S]*?<\/section>\s*<!-- Page Banner End -->/';
|
|
||||||
|
|
||||||
$newContent = preg_replace($pattern, $replacement, $content, 1, $count);
|
|
||||||
|
|
||||||
if ($count > 0 && file_put_contents($filepath, $newContent) !== false) {
|
|
||||||
$updated++;
|
|
||||||
echo "[UPDATE] $filename\n";
|
|
||||||
} else {
|
|
||||||
$failed++;
|
|
||||||
echo "[FAIL] $filename\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "\n";
|
|
||||||
echo str_repeat("=", 50) . "\n";
|
|
||||||
echo "BATCH UPDATE SUMMARY\n";
|
|
||||||
echo str_repeat("=", 50) . "\n";
|
|
||||||
echo "Updated: $updated\n";
|
|
||||||
echo "Skipped: $skipped\n";
|
|
||||||
echo "Failed: $failed\n";
|
|
||||||
echo str_repeat("=", 50) . "\n";
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user