Login   Register  
PHP Classes
elePHPant
Icontem

File: admin_xml

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of AUDUTEAU  >  admin_XML.lib  >  admin_xml  >  Download  
File: admin_xml
Role: ???
Content type: text/plain
Description: the admin class
Class: admin_XML.lib
Author: By
Last change:
Date: 13 years ago
Size: 11,263 bytes
 

Contents

Class file image Download
<?
/*	
	***************************************************************************
	Sur-couche apportée à XMLbasica afin de gérer l'interface d'administration.
	
	Cette applicatif repose sur la couche XMLBasica développée par C-Kit Leong as "BasicA"


 * Author : AUDUTEAU Alain
 * SiteURL: http://www.auduteau.net
 * Date   : 29/05/2001 (DD/MM/YY)

	***************************************************************************
*/
// ---------------------------------------------------------------------------
//	Function	XML_FileDisplay( $FileName )
//
//	Affiche la liste des occurrences du fichier XML passé en référence
// ---------------------------------------------------------------------------
Function XML_FileDisplay( $FileName )
{
	Global $TrtFile;
	Global $Title;
	Global $smallactions;
	Global $actions;

	$SearchData = "";
	
	$SearchData  = XML_DBarrayDump($TrtFile, $DB, $REC, $cntREC, $cntFLD, $FLD);
	
  	print "<table width=\"100%\" cellpadding=\"3\" border=\"1\" cellspacing=\"0\">";
// Affichage de l'entete du tableau		

	print "<tr bgcolor=\"" . C_bgTitle . "\"><td align=\"center\" colspan=\"" . ($cntFLD + 1) . "\"><font size=\"+1\"><b>" .  $FileName . "</b></font></td><td align=\"center\" colspan=\"4\"><b>Actions</b></td></tr>";
	print "<tr bgcolor=\"" . C_bgAction . "\" size=\"20\">";

	print "<td align=\"center\"><b>N°</b></td>";
	
	for ( $f = 0; $f < $cntFLD; $f++ )
	{
		print "<td valign=\"top\" align=\"center\"><b>" . $FLD[$f] . "</b></td>" ;
	}
	print "<td align=\"center\"><b>" . $smallactions[5] . "</b></td>";
	print "<td align=\"center\"><b>" . $smallactions[2] . "</b></td>";
	print "<td align=\"center\"><b>" . $smallactions[3] . "</b></td>";
	print "<td align=\"center\"><b>" . $smallactions[4] . "</b></td>";
	print "</tr>"; 
	
// Affichage du contenu du tableau		
	for ($i = 0; $i < $cntREC; $i++) {
		print "<tr>"; 

		// Permet d'intégrer un type de navigation inter fichiers XML
		// Inclut la variable $NextFile utilisée après.

		Include ( C_ABSTRACT_INC_PTH . "/admin/table_navigation.inc");

	// Affiche les données du fichier XML		
		for ( $f = 0; $f < $cntFLD; $f++ )
		{
			print "<td  bgcolor=\"" . C_bgColumn . "\" valign=\"top\" align=\"left\">";
			IF (trim($SearchData[$i][$f]) == "" ) {
				print "&nbsp;";
			} else {
				If (strlen($SearchData[$i][$f]) >14 ) 
				{
					print substr($SearchData[$i][$f],0,15) ."...";
				} else {
					print $SearchData[$i][$f];
				}
				
			}
			print "</td>";
		}
		print "<td  bgcolor=\"" . C_bgAction . "\" align=\"center\"><a href=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $actions[5] . "&record=" . ($i + 1) . "\" title=\"" . $Title[2] . "\">" . $smallactions[5] . "</a></td>";
		print "<td  bgcolor=\"" . C_bgAction . "\" align=\"center\"><a href=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $actions[2] . "&record=" . ($i + 1) . "\" title=\"" . $Title[3] . "\">" . $smallactions[2] . "</a></td>";
		print "<td  bgcolor=\"" . C_bgAction . "\" align=\"center\"><a href=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $actions[3] . "&record=" . ($i + 1) . "\" title=\"" . $Title[4] . "\">" . $smallactions[3] . "</a></td>";
		print "<td  bgcolor=\"" . C_bgAction . "\" align=\"center\"><a href=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $actions[4] . "&record=" . ($i + 1) . "\" title=\"" . $Title[5] . "\">" . $smallactions[4] . "</a></td>";
		print "</tr>"; 
	}
  	print "</table>"; 
}

// ---------------------------------------------------------------------------
//	Function	XML_FORM_RecordDisplay( $FileName, $Record )
//
//	Affiche l'occurrence du fichier XML passé en référence
// ---------------------------------------------------------------------------
Function	XML_FORM_RecordDisplay( $FileName, $record )
{
	Global $TrtFile;
	Global $FormTitle;

	$SearchData = "";
	
	$SearchData  = XML_DBarrayDump($TrtFile, $DB, $REC, $cntREC, $cntFLD, $FLD);

	$DataRecord = ($record - 1);

	print "<div align=\"center\">";
  	print "<table bgcolor=\"" . C_bgAction . "\" width=\"80%\" cellpadding=\"5\" border=\"1\" cellspacing=\"0\">";

	print "<tr><td colspan=\"2\" valign=\"top\" align=\"center\"><h3>" . $FormTitle[5] . $DataRecord . "</H3></td></tr>";

	for ( $f = 0; $f < $cntFLD; $f++ )
	{
		print "<tr>"; 
		print "<td width=\"60\" valign=\"top\" align=\"left\">";
		print $FLD[$f]. " :";
		print "</td>";
		print "<td valign=\"top\" align=\"left\">";
		print "<Font color=\"darkblue\">" ;
		IF (trim($SearchData[$DataRecord][$f])== "") 
		{ 
			print "&nbsp;"; 
		} else {
			print trim($SearchData[$DataRecord][$f]); 
		}
		Print "</font></td></tr>"; 
	}
  	print "</table>"; 
	print "</div>";
}

// ---------------------------------------------------------------------------
//	Function	XML_FORM_Recordupdate( $FileName, $record, $action )
//	
//	Affiche le formulaire de saisie de l'occurence sélectionnée
// ---------------------------------------------------------------------------
Function	XML_FORM_Recordupdate( $FileName, $record, $action )
{
	Global $TrtFile;
	Global $actions;
	Global $FormTitle;

	IF ($action == $actions[5] ) 
	{
		XML_FORM_RecordDisplay( $FileName, $record );
		Return True;
	}

	$SearchData = "";
	
	// Le n° d'enregistrement passé est surpondéré de 1. On le décrémente donc
	$DataRecord = ($record - 1);
	
	$SearchData  = XML_DBarrayDump($TrtFile, $DB, $REC, $cntREC, $cntFLD, $FLD);

	print "<div align=\"center\">";
  	print "<table bgcolor=\"" . C_bgTitle . "\" width=\"80%\" cellpadding=\"5\" border=\"1\" cellspacing=\"0\">";
	print "<tr>"; 
	print "<td>"; 
	
	print "<FORM action=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $action ."&record=" . $record . "\" encType=\"multipart/form-data\" method=\"post\" name=\"frmRecord\">";
  	print "<table cellpadding=\"5\" border=\"0\" cellspacing=\"0\">";

		IF ( $action == $actions[2] || $action == $actions[1]) 
		{
			print "<tr>"; 
			print "<td colspan=\"2\" valign=\"top\" align=\"center\"><h3>" ;
			If ( $action == $actions[2] ) // insert
			{
				Print $FormTitle[1] . $DataRecord ;
			} else {	// Ajout
				Print $FormTitle[2] ;
			}
			print "</h3></td><br>";
			print "</tr>";
			for ( $f = 0; $f < $cntFLD; $f++ )
			{
				print "<tr>"; 
				print "<td width=\"60\" valign=\"top\" align=\"left\">";
				print $FLD[$f]. " :";
				print "</td>";
				print "<td valign=\"top\" align=\"left\">";
				print "<INPUT name=\"" .$FLD[$f]. "\" size=\"100\" type=\"text\" value=\"\"></INPUT>";
				print "</td>";
				print "</tr>"; 
			}
			print "<tr>"; 
			print "<td width=\"60\" valign=\"top\" align=\"left\">Document :";
			print "</td>";
			print "<td valign=\"top\" align=\"left\">";
			print "<INPUT type=\"file\" name=\"UpLoad\" size=\"50\"></input>";
			print "</td>";
			print "</tr>"; 
		} else {
			print "<tr>"; 
			print "<td colspan=\"2\" valign=\"top\" align=\"center\"><h3>" ;
			If ( $action == $actions[3] ) // update
			{
				Print $FormTitle[3] . $DataRecord ;
			} else { // delete
				Print $FormTitle[4] . $DataRecord ;
			}
			print "</h3></td><br>";
			print "</tr>";
			for ( $f = 0; $f < $cntFLD; $f++ )
			{
				print "<tr>"; 
				print "<td width=\"60\" valign=\"top\" align=\"left\">";
				print $FLD[$f]. " :";
				print "</td>";
				print "<td valign=\"top\" align=\"left\">";
				print "<INPUT name=\"" .$FLD[$f]. "\" size=\"100\" type=\"text\" value=\"" . trim($SearchData[$DataRecord][$f]). "\"></INPUT>";
				print "</td>";
				print "</tr>"; 
			}
		}
		
	print "<tr>"; 
	print "<td>&nbsp;</td><td>"; 
	print "<INPUT name=\"submit\" type=\"submit\" value=\"" . ucfirst($action) . "\"></INPUT>&nbsp;&nbsp;";
	print "<INPUT name=\"reset\" type=\"reset\" value=\"" . ucfirst($actions[7]) . "\"></INPUT>";
	print "</td>";
	print "</tr>"; 
  	print "</table>"; 
 	print "<form>"; 
	print "</td>";
	print "</tr>"; 
  	print "</table>"; 
	print "</div>";
}
// ---------------------------------------------------------------------------
//	Function	XML_AddColumn( $FileName )
//
//	Add a column to the data and assign the default value 
// ---------------------------------------------------------------------------
Function	XML_FORM_DBAddColumn( $FileName )
{
		Global $FormTitle;
		Global $actions;

		print "<div align=\"center\">";
  		print "<table bgcolor=\"" . C_bgTitle . "\" width=\"80%\" cellpadding=\"5\" border=\"1\" cellspacing=\"0\">";
		print "<tr>"; 
		print "<td>"; 
	
		print "<FORM action=\"" . C_ADMIN_APP . "?FileName=" . $FileName . "&action=" . $actions[6] . "\" encType=\"multipart/form-data\" method=\"post\" name=\"frmColumn\">";
  		print "<table cellpadding=\"5\" border=\"0\" cellspacing=\"0\">";
		print "<tr>"; 
		print "<td colspan=\"2\" valign=\"top\" align=\"center\"><h3>" ;
		Print $FormTitle[6] ;
		print "</h3></td><br>";
		print "</tr>";

		print "<tr>"; 
		print "<td width=\"120\" valign=\"top\" align=\"left\">";
		print $FormTitle[7];
		print "</td>";
		print "<td valign=\"top\" align=\"left\">";
		print "<INPUT name=\"XMLColumn\" size=\"100\" type=\"text\" value=\"\"></INPUT>";
		print "</td>";
		print "</tr>"; 
  		
		print "<tr>"; 
		print "<td width=\"120\" valign=\"top\" align=\"left\">";
		print $FormTitle[8];
		print "</td>";
		print "<td valign=\"top\" align=\"left\">";
		print "<INPUT name=\"default\" size=\"100\" type=\"text\" value=\"\"></INPUT>";
		print "</td>";
		print "</tr>"; 
  		
		print "<tr>"; 
		print "<td>&nbsp;</td><td>"; 
		print "<INPUT name=\"submit\" type=\"submit\" value=\"" . ucfirst($actions[6]) . "\"></INPUT>&nbsp;&nbsp;";
		print "<INPUT name=\"reset\" type=\"reset\" value=\"" . ucfirst($actions[7]) . "\"></INPUT>";
		print "</td>";
		print "</tr>"; 
  		print "</table>"; 
 		print "<form>"; 
		print "</td>";
		print "</tr>"; 
  		print "</table>"; 
		print "</div>";
}

// ---------------------------------------------------------------------------
//	Function	XML_DBAddColumn( $FileName, $Record, $Default )
//
//	Add a column to the data and assign the default value 
// ---------------------------------------------------------------------------
Function	XML_DBAddColumn( $XMLFile, $XMLColumn, $Default )
{

	IF ( $XMLColumn != "" ) {
		$XMLArray  = XML_DBarrayDump($XMLFile, $DB, $REC, $cntREC, $cntFLD, $FLD);

		//Search if $XMLColumn dos not exist
		for ($flds = 0; $flds < $cntFLD; $flds++) {
			if (strtolower(trim($XMLColumn)) == strtolower(trim($FLD[$flds]))) {
				$ErrorMsg = "<dir>The column name <h4><dir>" . $XMLColumn . "</dir></h4> so exist in file ". $XMLFile . " !</dir>" ;
				return false;
			}
		}

		//Add column.
		$FLD[$cntFLD] = $XMLColumn;
		$cntFLD ++;

		for ($i = 0; $i < $cntREC; $i++) {
			$XMLArray[$i][$cntFLD-1] = $Default;
		}

		//Update XML File.
		XML_DBwriteFile($XMLFile, $XMLArray, $DB, $REC, $FLD, $cntREC, $cntFLD);

		return true;
	} else {
		$ErrorMsg = "<dir>The column name <h4><dir>" . $XMLColumn . "</dir></h4> does not exist in file <h5>". $XMLFile . " !</h5></dir>" ;
		return false;
	}

}

?>