-function _~form_name~_main() {<!--~opt_http_pass_2 start~-->
- # To remove password protection, just delete this block:
- if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != AUTH_USER || $_SERVER['PHP_AUTH_PW'] != AUTH_PASS) {
- header('WWW-Authenticate: Basic realm="' . AUTH_REALM . '"');
- header('HTTP/1.0 401 Unauthorized');
- echo '401 Unauthorized';
- exit;
- }
- <!--~end~--><!--~pulldowns start~-->
- pulldown('~name~', array('option 1', 'option 2', 'option 3'));
- <!--~end~--><!--~opt_db_3 start~-->
- $edit_id = format_int($_REQUEST['~form_name~_edit_id']);
- unset($_REQUEST['~form_name~_edit_id']);
- if($edit_id) {
- # add hidden field for database id of row we're editing
- tem_set('~form_name~_edit_id', $edit_id);
- tem_show('editing');
- }
-
- $delete_id = format_int($_REQUEST['~form_name~_delete_id']);
- unset($_REQUEST['~form_name~_delete_id']);
- if($delete_id) {
- db_delete('~form_name~', 'where id=%i', $delete_id);
- message('Entry deleted.');
-
- return './~form_name~.html';
- }
-
- if(!$edit_id) {<!--~opt_listing_1 start~-->
- if(!isset($_REQUEST['~form_name~_new']) && !isset($_REQUEST['~always_field~'])) {
- ~form_name~_display_listing();
- return;
+ if (isset($_POST['~always_field~'])) {
+ return ~file_name~_main_form();
+ }
+
+ # default action:
+ return ~file_name~_main_listing();~}~~opt_listing unset {~
+ return ~file_name~_main_form();~}~
+}~opt_display {~
+
+function ~file_name~_main_display($id) {
+ $data = db_get_assoc('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'where id=%i', $id);
+ if (!$data) {
+ message("Error: Broken Link (~singular cap~ #$id not found)");~opt_public_something {~
+ return './' . $GLOBALS['wfpl_basename'];~}~~opt_public_something unset {~
+ return './~file_name~';~}~
+ }
+ tem_set('display', $data);
+}~}~~opt_db {~
+
+function ~file_name~_main_delete($id) {
+ db_delete('~table_name~', 'where id=%i', $id);
+ message('~singular cap~ deleted.');
+ return './~file_name~';
+}~}~~opt_listing {~
+
+function ~file_name~_csv_download() {
+ require_once('code/wfpl/csv.php');
+ $rows = db_get_rows('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'order by id');
+ $fields = explode(',', 'id,'.~file_name upper~_DB_FIELDS);
+ $header = array();
+ foreach ($fields as $field) {
+ if (isset($GLOBALS['~file_name~_field_to_caption'][$field])) {
+ $header[] = $GLOBALS['~file_name~_field_to_caption'][$field];
+ } else {
+ $header[] = $field;