Location: PHPKode > projects > HuMo-gen > include/mainindex_cls.php
<?php
class hoofdindex_cls{

	// *** List family trees ***
	function stambomen_lijst($datasql){
		global $db, $humo_option, $uri_pad, $user, $language, $cms;
		$tekst='';
		while (@$dataDb=mysql_fetch_object($datasql)){

			// *** Check is family tree is showed or hidden for user group ***
			$hide_tree_array=explode(";",$user['group_hide_trees']);
			$hide_tree=false;
			for ($x=0; $x<=count($hide_tree_array)-1; $x++){
				if ($hide_tree_array[$x]==$dataDb->tree_id){ $hide_tree=true; }
			}
			if ($hide_tree==false){	

				$treetext_name=$dataDb->treetext_name;
				if ($treetext_name==''){
					$treetext_name=$language["main_tree_no_name"];
					$data2qry = "SELECT * FROM humo_trees LEFT JOIN humo_tree_texts
						ON humo_trees.tree_id=humo_tree_texts.treetext_tree_id
						AND treetext_name LIKE '_%'
						WHERE tree_prefix='".$dataDb->tree_prefix."'";
					@$data2sql = mysql_query($data2qry,$db);
					@$data2Db=mysql_fetch_object($data2sql);	
					if (isset($data2Db->treetext_name)){ $treetext_name=$data2Db->treetext_name; }
				}

				// *** Name family tree ***
				if (isset($_SESSION['tree_prefix']) AND $_SESSION['tree_prefix']==$dataDb->tree_prefix){
					$naam='<span class="stamboom_link fonts">'.$treetext_name.'</span><br>';
				}
				else{
					if ($cms['cms_name']=='Joomla'){
						$path_tmp='index.php?option=com_humo-gen&amp;database='.$dataDb->tree_prefix;
					}
					// *** url_rewrite ***
					elseif ($humo_option["url_rewrite"]=="j"){
						// *** $uri_pad is gemaakt in header.php ***
						$path_tmp=$uri_pad.'index/'.$dataDb->tree_prefix.'/';
					}
					else{
					  $path_tmp=$_SERVER['PHP_SELF'].'?database='.$dataDb->tree_prefix;
					}
					$naam='<a href="'.$path_tmp.'">';
					$naam.='<span class="stamboom_link fonts">'.$treetext_name.'</span></a><br>';					
				}
				// *** Show empty line ***
				if ($dataDb->tree_prefix=='LEEG'){ $naam='<br>'; }
				$tekst.=$naam;

			}		// end of family tree check

		}
		echo $tekst;
	}

	// *** Family tree data ***
	function gegevens(){
		global $dataDb,$language;
		$datum=$dataDb->tree_date;

		$maand=''; // *** empty date ***
		if (substr($datum,5,2)=='01'){ $maand=' '.$language["date_jan"].' ';}
		if (substr($datum,5,2)=='02'){ $maand=' '.$language["date_feb"].' ';}
		if (substr($datum,5,2)=='03'){ $maand=' '.$language["date_mar"].' ';}
		if (substr($datum,5,2)=='04'){ $maand=' '.$language["date_apr"].' ';}
		if (substr($datum,5,2)=='05'){ $maand=' '.$language["date_may"].' ';}
		if (substr($datum,5,2)=='06'){ $maand=' '.$language["date_jun"].' ';}
		if (substr($datum,5,2)=='07'){ $maand=' '.$language["date_jul"].' ';}
		if (substr($datum,5,2)=='08'){ $maand=' '.$language["date_aug"].' ';}
		if (substr($datum,5,2)=='09'){ $maand=' '.$language["date_sep"].' ';}
		if (substr($datum,5,2)=='10'){ $maand=' '.$language["date_oct"].' ';}
		if (substr($datum,5,2)=='11'){ $maand=' '.$language["date_nov"].' ';}
		if (substr($datum,5,2)=='12'){ $maand=' '.$language["date_dec"].' ';}

		$datum=substr($datum,8,2).$maand.substr($datum,0,4);
		return $language["main_update"].' '.$datum.', '.$dataDb->tree_persons.$language["main_nr_persons"].", ".$dataDb->tree_families.$language["main_nr_fams"].".";
	}

