','^','[',']', '(',')','\'','','',',','.', ':',';','?','l\'','l`','/','', '','','','','','','','', '','', '', '', '', '', '', '', '', '', '','','','','','','','','','','','','','','','','','','','','','','','','', '','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','', '','','','','','','','','&' ); $replacer = array('a','a','a','a','e','i', 'o','o','s','u','y','z','A', 'A','E','I','O','O','S','U', 'Y','Z','','l','','','', '','','','','','','', '','','','i','e','','.', '','','','I','L','-','', 'e','e','a','','i','','n','o', 'a','a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'c','o','u','u','A','A','C','E','E','E','E','I','I','C','A','e','i','n','o','u','u','A','E','I','N', 'O','U','U','i','i','O','U','U','a','e','i','o','u','A','E','I','O','U','A','A','c','C','o','O','o','O','o','O','a','a','a','o','e','o','o','ss','b','u','y','A', 'A','A','D','E','O','O','p','U','_and_' ); $choy = str_replace($takeOff, $replacer, $text); $choy = strtr(utf8_decode($choy),utf8_decode(''), 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy'); return $choy; } #------------------------------------------------------------------------------------------------------------------------------------------ # END: REPLACE SPECIAL CHARACTER #------------------------------------------------------------------------------------------------------------------------------------------ // days of the week translation function dayOfWeekTranslate($days, $lang) { if($days!="1234567") { if(strlen(trim("$days"))==6 && $lang!='jp') { for($d=1; $d<=7; $d++) { if(stristr("$days","$d") === FALSE) { if($d==1) $xp = $this->translateThis("Monday", $lang); if($d==2) $xp = $this->translateThis("Tuesday", $lang); if($d==3) $xp = $this->translateThis("Wednesday", $lang); if($d==4) $xp = $this->translateThis("Thursday", $lang); if($d==5) $xp = $this->translateThis("Friday", $lang); if($d==6) $xp = $this->translateThis("Saturday", $lang); if($d==7) $xp = $this->translateThis("Sunday", $lang); $day = $this->translateThis("daily except", $lang). " " . $xp . ","; } } } else { $xpp = array(); for($i=0; $itranslateThis("Monday", $lang); if(substr($days,$i,1)==2) $xpp[] = $this->translateThis("Tuesday", $lang); if(substr($days,$i,1)==3) $xpp[] = $this->translateThis("Wednesday", $lang); if(substr($days,$i,1)==4) $xpp[] = $this->translateThis("Thursday", $lang); if(substr($days,$i,1)==5) $xpp[] = $this->translateThis("Friday", $lang); if(substr($days,$i,1)==6) $xpp[] = $this->translateThis("Saturday", $lang); if(substr($days,$i,1)==7) $xpp[] = $this->translateThis("Sunday", $lang); } $day = implode(', ', $xpp); } } else { $day = $this->translateThis("daily", $lang); } $returnThis = rtrim($day, ","); return $returnThis; } function cleanthisstrxx_trns($stringtoclean) { $normalizeChars = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ','', '','' ); $normalizeChars2 = array( 'Š', 'š', 'Ð', 'Z', 'z', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ý', 'ý', 'þ', 'ÿ', 'ƒ', 'ü', '', 'œ', '¡','„' ); $stringtoclean = str_replace($normalizeChars, $normalizeChars2, $stringtoclean); $arrayIllegal = array("", "", "", "", "", "", "*", "", "°", "","", "", " "); $arrayReplaced = array("\"","\"", "'", "'", "...", "'", "", "", "degrees", "", "", "", ""); $returnedString = str_replace($arrayIllegal, $arrayReplaced, $stringtoclean); $returnedString = iconv(mb_detect_encoding($returnedString, mb_detect_order(), true), "UTF-8", $returnedString); #$pattern = '/(?<=href\=")[^]]+?(?=")/'; #$returnedString = preg_replace($pattern, "#", $returnedString); return $returnedString; } function fixEncodingDisplay($string, $lang='') { $checkEncoding = mb_detect_encoding($string); if($checkEncoding==='ASCII') { $string = mb_convert_encoding($string, 'UTF-8', 'HTML-ENTITIES'); } else { if(strtoupper($lang)!='CN') { $string = $this->cleanthisstrxx_trns($string); } else { $string = iconv("gb2312", "UTF-8//IGNORE", $string); } } return $string; } //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------// ############################################################################################################################################################################# # Language Translations ############################################################################################################################################################################# //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------// // Translation for Phrases function getTranslationFronDB($phrase, $lang) { global $pdoCd, $cd_db; /* $mysql_get_translate = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE ? AND tr_enTranslated !='' AND tr_lang LIKE ? ",trim($phrase), trim($lang)); $count_translation = $mysql_get_translate->rowCount(); $tr = $mysql_get_translate->fetch(); */ $mysql_get_translate = mysql_query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE '".mysql_real_escape_string($phrase)."' AND tr_enTranslated !='' AND tr_lang LIKE '".mysql_real_escape_string($lang)."' ",$cd_db); $count_translation = mysql_num_rows($mysql_get_translate); $tr = mysql_fetch_array($mysql_get_translate); if(($count_translation>0) && ($tr["tr_enTranslated"] != "")) { $checkEncoding = mb_detect_encoding($tr["tr_enTranslated"]); if(strtoupper($lang)==="CN"){ if($checkEncoding==='ASCII') $resulttranslation = mb_convert_encoding($tr["tr_enTranslated"], 'UTF-8', 'HTML-ENTITIES'); else $resulttranslation = iconv("gb2312", "UTF-8", $tr["tr_enTranslated"]); }else{ if($checkEncoding==='ASCII') $resulttranslation = mb_convert_encoding($tr["tr_enTranslated"], 'UTF-8', 'HTML-ENTITIES'); else $resulttranslation = $this->cleanthisstrxx_trns($tr["tr_enTranslated"]); } } else { //get translation of the word hour and hours if(preg_match('/\bhours\b/i',$phrase)){ $sql_getHours = mysql_query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hours' AND tr_lang LIKE '".mysql_real_escape_string($lang)."' ",$cd_db); $row_getHours = mysql_fetch_array($sql_getHours); $checkEncoding = mb_detect_encoding($row_getHours["tr_enTranslated"]); if(strtoupper($lang)==="CN"){ if($checkEncoding==='ASCII') $resulttranslation = mb_convert_encoding($row_getHours["tr_enTranslated"], 'UTF-8', 'HTML-ENTITIES'); else $resulttranslation = iconv("gb2312", "UTF-8", $row_getHours["tr_enTranslated"]); }else{ $resulttranslation = $this->cleanthisstrxx_trns($row_getHours["tr_enTranslated"]); } $returnThis = str_replace("hours", $resulttranslation, $phrase); } elseif(preg_match('/\bhour\b/i',$phrase)){ $sql_getHour = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hour' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHour->fetch(); $returnThis = str_replace("hour", $row_getHour["tr_enTranslated"], $phrase); }elseif(strstr($phrase,'at any time during operating hours')){ $sql_getHours = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'at any time during operating hours' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); if($row_getHours["tr_enTranslated"]!=""){ $returnThis = str_replace("at any time during operating hours", $row_getHours["tr_enTranslated"], $phrase); } } else{ $returnThis = '' . $phrase . ''; } if( $lang=='cn' ){ $takeOff = array('','');//take off that weird char that turns to be parang question mark $replacer = array('"','"'); $resulttranslation = trim( str_replace($takeOff,$replacer,$returnThis) ); }else{ $resulttranslation = trim($returnThis); } } return $resulttranslation; } function allLanguages() { $result = array("fr","es","ru","po","it","de","da","sv","no","fi","du","jp","ko","cn","gr"); return $result; } // Translation for Phrases function translateThis($phrase, $lang, $option=1) { global $pdoCd, $languageGettext, $localelocation, $charsetencoding; $alllanguages = $this->allLanguages(); if(in_array(trim(strtolower($lang)),$alllanguages)) { if(trim($phrase)!="") { //$thistranslate = _(trim($phrase)); $thislccode = getenv('LC_MESSAGES'); if($thislccode!="") { $lcmessagecode = $this->getLanguageFromLang($thislccode); } else { $lcmessagecode = $lang; } if(strtolower(trim($lcmessagecode))===strtolower(trim($lang))){ $thistranslate = _(trim($phrase)); } else { $thistranslate = $phrase; } if(trim($thistranslate)===trim($phrase)) { $resulttranslation = $this->getTranslationFronDB($phrase, $lang); if(($lang==="po")&&(trim($phrase)==="with City-Discovery.com")) $resulttranslation = str_replace("City-Discovery.com","CityDiscovery.com.br",$resulttranslation); return $resulttranslation; } else { if(($lang==="po")&&(trim($phrase)==="with City-Discovery.com")) $thistranslate = str_replace("City-Discovery.com","CityDiscovery.com.br",$thistranslate); return strip_tags($thistranslate); } } } else { if($lang=='en'){ return trim($phrase); } else{ $array_redundanttext = array("tour", "Tours", "Add to my wishbox", "From", "from", "is at", "On", "to", "Starting From", "Starting from", "Check Availability", "Highlights", "Email", "Print", "Tweet", "Type", "Departs From", "Meeting Point", "Will be indicated on voucher", "Duration", "Languages", "Available", "Departs", "Departs from", "Product Code", "Description", "Price information", "Tours and Attractions", "Page", "Book Now", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "daily except", "any time during operating hours", "at any time during operating hours"); $cleanphraseId = ""; if(in_array(trim($phrase),$array_redundanttext)) { $cleanphraseId = str_replace(" ","",trim(strtolower($phrase))); $variableAPCname = $cleanphraseId.trim($lang); } if(trim($cleanphraseId)!="") { //if (apc_exists($variableAPCname)) { //$resulttranslation = apc_fetch($variableAPCname); //} else { $mysql_get_translate = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE ? AND tr_lang LIKE ? ",$phrase, $lang); $count_translation = $mysql_get_translate->rowCount(); $tr = $mysql_get_translate->fetch(); if(($count_translation>0) && ($tr["tr_enTranslated"] != "")) { $resulttranslation = stripslashes(str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $tr["tr_enTranslated"])); } else { //get translation of the word hour and hours if(preg_match('/\bhours\b/i',$phrase)){ $sql_getHours = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hours' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); $returnThis = str_replace("hours", $row_getHours["tr_enTranslated"], $phrase); } elseif(preg_match('/\bhour\b/i',$phrase)){ $sql_getHour = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hour' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); $returnThis = str_replace("hour", $row_getHour["tr_enTranslated"], $phrase); }elseif(preg_match('/\at any time during operating hours\b/i',$phrase)){ $sql_getHours = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'at any time during operating hours' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); if($row_getHours["tr_enTranslated"]!="") $returnThis = str_replace("at any time during operating hours", $row_getHours["tr_enTranslated"], $phrase); } else{ $returnThis = '' . $phrase . ''; } if( $lang=='cn' ){ $takeOff = array('','');//take off that weird char that turns to be parang question mark $replacer = array('"','"'); $resulttranslation = trim( str_replace($takeOff,$replacer,$returnThis) ); }else{ $resulttranslation = trim($returnThis); } } #apc_store($variableAPCname, $resulttranslation); //} return $resulttranslation; } else { $mysql_get_translate = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE ? AND tr_lang LIKE ? ",$phrase, $lang); $count_translation = $mysql_get_translate->rowCount(); $tr = $mysql_get_translate->fetch(); if(($count_translation>0) && ($tr["tr_enTranslated"] != "")) { $resulttranslation = stripslashes(str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $tr["tr_enTranslated"])); } else { //get translation of the word hour and hours if(preg_match('/\bhours\b/i',$phrase)){ $sql_getHours = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hours' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); $returnThis = str_replace("hours", $row_getHours["tr_enTranslated"], $phrase); } elseif(preg_match('/\bhour\b/i',$phrase)){ $sql_getHour = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'hour' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); $returnThis = str_replace("hour", $row_getHour["tr_enTranslated"], $phrase); }elseif(preg_match('/\at any time during operating hours\b/i',$phrase)){ $sql_getHours = $pdoCd->query("SELECT tr_enTranslated FROM translation WHERE tr_enWord LIKE 'at any time during operating hours' AND tr_lang LIKE ?",$lang); $row_getHours = $sql_getHours->fetch(); if($row_getHours["tr_enTranslated"]!="") $returnThis = str_replace("at any time during operating hours", $row_getHours["tr_enTranslated"], $phrase); } else{ $returnThis = '' . $phrase . ''; } if( $lang=='cn' ){ $takeOff = array('','');//take off that weird char that turns to be parang question mark $replacer = array('"','"'); $resulttranslation = trim( str_replace($takeOff,$replacer,$returnThis) ); }else{ $resulttranslation = trim($returnThis); } } return $resulttranslation; } } } } // Translation for Destinations function translateDestination($phrase, $lang) { $returnthis = $this->translateThis($phrase, $lang); return $returnthis; } // Translation back to english function translateEnglish($phrase, $lang) { global $cd_db; if(strlen($phrase)>3) { $mysql_get_translate1 = mysql_query("SELECT tr_enWord FROM translation WHERE MATCH(tr_enTranslated) AGAINST ('".mysql_real_escape_string($phrase)."' IN BOOLEAN MODE) AND tr_lang LIKE '".mysql_real_escape_string($lang)."' AND tr_enTranslated LIKE '".mysql_real_escape_string($phrase)."' ", $cd_db) or do_error(mysql_error($cd_db)); $count_translationtemp = mysql_num_rows($mysql_get_translate1); if($count_translationtemp==0){ $mysql_get_translate1 = mysql_query("SELECT tr_enWord FROM translation WHERE tr_lang LIKE '".mysql_real_escape_string($lang)."' AND tr_enTranslated LIKE '".mysql_real_escape_string($phrase)."' ", $cd_db) or do_error(mysql_error($cd_db)); } } else { $mysql_get_translate1 = mysql_query("SELECT tr_enWord FROM translation WHERE tr_enTranslated LIKE '".mysql_real_escape_string($phrase)."' AND tr_lang LIKE '".mysql_real_escape_string($lang)."' ", $cd_db) or do_error(mysql_error($cd_db)); } $count_translation1 = mysql_num_rows($mysql_get_translate1); $tr1 = mysql_fetch_object($mysql_get_translate1); if(($count_translation1>0) && ($tr1->tr_enWord != "")) { return stripslashes($tr1->tr_enWord); } else { return $phrase; } mysql_free_result($tr1); } // Translation for Transfers function translateWat($phrase, $lang) { global $wat_db; $mysql_get_wat_translate = mysql_query("SELECT translation_translated FROM translation WHERE translation_original LIKE '".mysql_real_escape_string($phrase)."' AND translation_lang LIKE '".mysql_real_escape_string($lang)."' ", $wat_db) or do_error(mysql_error($wat_db)); $count_wat_translation = mysql_num_rows($mysql_get_wat_translate); $tr = mysql_fetch_object($mysql_get_wat_translate); if(($count_wat_translation>0) && ($tr->translation_translated != "")) { return stripslashes($tr->translation_translated); } else { return $phrase; } mysql_free_result($tr); } #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET ALL COUNTRIES #------------------------------------------------------------------------------------------------------------------- function get_allCountries_translation(){ global $cd_db, $language; $result = array(); $variableAPCname = "var_get_allCountries_translation".trim($language); if (apc_exists($variableAPCname)) { $result = apc_fetch($variableAPCname); } else { $sql = "SELECT DISTINCT(products_country) FROM products as t1, prices as t2, products_translation as t3 WHERE t1.products_country!='' AND t1.products_valid='Y' AND t1.products_id=t2.prices_id AND t2.prices_valid='Y' AND t1.products_id=t3.pt_prodId AND t3.pt_lang='" . mysql_real_escape_string($language) . "' ORDER BY products_country ASC"; $sql = mysql_query($sql,$cd_db) or die(mysql_error($cd_db)); while($row=mysql_fetch_object($sql)){ //$result[] = ucwords(strtolower($row->products_country)); //do the translation on the actual select page $array_one["translation"][] = $this->translateThis(ucwords(strtolower($row->products_country)),$language); $array_one["english"][] = ucwords(strtolower($row->products_country)); } mysql_free_result($sql); asort($array_one["translation"]); foreach($array_one['translation'] AS $key=>$value) { $result[] = $array_one["english"][$key]; } apc_store($variableAPCname, $result); } return $result; } #------------------------------------------------------------------------------------------------------------------- # END: GET ALL COUNTRIES #------------------------------------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET ALL COUNTRIES TRANSLATED #------------------------------------------------------------------------------------------------------------------- function get_allCountries_translation_translated($language){ global $cd_db, $language; $result = array(); $variableAPCname = "var_get_allCountries_translation_translated".trim($language); if (apc_exists($variableAPCname)) { $result = apc_fetch($variableAPCname); } else { $sql = "SELECT DISTINCT(products_country) FROM products as t1, prices as t2, products_translation as t3 WHERE t1.products_country!='' AND t1.products_valid='Y' AND t1.products_id=t2.prices_id AND t2.prices_valid='Y' AND t1.products_id=t3.pt_prodId AND t3.pt_lang='" . mysql_real_escape_string($language) . "' ORDER BY products_country ASC"; $sql = mysql_query($sql,$cd_db) or die(mysql_error($cd_db)); while($row=mysql_fetch_object($sql)){ $translated = $this->translateThis($row->products_country, $language,0); $result[] = $translated; //ucwords(strtolower()); //do the translation on the actual select page } mysql_free_result($sql); sort($result); apc_store($variableAPCname, $result); } return $result; } #------------------------------------------------------------------------------------------------------------------- # END: GET ALL COUNTRIES #------------------------------------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET COUNTRY #------------------------------------------------------------------------------------------------------------------- function get_country_translation($city='Paris'){ global $cd_db; $sql = "SELECT DISTINCT(products_country) FROM products WHERE products_country!='' AND products_valid='Y' AND products_city='" . mysql_real_escape_string($city) . "'"; $sql = mysql_query($sql,$cd_db) or die(mysql_error($cd_db)); $row=mysql_fetch_object($sql); mysql_free_result($sql); /** * Note: Return value must be in english, this is being used to get the country of a given city on file httpdocs/fr/destination.php * By: Rnel */ return $row->products_country; } #------------------------------------------------------------------------------------------------------------------- # END: GET COUNTRY #------------------------------------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET ALL COUNTRIES TRANSFER #------------------------------------------------------------------------------------------------------------------- function get_allCountries_transfer_translation(){ global $language,$wat_db; $result = array(); $variableAPCname = "var_get_allCountries_transfer_translation".trim($language); if (apc_exists($variableAPCname)) { $result = apc_fetch($variableAPCname); } else { $sql = "SELECT airport_country FROM airport WHERE airport_valid='Y' GROUP BY airport_country ORDER BY airport_country ASC"; $sql = mysql_query($sql,$wat_db) or die(mysql_error($wat_db)); while($row=mysql_fetch_object($sql)){ $translated = $this->translateThis($row->airport_country, $language,0); $result[] = ucwords(strtolower($translated)); } mysql_free_result($sql); apc_store($variableAPCname, $result); } return $result; } #------------------------------------------------------------------------------------------------------------------- # END: GET ALL COUNTRIES TRANSFER #------------------------------------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET ALL CITIES #------------------------------------------------------------------------------------------------------------------- function get_allCities_translation($country='France'){ global $cd_db, $language; $sql = "SELECT DISTINCT(products_city) FROM products as t1, prices as t2, products_translation as t3 WHERE products_country='" . mysql_real_escape_string($country). "' AND t1.products_country!='' AND t1.products_valid='Y' AND t1.products_id=t2.prices_id AND t2.prices_valid='Y' AND t1.products_id=t3.pt_prodId AND t3.pt_lang='" . mysql_real_escape_string($language) . "' ORDER BY products_country ASC"; $sql = mysql_query($sql,$cd_db) or die(mysql_error($cd_db)); $result = array(); while($row=mysql_fetch_object($sql)){ $result[] = ucwords(strtolower($row->products_city)); //do the translation on the actual select page } mysql_free_result($sql); return $result; } #------------------------------------------------------------------------------------------------------------------- # END: GET ALL CITIES #------------------------------------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------------------- # BEGIN: GET ALL CITIES TRANSLATED #------------------------------------------------------------------------------------------------------------------- function get_allCities_translation_translated($country='France'){ global $cd_db, $cd_translation, $language; $sql = "SELECT DISTINCT(products_city) FROM products as t1, prices as t2, products_translation as t3 WHERE products_country='" . mysql_real_escape_string($country). "' AND t1.products_country!='' AND t1.products_valid='Y' AND t1.products_id=t2.prices_id AND t2.prices_valid='Y' AND t1.products_id=t3.pt_prodId AND t3.pt_lang='" . mysql_real_escape_string($language) . "' ORDER BY products_country ASC"; $sql = mysql_query($sql,$cd_db) or die(mysql_error($cd_db)); $result = array(); while($row=mysql_fetch_object($sql)){ $translated = $this->translateThis($row->products_city, $language,0); $result[] = $translated; //do the translation on the actual select page } mysql_free_result($sql); sort($result); return $result; } #------------------------------------------------------------------------------------------------------------------- # END: GET ALL CITIES #------------------------------------------------------------------------------------------------------------------- function createLink_tourPage_translation($tourId,$tourName){ global $cd_db, $lang; $language = $this->getLanguageFromLang($lang); $subdomain = $this->createURLsubdomain($language); if($this->translation_isExempted($language)){ $sql = "SELECT * FROM products WHERE products_id='" . mysql_real_escape_string($tourId) . "'"; $sql = mysql_query($sql,$cd_db); $row = mysql_fetch_object($sql); mysql_free_result($sql); $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); $href = "ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($row->products_tour_name))); } else{ $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); //$href = "ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($tourName))); $href = "ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($tourName))); } return $subdomain.$href; } function createLink_tourPage_translation_withlang($tourId,$tourName,$language){ global $cd_db; if($this->translation_isExempted($language)){ $sql = "SELECT * FROM products WHERE products_id='" . mysql_real_escape_string($tourId) . "'"; $sql = mysql_query($sql,$cd_db); $row = mysql_fetch_object($sql); mysql_free_result($sql); $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); $href = "ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($row->products_tour_name))); } else{ $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); $href = "ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($tourName))); } return $href; } function createLink_ReviewtourPage_translation_withlang($tourId,$tourName,$language){ global $cd_db; if($this->translation_isExempted($language)){ $sql = "SELECT * FROM products WHERE products_id='" . mysql_real_escape_string($tourId) . "'"; $sql = mysql_query($sql,$cd_db); $row = mysql_fetch_object($sql); mysql_free_result($sql); $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); $href = "Review_ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($row->products_tour_name))); } else{ $arrayRemove = array("\"", " "); $arrayReplace = array("","_"); $href = "Review_ID".$tourId."_".str_replace($arrayRemove,$arrayReplace,$this->replaceSpecialChars_translation(trim($tourName))); } return $href; } function translation_isExempted($language){ $isExempted = 0; $exempted = array('CN','RU','KO','JP','GR'); if(in_array(strtoupper($language),$exempted)){ $isExempted = 1; } return $isExempted; } function replaceSpecialChars_translation($text) { $text = str_replace(" ", "_", $text); $takeOff = array('','','','','','', '','','','','','','', '','','','','','','', '','','`','l','@','$','%', '{','}','<','>','^','[',']', '(',')','\'','','',',','.', ':',';','?','l\'','l`','/','', '','','','','','','','', '','', '', '', '', '', '', '', '', '', '','','','','','','','','','','','','','','','','','','','','','','','','', '','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','', '','','','','','','','','&','\"' ); $replacer = array('a','a','a','a','e','i', 'o','o','s','u','y','z','A', 'A','E','I','O','O','S','U', 'Y','Z','','l','','','', '','','','','','','', '','','','i','e','','.', '','','','I','L','-','', 'e','e','a','','i','','n','o', 'a','a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'c','o','u','u','A','A','C','E','E','E','E','I','I','C','A','e','i','n','o','u','u','A','E','I','N', 'O','U','U','i','i','O','U','U','a','e','i','o','u','A','E','I','O','U','A','A','c','C','o','O','o','O','o','O','a','a','a','o','e','o','o','ss','b','u','y','A', 'A','A','D','E','O','O','p','U','_and_','' ); $choy = str_replace($takeOff, $replacer, $text); $choy = strtr(utf8_decode($choy),utf8_decode(''), 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy'); return $choy; } function format_city($city,$language='fr'){ if($this->translation_isExempted(trim($language))){ $result = str_replace(' ','_',$city); } else{ $translateddest = $this->translateThis($city,$language,0); /* $originaltransalated = $translateddest; if(strstr($translateddest, ';')) $translateddest = $city; $normalizeChars = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ','' ); $normalizeChars2 = array( 'Š', 'š', 'Ð', 'Z', 'z', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ý', 'ý', 'þ', 'ÿ', 'ƒ', 'u', '', 'œ' ); $stringtoclean = str_replace($normalizeChars, $normalizeChars2, $translateddest); if(strstr($stringtoclean, ';')){ //$translateddest = $city; $result = toAscii($originaltransalated); } else { $result = $this->replaceSpecialChars($translateddest); } */ if(strstr($translateddest, ';')) $translateddest = $city; $normalizeChars = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ','' ); $normalizeChars2 = array( 'Š', 'š', 'Ð', 'Z', 'z', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ý', 'ý', 'þ', 'ÿ', 'ƒ', 'u', '', 'œ' ); $stringtoclean = str_replace($normalizeChars, $normalizeChars2, $translateddest); if(strstr($stringtoclean, ';')) $translateddest = $city; $result = $this->replaceSpecialChars($translateddest); } return trim($result); } function createLink_destination_translation($cityOrCountry,$city,$language='fr'){ $language = strtolower(trim($language)); $city = $this->format_city(trim($city),$language); $subdomain = $this->createURLsubdomain($language); $hrefMiddle = $subdomain.'cd_'; if (!$cityOrCountry){ if ($language=='fr'){ $hrefMiddle .= 'activites_pays_'; } elseif ($language=='it'){ $hrefMiddle .= 'activita_'; } elseif ($language=='es'){ $hrefMiddle .= 'excursiones_'; } elseif ($language=='cn'){ $hrefMiddle .= 'country_'; } elseif ($language=='de'){ $hrefMiddle .= 'ausfluge_land_'; } elseif ($language=='fi'){ $hrefMiddle .= 'maa_'; } elseif ($language=='po'){ $hrefMiddle .= 'actividades_pais_'; } elseif ($language=='no'){ $hrefMiddle .= 'land_'; } elseif ($language=='da'){ $hrefMiddle .= 'sightseeing_'; } elseif ($language=='sv'){ $hrefMiddle .= 'turer_land_'; } elseif ($language=='du'){ $hrefMiddle .= 'country_'; } elseif ($language=='ru'){ $hrefMiddle .= 'country_'; } elseif ($language=='ko'){ $hrefMiddle .= 'country_'; } elseif ($language=='jp'){ $hrefMiddle .= 'country_'; } elseif ($language=='gr'){ $hrefMiddle .= 'country_'; } } else{ if ($language=='fr'){ $hrefMiddle .= 'visites_activites_'; } elseif ($language=='it'){ $hrefMiddle .= 'escurzioni_attrazioni_'; } elseif ($language=='es'){ $hrefMiddle .= 'actividades_excursiones_'; } elseif ($language=='cn'){ $hrefMiddle .= 'city_'; } elseif ($language=='de'){ $hrefMiddle .= 'aktivitaten_ausfluge_'; } elseif ($language=='fi'){ $hrefMiddle .= 'kaupunki_'; } elseif ($language=='po'){ $hrefMiddle .= 'visita_actividades_'; } elseif ($language=='no'){ $hrefMiddle .= 'by_'; } elseif ($language=='da'){ $hrefMiddle .= 'sightseeing_ture_'; } elseif ($language=='sv'){ $hrefMiddle .= 'sightseeing_turer_'; } elseif ($language=='du'){ $hrefMiddle .= 'city_'; } elseif ($language=='ru'){ $hrefMiddle .= 'city_'; } elseif ($language=='ko'){ $hrefMiddle .= 'city_'; } elseif ($language=='jp'){ $hrefMiddle .= 'city_'; } elseif ($language=='gr'){ $hrefMiddle .= 'city_'; } elseif ($language=='en'){ $hrefMiddle .= 'city_'; } } $hrefMiddle .= str_replace(' ','_',$city) . '_'; return trim($hrefMiddle); } function createLink_continent_translation($lang, $continent){ global $mainsubdomain; $subdomain = $this->createURLsubdomain($lang); if($this->translation_isExempted($lang)){ $continent = str_replace(' ', '_',$this->replaceSpecialChars($continent,$lang,0)); } else{ $translateddest = $this->translateThis($continent,$lang,0); $translateddest = $this->cleanthisstrxx_trns($translateddest); if(strstr($translateddest, ';')) $translateddest = $continent; $continent = $this->replaceSpecialChars($translateddest); #$this->cleanthisstrxx_trns($tr["tr_enTranslated"]); #$continent = $this->format_city(trim($continent),$lang); $continent = str_replace(' ', '_',$continent); } $url = $subdomain."continent_{$continent}"; return $url; } function strip_newCategories($value){ $string = str_replace(array(' ',',',', ','&','/','"','\''),array('_','','','and','and','',''),$value); $string = $this->replaceSpecialChars_translation($string); return $string; } function strip_newCategories_dash($value){ $string = str_replace(array(' ',',',', ','&','/','"','\''),array('-','','','and','and','',''),strtolower($value)); $string = $this->replaceSpecialChars_translation($string); return $string; } function strip_newsubCategories($value){ $string = str_replace(array(' ',',',', ','&','/','"','\''),array('-','','','and','and','',''),$value); $string = $this->replaceSpecialChars_translation($string); return $string; } function createLink_transfer_translation($city, $transferName='', $transferId=0, $transferType='', $page=0, $lang='fr', $englishcity=''){ /** * Note: * $city must be already translated * * Usage: * httpdocs/fr/airport_shuttle.php * - createLink_transfer_translation($city,'','','',$page,$language); * httpdocs/includes_destination_translation/destinationTransferPage.php * - createLink_transfer_translation('',$transferName,$transferId,$transferType,'',$language); */ $thislangexempted = $this->translation_isExempted($lang); $country = $this->replaceSpecialChars($country); //$city = $this->replaceSpecialChars($city); //$transferName = $this->replaceSpecialChars($transferName); $transferType = $this->replaceSpecialChars($transferType); if(trim(strtolower($transferType))=="private"){ if($thislangexempted){ $href = "pID".$transferId."_".toAscii($transferName); }else{ $transferName = $this->fixEncodingDisplay($transferName, $lang); $href = "pID".$transferId."_".toAscii($transferName); } }elseif(trim(strtolower($transferType))=="shared"){ if($thislangexempted){ $href = "sID".$transferId."_".toAscii($transferName); }else{ $transferName = $this->fixEncodingDisplay($transferName, $lang); $href = "sID".$transferId."_".toAscii($transferName); } } if((trim($city)!="")&&(trim($transferName)=="")){ if($thislangexempted){ if(!empty($englishcity)){ $href = "wat_".toAscii($englishcity, array(), "_"); } else { $href = "wat_".toAscii($city, array(), "_"); } } else { $translatedcountry = $this->fixEncodingDisplay($city, $lang); $href = "wat_".toAscii($translatedcountry, array(), "_"); } } if(trim($page)!="") $href.= "_page_".$page; return $href; } function getLanguageFromLang($language){ $languageGettext = ""; if($language==="fr_FR") $languageGettext = "fr"; if($language==="es_ES") $languageGettext = "es"; if($language==="ru_RU") $languageGettext = "ru"; if($language==="pt_PT") $languageGettext = "po"; if($language==="it_IT") $languageGettext = "it"; if($language==="de_DE") $languageGettext = "de"; if($language==="da_DK") $languageGettext = "da"; if($language==="sv_SE") $languageGettext = "sv"; if($language==="no_NO") $languageGettext = "no"; if($language==="fi_FI") $languageGettext = "fi"; if($language==="nl_NL") $languageGettext = "du"; if($language==="ja_JP") $languageGettext = "jp"; if($language==="ko_KR") $languageGettext = "ko"; if($language==="zh_CN") $languageGettext = "cn"; if($language==="el_GR") $languageGettext = "gr"; $this->globallanguage = $languageGettext; return $languageGettext; } function createURLsubdomain($language) { $language = trim(strtolower($language)); if(($language!="")&&($language!="en")) { if($language==="po") $returnstring = "http://www.citydiscovery.com.br/"; else $returnstring = "http://".$language.".city-discovery.com/"; } else { $returnstring = "http://www.city-discovery.com/"; } return $returnstring; } function generalTranslation($params) { global $cd_db; $params["tg_lang"] = ($params["tg_lang"]==="zh" ? 'cn' : $params["tg_lang"]); $sql = "SELECT tg_value FROM translation_general WHERE tg_table='" . mysql_real_escape_string($params["tg_table"]) . "' AND tg_field='" . mysql_real_escape_string($params["tg_field"]) . "' AND tg_lang='" . mysql_real_escape_string($params["tg_lang"]) . "' AND tg_itemid='" . mysql_real_escape_string($params["tg_itemid"]) . "' AND tg_source='" . mysql_real_escape_string($params["tg_source"]) . "' "; $sql = mysql_query($sql,$cd_db); $count_match = mysql_num_rows($sql); if($count_match>0) { $row = mysql_fetch_object($sql); if(!empty($row->tg_value)) return trim($row->tg_value); else return $params["tg_source"]; } else { return $params["tg_source"]; } } } ?>