Location: PHPKode > projects > Openelibrary > e-library/include/functions.php
<?

function print_foto($idthem){
//echo $idthem;
echo '<img class="thumbnail"  src="el-img/';
switch ($idthem){

	case 1:
	echo "agricolture.png";
	break;

	case 2:
	echo "animal_rights";
	break;

	case 3:
	echo "art_culture";
	break;

	case 4:
	echo "common_goods";
	break;

	case 5:
	echo "communication_tech";
	break;

	case 6:
	echo "community";
	break;

	case 7:
	echo "cross_thematic";
	break;

	case 8:
	echo "cultural_and";
	break;

	case 9:
	echo "democracy";
	break;

	case 10:
	echo "ecology";
	break;

	case 11:
	echo "economy";
	break;

	case 12:
	echo "education";
	break;

	case 13:
	echo "gender";
	break;

	case 14:
	echo "global_governance";
	break;

	case 15:
	echo "health";
	break;

	case 16:
	echo "housing";
	break;

	case 17:
	echo "human";
	break;

	case 18:
	echo "international_solidarity";
	break;

	case 19:
	echo "labour";
	break;

	case 20:
	echo "media";
	break;

	case 21:
	echo "migrations";
	break;

	case 22:
	echo "religiosity";
	break;

	case 23:
	echo "research";
	break;

	case 24:
	echo "exclusion";
	break;

	case 25:
	echo "territory";
	break;

	case 26:
	echo "war";
	break;

	case 27:
	echo "youth";
	break;

	case 28:
	echo "european_sf";
	break;

	case 29:
	echo "social_movements";
	break;

	case 30:
	echo "european_dimension";
	break;

	case 31:
	echo "europe";
	break;

	case 33:
	echo "esf_florence";
	break;

	case 34:
	echo "esf_paris";
	break;

	case 35:
	echo "esf_london";
	break;

	case 36:
	echo "esf_greece";
	break;

	case 37:
	echo "global_movement";
	break;

	case 38:
	echo "world_sf";
	break;

	case 40:
	echo "european_dimension";
	break;

	case 41:
	echo "europe.png";
	break;

	case 45:
	echo "art_culture";
	break;

}
echo '.png">';


}

function showlang($id_autore){
global $conn;

$transquery = "SELECT  language.language
FROM autori, language
 WHERE autori.id_autore=".$id_autore."
AND autori.id_language=language.id_language
 ";
if ($transrs = phpmkr_query($transquery,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $transquery)){
	$transrow = phpmkr_fetch_array($transrs); 

echo '<a href="autorsview.php?id_autore='.$id_autore.'" class="lang">['.$transrow['language'].']</a>';
}

}

function find_translations1($id_autore){
global $conn;
global $array_id;
global $orig_aut;

//echo "cerco ".$id_autore."<br />";

if(!in_array($id_autore, $array_id)&&($id_autore != $orig_aut))
	$array_id[sizeof($array_id)]=$id_autore;

$transquery = "SELECT * FROM `translation` WHERE id_autore2=".$id_autore." ";
if ($transrs = phpmkr_query($transquery,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $transquery)){
	while($transrow = phpmkr_fetch_array($transrs)){ 
		$itmp = $transrow["id_autore1"];

		if(!in_array($itmp, $array_id)){
			find_translations1($itmp);
		}

		}
	}

@phpmkr_free_result($transrs);


}

function find_translations2($id_autore){
global $conn;
global $array_id;
global $orig_aut;

//echo "cerco ".$id_autore."<br />";

if(!in_array($id_autore, $array_id)&&($id_autore != $orig_aut))
	$array_id[sizeof($array_id)]=$id_autore;

$transquery = "SELECT * FROM `translation` WHERE id_autore1=".$id_autore." ";
if ($transrs = phpmkr_query($transquery,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $transquery)){
	while($transrow = phpmkr_fetch_array($transrs)){ 
		$itmp = $transrow["id_autore2"];

		if(!in_array($itmp, $array_id)){
			find_translations2($itmp);
		}
		
		}
	}
@phpmkr_free_result($transrs);




}

function remfrombasket($id_autore){
	global $HTTP_SESSION_VARS;
	$inthebasket=$HTTP_SESSION_VARS[inthebasket];
	if($inthebasket != ""){	
		$singleaut=explode(",", $inthebasket);
		if(in_array($id_autore, $singleaut )){	
			$newbask='';
			$found=0;
			for($r=0;$r<count($singleaut);$r++){
				if($singleaut[$r] != $id_autore){
								
				if($found>0)
					$newbask.= ",";
				$newbask.=$singleaut[$r];

				$found++;
				}
				
			}

		}else{
			$newbask=$inthebasket;
		}
	}
	
	$HTTP_SESSION_VARS[inthebasket]=$newbask;
}

function addtobasket($id_autore){
	global $HTTP_SESSION_VARS;
	$inthebasket=$HTTP_SESSION_VARS[inthebasket];
	$singleaut=explode(",", $inthebasket);
	if($inthebasket == ""){
		$inthebasket.= $id_autore;
	}
	else{
		if(!in_array($id_autore, $singleaut )){	
			$inthebasket.= ",".$id_autore;
		}
	}
	
	$HTTP_SESSION_VARS[inthebasket]=$inthebasket;
}

function checkbasket(){
	global $HTTP_SESSION_VARS;
	$inthebasket=$HTTP_SESSION_VARS[inthebasket]; 
	
	if($inthebasket != "")
	$singleaut=explode(",", $inthebasket);
	else
	$singleaut="";
	
	return $singleaut;
}


function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}


function isinbasket($allbasket, $idobj){
	$trovato=0;
	for($i=0; $i<sizeof($allbasket); $i++){
	
	
	if($allbasket[$i]== $idobj)
		$trovato=1;
	}
	return $trovato;
}

function emptybasket(){
	global $HTTP_SESSION_VARS;
	$HTTP_SESSION_VARS[inthebasket]='';
}

function sortmddata($array, $by, $order, $type){

//$array: the array you want to sort
//$by: the associative array name that is one level deep
////example: name
//$order: ASC or DESC
//$type: num or str
      
$sortby = "sort$by"; //This sets up what you are sorting by

$firstval = current($array); //Pulls over the first array

$vals = array_keys($firstval); //Grabs the associate Arrays

foreach ($vals as $init){
   $keyname = "sort$init";
   $$keyname = array();
}
//This was strange because I had problems adding
//Multiple arrays into a variable variable
//I got it to work by initializing the variable variables as arrays
//Before I went any further

foreach ($array as $key => $row) {
  
foreach ($vals as $names){
   $keyname = "sort$names";
   $test = array();
   $test[$key] = $row[$names];
   $$keyname = array_merge($$keyname,$test);
  
}

}

//This will create dynamic mini arrays so that I can perform
//the array multisort with no problem
//Notice the temp array... I had to do that because I
//cannot assign additional array elements to a
//varaiable variable           

if ($order == "DESC"){   
if ($type == "num"){
array_multisort($$sortby,SORT_DESC, SORT_NUMERIC,$array);
} else {
array_multisort($$sortby,SORT_DESC, SORT_STRING,$array);
}
} else {
if ($type == "num"){
array_multisort($$sortby,SORT_ASC, SORT_NUMERIC,$array);
} else {
array_multisort($$sortby,SORT_ASC, SORT_STRING,$array);
}
}

//This just goed through and asks the additional arguments
//What they are doing and are doing variations of
//the multisort

return $array;
}


?>
Return current item: Openelibrary