pageInfo->totalResults;
//return $status_id;
//Get address from json data
$result = ($status_id=="1")?$link:'';
return $result;
}
function getLanguageText($key) {
if ($key != '') {
$db = (new db_connect())->connect();
$valore = "";
$stmtSelect = $db->prepare(
"SELECT valore
FROM linguaggi_traduzioni
WHERE chiave = ? AND id_lingua = ?
LIMIT 1");
if ($stmtSelect) {
$stmtSelect->bind_param('si', $key, $_SESSION['lingua']);
if($stmtSelect->execute()) {
$stmtSelect->store_result();
$stmtSelect->bind_result($valore);
$stmtSelect->fetch();
} else {
consoleLog('Error! ' . $db->error);
}
} else {
consoleLog('Error! ' . $stmtSelect->error);
}
return $valore;
} else {
return '';
}
}
function getLanguageTextIta($key) {
if ($key != '') {
$db = (new db_connect())->connect();
$valore = "";
$stmtSelect = $db->prepare(
"SELECT chiave
FROM linguaggi_traduzioni
WHERE valore = ? AND id_lingua = 2
LIMIT 1");
if ($stmtSelect) {
$stmtSelect->bind_param('s', $key);
if($stmtSelect->execute()) {
$stmtSelect->store_result();
$stmtSelect->bind_result($valore);
$stmtSelect->fetch();
} else {
consoleLog('Error! ' . $db->error);
}
} else {
consoleLog('Error! ' . $stmtSelect->error);
}
if($valore=="Depoca") $valore="D'epoca";
if($_SESSION['lingua']==2) $valore= str_replace("'","\'",$valore);
return $valore;
} else {
return '';
}
}
function getTitleLocationFromId($id)
{
$db = (new db_connect())->connect();
$stmtSelect = $db->prepare("SELECT titolo FROM oggetto_location "
. "WHERE id = ?");
if ($stmtSelect) {
$stmtSelect->bind_param('i', $id);
if ($stmtSelect->execute()) {
$stmtSelect->store_result();
$stmtSelect->bind_result($valore);
$stmtSelect->fetch();
return $valore;
}
}
}
function getLanguageTextAPI($key,$lingua,$tipo=Null) {
if($lingua=="") return $key;
if($key != '') {
$db = (new db_connect())->connect();
if($lingua=="en_") $language = 2;
$valore = "";
if($tipo=="Array")
{
$array = explode(",",$key);
$value="";
foreach($array as $ar)
{
$stmtSelect = $db->prepare("SELECT valore FROM linguaggi_traduzioni "
. "WHERE chiave = ? AND id_lingua = ? LIMIT 1");
if($stmtSelect) {
$stmtSelect->bind_param('si', $ar, $language);
if($stmtSelect->execute()) {
$stmtSelect->store_result();
$stmtSelect->bind_result($valore);
$stmtSelect->fetch();
} else {
consoleLog('Error! ' . $db->error);
}
} else {
consoleLog('Error! ' . $stmtSelect->error);
}
if($valore!="") $value .= ",".$valore;
}
return substr($value,1);
} else {
$stmtSelect = $db->prepare("SELECT valore FROM linguaggi_traduzioni "
. "WHERE chiave = ? AND id_lingua = ? LIMIT 1");
if($stmtSelect) {
$stmtSelect->bind_param('si', $key, $language);
if($stmtSelect->execute()) {
$stmtSelect->store_result();
$stmtSelect->bind_result($valore);
$stmtSelect->fetch();
} else {
consoleLog('Error! ' . $db->error);
}
} else {
consoleLog('Error! ' . $stmtSelect->error);
}
if($valore!="") return $valore;
else return $key;
}
} else {
return '';
}
}
function printCatDoveSelect($catDoveSelected) {
$catDoveArray = ['borgo', 'campagna', 'centro storico', 'città',
'collina', 'lago', 'mare', 'montagna', 'paese', 'periferia', 'pianura'];
echo '
Territorio
';
foreach($catDoveArray as $catDove) {
$checkCatDove = '';
if($catDoveSelected != '') {
$catDoveLocation = explode(",", $catDoveSelected);
if(in_array($catDove, $catDoveLocation)) {
$checkCatDove = ' selected';
}
}
echo '' . $catDove . ' ';
}
echo '
';
}
function printCatAtmosferaSelect($catAtmosferaSelected) {
$catAtmosferaArray = [
getLanguageText('Action'),
getLanguageText('Alpino'),
getLanguageText('Contemporaneo'),
getLanguageText("Depoca"),
getLanguageText('Fatiscente'),
getLanguageText('Drammatico'),
getLanguageText('Epico'),
getLanguageText('Fantascientifico'),
getLanguageText('Fantasy'),
getLanguageText('Horror'),
getLanguageText('Industriale'),
getLanguageText('Mediterraneo'),
getLanguageText('Militare'),
getLanguageText('Mistico'),
getLanguageText('Mitologico'),
getLanguageText('Noir'),
getLanguageText('Romantico'),
getLanguageText('Rurale'),
getLanguageText('Sportivo'),
getLanguageText('Tradizionale'),
getLanguageText('Thriller'),
getLanguageText('Urbano')
];
echo '
'.getLanguageText('Atmosfera').'
';
foreach($catAtmosferaArray as $catAtmosfera) {
$checkCatAtmosfera = '';
if($catAtmosferaSelected != '') {
$catAtmosferaLocation = explode(",", $catAtmosferaSelected);
if(in_array($catAtmosfera, $catAtmosferaLocation)) {
$checkCatAtmosfera = ' selected';
}
}
echo '' . $catAtmosfera . ' ';
}
echo '
';
}
function ifCategoryExist($id){
$db = (new db_connect())->connect();
$stmtSelect= "SELECT COUNT(id) as tot
FROM oggetto_location
WHERE (tipologia = '".$id."N' OR tipologia = '".$id."A') OR (FIND_IN_SET(".$id.",chiavi_ricerca_arc)>0 OR FIND_IN_SET(".$id.",chiavi_ricerca_nat)>0)";
$stmtSelect1 = $db->query($stmtSelect);
if ($stmtSelect1->num_rows > 0) return 1;
else return 0;
}
function printCatComeSelect($catComeSelected) {
$catComeArray = ["Abbandonato",
"Alternativo",
//"Alto borghese",
"Aristocratico",
"Arredato",
"Autentico (non ristrutturato)",
"Borghese",
"Diroccato",
"Elegante",
//"In rovina",
"Informale",
"Moderno",
//"Piccolo-borghese",
"Popolare",
"Ristrutturato",
"Tradizionale",
"Vuoto"];
$catComeArray2=["Preistorica",
"Fenicia",
"Nuragica",
"Sicilia greca",
"Etrusca",
"Antica Roma",
"Medioevo",
"Rinascimento",
"Seicento",
"Settecento",
"Ottocento",
"Inizio '900",
"Anni '20-'40",
"Anni '50",
"Anni '60",
"Anni '70",
"Anni '80",
"Anni '90",
"Anni 2000"];
//"Secolo XI-XIV",
//"Secolo XVI",
//"Anni '50",
//"Anni '60",
//"Anni '70",
//"Anni '80",
$catComeArray3= ["Architettura siceliota",
"Barocco",
"Bizantino",
"Classico",
"Contemporaneo",
//"Deco",
//"Design",
"Eclettico",
"Etnico",
"Gotico",
//"Hi-tech",
//"Impero",
//"Kitsch",
"Liberty/Deco",
"Medievale",
//"Minimal",
"Moresco",
"Neorinascimentale",
"Neoclassico",
"Neogotico",
"Paleocristiano",
"Razionalista",
"Rinascimentale",
"Romanico",
"Rustico",
"Umbertino"];
echo '
'.getLanguageText('Aspetto e Condizione').'
';
foreach($catComeArray as $catCome) {
$checkCatCome = '';
if($catComeSelected != '') {
$catComeLocation = explode(",", $catComeSelected);
if(in_array($catCome, $catComeLocation)) {
$checkCatCome = ' selected';
}
}
echo '' . $catCome . ' ';
}
echo '
';
echo '
'.getLanguageText('Epoca').'
';
foreach($catComeArray2 as $catCome) {
$checkCatCome = '';
if($catComeSelected != '') {
$catComeLocation = explode(",", $catComeSelected);
if(in_array($catCome, $catComeLocation)) {
$checkCatCome = ' selected';
}
}
echo '' . $catCome . ' ';
}
echo '
';
echo '
'.getLanguageText('Stile').'
';
foreach($catComeArray3 as $catCome) {
$checkCatCome = '';
if($catComeSelected != '') {
$catComeLocation = explode(",", $catComeSelected);
if(in_array($catCome, $catComeLocation)) {
$checkCatCome = ' selected';
}
}
echo '' . $catCome . ' ';
}
echo '
';
}
function printCatDoveSelect2($catDoveSelected) {
$catDoveArray = [getLanguageText('borgo'), getLanguageText('campagna'), getLanguageText('centro storico'), getLanguageText('città'),
getLanguageText('collina'), getLanguageText('lago'), getLanguageText('mare'), getLanguageText('montagna'), getLanguageText('paese'), getLanguageText('periferia'), getLanguageText('pianura')];
echo ''
.'
'
.''.getLanguageText('Territorio').' '
.' ';
echo ' ';
}
function printCatAtmosferaSelect2($catAtmosferaSelected) {
$catAtmosferaArray = [
getLanguageText('Action'),
getLanguageText('Alpino'),
getLanguageText('Contemporaneo'),
getLanguageText("Depoca"),
getLanguageText('Drammatico'),
getLanguageText('Epico'),
getLanguageText('Fantascientifico'),
getLanguageText('Fantasy'),
getLanguageText('Fatiscente'),
getLanguageText('Horror'),
getLanguageText('Industriale'),
getLanguageText('Mediterraneo'),
getLanguageText('Militare'),
getLanguageText('Mistico'),
getLanguageText('Mitologico'),
getLanguageText('Noir'),
getLanguageText('Romantico'),
getLanguageText('Rurale'),
getLanguageText('Sportivo'),
getLanguageText('Tradizionale'),
getLanguageText('Thriller'),
getLanguageText('Urbano')
];
echo ''
.'
'
.''.getLanguageText('Atmosfera').' '
.' ';
echo ' ';
}
function printCatComeSelect2($catComeSelected) {
$catComeArray = [
getLanguageText("Abbandonato"),
getLanguageText("Alternativo"),
getLanguageText("Aristocratico"),
getLanguageText("Arredato"),
getLanguageText("Autentico (non ristrutturato)"),
getLanguageText("Borghese"),
getLanguageText("Diroccato"),
getLanguageText("Elegante"),
//"In rovina"),
getLanguageText("Informale"),
getLanguageText("Moderno"),
//"Piccolo-borghese"),
getLanguageText("Popolare"),
getLanguageText("Ristrutturato"),
getLanguageText("Tradizionale"),
getLanguageText("Vuoto")];
$catComeArray2 =[getLanguageText("Preistorica"),
getLanguageText("Fenicia"),
getLanguageText("Nuragica"),
getLanguageText("Sicilia greca"),
getLanguageText("Etrusca"),
getLanguageText("Antica Roma"),
getLanguageText("Medioevo"),
getLanguageText("Rinascimento"),
getLanguageText("Seicento"),
getLanguageText("Settecento"),
getLanguageText("Ottocento"),
getLanguageText("Inizio '900"),
getLanguageText("Anni '20-'40"),
getLanguageText("Anni '50"),
getLanguageText("Anni '60"),
getLanguageText("Anni '70"),
getLanguageText("Anni '80"),
getLanguageText("Anni '90"),
getLanguageText("Anni 2000")];
$catComeArray3 = [getLanguageText("Architettura siceliota"),
getLanguageText("Barocco"),
getLanguageText("Bizantino"),
getLanguageText("Classico"),
getLanguageText("Contemporaneo"),
getLanguageText("Eclettico"),
getLanguageText("Etnico"),
getLanguageText("Gotico"),
getLanguageText("Liberty / Deco"),
getLanguageText("Medievale"),
getLanguageText("Moresco"),
getLanguageText("Neorinascimentale"),
getLanguageText("Neoclassico"),
getLanguageText("Neogotico"),
getLanguageText("Paleocristiano"),
getLanguageText("Razionalista"),
getLanguageText("Rinascimentale"),
getLanguageText("Romanico"),
getLanguageText("Rustico"),
getLanguageText("Umbertino")];
echo ''
.'
'
.''.getLanguageText('Aspetto e Condizione').' '
.' ';
echo ' ';
echo ''
.'
'
.''.getLanguageText('Epoca').' '
.' ';
echo ' ';
echo ''
.'
'
.''.getLanguageText('Stile').' '
.' ';
echo ' ';
}
function printAccessoSelect($accessoSelected) {
$accessoArray = ['strada asfaltata', 'sterrata', 'mulattiera', 'sentiero',
'raggiungibile con mezzi di grandi dimensioni', 'raggiungibile in auto',
'raggiungibile con mezzi fuoristrada', 'raggiungibile a piedi',
'accesso con funivia/teleferica', 'accesso con elicottero o mezzo aereo',
'accesso con imbarcazione', 'accessibile ai disabili', 'non accessibile ai disabili'];
echo '
Accesso
';
foreach($accessoArray as $accesso) {
$checkAccesso = '';
if($accessoSelected != '') {
$accessoLocation = explode(",", $accessoSelected);
if(in_array($accesso, $accessoLocation)) {
$checkAccesso = ' selected';
}
}
echo '' . $accesso . ' ';
}
echo '
';
}
function printFacilitiesSelect($facilitySelected) {
$facilitiesArray = [
'Assistenza durante le riprese',
'Collegamento e incontro tra produzione e professionalita\' locali',
'Contatti con istituzioni locali',
'Facilitazioni per tariffe agevolate accomodation',
'Facilitazioni per tariffe agevolate ristorazione',
'Fornitura spazi logistici',
'Informazioni e assistenza per il rilascio di permessi e autorizzazioni',
'Informazioni preliminari di carattere tecnico logistico e burocratico',
'Location scouting',
'Organizzazione anteprime e programmazione',
'Organizzazione e collaborazione alle attivita\' promozionali',
'Photoscouting',
'Supporto economico',
'Supporto logistico',
'Ufficio stampa'
];
echo '
Facilities:
';
foreach($facilitiesArray as $facility) {
$checkFacility = '';
if($facilitySelected != '') {
$facilityIncentivo = explode(",", $facilitySelected);
if(in_array($facility, $facilityIncentivo)) {
$checkFacility = ' selected';
}
}
echo '' . $facility . ' ';
}
echo '
';
}
function printFacilitiesSelectEN($facilitySelected) {
$facilitiesArray = ['Informazioni e assistenza per il rilascio di permessi e autorizzazioni',
'Location scouting',
'Facilitazioni per tariffe agevolate accomodation',
'Facilitazioni per tariffe agevolate ristorazione',
'Contatti con istituzioni locali',
'Ufficio stampa',
'Photoscouting',
'Organizzazione anteprime e programmazione',
'Fornitura spazi logistici',
'Informazioni preliminari di carattere tecnico logistico e burocratico',
'Collegamento e incontro tra produzione e professionalita\' locali',
'Organizzazione e collaborazione alle attivita\' promozionali',
'Assistenza durante le riprese',
'Supporto economico',
'Supporto logistico'];
echo '
Elenco Facilities:
';
foreach($facilitiesArray as $facility) {
$checkFacility = '';
if($facilitySelected != '') {
$facilityIncentivo = explode(",", $facilitySelected);
if(in_array($facility, $facilityIncentivo)) {
$checkFacility = ' selected';
}
}
echo '' . $facility . ' ';
}
echo '
';
}
function getCallExpiryState($dataInserimento, $primaScadenza, $secondaScadenza, $terzaScadenza) {
$nowTimestamp = time();
$callLabel = '';
$callNextExpiry = null;
if ($nowTimestamp < $primaScadenza) {
$callNextExpiry = $primaScadenza;
} else if ($nowTimestamp < $secondaScadenza) {
$callNextExpiry = $secondaScadenza;
} else if ($nowTimestamp < $terzaScadenza) {
$callNextExpiry = $terzaScadenza;
}
if ($nowTimestamp < $dataInserimento) {
$callLabel = 'In arrivo';
} elseif ($nowTimestamp >= $dataInserimento &&
$nowTimestamp < strtotime('-1 week', $callNextExpiry)) {
$callLabel = 'Bando aperto ';
} elseif ($nowTimestamp >= strtotime('-1 week', $callNextExpiry) &&
$nowTimestamp < $callNextExpiry) {
$callLabel = 'In chiusura ';
} elseif ($nowTimestamp >= $callNextExpiry) {
$callLabel = 'Bando chiuso ';
}
$callLabel .= ($callNextExpiry !== null)
? 'Scadenza sessione: ' . date('d.m.Y', $callNextExpiry)
: ' ';
return $callLabel;
}
function getRegionNameById($idRegione) {
$nomeRegione = '';
switch($idRegione) {
case "1":
$nomeRegione = "Piemonte";
break;
case "2":
$nomeRegione = "Valle d'Aosta";
break;
case "3":
$nomeRegione = "Lombardia";
break;
case "4":
$nomeRegione = "Trentino";
break;
case "5":
$nomeRegione = "Veneto";
break;
case "6":
$nomeRegione = "Friuli-Venezia Giulia";
break;
case "7":
$nomeRegione = "Liguria";
break;
case "8":
$nomeRegione = "Emilia-Romagna";
break;
case "9":
$nomeRegione = "Toscana";
break;
case "10":
$nomeRegione = "Umbria";
break;
case "11":
$nomeRegione = "Marche";
break;
case "12":
$nomeRegione = "Lazio";
break;
case "13":
$nomeRegione = "Abruzzo";
break;
case "14":
$nomeRegione = "Molise";
break;
case "15":
$nomeRegione = "Campania";
break;
case "16":
$nomeRegione = "Puglia";
break;
case "17":
$nomeRegione = "Basilicata";
break;
case "18":
$nomeRegione = "Calabria";
break;
case "19":
$nomeRegione = "Sicilia";
break;
case "20":
$nomeRegione = "Sardegna";
break;
case "21":
$nomeRegione = "Alto Adige";
break;
}
return $nomeRegione;
}
function getYN($input) {
switch($_SESSION['lingua']) {
case 1:
if($input) {
return "Sì";
} else {
return "No";
}
case 2:
if($input) {
return "Yes";
} else {
return "No";
}
}
}
function getImageOrThumb($img) {
if(file_exists("./media/img/oggetto_location/thumb/thumb_" . $img)) {
return "./media/img/oggetto_location/thumb/thumb_" . $img;
} else {
return "./media/img/oggetto_location/" . $img;
}
}
function getAddress($latitude,$longitude){
if(!empty($latitude) && !empty($longitude)){
//Send request and receive json data by address
if($_SESSION['lingua']==1){
$geocodeFromLatLong = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($latitude).','.trim($longitude).'&key=AIzaSyCWCd08thpSwoauXv_JbG_oH6ek1zAUKss&q&language=IT');
} else {
$geocodeFromLatLong = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($latitude).','.trim($longitude).'&key=AIzaSyCWCd08thpSwoauXv_JbG_oH6ek1zAUKss&q&language=EN');
}
//return $geocodeFromLatLong;
$output = json_decode($geocodeFromLatLong);
$status = $output->status;
//Get address from json data
$address = ($status=="OK")?$output->results[0]->formatted_address:'';
//Return address of the given latitude and longitude
if(!empty($address)){
return $address;
}else{
return false;
}
}else{
return false;
}
}
function getMapDetails($text) {
$part1 = explode("|", $text);
$arrayElements = explode("}", $part1[1]);
$arrayOutput = array();
foreach($arrayElements as $element) {
$elementParts = explode("=", $element);
$arrayOutput[$elementParts[0]] = $elementParts[1];
}
return $arrayOutput;
}
function getAddressForMap($indirizzo) {
$addressOutput = str_replace(" ", " ", $indirizzo);
$addressOutput = str_replace(" ", " ", $addressOutput);
$addressOutput = str_replace(" ", " ", $addressOutput);
$addressOutput = str_replace(" ", "+", $addressOutput);
return $addressOutput;
}
function getLatLngFromAddress($address) {
$address = str_replace(" ", "+", $address);
$response = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=" . $address .
"&key=AIzaSyCWCd08thpSwoauXv_JbG_oH6ek1zAUKss");
$jsonDecoded = json_decode($response);
$outputArray = array(
'latitudine' => $jsonDecoded->{'results'}[0]->{'geometry'}->{'location'}->{'lat'},
'longitudine' => $jsonDecoded->{'results'}[0]->{'geometry'}->{'location'}->{'lng'}
);
return $outputArray;
}
function formatTextEditorInput($text) {
$text = addslashes($text);
$text = trim($text);
return $text;
}
function formatTextEditorOutput($text) {
$text = stripslashes($text);
return $text;
}
function parseNewsText($text) {
$text = trim(strip_tags($text));
$wordsArray = explode(" ", $text);
$wordsArray = array_slice($wordsArray, 0, 20);
$output = implode(" ", $wordsArray);
$output = preg_replace('/\.([a-zA-Z0-9])/', '. $1', $output);
$output = preg_replace('/\?([a-zA-Z0-9])/', '? $1', $output);
$output = preg_replace('/\!([a-zA-Z0-9])/', '! $1', $output);
return $output;
}
function parseNewsTextAll($text) {
$text = strip_tags($text);
$wordsArray = explode(" ", $text);
$wordsArray = array_slice($wordsArray, 0, 10000);
$output = implode(" ", $wordsArray);
return $output;
}
function parseRequirement($requirement) {
if(strpos($requirement, "") !== false) {
return $requirement;
} else {
return strip_tags($requirement);
}
}
function replaceEuroSymbol($text) {
return str_replace("€", "€", $text);
}
function parseErogationTimes($text) {
$text = str_replace("", "
", $text);
$text = str_replace("", " ", $text);
return $text;
}
function parseParagraphs($text) {
$text = str_replace("", "", $text);
return str_replace("
", "", $text);
}
function getAddressFromRoadMap($roadMap) {
$addressToReturn = explode("indirizzo=", $roadMap)[1];
$addressToReturn = explode("}", $addressToReturn)[0];
return $addressToReturn;
}
function checkValiditaIncentivo($expiry) {
$expiry += 86400;
if(time() <= $expiry) {
return getLanguageText("Attivo");
} else {
return getLanguageText("Scaduto");
}
}
function findElementByValue($array, $toSearch, $field) {
foreach($array as $index => $element) {
if($element[$field] == $toSearch) return $index;
}
return -1;
}
function getRoleByPermits($permits) {
$role = '';
if($permits == '10') {
$role = 'SuperAdmin';
} else if($permits == '4') {
$role = 'Amministratore';
} else if($permits == '2') {
$role = 'Redattore';
} else if($permits == '1') {
$role = 'Utente Semplice';
}
return $role;
}
function parseURIController($text) {
$textParts = explode("-", $text);
foreach ($textParts as $index => $textPart) {
if ($index > 0) $textParts[$index] = ucfirst($textPart);
}
return implode("", $textParts);
}
function getTitleElementForURL($title) {
$title = str_replace('-', '', $title);
$title = strtolower(str_replace(' ', '-', $title));
$title = str_replace('à', 'a', $title);
$title = str_replace('è', 'e', $title);
$title = str_replace('é', 'e', $title);
$title = str_replace('ì', 'i', $title);
$title = str_replace('ò', 'o', $title);
$title = str_replace('ù', 'u', $title);
$title = preg_replace('/[^A-Za-z0-9\-]/', '', $title);
$title = preg_replace("/(-)\\1+/", "$1", $title);
return $title;
}
function sortCategoriesByAlphabet($a, $b) {
return $a["categoria"] > $b["categoria"];
}
function getTitleElementForImages($title) {
$title = str_replace('-', '_', $title);
$title = strtolower(str_replace('\'', '_', $title));
$title = strtolower(str_replace('"', '', $title));
$title = strtolower(str_replace('´', '_', $title));
$title = strtolower(str_replace('’', '_', $title));
$title = strtolower(str_replace(' ', '_', $title));
$unwantedArray = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', '&' => 'e', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y');
$title = strtr($title, $unwantedArray);
$title = preg_replace('/[^A-Za-z0-9\_]/', '', $title);
$title = preg_replace("/(_)\\1+/", "$1", $title);
return $title;
}
function printAddAdminButton($type) {
if(isset($_SESSION['userId']) && $_SESSION['permessi'] >= 4) {
echo '';
}
}
function printEditAdminButton($id, $idProprietario, $idRegione, $type) {
if(isset($_SESSION['userId']) && ($_SESSION['permessi'] >= 4 || $idProprietario == $_SESSION['userId'] ||
$idRegione == $_SESSION['userRegione'])) {
echo '';
}
}
function printSocialSection($currentURL) {
echo '';
}
function printAdminGeneralActions($type, $id) {
if ($_SESSION['userId']) {
return ' ';
} else {
return '';
}
}
function printAdminDetailActions($type, $id) {
if ($_SESSION['userId']) {
return
'';
} else {
return '';
}
}
function printTopLanguageAdmin() {
echo '';
}
function getEmbedVideoByType($idVideo, $typeVideo) {
$urlVideo = '';
switch ($typeVideo) {
case 'youtube':
$urlVideo = 'https://www.youtube.com/embed/' . $idVideo;
break;
case 'vimeo':
$urlVideo = 'https://player.vimeo.com/video/' . $idVideo . '?title=0&byline=0&portrait=0&badge=0';
break;
}
return '';
}
function parseFilmDetail($detail) {
$detail = strip_tags($detail);
return $detail;
}
function getPaginationParams($limit, $total) {
$numPages = ceil($total / $limit);
$page = min($numPages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
'options' => array(
'default' => 1,
'min_range' => 1,
),
)));
$offset = ($page - 1) * $limit;
$pages = array();
for ($i = ( ($page - 2 > 0) ? ($page - 2) : 1); $i <= ( ($page + 2 <= $numPages) ? ($page + 2) : $numPages); $i++) {
array_push($pages, $i);
}
return array(
'numPages' => $numPages,
'page' => $page,
'offset' => $offset,
'page1' => $page > 3,
'pageLast' => $page <= ($numPages - 3),
'pages' => $pages,
'start' => $offset + 1,
'end' => min(($offset + $limit), $total)
);
}
function printDocumentCategoryRecursive($idCategory) {
$lngTag = getLanguagePrefix();
$documentiClass = new Documenti();
$categoriesRec = $documentiClass->getDocumentCategoriesByIdParent($idCategory);
foreach ($categoriesRec as $categoryRec) {
$currentDocuments = $documentiClass->getDocumentsByTypeAndIdCategory(
(in_array($_SESSION['userTipologia'], ['admin', 'fc'])) ? ['private', 'public'] : ['public'],
$categoryRec["id"]
);
if (count($currentDocuments) > 0) {
echo '
' . $categoryRec["{$lngTag}nome"] . '
';
}
}
}
function addGETParameterToURL($key, $value, $url) {
$info = parse_url( $url );
parse_str( $info['query'], $query );
return $info['host'] . $info['path'] . '?' . http_build_query( $query ? array_merge( $query, array($key => $value ) ) : array( $key => $value ) );
}
function getStringAvatar($string) {
$words = preg_split("/(\s|\-|\.)/", $string);
foreach ($words as $word) {
$acronym .= substr($word,0,1) . '.';
}
return $acronym;
}
function getTimestampFromDate($date) {
$a = strptime($date, '%d/%m/%Y');
return mktime(0, 0, 0, $a['tm_mon'] + 1, $a['tm_mday'], $a['tm_year'] + 1900);
}
function strContains($stringArray, $string) {
return strpos($stringArray, $string) !== false;
}
function consoleLog($message) {
echo '';
}
function printNotAuthorizedMessage() {
echo '
Non sei autorizzato ad accedere a questa pagina. Effettua il login.
';
}
function printForDeveloper($array) {
if(isset($_SESSION['userId'])) {
if($_SESSION['userId'] == 29) {
printArray($array);
}
}
}
function printArray($array) {
echo '';
print_r($array);
echo ' ';
}
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
// open the directory
$dir = opendir( $pathToImages );
// loop through it, looking for any/all JPG files:
while (false !== ($fname = readdir( $dir ))) {
// parse path for the extension
$info = pathinfo($pathToImages . $fname);
// continue only if this is a JPEG image
if ( strtolower($info['extension']) == 'jpg' )
{
echo "Creating thumbnail for {$fname} ";
// load image and get image size
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
// close the directory
closedir( $dir );
}
function getImageURLByIDAndType($id, $filename, $type) {
$imageURL = "";
if ($id > 7049) {
switch ($type) {
case 'film':
if(file_exists("app/img/film/" . $id . "/" . $filename)) $imageURL = "/app/img/film/" . $id . "/" . $filename;
else $imageURL = "http://www.italyformovies.it/media/img/oggetto_film/" . $filename;
break;
case 'itinerario':
if(file_exists("app/img/itinerari/" . $filename)) $imageURL = "/app/img/itinerari/" . $filename;
else $imageURL = "http://www.italyformovies.it/media/img/oggetto_film/" . $filename;
break;
case 'film_locandina':
if(file_exists("app/img/film/locandine/" . $filename)) $imageURL = "/app/img/film/locandine/" . $filename;
else $imageURL = "http://www.italyformovies.it/media/img/oggetto_film/" . $filename;
break;
}
} else {
switch ($type) {
case 'film':
if(file_exists("app/img/film/" . $id . "/" . $filename)) $imageURL = "/app/img/film/" . $id . "/" . $filename;
else $imageURL = "http://www.italyformovies.it/media/img/oggetto_film/" . $filename;
break;
case 'film_locandina':
if(file_exists("app/img/film/locandine/" . $filename)) $imageURL = "/app/img/film/locandine/" . $filename;
else $imageURL = "http://www.italyformovies.it/media/img/oggetto_film/" . $filename;
break;
}
}
return $imageURL;
}
?>