mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
module creator improvements layout .tpl fix
This commit is contained in:
parent
a80e69efa2
commit
682d680d2a
@ -25,9 +25,20 @@ $user = 'xenomporiodev';
|
||||
$passwd = 'xenomporiodev';
|
||||
$schema = 'xenomporiodev';
|
||||
|
||||
if ($argc == 2) {
|
||||
if ($argc >= 2) {
|
||||
|
||||
$module_name = $argv[1];
|
||||
if (in_array('-v', $argv)) {
|
||||
$verbose = true;
|
||||
} else {
|
||||
$verbose = false;
|
||||
}
|
||||
|
||||
if (!str_starts_with($argv[1],'-')) {
|
||||
$module_name = $argv[1];
|
||||
} else {
|
||||
info();
|
||||
exit;
|
||||
}
|
||||
$module_class_name = ucfirst($module_name);
|
||||
$php_file_name = $module_name . ".php";
|
||||
$php_template_file_name = "module_creator_php_template.txt";
|
||||
@ -109,6 +120,9 @@ if ($argc == 2) {
|
||||
$list_of_columns = implode(', ', $columns);
|
||||
$list_of_columns_in_quotes = "'" . implode('\', \'', $columns) . "'";
|
||||
|
||||
$get_input = "";
|
||||
$set_input = "";
|
||||
|
||||
foreach ($columns as $column) {
|
||||
$get_input = $get_input . "\$input['$column'] = \$this->app->Secure->GetPOST('$column');\n\t";
|
||||
$set_input = $set_input . "\$this->app->Tpl->Set('" . strtoupper($column) . "', \$input['$column']);\n\t";
|
||||
@ -132,10 +146,6 @@ if ($argc == 2) {
|
||||
$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);
|
||||
|
||||
if ($verbose) {
|
||||
echo($php_file_contents);
|
||||
}
|
||||
|
||||
$php_file = fopen($target_php_folder . $php_file_name, "w");
|
||||
if (empty($php_file)) {
|
||||
echo ("Failed to write to " . $target_php_folder . $php_file_name);
|
||||
@ -153,9 +163,6 @@ if ($argc == 2) {
|
||||
fclose($php_file);
|
||||
|
||||
$list_template_contents = file_get_contents("module_creator_list.tpl");
|
||||
if ($verbose) {
|
||||
echo($list_template_contents);
|
||||
}
|
||||
fwrite($template_list_file, $list_template_contents);
|
||||
fclose($template_list_file);
|
||||
|
||||
@ -163,18 +170,45 @@ if ($argc == 2) {
|
||||
$edit_template_contents = str_replace('PLACEHOLDER_LEGEND', "<!--Legend for this form area goes here>-->".$module_name, $edit_template_contents);
|
||||
$edit_template_contents = str_replace('PLACEHOLDER_FIELDS', $edit_form, $edit_template_contents);
|
||||
|
||||
if ($verbose) {
|
||||
echo($edit_template_contents);
|
||||
}
|
||||
fwrite($template_edit_file, $edit_template_contents);
|
||||
fclose($template_edit_file);
|
||||
|
||||
echo("\n\nCreated module files: \n");
|
||||
echo ($target_php_folder . $php_file_name . "\n");
|
||||
if ($verbose) {
|
||||
echo("-----------\n\n");
|
||||
echo($php_file_contents);
|
||||
echo("-----------\n\n");
|
||||
}
|
||||
|
||||
echo ($target_tpl_folder . $template_list_file_name . "\n");
|
||||
if ($verbose) {
|
||||
echo("-----------\n\n");
|
||||
echo($list_template_contents);
|
||||
echo("-----------\n\n");
|
||||
}
|
||||
|
||||
echo ($target_tpl_folder . $template_edit_file_name . "\n");
|
||||
if ($verbose) {
|
||||
echo("-----------\n\n");
|
||||
echo($edit_template_contents);
|
||||
echo("-----------\n\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
echo("Wrong parameters\n");
|
||||
info();
|
||||
exit;
|
||||
}
|
||||
|
||||
function info() {
|
||||
echo("\nXenomporio module creator\n");
|
||||
echo("Copyright 2022 (c) Xenomporio project\n\n");
|
||||
echo("Create a module.php file, a template for listing and a template for editing, based on a SQL table\n");
|
||||
echo("\n");
|
||||
echo("arg1: SQL table name\n");
|
||||
echo("Options\n");
|
||||
echo("\t-v: verbose output\n");
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,49 +1,56 @@
|
||||
<!-- Example for multiple tabs
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1">First Tab</a></li>
|
||||
<li><a href="#tabs-2">Second Tab</a></li>
|
||||
</ul>
|
||||
-->
|
||||
<form action="" method="post">
|
||||
<ul>
|
||||
<li><a href="#tabs-1"></a></li>
|
||||
</ul>
|
||||
<!-- Example for multiple tabs
|
||||
<ul hidden">
|
||||
<li><a href="#tabs-1">First Tab</a></li>
|
||||
<li><a href="#tabs-2">Second Tab</a></li>
|
||||
</ul>
|
||||
-->
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|PLACEHOLDER_LEGEND|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
PLACEHOLDER_FIELDS
|
||||
</table>
|
||||
</fieldset>
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Example for second tab
|
||||
<form action="" method="post">
|
||||
[FORMHANDLEREVENT]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|PLACEHOLDER_LEGEND|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
PLACEHOLDER_FIELDS
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Example for 2nd tab
|
||||
<div id="tabs-2">
|
||||
[MESSAGE]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Legend goes here|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
PLACEHOLDER_FIELDS
|
||||
</table>
|
||||
</fieldset>
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</form>
|
||||
|
||||
<form action="" method="post">
|
||||
[FORMHANDLEREVENT]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|...|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
...
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
|
@ -14,14 +14,11 @@ class PLACEHOLDER_MODULECLASSNAME {
|
||||
return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
|
||||
$this->app->ActionHandler("list", "PLACEHOLDER_LIST");
|
||||
$this->app->ActionHandler("create", "PLACEHOLDER_EDIT"); // This automatically adds a "New" button
|
||||
$this->app->ActionHandler("edit", "PLACEHOLDER_EDIT");
|
||||
$this->app->ActionHandler("delete", "PLACEHOLDER_DELETE");
|
||||
|
||||
$this->app->DefaultActionHandler("list");
|
||||
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
@ -46,10 +43,9 @@ class PLACEHOLDER_MODULECLASSNAME {
|
||||
|
||||
$sql = "PLACEHOLDER_SQL_LIST";
|
||||
|
||||
$where = "1
|
||||
";
|
||||
// $groupby = "";
|
||||
$where = "1";
|
||||
$count = "SELECT count(DISTINCT id) FROM PLACEHOLDER_MODULENAME WHERE $where";
|
||||
// $groupby = "";
|
||||
|
||||
break;
|
||||
}
|
||||
@ -57,8 +53,9 @@ class PLACEHOLDER_MODULECLASSNAME {
|
||||
$erg = false;
|
||||
|
||||
foreach ($erlaubtevars as $k => $v) {
|
||||
if (isset($$v))
|
||||
if (isset($$v)) {
|
||||
$erg[$v] = $$v;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
@ -130,8 +127,7 @@ class PLACEHOLDER_MODULECLASSNAME {
|
||||
|
||||
$sql = "INSERT INTO PLACEHOLDER_MODULENAME (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
|
||||
|
||||
|
||||
echo($sql);
|
||||
// echo($sql);
|
||||
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
@ -150,8 +146,7 @@ class PLACEHOLDER_MODULECLASSNAME {
|
||||
foreach ($result[0] as $key => $value) {
|
||||
$this->app->Tpl->Set(strtoupper($key), $value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Add displayed items later
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user