xpath("/dummy/" . $metaType . "/lang[@val='" . $currentCulture . "']/title"); $xmlDescription = $xml->xpath("/dummy/" . $metaType . "/lang[@val='" . $currentCulture . "']/description"); $xmlKeywords = $xml->xpath("/dummy/" . $metaType . "/lang[@val='" . $currentCulture . "']/keywords"); switch ($metaType) { case 'manufacturers': $title = trim((string) $xmltitle[0]); $description = trim((string) $xmlDescription[0]); $keywords = trim((string) $xmlKeywords[0]); break; case 'manufacturer': $manufacturerName = $_GET['manufacturerName']; $title = trim(str_replace('%%manufacturerName%%', $manufacturerName, (string) $xmltitle[0])); $description = trim(str_replace('%%manufacturerName%%', $manufacturerName, (string) $xmlDescription[0])); $keywords = trim(str_replace('%%manufacturerName%%', $manufacturerName, (string) $xmlKeywords[0])); break; case 'model': $modelName = $_GET['modelName']; $title = trim(str_replace('%%modelName%%', $modelName, (string) $xmltitle[0])); $description = trim(str_replace('%%modelName%%', $modelName, (string) $xmlDescription[0])); $keywords = trim(str_replace('%%modelName%%', $modelName, (string) $xmlKeywords[0])); break; } //print_r($metaType);}function GetString($label){ $value; global $currentCulture; if (file_exists('resources.xml')) { $xml = simplexml_load_file('resources.xml', 'SimpleXMLElement', LIBXML_NOCDATA); } else { exit('Failes to load xml file.'); } $value = $xml->xpath("/resources/lang[@val='" . $currentCulture . "']/data[@name='" . $label . "']/value"); return (string) $value[0];}function GetStringWithCulture($label, $culture){ $value; if (file_exists('resources.xml')) { $xml = simplexml_load_file('resources.xml', 'SimpleXMLElement', LIBXML_NOCDATA); } else { exit('Failes to load xml file.'); } $value = $xml->xpath("/resources/lang[@val='" . $culture . "']/data[@name='" . $label . "']/value"); return (string) $value[0];}//manufacturersfunction loadManufacturers(){ //echo phpinfo(); global $currentCulture; $client = new nusoap_client('https://www.zeilboten-huren.nl/CMSTemplates/WishfulSailing/ModelListWS.asmx?wsdl', 'wsdl'); $client->soap_defencoding = 'UTF-8'; $client->decode_utf8 = false; $proxy = $client->getProxy(); $err = $proxy->getError(); if ($err) { echo '

Client error

' . $err . '
'; } $request = $proxy->call('GetManufacturers'); $manufacturers = $request['GetManufacturersResult']['Manufacturer']; print_r(ListManufacturers($manufacturers)); }function GetHomeBreadCrumps (){ global $currentCulture; //bradcrumps switch($currentCulture) { case 'NL': $html = '' . GetStringWithCulture('home', 'NL') . ''; break; case 'EN': $html = '' . GetStringWithCulture('home', 'EN') . ''; break; case 'DE': $html = '' . GetStringWithCulture('home', 'DE') . ''; break; } return $html;}function ListManufacturers($manufacturers){ global $currentCulture; $html = '

'. GetString("manufacturers") . '

