function metaform() {
if(isset($_REQUEST['form_name'])) {
- $GLOBALS['form_name'] = ereg_replace('[^a-z0-9_-]', '', $_REQUEST['form_name']);
+ $GLOBALS['form_name'] = format_varname($_REQUEST['form_name']);
+ $GLOBALS['singular'] = format_varname($_REQUEST['singular']);
+ tem_set('singular', $GLOBALS['singular']);
$GLOBALS['opt_email'] = format_yesno($_REQUEST['opt_email']);
tem_set('opt_email', $GLOBALS['opt_email']);
$GLOBALS['opt_db'] = format_yesno($_REQUEST['opt_db']);
$tem = new tem();
$tem->load('code/wfpl/metaform/template.html');
$tem->set('form_name', $GLOBALS['form_name']);
+ $tem->set('singular', $GLOBALS['singular']);
$fields = get_fields();
$tem->set('always_field', find_always_field($fields));
foreach($fields as $field) {
$tem = new tem();
$tem->load('code/wfpl/metaform/template.php');
$tem->set('form_name', $GLOBALS['form_name']);
+ $tem->set('singular', $GLOBALS['singular']);
$fields = get_fields();
$db_fields = '';
$php_fields = '';
unset($preview_tem);
$preview = ereg_replace('type="submit"', 'type="submit" disabled="disabled"', $preview);
tem_set('preview', $preview);
+ tem_show('hiddens');
set_form_action();
tem_output();
}
<form action="~metaform_name~" method="get">
<p>The form name should not contain any capitals or symbols (besides underscore)</p>
- <p>Form name: <input type="text" name="form_name" value="~form_name.attr~" /> (This is used as the database table name (if any) and the basename of all the files.)</p>
+ <p>page/table name: <input type="text" name="form_name" value="~form_name.attr~" /></p>
+
+ <p>Same as above but singular: <input type="text" name="singular" value="~singular.attr~" /> (Used in messages and headers.)</p>
<h3>Features</h3>
<h1 class="first">PREVIEW</h1>
~preview~
</div>
- <p><form action="~form_name~.tgz" method="get"><input type="hidden" name="form_name" value="~form_name.attr~" /><input type="hidden" name="opt_email" value="~opt_email.attr~" /><input type="hidden" name="opt_db" value="~opt_db.attr~" /><input type="hidden" name="opt_listing" value="~opt_listing.attr~" /><input type="hidden" name="opt_listing" value="~opt_display.attr~" /><input type="hidden" name="opt_http_pass" value="~opt_http_pass.attr~" /><input type="hidden" name="fields" value="~fields.attr~" /><input type="submit" name="download_tar" value="Download tarball" /></form></p>
+ <p><form action="~form_name~.tgz" method="get">~hiddens~<input type="submit" name="download_tar" value="Download tarball" /></form></p>
<form action="~metaform_name~" method="get">
- <p><input type="hidden" name="form_name" value="~form_name.attr~" /><input type="hidden" name="opt_email" value="~opt_email.attr~" /><input type="hidden" name="opt_db" value="~opt_db.attr~" /><input type="hidden" name="opt_listing" value="~opt_listing.attr~" /><input type="hidden" name="opt_display" value="~opt_display.attr~" /><input type="hidden" name="opt_http_pass" value="~opt_http_pass.attr~" /><input type="hidden" name="fields" value="~fields.attr~" /><input type="submit" name="edit" value="Back to editing" /></p>
+ <p><!--~hiddens start~--><input type="hidden" name="form_name" value="~form_name.attr~" /><input type="hidden" name="singular" value="~singular.attr~" /><input type="hidden" name="opt_email" value="~opt_email.attr~" /><input type="hidden" name="opt_db" value="~opt_db.attr~" /><input type="hidden" name="opt_listing" value="~opt_listing.attr~" /><input type="hidden" name="opt_display" value="~opt_display.attr~" /><input type="hidden" name="opt_http_pass" value="~opt_http_pass.attr~" /><input type="hidden" name="fields" value="~fields.attr~" /><!--~end~--><input type="submit" name="edit" value="Back to editing" /></p>
<p><input type="submit" name="view_sql" value="View SQL" /></p>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>~form_name~ entry</title>
+ <title>~form_name.cap~</title>
<link rel="stylesheet" href="style.css" type="text/css" /><!--~html_editor_headers start~-->
<script type="text/javascript" src="code/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
<!--~~end~~-->
<!--~opt_display_1 start~-->
<!--~~display_body start~~-->
- <h2>Details</h2>
+ <h2>~singular.cap~ details</h2>
<!--~display_row start~--><!--~display_short start~-->
- <div><span class="caption">~caption.html~:</span> ~~~name~.htmlbr~~</div>
+ <div><span class="caption">~caption.html~:</span> ~~~name~.html~~</div>
<!--~end~--><!--~display_html start~-->
<div><span class="caption">~caption.html~:</span> <div style="padding-left: 20px; border: 1px solid black">~~~name~~~</div></div>
<!--~end~--><!--~display_multiline start~-->
- <div><span class="caption">~caption.html~:</span> <div style="padding-left: 20px">~~~name~.htmlbr~~</div></div>
+ <div><span class="caption">~caption.html~:</span> <div style="padding-left: 20px">~~~name~.htmlbrtab~~</div></div>
<!--~end~--><!--~end~-->
<p><a href="~form_name~?~form_name~_edit_id=~~id.attr~~">Edit</a></p>
<!--~~edit_body start~~-->
<!--~end~-->
<!--~~form start~~--><!--~form start~-->
- <h2><!--~opt_db_1 start~--><!--~~new_msg start~~-->Add a new entry<!--~~end~~--><!--~~edit_msg start~~-->Edit entry "~~~always_field~.html~~"<!--~~end~~--><!--~end~--><!--~opt_db_1_else start~-->~form_name~ entry form<!--~end~--></h2>
+ <h2><!--~opt_db_1 start~--><!--~~new_msg start~~-->Add a new ~singular~<!--~~end~~--><!--~~edit_msg start~~-->Edit ~singular~ "~~~always_field~.html~~"<!--~~end~~--><!--~end~--><!--~opt_db_1_else start~-->~form_name.cap~ form<!--~end~--></h2>
<form action="~form_name~" method="post~enctype_attr~"><!--~opt_db_2 start~--><!--~~editing start~~--><input type="hidden" name="~form_name~_edit_id" value="~~~form_name~_edit_id.attr~~" /><!--~~end~~--><!--~end~--><!--~uploads start~--><input type="hidden" name="MAX_FILE_SIZE" value="~~upload_max_filesize~~" /><!--~end~-->
<table cellspacing="0" cellpadding="4" border="0" summary=""><!--~row start~-->
</form>
<!--~end~--><!--~~end~~-->
<!--~opt_listing_1 start~--><!--~~listings start~~-->
- <h2>~form_name~ Listing</h2>
+ <h2>~form_name.cap~ Listing</h2>
<!--~~populated_listing start~~-->
- <p><a href="~form_name~?~form_name~_new=1">[Add a new record]</a></p>
+ <p><a href="~form_name~?~form_name~_new=1">[Add a new ~singular~]</a></p>
<table cellspacing="0" cellpadding="4" border="1" summary=""><!--~~listing_row start~~-->
- <tr><td class="listing"><a href="~form_name~?~form_name~_<!--~opt_display_a_else start~-->edit_<!--~end~-->id=~~id~~">~~~always_field~.html~~</a></td><td><a href="~form_name~?~form_name~_delete_id=~~id~~" onclick="return confirm('Permanently delete?')">[delete this record]</a></td></tr><!--~~end~~-->
+ <tr><td class="listing"><a href="~form_name~?~form_name~_<!--~opt_display_a_else start~-->edit_<!--~end~-->id=~~id~~">~~~always_field~.html~~</a></td><td><a href="~form_name~?~form_name~_delete_id=~~id~~" onclick="return confirm('Permanently delete?')">[delete this ~singular~]</a></td></tr><!--~~end~~-->
</table>
<!--~~end~~-->
<!--~~empty_listing start~~-->
- <p>No ~~field_plural.html~~ in database.</p>
+ <p>No ~form_name~ in database.</p>
<!--~~end~~-->
- <p><a href="~form_name~?~form_name~_new=1">[Add a new record]</a></p>
+ <p><a href="~form_name~?~form_name~_new=1">[Add a new ~singular~]</a></p>
<!--~~end~~--><!--~end~-->
<!--~opt_display_2 start~-->
}
$row = db_get_row('~form_name~', ~form_name.upper~_DB_FIELDS, 'where id=%i', $id);
if(!$row) {
- message('Error: Not found');
+ message('Error: ~singular.cap~ not found');
return './~form_name~';
}
list(~php_fields~) = $row;
unset($_REQUEST['~form_name~_delete_id']);
if($delete_id) {
db_delete('~form_name~', 'where id=%i', $delete_id);
- message('Entry deleted.');
+ message('~singular.cap~ deleted.');
return './~form_name~';
}
if("you're happy with the POSTed values") {<!--~opt_db_4 start~-->
if($edit_id) {
db_update('~form_name~', ~form_name.upper~_DB_FIELDS, ~php_fields~, 'where id=%i', $edit_id);
- message('Updated.');
+ message('~singular.cap~ updated.');
} else {
db_insert('~form_name~', ~form_name.upper~_DB_FIELDS, ~php_fields~);
- message('Saved.');
+ message('~singular.cap~ saved.');
}<!--~end~--><!--~opt_email_2 start~-->
if($GLOBALS['~form_name~_form_recipient'] != "fixme@example.com") {
$to = $GLOBALS['~form_name~_form_recipient'];