	// *** Owner family tree ***
	function eigenaar(){
		global $language, $dataDb, $cms;
		$eigenaar='';

		if ($dataDb->tree_owner){
			$eigenaar=$language["main_owner"].' ';
			// *** Show owner e-mail address ***
			if ($dataDb->tree_email){
				if ($cms['cms_name']=='Joomla'){
					$path_tmp='index.php?option=com_humo-gen&amp;task=mailform';
				}
				else{
					$path_tmp='mailform.php';
				}
				$eigenaar.='<a href="'.$path_tmp.'">'.$dataDb->tree_owner."</a><br>\n";
			}
			else{
				$eigenaar.=$dataDb->tree_owner."<br>\n";
			}
		}
		return $eigenaar;
	}

	//*** Most frequent names ***
	function achternamen(){
		global $db, $language, $user, $humo_option, $uri_pad, $cms;

		$persoonqry="SELECT pers_lastname, pers_prefix,
			CONCAT(pers_prefix,pers_lastname) as totaalnaam, count(pers_lastname) as aantal
			FROM ".veilig($_SESSION['tree_prefix'])."person
			WHERE pers_lastname NOT LIKE ''
			AND pers_lastname != 'doodgeboren kind'
			GROUP BY totaalnaam ORDER BY aantal DESC LIMIT 0,5";
		$persoon=mysql_query($persoonqry, $db);
		while (@$personDb=mysql_fetch_object($persoon)){
			//Een & teken mag niet meegestuurd worden in de GET, dus een replace naar | !!!
			$achternamen[]=$personDb->pers_lastname;
			$pers_prefix[]=$personDb->pers_prefix;
			$aantal[]=$personDb->aantal;
		}
		print $language["main_most_names"]."<br>";
		for ($i=0; $i<@count($achternamen); $i++){
			$top_pers_lastname='';
			if ($pers_prefix[$i]){ $top_pers_lastname=str_replace("_", " ", $pers_prefix[$i]); }
			$top_pers_lastname.=$achternamen[$i];

			if ($cms['cms_name']=='Joomla'){
				$path_tmp='index.php?option=com_humo-gen&amp;task=lijst&amp;database='.$_SESSION['tree_prefix'];
			}
			else{
				$path_tmp='lijst.php?database='.$_SESSION['tree_prefix'];
			}

			if ($user['soortindex']=="j"){
				//echo '<a href="lijst.php?database='.$_SESSION['tree_prefix'].'&amp;pers_lastname='.
				//str_replace("_", " ", $pers_prefix[$i]).str_replace("&", "|", $achternamen[$i]);
				echo '<a href="'.$path_tmp.'&amp;pers_lastname='.
				str_replace("_", " ", $pers_prefix[$i]).str_replace("&", "|", $achternamen[$i]);
			}
			else{
				$top_pers_lastname=$achternamen[$i];
				if ($pers_prefix[$i]){ $top_pers_lastname.=', '.str_replace("_", " ", $pers_prefix[$i]); }

				//echo '<a href="lijst.php?database='.$_SESSION['tree_prefix'].'&amp;pers_lastname='.
				//	str_replace("&", "|", $achternamen[$i]);
				echo '<a href="'.$path_tmp.'&amp;pers_lastname='.
					str_replace("&", "|", $achternamen[$i]);
				if ($pers_prefix[$i]){
					echo '&amp;pers_prefix='.addslashes($pers_prefix[$i]);
				}
				else{
					echo '&amp;pers_prefix=LEEG';
				}
			}
			echo '&amp;zoekdeelpers_lastname=gelijk">'.$top_pers_lastname."</a>";
			
			echo " (".$aantal[$i].")";

			if ($i<count($achternamen)-1){ echo ' / '; }
		}

	}

	// *** Search field ***
	function zoekvak(){
		global $language, $pers_firstname, $pers_lastname, $db, $zoekdatabase;
		global $search_partpers_firstname, $search_partpers_lastname;
		global $cms;

		if ($cms['cms_name']=='Joomla'){
			$path_tmp='index.php?option=com_humo-gen&amp;task=lijst';
		}
		else{
			$path_tmp='lijst.php';
		}
		print '<form method="post" action="'.$path_tmp.'">';
		print $language["main_firstname"].':<br>';
		print ' <select name="zoekdeelpers_firstname" style="width: 70px">';
		echo '<option value="bevat">'.$language["main_contains"].'</option>';
		$selecteer=''; if ($search_partpers_firstname=='gelijk'){ $selecteer=' selected'; }
		echo '<option value="gelijk"'.$selecteer.'>'.$language["main_equals"].'</option>';
		$selecteer=''; if ($search_partpers_firstname=='begint'){ $selecteer=' selected'; }
		echo '<option value="begint"'.$selecteer.'>'.$language["main_starts_with"].'</option>';
		print '</select>';
		print ' <input type="text" name="pers_firstname" value="'.$pers_firstname.'" size="15"><br>';

		print '<p>'.$language["main_lastname"].':<br>';
		print ' <select name="zoekdeelpers_lastname" style="width: 70px">';
		echo '<option value="bevat">'.$language["main_contains"].'</option>';
		$selecteer=''; if ($search_partpers_lastname=='gelijk'){ $selecteer=' selected'; }
		echo '<option value="gelijk"'.$selecteer.'>'.$language["main_equals"].'</option>';
		$selecteer=''; if ($search_partpers_lastname=='begint'){ $selecteer=' selected'; }
		echo '<option value="begint"'.$selecteer.'>'.$language["main_starts_with"].'</option>';
		print '</select>';
		print ' <input type="text" name="pers_lastname" value="'.$pers_lastname.'" size="15"></p>';

		// Kijken of er meerdere stambomen in de tabel staan.
		$datasql2 = mysql_query("SELECT * FROM humo_trees",$db);
		$num_rows2 = mysql_num_rows($datasql2);
		if ($num_rows2>1){
			$checked=''; if ($zoekdatabase=="geselecteerd"){ $checked='CHECKED'; }
			print '<INPUT TYPE="RADIO" NAME="zoekdatabase" value="geselecteerd" '.$checked.'> '.$language["main_selected_family_tree"].'<br>';
			$checked=''; if ($zoekdatabase=="allemaal"){ $checked='CHECKED'; }
			print '<INPUT TYPE="RADIO" NAME="zoekdatabase" value="allemaal" '.$checked.'> '.$language["main_all_family_trees"];
		}

		print '<p><input type="submit" value="'.$language["main_search"].'"></p>';

		if ($cms['cms_name']=='Joomla'){
			$path_tmp='index.php?option=com_humo-gen&amp;task=lijst&amp;adv_search=1';
		}
		else{
			$path_tmp='lijst.php?adv_search=1';
		}
		print '<p><a href="'.$path_tmp.'">'.$language["search_advanced"].'</a></p>';

		print "</form>\n";
	}

	// *** Extra links ***
	function extra_linken(){
		global $db, $humo_option, $uri_pad, $cms;
 
		// *** eerst controle of er linken gemaakt zijn.
		$datasql = mysql_query("SELECT * FROM humo_settings WHERE setting_variabele='link'",$db);
		@$num_rows = mysql_num_rows($datasql);
		if ($num_rows>0){
			include($cms['cms_path'].'include/person_cls.php');
			$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
				WHERE pers_own_code NOT LIKE ''",$db);
			while(@$personDb=mysql_fetch_object($persoon)){
				$datasql = mysql_query("SELECT * FROM humo_settings WHERE setting_variabele='link'",$db);
				while (@$dataDb=mysql_fetch_object($datasql)){
					$lijst=explode("|",$dataDb->setting_value);
					if ($personDb->pers_own_code==$lijst[0]){
						$persoon_cls = New persoon_cls;
						if ($cms['cms_name']=='Joomla'){
							$path_tmp='index.php?option=com_humo-gen&amp;task=family&amp;database='.$_SESSION['tree_prefix'].
								'&amp;id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber;
						}
						elseif ($humo_option["url_rewrite"]=="j"){
							// *** $uri_pad is gemaakt in header.php ***
							$path_tmp=$uri_pad.'gezin/'.$_SESSION['tree_prefix'].'/'.$personDb->pers_indexnr.
								'/'.$personDb->pers_gedcomnumber.'/';
						}
						else{
							$path_tmp= 'gezin.php?database='.$_SESSION['tree_prefix'].
								'&amp;id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber;
						}
						echo '<a href="'.$path_tmp.'">'.$persoon_cls->naam($personDb).'</a>';
				        echo " $lijst[1]<br>\n";
					}
				}		
			}
		}
	}

	// *** Alphabet line ***
	function alfabet(){
		global $language, $user, $db, $humo_option, $uri_pad, $cms;

		//*** Find first letter of last name ***
		print $language["main_lastnames"]."<br>\n";
		$persoonqry="SELECT UPPER(substring(pers_lastname,1,1)) as letter FROM ".veilig($_SESSION['tree_prefix'])."person GROUP BY letter";
		// *** Voor "van Mons", ook pers_prefix zoeken ***
		if ($user['soortindex']=="j"){
			$persoonqry="SELECT UPPER(substring(CONCAT(pers_prefix,pers_lastname),1,1)) as letter FROM ".veilig($_SESSION['tree_prefix'])."person GROUP BY letter";
		}
		@$persoon=mysql_query($persoonqry, $db);
		while (@$personDb=mysql_fetch_object($persoon)){ $letter[$personDb->letter]=$personDb->letter; }
		for ($i=1; $i<=26; $i++) {
			$letter2=chr($i+64); //chr(65)=A
			if (isset($letter[$letter2])){
				if ($cms['cms_name']=='Joomla'){
					$path_tmp='index.php?option=com_humo-gen&amp;task=lijst_namen&amp;database='.
					$_SESSION['tree_prefix'].'&amp;last_name='.$letter2;
				}
				elseif ($humo_option["url_rewrite"]=="j"){
					// *** url_rewrite ***
					// *** $uri_pad is gemaakt in header.php ***
					$path_tmp=$uri_pad.'lijst_namen/'.$_SESSION['tree_prefix'].'/'.$letter2.'/';
				}
				else{
					$path_tmp='lijst_namen.php?database='.$_SESSION['tree_prefix'].'&amp;last_name='.$letter2;
				}
				print ' <a href="'.$path_tmp.'">'.$letter2.'</a>';
			}
			else{
				print ' <b>'.$letter2.'</b>';
			}
		}

		if ($cms['cms_name']=='Joomla'){
			$path_tmp='index.php?option=com_humo-gen&amp;task=lijst&amp;pers_lastname=...';
		}
		else{
			$path_tmp='lijst.php?pers_lastname=...';
		}

		echo ' <a href="'.$path_tmp. '">'.$language["main_other"]."</a>\n";
	
		$persoon="SELECT pers_patronym FROM ".veilig($_SESSION['tree_prefix'])."person WHERE pers_patronym LIKE '_%' AND pers_lastname =''";
		@$personDb=mysql_query($persoon,$db);
		if (@mysql_num_rows($personDb)>0) {
			print ' <a href="lijst.php?index_list=patronym">'.$language["main_patronym_list"].'</a>';
		}

	}

}
?>
Return current item: HuMo-gen