adamTablaPlugin Ez a plugin csinálja meg a táblás CRUDot, amit bemutattam. Adam Szanto **/ class adamTablaPlugin { var $tableObject; function adamTablaPlugin ($arguments="") { $db = $arguments['db']; $table = $arguments['table']; $thisTable = new table($table,$db); // Instantiating New Table Object $this->tableObject = $thisTable; // Setting table Object in Local variable } function generate() { $thisTable = $this->tableObject; // The things you can get from $thisTable are $thisHostName = $thisTable->getDatabaseHost(); // Database Server Address $thisUserName = $thisTable->getDbUserName(); // Database UserName being used $thisDbPassword = $thisTable->getDbPassword(); // User password used to access database $thisDbName = $thisTable->getDatabase(); // Database connected to $thisTableName = $thisTable->getTableName(); // Name of the table Selected $thisTablesArray = $thisTable->getDbTables(); // All Tables in Database $thisFieldNameArray = $thisTable->getFieldNameArray(); // Array with all fieldNames (Strings) $thisFieldInfoArray = $thisTable->getFieldInfoArray(); // Array of Fields with all meta data (fieldInfo Objects) $thisPrimaryKey = $thisTable->getPrimaryKey(); // Primary Key of the current table //$code = ""; //$code .= "You are connected to : ".$thisHostName."
\n"; //$code .= "You are connected as : ".$thisUserName."

\n"; if (isset($_POST['tabla_field'])) { //< $mezok=$_POST['tabla_field']; $recname=substr($thisTableName,0,-1); $q='show fields from '.$thisTableName; $mezok_r=mysql_query($q) or print(mysql_error()); $mezo_data=array(); while ($mezo_elem=mysql_fetch_array($mezok_r)) $mezo_data[$mezo_elem['Field']]=$mezo_elem['Type']; $code=' $a) //< $code.=$mezo.', '; $code=substr($code, 0, -2).') VALUES ('; foreach ($mezok as $mezo => $a) //< $code.=get_code_of($recname, $mezo_data, $mezo).", "; $code=substr($code, 0, -2).")';\n mysql_query(\$q) or print(mysql_error());\n\n". ' break;'."\n".' case "edit":'."\n"; $elso_mezohoz=array_keys($mezok); $code.=' if (isset($_POST['."'".$recname."_".strtolower($elso_mezohoz[0])."'".'])) {'."\n". " \$q='UPDATE ".$thisTableName." SET "; foreach ($mezok as $mezo => $a) //< $code.=$mezo.'='.get_code_of($recname, $mezo_data, $mezo).', '; $code=substr($code, 0, -2)." WHERE ID='.\$_GET['id'];\n mysql_query(\$q) or print(mysql_error());\n". ' } else {'."\n".' $q='."'SELECT "; $osszes=array(); for ($a=0;$a'."\n"; $code.=""; foreach ($mezok as $mezo => $value_ami_egyaltalan_nem_kell_senkinek_sem) //< $code.="\n"; $code.="\n\n". "\n\n"; $code.="'; foreach($mezok as $mezo => $a) //< $code.='\n".'."\n ".'"'; $id_var='$'.$recname.'['."'".'ID'."'".']'; $code.='\n".'."\n ". '"\n\n";'."\n\n"; $code.='?>
".$mezo."SzerkesztTöröl
".$'.$recname.'['."'".$mezo."'".']."XX

'."\n\n".''."\n". '

Elem szerkesztő

'."\n". '
">'."\n\n". ''; foreach($mezok as $mezo => $a) { //< $code.=''."\n".''."\n\n"; } $code.='
'.$mezo.' :   '; $hossz=strstr($mezo_data[$mezo], "("); if (strlen($hossz)!=0) { $hossz=substr($hossz, 1, -1); } if ($mezo_data[$mezo]=='text') { $code.=''; } else { $code.='>'; //" } $code.='


'."\n". '
'; highlight_string($code); exit; $code=''; } else { $lista='?'; foreach ($_GET as $k => $val) //< $lista.=$k."=".urlencode($val)."&"; $lista=substr($lista, 0, -1); $code = "


\n"; $code.="Melyik mezők kerüljenek be?

\n"; for ($a=0;$a".$thisFieldName."
\n"; } $code.='

'; } // Returning Generated Code return $code; } } // end of myDbPlugin class function eleje_of ($dolog, $resz) { return (substr($dolog, 0, strlen($resz))==$resz); } function get_code_of($recname, $mezo_data, $mezo) { if (eleje_of($mezo_data[$mezo], 'varchar') || $mezo_data[$mezo]=='text') { $cucc='"'."'".'.mysql_escape_string($'.$recname.'_'.strtolower($mezo).').'."'".'"'; } else { $cucc="'".'.mysql_escape_string($'.$recname.'_'.strtolower($mezo).').'."'"; } return $cucc; } ?>