Example #1
0
function createMenu($hotelcsv, &$parentMenuObject, $navAppend = "", &$listPageObjectArray, $hotelChainMenu = false)
{
    global $statusFile;
    $maxRows = count($hotelcsv);
    $rowCounter = 0;
    $currentCountryMenuObject = null;
    $currentStateMenuObject = null;
    $currentHotelChainObject = null;
    $previousRow = null;
    $currentListObject = null;
    $debugCounter = 0;
    while ($rowCounter < $maxRows) {
        $currentRow = $hotelcsv[$rowCounter];
        if (empty($navAppend) || !empty($navAppend) && strpos($currentRow[CSV_TYPE_INDEX], $navAppend) !== false) {
            $hotelMenuObject = new MenuJSONObject($currentRow[CSV_HOTEL_NAME_INDEX], "/" . $currentRow[CSV_URL_INDEX], $navAppend);
            if ($hotelChainMenu) {
                $debugCounter++;
                if (DEBUG_MODE && $debugCounter > 6) {
                    break;
                }
                if (kill_build()) {
                    if (isset($statusFile)) {
                        fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                    }
                    $errorArray[] = "Build Killed!";
                    break;
                }
                //If same hotel chain then add to existing listing
                if (isSameHotelChainAsPrevious($currentRow, $previousRow)) {
                    //Add the hotel chain to the submenu
                    $currentHotelChainMenuObject->addSubmenu($hotelMenuObject);
                    //Listing is the same regardless
                    $currentListObject->addListing($currentRow[CSV_COUNTRY_CODE_INDEX], $currentRow[CSV_HOTEL_CODE_INDEX]);
                    //If not create a new listing and add it
                } else {
                    //Create new hotel chain menu object
                    $hotelChainUrl = create_hotel_chain_url($currentRow);
                    $currentHotelChainMenuObject = new MenuJSONObject($currentRow[CSV_HOTEL_CHAIN_INDEX], $hotelChainUrl);
                    $currentHotelChainMenuObject->addSubmenu($hotelMenuObject);
                    //Tack on the hotel chain to the parent object
                    $parentMenuObject->addSubmenu($currentHotelChainMenuObject);
                    //New listing object as well
                    $chainPath = $currentRow[CSV_HOTEL_CHAIN_INDEX];
                    $currentListObject = new ChainListPageObject($chainPath, $currentRow[CSV_HOTEL_CHAIN_INDEX]);
                    $currentListObject->addListing($currentRow[CSV_COUNTRY_CODE_INDEX], $currentRow[CSV_HOTEL_CODE_INDEX]);
                    $listPageObjectArray[] = $currentListObject;
                }
            } else {
                if (isSameStateAsPrevious($currentRow, $previousRow) && isSameCountryAsPrevious($currentRow, $previousRow)) {
                    //If no state these will still be equal
                    if (empty($currentStateMenuObject)) {
                        //Empty state field in the csv
                        $currentCountryMenuObject->addSubmenu($hotelMenuObject);
                    } else {
                        $currentStateMenuObject->addSubmenu($hotelMenuObject);
                    }
                    //Listing is the same regardless
                    $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                } else {
                    if (isSameCountryAsPrevious($currentRow, $previousRow)) {
                        //Means same country but different states
                        //Create a new parent object for this state
                        $stateUrl = create_listing_url($currentRow, $navAppend);
                        $currentStateMenuObject = new MenuJSONObject($currentRow[CSV_CITY_OR_STATE_INDEX], $stateUrl, $navAppend);
                        //Add the hotel to the new state
                        $currentStateMenuObject->addSubmenu($hotelMenuObject);
                        //Add the new state to the country
                        $currentCountryMenuObject->addSubmenu($currentStateMenuObject);
                        //New listing object as well
                        $currentListObject = new ListPageObject($currentRow, $navAppend);
                        $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                        $listPageObjectArray[] = $currentListObject;
                    } else {
                        if (empty($currentRow[CSV_CITY_OR_STATE_INDEX])) {
                            //Create new country menu object
                            $countryUrl = create_listing_url($currentRow, $navAppend);
                            $currentCountryMenuObject = new MenuJSONObject($currentRow[CSV_COUNTRY_INDEX], $countryUrl, $navAppend);
                            //If no state then null out the state object
                            $currentStateMenuObject = null;
                            $currentCountryMenuObject->addSubmenu($hotelMenuObject);
                        } else {
                            //Create new country menu object, but no url since the states will carry the list page urls
                            $countryUrl = create_listing_url($currentRow, $navAppend);
                            $currentCountryMenuObject = new MenuJSONObject($currentRow[CSV_COUNTRY_INDEX], "", $navAppend);
                            //If has a state, create that as well
                            $stateUrl = create_listing_url($currentRow, $navAppend);
                            $currentStateMenuObject = new MenuJSONObject($currentRow[CSV_CITY_OR_STATE_INDEX], $stateUrl, $navAppend);
                            $currentStateMenuObject->addSubmenu($hotelMenuObject);
                            $currentCountryMenuObject->addSubmenu($currentStateMenuObject);
                        }
                        //Tack on the country to the parent object
                        $parentMenuObject->addSubmenu($currentCountryMenuObject);
                        //New listing object as well
                        $currentListObject = new ListPageObject($currentRow, $navAppend);
                        $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                        $listPageObjectArray[] = $currentListObject;
                    }
                }
            }
            $previousRow = $currentRow;
        }
        $rowCounter++;
    }
}
Example #2
0
         $priceDisplayHTML = str_replace("#trip-start#", $tripStart, $priceDisplayHTML);
         $pageToBeDeployed = str_replace("<!--#price-info#-->", $priceDisplayHTML, $pageToBeDeployed);
     } else {
         if (!empty($threeDayPrice)) {
             //Valid prices were returned and should be displayed
             $priceDisplayHTML = str_replace("#three-day-price-output#", $threeDayPrice, $priceDisplayHTML);
             $priceDisplayHTML = str_replace("#seven-day-price-output#", $sevenDayPrice, $priceDisplayHTML);
             $priceDisplayHTML = str_replace("#trip-start#", $tripStart, $priceDisplayHTML);
             $pageToBeDeployed = str_replace("<!--#price-info#-->", $priceDisplayHTML, $pageToBeDeployed);
         }
     }
 }
 //Add the country listing breadcrumb
 //TODO figure out a solution to point back to listings for adults only or however they got to the detail page.
 //  probably don't generate a different detail page for each category
 $listingUrl = create_listing_url($datarow, "");
 $listingBreadcrumb = "<a href='" . $listingUrl . "'><h2 style='text-decoration:underline'>&#171; Return to All Inclsuive Hotels in " . $datarow[CSV_CITY_OR_STATE_INDEX] . " " . $datarow[CSV_COUNTRY_INDEX] . "</h2></a>";
 $pageToBeDeployed = str_replace("<!--#country-listing-breadcrumb#-->", $listingBreadcrumb, $pageToBeDeployed);
 $filePath = $datarow[CSV_URL_INDEX];
 if (!file_exists(DOC_ROOT_PATH . "{$filePath}")) {
     build_directory_structure($filePath);
     if (FTP_ENABLED) {
         build_directory_structure_ftp($conn_id, get_file_dir($filePath));
     }
 }
 $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 'w') or die("can't open file");
 fwrite($pageToBeDeployedHandle, $pageToBeDeployed);
 chmod(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 0777);
 // Close reference to file
 fclose($pageToBeDeployedHandle);
 if (FTP_ENABLED) {
Example #3
0
 function ListPageObjectConstructor2($currentRow, $navAppend)
 {
     $this->url = create_listing_url($currentRow, $navAppend);
     $listingName_ = $currentRow[CSV_COUNTRY_INDEX] . (!empty($currentRow[CSV_CITY_OR_STATE_INDEX]) ? " - " . $currentRow[CSV_CITY_OR_STATE_INDEX] : " ");
     if (!empty($navAppend)) {
         if ($navAppend == "a") {
             $listingName_ .= " Adults Only";
         } else {
             if ($navAppend == "c") {
                 $listingName_ .= " Couples Only";
             } else {
                 if ($navAppend == "h") {
                     $listingName_ .= " Honeymoon";
                 } else {
                     if ($navAppend == "f") {
                         $listingName_ .= " Families";
                     }
                 }
             }
         }
     }
     $this->listingName = ucwords(strtolower($listingName_));
     $this->countryCode = $currentRow[CSV_COUNTRY_CODE_INDEX];
     $this->countryCode = convertLongCountryCodes($this->countryCode);
 }