Location: PHPKode > projects > HuMo-gen > admin/include/trees_cls.php
<?php
class tree_cls{

// *** List of trees ***
function tree_main(){
	global $language, $db, $page, $language_tree, $language_file, $menu_admin, $stamboom_id, $cms;

	echo '<br>';

	echo $language["trees_intro"].'<br>';

	// *** Moet op deze plaats om de radio button meteen goed weer te geven na wijzigen. ***
	include($cms['cms_path']."include/settings_global.php"); //Variabelen

	// *** Automatische update ***
	$datasql = mysql_query("SELECT * FROM humo_trees",$db);
	$dataDb=mysql_fetch_object($datasql);
	$aantal=mysql_num_rows($datasql);
	if ($aantal>0){
		if (!isset($dataDb->tree_email)){
			$sql="ALTER TABLE humo_trees ADD tree_email VARCHAR( 100 ) NOT NULL,
				ADD tree_owner VARCHAR( 100 ) NOT NULL,
				ADD tree_pict_path VARCHAR( 100 ) NOT NULL;
				";
			$result=mysql_query($sql) or die(mysql_error());
		}
		if (!isset($dataDb->tree_privacy)){
			$sql="ALTER TABLE humo_trees ADD tree_privacy VARCHAR ( 50 ) NOT NULL ;";
			$result=mysql_query($sql) or die(mysql_error());
		}
	}

	echo '<table class="humo" border="1" cellspacing="0" width="100%">';
	echo '<tr class="tabel_kop"><th>'.$language["trees_order"].'</th>';
		echo '<th>'.$language["trees_name_2"].'</th>';
		echo '<th>'.$language["trees_treedata"].'</th>';
		//echo '<th>'.$language["admin_select"].'</th>';
		echo '<th>'.$language["admin_remove"].'</th>';
	echo '</tr>';

	echo '<tr class="tabel_kop">';
	echo '<td></td>';
	echo '<th>';
		// *** Talen knoppen ***
		for ($i=0; $i<count($language_file); $i++){
			// *** Get language name ***
			include($cms['cms_path'].'languages/'.$language_file[$i].'/language_data.php');
			//echo '<a href="index.php?page=tree&amp;language_tree='.$language_file[$i].'" style="border-right:none; background:none;">';
			echo '<a href="index.php?page=tree&amp;language_tree='.$language_file[$i].'&amp;stamboom_id='.$stamboom_id.'" style="border-right:none; background:none;">';
			echo '<img src="'.$cms['cms_path'].'languages/'.$language_file[$i].'/flag.gif" title="'.$language["name"].'" alt="'.$language["name"].'"';
			if ($language_tree!=$language_file[$i]){ echo ' style="border:none;"'; }
			echo '></a>';
			echo ' ';
		}
	echo '</th>';
	echo '<td></td>';
	echo '<td></td>';
	echo '</tr>';

	// *** Nummer voor een nieuwe stamboom ***
	$nieuw_nummer='1';
	$regel=0;
	$datasql = mysql_query("SELECT * FROM humo_trees ORDER BY tree_order",$db);
	if ($datasql){
	// *** Aantal regels in querie ***
	$aantal=mysql_num_rows($datasql);
	while ($dataDb=mysql_fetch_object($datasql)){
		$regel++;

		$stijl=''; if ($stamboom_id==$dataDb->tree_id){ $stijl=' bgcolor="#99CCFF"'; }
		echo '<tr'.$stijl.'>';
		print '<td nowrap>';
		if ($dataDb->tree_order<10){ echo '0'; }
		echo $dataDb->tree_order;
		// *** Nummer voor een nieuwe stamboom ***
		$nieuw_nummer=$dataDb->tree_order+1;
		if ($dataDb->tree_order!='1'){
			echo ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'&amp;up=1&amp;volgorde='.$dataDb->tree_order.
			'&amp;id='.$dataDb->tree_id.'"><img src="'.$cms['cms_path_admin'].'images/pijl-hoog.gif" border="0" alt="up"></a>'; }
		if ($dataDb->tree_order!=$aantal){
			echo ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'&amp;down=1&amp;volgorde='.$dataDb->tree_order.'&amp;id='.
			$dataDb->tree_id.'"><img src="'.$cms['cms_path_admin'].'images/pijl-laag.gif" border="0" alt="down"></a>'; }
		echo '</td>';

		echo '<td>';
			
		$treetext_name=database_name($dataDb->tree_prefix, $language_tree);
		if ($dataDb->tree_prefix=='LEEG'){
			echo '* '.$language["trees_empty_line"].' *';
		}
		//elseif ($treetext_name==$language["main_tree_no_name"]){
		//	echo ' <font color="#FF0000"><b>'.$treetext_name.'<b></font>';
		//}
		else{
			echo ' '.$treetext_name;
		}

	echo '</td>';
	echo '<td>';

		if ($dataDb->tree_prefix=='LEEG'){
			//
		}
		elseif ($dataDb->tree_persons>0){ echo ' <font color="#00FF00"><b>'.$language["admin_ok"].'</b></font>'; }
			else{ echo ' <font color="#FF0000"><b>'.$language["admin_fault"].'!</b></font>'; }

		if ($dataDb->tree_prefix=='LEEG'){
			//
		}
		elseif ($dataDb->tree_persons>0){
			$datum=$dataDb->tree_date;
			$maand=''; //voor lege datums
			if (substr($datum,5,2)=='01'){ $maand=' jan ';}
			if (substr($datum,5,2)=='02'){ $maand=' feb ';}
			if (substr($datum,5,2)=='03'){ $maand=' mrt ';}
			if (substr($datum,5,2)=='04'){ $maand=' apr ';}
			if (substr($datum,5,2)=='05'){ $maand=' mei ';}
			if (substr($datum,5,2)=='06'){ $maand=' jun ';}
			if (substr($datum,5,2)=='07'){ $maand=' jul ';}
			if (substr($datum,5,2)=='08'){ $maand=' aug ';}
			if (substr($datum,5,2)=='09'){ $maand=' sep ';}
			if (substr($datum,5,2)=='10'){ $maand=' okt ';}
			if (substr($datum,5,2)=='11'){ $maand=' nov ';}
			if (substr($datum,5,2)=='12'){ $maand=' dec ';}
			//$datum=substr($datum,8,2).$maand.substr($datum,0,4)." ".substr($datum,11,5);
			$datum=substr($datum,8,2).$maand.substr($datum,0,4);
			print ' <font size=-1>'.$datum.': '.$dataDb->tree_persons.$language["main_nr_persons"].', '.$dataDb->tree_families.$language["main_nr_fams"].'</font>';
		}
		else{
			echo ' <b>'.$language["trees_nodata"].'</b>';
		}

	echo '</td>';
	echo '<td nowrap>';
		echo ' <a href="index.php?&amp;page='.$page.'&amp;verwijder='.$dataDb->tree_id.'&amp;treetext_name='.$treetext_name.'">';
		print '<img src="'.$cms['cms_path_admin'].'images/button_drop.png" alt="Verwijder stamboom" border="0"></a>';
	echo '</td>';
	}

	echo '</tr>';
	}

	// *** Nieuwe stamboom toevoegen ***

	// *** Laatste tree_prefix zoeken ***
	$gevonden='1'; $i=1;
	while ($gevonden=='1'){
		$nieuw_tree_prefix='humo'.$i.'_';
		$datasql = mysql_query("SELECT * FROM humo_trees
			WHERE tree_prefix='$nieuw_tree_prefix'",$db);
		$gevonden=mysql_num_rows($datasql);
		$i++;
	}

	echo '<tr><td colspan="4"><br></td></tr>';

	echo '<tr><td>';
		if ($nieuw_nummer<10){ echo '0'; }
		echo $nieuw_nummer.'</td>';
		echo '<td colspan="3">';
			print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
			echo '<input type="hidden" name="page" value="'.$page.'">';
			echo '<input type="hidden" name="volgorde" value="'.$nieuw_nummer.'">';
			//echo '<b>'.$language["trees_name_2"].':</b> <input type="text" name="naam" value="'.$language["trees_name_2"].'" size="25">';
			echo ' <b>'.$language["trees_prefix"].':</b> <input type="text" name="tree_prefix" value="'.$nieuw_tree_prefix.'" size="10">';
			echo ' <input type="Submit" name="toevoegen" value="'.$language["trees_add"].'">';
			echo '</form>';
	echo '</td></tr>';

	echo '<tr><td colspan="4"><br></td></tr>';

	echo '<tr>';
	echo '<td>';
	if ($nieuw_nummer<10){ echo '0'; }
	echo $nieuw_nummer.'</td>';
	echo '<td colspan="3">';
		print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
		echo '<input type="hidden" name="page" value="'.$page.'">';
		echo '<input type="hidden" name="volgorde" value="'.$nieuw_nummer.'">';
		echo ' <input type="Submit" name="toevoegen_leeg" value="'.$language["empty_add"].'"> ';
		echo $language["empty_add2"];
		echo '</form>';
	echo '</td>';
	echo '</tr>';

	print "</table>";
}

function tree_data(){
	global $language, $data2Db, $page, $menu_admin;

	print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
	echo '<input type="hidden" name="page" value="'.$page.'">';
	echo '<input type="hidden" name="stamboom_id" value="'.$data2Db->tree_id.'">';
	echo '<input type="hidden" name="menu_admin" value="'.$menu_admin.'">';

	print '<br><table class="humo" cellspacing="0" width="100%" style="background-color : #CCFFFF;">';
		echo '<tr class="tabel_kop"><th colspan="2">'.$language["trees_treedata"].'</th></tr>';

		echo '<tr><td>'.$language["trees_prefix"].'</td><td>'.$data2Db->tree_prefix.'</td></tr>';

		print  '<tr><td>'.$language["trees_email"].'<br>'.$language["trees_owner"].'</td>';
		print '<td>'.$language["trees_email2"].'<br><input type="text" name="email" value="'.$data2Db->tree_email.'" size="40"><br>';
		print '<input type="text" name="eigenaar" value="'.$data2Db->tree_owner.'" size="40"></td></tr>';
		print '<tr><td>'.$language["trees_pict_path"].'</td>';
			$data2Db->tree_pict_path.'</textarea></td></tr>';
		print '<td>'.$language["trees_pict_path2"].'<br><textarea rows="1" cols="20" name="afbpad" style="height: 20px; width:500px">'.
			$data2Db->tree_pict_path.'</textarea></td></tr>';

		// *** Stamboom privacy ***
		print '<tr><td>'.$language["trees_privacy"].':</td>';
		print '<td>'.$language["trees_privacy2"].'<br><select size="1" name="privacy_stamboom">';
		echo '<option value="Standaard">'.$language["trees_priv1"].'</option>';
		$select=''; if ($data2Db->tree_privacy=='personen_filteren'){ $select='selected'; }
		echo '<option value="personen_filteren"'.$select.'>'.$language["trees_priv2"].'</option>';
		$select=''; if ($data2Db->tree_privacy=='personen_weergeven'){ $select='selected'; }
		echo '<option value="personen_weergeven"'.$select.'>'.$language["trees_priv3"].'</option>';
		print '</select>';
		print '</td></tr>';

		echo '<tr><td>'.$language["admin_change"].'</td><td><input type="Submit" name="wijzigen" value="'.$language["admin_change"].'">';

		echo '</td></tr>';
	print '</table>';
	print '</form>';
}

function tree_text(){
	global $language, $page, $stamboom_id, $language_tree, $treetext_name, $language_file, $data2Db;
	global $treetext_mainmenu_text, $treetext_mainmenu_source, $treetext_family_top, $treetext_family_footer, $tekst_id, $menu_admin;
	global $cms;

	print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
	echo '<input type="hidden" name="page" value="'.$page.'">';
	echo '<input type="hidden" name="stamboom_id" value="'.$stamboom_id.'">';
	echo '<input type="hidden" name="menu_admin" value="'.$menu_admin.'">';
	echo '<input type="hidden" name="language_tree" value="'.$language_tree.'">';
	if (isset($tekst_id)){ echo '<input type="hidden" name="tekst_id" value="'.$tekst_id.'">'; }

	print '<br><table class="humo" cellspacing="0" width="100%" style="background-color : #CCFFFF;">';
	echo '<tr class="tabel_kop"><th colspan="2">'.$language["trees_treetext"].'</th></tr>';

	echo '<tr><td colspan="2">';
	echo $language["trees_test_explanation"].'<br>';
	// *** Talen knoppen ***
	for ($i=0; $i<count($language_file); $i++){
		// *** Get language name ***
		include($cms['cms_path'].'languages/'.$language_file[$i].'/language_data.php');
		//echo '<a href="index.php?page=tree&amp;menu_admin=tree_text&amp;language_tree='.$language_file[$i].'" style="border-right:none; background:none;">';
		echo '<a href="index.php?page=tree&amp;menu_admin=tree_text&amp;language_tree='.$language_file[$i].'&amp;stamboom_id='.$stamboom_id.'" style="border-right:none; background:none;">';
		echo '<img src="'.$cms['cms_path'].'languages/'.$language_file[$i].'/flag.gif" title="'.$language["name"].'" alt="'.$language["name"].'"';
		if ($language_tree!=$language_file[$i]){ echo ' style="border:none;"'; }
		echo '></a> ';
	}
	echo '</td></tr>';

	echo '<tr><td><b>'.$language["trees_name_2"].'</b></td><td><input type="text" name="treetext_name" value="'.$treetext_name.'" size="80"></td></tr>';

	print '<tr><td>'.$language["trees_mainmenu_text"].'</td>';
	echo '<td>';
	print $language["trees_mainmenu_source2"].': &lt;a href="http://www.website.com"&gt;www.website.com&lt;/a&gt;<br>';
	echo '<textarea cols="60" rows="2" name="treetext_mainmenu_text">'.$treetext_mainmenu_text.'</textarea>';
	echo '</td>';

	print '<tr><td>'.$language["trees_mainmenu_source"].'</td>';
	echo '<td>';
	print $language["trees_mainmenu_source2"].': &lt;a href="http://www.website.com"&gt;www.website.com&lt;/a&gt;<br>';
	echo '<textarea cols="60" rows="2" name="treetext_mainmenu_source">'.$treetext_mainmenu_source.'</textarea>';
	echo '</td></tr>';

	print '<tr><td>'.$language["treetext_family_top"].'</td>';
	print '<td>'.$language["treetext_family_top2"].'<br>';
	echo '<textarea cols="60" rows="1" name="treetext_family_top">'.$treetext_family_top.'</textarea>';
	echo '</td></tr>';

	print '<tr><td>'.$language["treetext_family_footer"].'</td>';
	print '<td>'.$language["treetext_family_footer2"].'<br>';
	echo '<textarea cols="60" rows="1" name="treetext_family_footer">'.$treetext_family_footer.'</textarea>';
	echo '</td></tr>';

	if (isset($tekst_id)){
		echo '<tr><td>'.$language["admin_change"].'</td><td><input type="Submit" name="wijzig_teksten" value="'.$language["admin_change"].'">';
	}
	else{
		echo '<tr><td>'.$language["admin_change"].'</td><td><input type="Submit" name="toevoegen_teksten" value="'.$language["admin_change"].'">';
	}

	echo '</table>';
	print '</form>';
}

} // *** End of class ***
?>
Return current item: HuMo-gen