'; //breadcrumps $html .= '
'; $html .= GetHomeBreadCrumps(); $html .= ' > ' . GetString('manufacturers') . '
'; $html .= ''; if (empty($manufacturers['manufacturerID'])) { //more than one manufacturers $n = sizeof($manufacturers); $chunk = array_chunk($manufacturers, 3); foreach ($chunk as $ch) { $html .= ''; for ($i = 0; $i < sizeof($ch); $i++) { $html .= ''; } $html .= ''; } $html .= '
' . (string) $ch[$i]['manufacturerName'] . '
'; } else { // just one manufacturer $html .= ''; $html .= '' . $manufacturers['manufacturerName'] . ''; $html .= ''; } $html .= ''; return $html;}function GetModelsImages(){ global $xml; $imageUrl = 'https://media.yachtbooker.com/images/80x60/'; $mainImg = $xml->xpath('//images/image[substring(@filename, string-length(@filename) - string-length("pic1") +1) = "pic1"]'); $imageUrl .= (string) $mainImg[0]["filename"] . "." . (string) $mainImg[0]->medium["fileextension"]; return $imageUrl; }//models pagefunction loadModels(){ global $currentCulture; $client = new nusoap_client('https://www.zeilboten-huren.nl/CMSTemplates/WishfulSailing/ModelListWS.asmx?wsdl', 'wsdl'); $client->soap_defencoding = 'UTF-8'; $client->decode_utf8 = false; $proxy = $client->getProxy(); $err = $proxy->getError(); if ($err) { echo '

Client error

' . $err . '
'; } $modelsWsParams = array( 'manufacturerID' => $_GET['manufacturerID'] ); $request = $proxy->call('GetModels', $modelsWsParams); //model listing echo '

' . $_GET['manufacturerName'] .' ' . GetString("models") . ' :

'; if (empty($request['GetModelsResult'])) { echo 'There are no yacht models for the selected manufacturer.
'; } else { $models = $request['GetModelsResult']['Model']; print_r(ListModels($models)); } //go back button echo ''; }//receives the url for an image, checks response from serverfunction setImageUrl($urlToCheck){ $status = check_url($urlToCheck); //check response if ($status == '200') $imageUrl = $urlToCheck; else { //not ok - user demo_yacht.jpg image $imageUrl = str_replace(substr($urlToCheck, strrpos($urlToCheck, '/', 0) + 1), '', $urlToCheck) . 'demo_yacht.jpg'; } return $imageUrl;}function ListModels($models){ global $currentCulture; $imageUrl = 'https://media.yachtbooker.com/images/80x60/'; //breadcrumps $html = '
'; $html .= GetHomeBreadCrumps(); $html .= ' > ' . '' . GetString('manufacturers') . ''; $html .= ' > ' . $_GET['manufacturerName'] . '
' ; //set variable in session //session_start();// $_SESSION['manufacturerID'] = $_GET['manufacturerID']; //$_SESSION['manufacturerName'] = $_GET['manufacturerName']; $html .= ''; if (empty($models['modelID'])) { //more than one model $n = sizeof($models); //$chunk = array_chunk($models,ceil(count($models)/3)); $chunk = array_chunk($models, 3); foreach ($chunk as $ch) { $html .= ''; for ($i = 0; $i < sizeof($ch); $i++) { if($ch[$i]['modelImage'] != null) { $allImgs = explode(',', $ch[$i]['modelImage']); $reg = preg_quote('1.','~'); $img = preg_grep('~' . $reg . '~',$allImgs); } $urlToCheck = $imageUrl . reset($img); $html .= ''; } $html .= ''; } $html .= '
'; $html .= ''; $html .= '' . $ch[$i]['modelName'] . '
'; $html .= $ch[$i]['modelHullTpye'] . '
'; $html .= $ch[$i]['modelLength'] . ' m
'; $html .= '
'; } else { // just one model $urlToCheck = $imageUrl . $models['modelImage']; $html .= ''; $html .= '
'; $html .= ''; $html .= '' . $models['modelName'] . '
'; $html .= $models['modelHullTpye'] . '
'; $html .= $models['modelLength'] . ' m
'; $html .= '
'; } $html .= ''; return $html;}//modelDetailsfunction loadModelDetails(){ global $currentCulture; $modelImagesClient = new nusoap_client('https://xmlserver.yachtbooker.com/YBDataInterface_V3/DistributionDataRetriever.asmx?wsdl', 'wsdl'); $modelImagesClient->soap_defencoding = 'UTF-8'; $modelImagesClient->decode_utf8 = false; $proxy = $modelImagesClient->getProxy(); $staggingUser = 'ybcontent'; $staggingPassword = 'ybgetcontent'; $yachtCode = $_GET['yachtCode']; $query = 'action=GetUnit&code=' . $yachtCode . '&lang=' . $currentCulture; //------service error messages---------- $err = $proxy->getError(); $err = $modelImagesClient->getError(); if ($err) { echo '

