Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(__DIR__ . "/fbm-core/Classes/Pages.php");
- require_once(__DIR__ . "/fbm-core/Classes/UserAccounts.php");
- $account = UserAccounts::getSessionUser();
- if (empty($account)){
- print("Please login");
- exit();
- }
- $cityPages = Pages::getPages(0, "City"); // Array of SQL rows with their columns
- $imageArray = [
- ];
- $maxImageArray = count($imageArray) - 1; // Max index
- $currentIndex = 0; // The current image array index in the for loop
- // This will go through every city page and every image in order
- // Upon hitting the last image in $imageArray, if there are still more pages it will reset from the first image again
- foreach($cityPages as $page){
- $imageSrc = $imageArray[$currentIndex];
- $fileName = basename($imageSrc);
- $fileName = str_replace("-", " ", $fileName);
- $alt = str_replace(".jpg", "", $fileName);
- $pageContent = $page['pageBody'];
- $pageContent = preg_replace("/(<h1>.+<\/h1>)/ism", "$1\n<img class=\"img-r-dynamic\" src=\"" . $imageSrc . "\" alt=\"" . $alt . "\">\n", $pageContent);
- Pages::savePage(
- $page['id'],
- $page['pageName'],
- $page['pageRoute'],
- $page['isRouteRegex'],
- $page['pageLayout'],
- $page['pageHead'],
- $pageContent,
- 0,
- $page['customData'],
- $acount['id']
- );
- ++$currentIndex;
- if ($currentIndex > $maxImageArray){
- $currentIndex = 0;
- }
- print("Finished page $pageID \n");
- }
- print("<div><h3>Completed</h3></div>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement