mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-01-26 04:31:14 +01:00
module creator extended to use short table alias
This commit is contained in:
parent
dbf5201c20
commit
c6fe8a736b
@ -52,6 +52,7 @@ if ($argc >= 2) {
|
|||||||
$template_edit_file_name = $module_name . "_edit.tpl";
|
$template_edit_file_name = $module_name . "_edit.tpl";
|
||||||
$target_php_folder = "../../www/pages/";
|
$target_php_folder = "../../www/pages/";
|
||||||
$target_tpl_folder = "../../www/pages/content/";
|
$target_tpl_folder = "../../www/pages/content/";
|
||||||
|
$table_short_name = substr($module_name,0,1);
|
||||||
|
|
||||||
if (!$force && file_exists($target_php_folder.$php_file_name)) {
|
if (!$force && file_exists($target_php_folder.$php_file_name)) {
|
||||||
echo("File exists: ." .$target_php_folder.$php_file_name . "\n");
|
echo("File exists: ." .$target_php_folder.$php_file_name . "\n");
|
||||||
@ -82,6 +83,7 @@ if ($argc >= 2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
$sql_columns = array();
|
||||||
$edit_form = "";
|
$edit_form = "";
|
||||||
|
|
||||||
/* Iterate through the result set */
|
/* Iterate through the result set */
|
||||||
@ -96,6 +98,7 @@ if ($argc >= 2) {
|
|||||||
|
|
||||||
if ($value != 'id') {
|
if ($value != 'id') {
|
||||||
$columns[] = $value;
|
$columns[] = $value;
|
||||||
|
$sql_columns[] = $table_short_name.".".$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -126,6 +129,8 @@ if ($argc >= 2) {
|
|||||||
|
|
||||||
$list_of_columns = implode(', ', $columns);
|
$list_of_columns = implode(', ', $columns);
|
||||||
$list_of_columns_in_quotes = "'" . implode('\', \'', $columns) . "'";
|
$list_of_columns_in_quotes = "'" . implode('\', \'', $columns) . "'";
|
||||||
|
$sql_list_of_columns = implode(', ', $sql_columns);
|
||||||
|
$sql_list_of_columns_in_quotes = "'" . implode('\', \'', $sql_columns) . "'";
|
||||||
|
|
||||||
$get_input = "";
|
$get_input = "";
|
||||||
$set_input = "";
|
$set_input = "";
|
||||||
@ -147,11 +152,12 @@ if ($argc >= 2) {
|
|||||||
$php_file_contents = str_replace('PLACEHOLDER_LIST', $module_name . "_list", $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_LIST', $module_name . "_list", $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_EDIT', $module_name . "_edit", $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_EDIT', $module_name . "_edit", $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_DELETE', $module_name . "_delete", $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_DELETE', $module_name . "_delete", $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_SQL_LIST', "SELECT id, $list_of_columns, id FROM $module_name", $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_SQL_LIST', "SELECT $table_short_name.id, $sql_list_of_columns, $table_short_name.id FROM $module_name $table_short_name", $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_SQL_EDIT', "INSERT INTO $module_name ($list_of_columns, id) values ('\".implode('\', \'',\$input).\"', \$id) ON DUPLICATE KEY UPDATE SET ", $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_SQL_EDIT', "INSERT INTO $module_name ($list_of_columns, id) values ('\".implode('\', \'',\$input).\"', \$id) ON DUPLICATE KEY UPDATE SET ", $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_GET_INPUT', $get_input, $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_GET_INPUT', $get_input, $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_SET_INPUT', $set_input, $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_SET_INPUT', $set_input, $php_file_contents);
|
||||||
$php_file_contents = str_replace('PLACEHOLDER_COLUMNS', $list_of_columns_in_quotes, $php_file_contents);
|
$php_file_contents = str_replace('PLACEHOLDER_COLUMNS', $list_of_columns_in_quotes, $php_file_contents);
|
||||||
|
$php_file_contents = str_replace('PLACEHOLDER_SQL_COLUMNS', $sql_list_of_columns_in_quotes, $php_file_contents);
|
||||||
|
|
||||||
$php_file = fopen($target_php_folder . $php_file_name, "w");
|
$php_file = fopen($target_php_folder . $php_file_name, "w");
|
||||||
if (empty($php_file)) {
|
if (empty($php_file)) {
|
||||||
|
@ -33,8 +33,8 @@ class PLACEHOLDER_MODULECLASSNAME {
|
|||||||
$heading = array(PLACEHOLDER_COLUMNS, 'Menü');
|
$heading = array(PLACEHOLDER_COLUMNS, 'Menü');
|
||||||
$width = array('10%'); // Fill out manually later
|
$width = array('10%'); // Fill out manually later
|
||||||
|
|
||||||
$findcols = array(PLACEHOLDER_COLUMNS);
|
$findcols = array(PLACEHOLDER_SQL_COLUMNS);
|
||||||
$searchsql = array(PLACEHOLDER_COLUMNS);
|
$searchsql = array(PLACEHOLDER_SQL_COLUMNS);
|
||||||
|
|
||||||
$defaultorder = 1;
|
$defaultorder = 1;
|
||||||
$defaultorderdesc = 0;
|
$defaultorderdesc = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user