Client1 error

' . $err . '
'; } $modelImagesParams = array( 'user' => $staggingUser, 'password' => $staggingPassword, 'query' => $query ); $images = $proxy->call('GetData', $modelImagesParams); $resp = $proxy->responseData; global $xml, $unitSubtype, $manufacturer, $hulltype, $cabins, $LOA, $width, $draft, $displacement, $nrEngines, $enginePower, $machine, $typeOfFuel; $xml = new SimpleXMLElement($images['GetDataResult']); GetModelDetails(); }function LoadDummyText(){ global $unitSubtype, $manufacturer, $hulltype, $cabins, $LOA, $width, $draft, $displacement, $nrEngines, $enginePower, $machine, $typeOfFuel; global $xml, $currentCulture; if (file_exists('modelRandomText.xml')) { $xml = simplexml_load_file('modelRandomText.xml', 'SimpleXMLElement', LIBXML_NOCDATA); } else { exit('Failes to load xml file.'); } $random = rand(1, 4); $dummyText = $xml->xpath("/dummy/model/lang[@val='" . $currentCulture . "']/random[@val='" . $random . "']"); return '
' . replaceKeywords((string) $dummyText[0]) . '
'; }function replaceKeywords($string){ global $unitSubtype, $manufacturer, $hulltype, $cabins, $LOA, $width, $draft, $displacement, $nrEngines, $enginePower, $machine, $typeOfFuel; $searchArray = array( "%%modelName%%", "%%unitSubtype%%", "%%manufacturer%%", "%%hulltype%%", "%%cabins%%", "%%LOA%%", "%%width%%", "%%draft%%", "%%displacement%%", "%%nrEngines%%", "%%enginePower%%", "%%machine%%", "%%typeOfFuel%%" ); $replaceArray = array( $_GET['modelName'], $unitSubtype, $manufacturer, $hulltype, $cabins, $LOA, $width, $draft, $displacement, $nrEngines, $enginePower, $machine, $typeOfFuel ); return str_replace($searchArray, $replaceArray, $string);}function GetModelDetails(){ global $xml; $modelTehnicalDetails = GetModelTehnicalDetails(); echo '
'; echo '

' . $_GET['modelName'] . '

'; //breadcrumps $html = '
'; $html .= GetHomeBreadCrumps(); $html .= ' > ' . '' . GetString('manufacturers') . ''; $html .= ' > ' . '' . $_GET['manufacturerName'] . ''; $html .= ' > ' . $_GET['modelName'] . '
' ; echo $html; if (empty($_GET['yachtCode'])) { echo '
'; print_r(LoadDummyText()); echo '
'; } else { print_r(GetModelImages()); print_r($modelTehnicalDetails); echo '
'; print_r(LoadDummyText()); echo '
'; //go back button } echo ''; echo '
';}function GetModelImages(){ global $xml, $currentLanguage; $html = '
'; $imageUrl = 'https://media.yachtbooker.com/images/'; //main image $mainImg = $xml->xpath('//images/image[substring(@filename, string-length(@filename) - string-length("pic1") +1) = "pic1"]'); if (empty($mainImg)) { //main image array() is empty $mainImageHtml = '
'; $mainImageHtml .= ''; $mainImageHtml .= '
'; //print_r($mainImg); } else { $mainImageHtml = '
'; // $mainImgUrl = $imageUrl . 'medium/' . (string) $mainImg[0]["filename"] . "." . (string) $mainImg[0]->medium['fileextension']; $mainImageHtml .= 'medium['fileextension'] . '">'; $mainImageHtml .= 'medium['fileextension'] . '"/>'; $mainImageHtml .= '
'; } $html .= $mainImageHtml; //small images $smallImages = $xml->xpath('//images/image[substring(@filename, string-length(@filename) - string-length("pic1") +1) != "pic1" and substring(@filename, string-length(@filename) - string-length("pictitle") +1) != "pictitle"] '); //small images array empty if (empty($smallImages)) { $smallImgHtml = ''; } else { $smallImgHtml = '
'; $smallImgHtml .= '
'; //} } $html .= $smallImgHtml; $html .= '
'; return $html;}function GetModelTehnicalDetails(){ global $xml, $unitSubtype, $manufacturer, $hulltype, $cabins, $LOA, $width, $draft, $displacement, $nrEngines, $enginePower, $machine, $typeOfFuel; $unitSubtype = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@unit_subtype'); $manufacturer = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@Manufacturer'); $hulltype = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@hulltype'); $cabins = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@Cabins'); $LOA = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@lengthoverall'); $width = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@Beam'); $draft = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@Draft'); $displacement = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@Displacement'); $nrEngines = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@NoOfEngines'); $enginePower = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@EnginePower'); $machine = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@EngineName'); $typeOfFuel = $xml->xpath('//content/destination/touristic/region/subregion/location/operator/units/unit/@TypeOfFuel'); $unitSubtype = (string) $unitSubtype[0]['unit_subtype']; $manufacturer = (string) $manufacturer[0]['Manufacturer']; $hulltype = (string) $hulltype[0]['hulltype']; $cabins = (string) $cabins[0]['Cabins']; $LOA = (string) $LOA[0]['lengthoverall']; $width = (string) $width[0]['Beam']; $draft = (string) $draft[0]['Draft']; $displacement = (string) $displacement[0]['Displacement']; $nrEngines = (string) $nrEngines[0]['NoOfEngines']; $enginePower = (string) $enginePower[0]['EnginePower']; $machine = (string) $machine[0]['EngineName']; $typeOfFuel = (string) $typeOfFuel[0]['TypeOfFuel']; global $currentCulture; $html = '
'; $html .= '

' . GetString("tehnicalDetails") . '

'; $html .= ''; $tehnicalDetails = ''; if (strlen($unitSubtype) <> 0) $tehnicalDetails .= ''; if (strlen($manufacturer) <> 0) $tehnicalDetails .= ''; if (strlen($hulltype) <> 0) $tehnicalDetails .= ''; if (strlen($cabins) <> 0) $tehnicalDetails .= ''; if (strlen($unitSubtype) <> 0) $tehnicalDetails .= ''; if ($width != '') $tehnicalDetails .= ''; if ($draft != '') $tehnicalDetails .= ''; if ($displacement != '') $tehnicalDetails .= ''; if ($nrEngines != '') $tehnicalDetails .= ''; if ($enginePower != '') $tehnicalDetails .= ''; if ($machine != '') $tehnicalDetails .= ''; if ($typeOfFuel != '') $tehnicalDetails .= ''; if (empty($tehnicalDetails)) return ''; else { $html .= $tehnicalDetails; $html .= '
' . GetString("type") . '' . $unitSubtype . '
' . GetString("manufacturer") . '' . $manufacturer . '
' . GetString("hullType") . '' . $hulltype . '
' . GetString("cabins") . '' . $cabins . '
' . GetString("LOA") . '' . $LOA . '
' . GetString("width") . '' . $width . ' m
' . GetString("draft") . '' . $draft . ' m
' . GetString("displacement") . '' . $displacement . ' t
' . GetString("NOE") . '' . $nrEngines . '
' . GetString("enginePower") . '' . $enginePower . ' HP
' . GetString("machine") . '' . $machine . '
' . GetString("fuel") . '' . $typeOfFuel . '
'; $html .= '
'; return $html; }}?>