Project

General

Profile

« Previous | Next » 

Revision 81

Added by ryan about 19 years ago

Moved Form module

View differences:

trunk/wb/modules/form/install.php
1
<?php
2

  
3
// $Id: install.php,v 1.6 2005/04/02 08:21:46 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
if(defined('WB_URL')) {
32
		
33
	// Create tables
34
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_fields`");
35
	$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_fields` ( `field_id` INT NOT NULL AUTO_INCREMENT,'
36
	                 . ' `section_id` INT NOT NULL ,'
37
	                 . ' `page_id` INT NOT NULL ,'
38
	                 . ' `position` INT NOT NULL ,'
39
	                 . ' `title` VARCHAR(255) NOT NULL ,'
40
	                 . ' `type` VARCHAR(255) NOT NULL ,'
41
	                 . ' `required` INT NOT NULL ,'
42
	                 . ' `value` TEXT NOT NULL ,'
43
	                 . ' `extra` TEXT NOT NULL ,'
44
	                 . ' PRIMARY KEY ( `field_id` ) )'
45
	                 . ' ';
46
	$database->query($mod_form);
47
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_settings`");
48
	$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_settings` ('
49
						  . ' `section_id` INT NOT NULL,'
50
						  . ' `page_id` INT NOT NULL,'
51
	                 . ' `header` TEXT NOT NULL ,'
52
	                 . ' `field_loop` TEXT NOT NULL ,'
53
	                 . ' `footer` TEXT NOT NULL ,'
54
	                 . ' `email_to` TEXT NOT NULL ,'
55
	                 . ' `email_from` VARCHAR(255) NOT NULL ,'
56
	                 . ' `email_subject` VARCHAR(255) NOT NULL ,'
57
	                 . ' `success_message` TEXT NOT NULL ,'
58
						  . ' `stored_submissions` INT NOT NULL,'
59
						  . ' `max_submissions` INT NOT NULL,'
60
	                 . ' PRIMARY KEY ( `section_id` ) )'
61
	                 . ' ';
62
	$database->query($mod_form);
63
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_submissions`");
64
	$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_submissions` ( `submission_id` INT NOT NULL AUTO_INCREMENT,'
65
						  . ' `section_id` INT NOT NULL,'
66
						  . ' `page_id` INT NOT NULL,'
67
						  . ' `submitted_when` INT NOT NULL,'
68
						  . ' `submitted_by` INT NOT NULL,'
69
	                 . ' `body` TEXT NOT NULL ,'
70
	                 . ' PRIMARY KEY ( `submission_id` ) )'
71
	                 . ' ';
72
	$database->query($mod_form);
73
		
74
	// Insert info into the search table
75
	// Module query info
76
	$field_info = array();
77
	$field_info['page_id'] = 'page_id';
78
	$field_info['title'] = 'page_title';
79
	$field_info['link'] = 'link';
80
	$field_info['description'] = 'description';
81
	$field_info['modified_when'] = 'modified_when';
82
	$field_info['modified_by'] = 'modified_by';
83
	$field_info = serialize($field_info);
84
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'form', '$field_info')");
85
	// Query start
86
	$query_start_code = "SELECT [TP]pages.page_id, [TP]pages.page_title,	[TP]pages.link, [TP]pages.description, [TP]pages.modified_when, [TP]pages.modified_by	FROM [TP]mod_form_fields, [TP]mod_form_settings, [TP]pages WHERE ";
87
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'form')");
88
	// Query body
89
	$query_body_code = " [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.header [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'
90
	OR [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.footer [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'
91
	OR [TP]pages.page_id = [TP]mod_form_fields.page_id AND [TP]mod_form_fields.title [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'";
92
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'form')");
93
	// Query end
94
	$query_end_code = '';
95
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'form')");
96
	
97
	// Insert blank row (there needs to be at least on row for the search to work)
98
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_fields (page_id,section_id) VALUES ('0','0')");
99
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_settings (page_id,section_id) VALUES ('0','0')");
100

  
101
}
102

  
103
?>
104 0

  
trunk/wb/modules/form/modify_settings.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Include WB admin wrapper script
34
require(WB_PATH.'/modules/admin.php');
35

  
36
// Get header and footer
37
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
38
$setting = $query_content->fetchRow();
39

  
40
// Set raw html <'s and >'s to be replace by friendly html code
41
$raw = array('<', '>');
42
$friendly = array('&lt;', '&gt;');
43

  
44
?>
45

  
46
<style type="text/css">
47
.setting_name {
48
	vertical-align: top;
49
}
50
</style>
51

  
52
<form name="edit" action="<?php echo WB_URL; ?>/modules/form/save_settings.php" method="post" style="margin: 0;">
53

  
54
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
55
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
56

  
57
<table cellpadding="2" cellspacing="0" border="0" width="100%">
58
<tr>
59
	<td class="setting_name" width="220"><?php echo $TEXT['HEADER']; ?>:</td>
60
	<td class="setting_name">
61
		<textarea name="header" style="width: 100%; height: 80px;"><?php echo $admin->strip_slashes_dummy($setting['header']); ?></textarea>
62
	</td>
63
</tr>
64
<tr>
65
	<td class="setting_name"><?php echo $TEXT['FIELD'].' '.$TEXT['LOOP']; ?>:</td>
66
	<td class="setting_name">
67
		<textarea name="field_loop" style="width: 100%; height: 60px;"><?php echo $admin->strip_slashes_dummy($setting['field_loop']); ?></textarea>
68
	</td>
69
</tr>
70
<tr>
71
	<td class="setting_name"><?php echo $TEXT['FOOTER']; ?>:</td>
72
	<td class="setting_name">
73
		<textarea name="footer" style="width: 100%; height: 80px;"><?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['footer'])); ?></textarea>
74
	</td>
75
</tr>
76
<tr>
77
	<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['TO']; ?>:</td>
78
	<td class="setting_name">
79
		<textarea name="email_to" style="width: 100%; height: 30px;"><?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['email_to'])); ?></textarea>
80
	</td>
81
</tr>
82
<tr>
83
	<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['FROM']; ?>:</td>
84
	<td class="setting_name">
85
		<select name="email_from_field" style="width: 100%;">
86
			<option value="" onclick="javascript: document.getElementById('email_from').style.display = 'block';"><?php echo $TEXT['CUSTOM']; ?>:</option>
87
			<?php
88
			$email_from_value = str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['email_from']));
89
			$query_email_fields = $database->query("SELECT field_id,title FROM ".TABLE_PREFIX."mod_form_fields ORDER BY position ASC");
90
			if($query_email_fields->numRows() > 0) {
91
				while($field = $query_email_fields->fetchRow()) {
92
					?>
93
					<option value="field<?php echo $field['field_id']; ?>"<?php if($email_from_value == 'field'.$field['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
94
						<?php echo $TEXT['FIELD'].': '.$field['title']; ?>
95
					</option>
96
					<?php
97
				}
98
			}
99
			?>
100
		</select>
101
		<input type="text" name="email_from" id="email_from" style="width: 100%; display: <?php if(isset($selected) AND $selected == true) { echo 'none'; } else { echo 'block'; } ?>;" maxlength="255" value="<?php if(substr($email_from_value, 0, 5) != 'field') { echo $email_from_value; } ?>" />
102
	</td>
103
</tr>
104
<tr>
105
	<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td>
106
	<td class="setting_name">
107
		<input type="text" name="email_subject" style="width: 100%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['email_subject'])); ?>" />
108
	</td>
109
</tr>
110
<tr>
111
	<td class="setting_name"><?php echo $TEXT['SUCCESS'].' '.$TEXT['MESSAGE']; ?>:</td>
112
	<td class="setting_name">
113
		<textarea name="success_message" style="width: 100%; height: 80px;"><?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['success_message'])); ?></textarea>
114
	</td>
115
</tr>
116
<tr>
117
	<td class="setting_name"><?php echo $TEXT['MAX_SUBMISSIONS_PER_HOUR']; ?>:</td>
118
	<td class="setting_name">
119
		<input type="text" name="max_submissions" style="width: 100%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['max_submissions'])); ?>" />
120
	</td>
121
</tr>
122
<tr>
123
	<td class="setting_name"><?php echo $TEXT['SUBMISSIONS_STORED_IN_DATABASE']; ?>:</td>
124
	<td class="setting_name">
125
		<input type="text" name="stored_submissions" style="width: 100%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, $admin->strip_slashes_dummy($setting['stored_submissions'])); ?>" />
126
	</td>
127
</tr>
128
</table>
129
<table cellpadding="0" cellspacing="0" border="0" width="100%">
130
<tr>
131
	<td width="225">&nbsp;</td>
132
	<td align="left">
133
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE'].' '.$TEXT['SETTINGS']; ?>" style="width: 200px; margin-top: 5px;"></form>
134
	</td>
135
	<td align="right">
136
		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
137
	</td>
138
</tr>
139
</table>
140

  
141

  
142
<?php
143

  
144
// Print admin footer
145
$admin->print_footer();
146

  
147
?>
148 0

  
trunk/wb/modules/form/delete_submission.php
1
<?php
2

  
3
// $Id: delete_submission.php,v 1.1 2005/03/28 04:35:39 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra submission types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Get id
34
if(!isset($_GET['submission_id']) OR !is_numeric($_GET['submission_id'])) {
35
	header("Location: ".ADMIN_URL."/pages/index.php");
36
} else {
37
	$submission_id = $_GET['submission_id'];
38
}
39

  
40
// Include WB admin wrapper script
41
$update_when_modified = true; // Tells script to update when this page was last updated
42
require(WB_PATH.'/modules/admin.php');
43

  
44
// Delete row
45
$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_submissions WHERE submission_id = '$submission_id'");
46

  
47
// Check if there is a db error, otherwise say successful
48
if($database->is_error()) {
49
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
50
} else {
51
	$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
52
}
53

  
54
// Print admin footer
55
$admin->print_footer();
56

  
57
?>
58 0

  
trunk/wb/modules/form/save_settings.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Include WB admin wrapper script
34
$update_when_modified = true; // Tells script to update when this page was last updated
35
require(WB_PATH.'/modules/admin.php');
36

  
37
// This code removes any <?php tags and adds slashes
38
$friendly = array('&lt;', '&gt;', '?php');
39
$raw = array('<', '>', '');
40
$header = $admin->add_slashes($_POST['header']);
41
$field_loop = $admin->add_slashes($_POST['field_loop']);
42
$footer = $admin->add_slashes($_POST['footer']);
43
$email_to = $admin->add_slashes($_POST['email_to']);
44
if($_POST['email_from_field'] == '') {
45
	$email_from = $admin->add_slashes($_POST['email_from']);
46
} else {
47
	$email_from = $admin->add_slashes($_POST['email_from_field']);
48
}
49
$email_subject = $admin->add_slashes($_POST['email_subject']);
50
$success_message = $admin->add_slashes($_POST['success_message']);
51
if(!is_numeric($_POST['max_submissions'])) {
52
	$max_submissions = 50;
53
} else {
54
	$max_submissions = $_POST['max_submissions'];
55
}
56
if(!is_numeric($_POST['stored_submissions'])) {
57
	$stored_submissions = 100;
58
} else {
59
	$stored_submissions = $_POST['stored_submissions'];
60
}
61
// Make sure max submissions is not smaller than stored submissions
62
if($max_submissions < $stored_submissions) {
63
	$max_submissions = $stored_submissions;
64
}
65

  
66
// Update settings
67
$database->query("UPDATE ".TABLE_PREFIX."mod_form_settings SET header = '$header', field_loop = '$field_loop', footer = '$footer', email_to = '$email_to', email_from = '$email_from', email_subject = '$email_subject', success_message = '$success_message', max_submissions = '$max_submissions', stored_submissions = '$stored_submissions' WHERE section_id = '$section_id'");
68

  
69
// Check if there is a db error, otherwise say successful
70
if($database->is_error()) {
71
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
72
} else {
73
	$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
74
}
75

  
76
// Print admin footer
77
$admin->print_footer();
78

  
79
?>
80 0

  
trunk/wb/modules/form/move_up.php
1
<?php
2

  
3
// $Id: move_up.php,v 1.3 2005/03/28 04:34:45 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Get id
34
if(!isset($_GET['field_id']) OR !is_numeric($_GET['field_id'])) {
35
	header("Location: index.php");
36
} else {
37
	$field_id = $_GET['field_id'];
38
}
39

  
40
// Include WB admin wrapper script
41
require(WB_PATH.'/modules/admin.php');
42

  
43
// Include the ordering class
44
require(WB_PATH.'/framework/class.order.php');
45

  
46
// Create new order object an reorder
47
$order = new order(TABLE_PREFIX.'mod_form_fields', 'position', 'field_id', 'section_id');
48
if($order->move_up($field_id)) {
49
	$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
50
} else {
51
	$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
52
}
53

  
54
// Print admin footer
55
$admin->print_footer();
56

  
57
?>
58 0

  
trunk/wb/modules/form/view.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
// Must include code to stop this file being access directly
32
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
33

  
34
// Function for generating an optionsfor a select field
35
function make_option(&$n) {
36
	// start option group if it exists
37
	if (substr($n,0,2) == '[=') {
38
	 	$n = '<optgroup label="'.substr($n,2,strlen($n)).'">';
39
	} elseif ($n == ']') {
40
		$n = '</optgroup>';
41
	} else {
42
		$n = '<option value="'.$n.'">'.$n.'</option>';
43
	}
44
}
45

  
46
// Function for generating a checkbox
47
function make_checkbox(&$n, $idx, $params) {
48
	$field_id = $params[0];
49
	$seperator = $params[1];
50
	//$n = '<input class="field_checkbox" type="checkbox" id="'.$n.'" name="field'.$field_id.'" value="'.$n.'">'.'<font class="checkbox_label" onclick="javascript: document.getElementById(\''.$n.'\').checked = !document.getElementById(\''.$n.'\').checked;">'.$n.'</font>'.$seperator;
51
	$n = '<input class="field_checkbox" type="checkbox" id="'.$n.'" name="field'.$field_id.'['.$idx.']" value="'.$n.'">'.'<font class="checkbox_label" onclick="javascript: document.getElementById(\''.$n.'\').checked = !document.getElementById(\''.$n.'\').checked;">'.$n.'</font>'.$seperator;
52
}
53

  
54
// Function for generating a radio button
55
function make_radio(&$n, $idx, $params) {
56
	$field_id = $params[0];
57
	$group = $params[1];
58
	$seperator = $params[2];
59
	$n = '<input class="field_radio" type="radio" id="'.$n.'" name="field'.$field_id.'" value="'.$n.'">'.'<font class="radio_label" onclick="javascript: document.getElementById(\''.$n.'\').checked = true;">'.$n.'</font>'.$seperator;
60
}
61

  
62
// Work-out if the form has been submitted or not
63
if($_POST == array()) {
64

  
65
?>
66
<style type="text/css">
67
.required {
68
	color: #FF0000;
69
}
70
.field_title {
71
	font-size: 12px;
72
	width: 100px;
73
	vertical-align: top;
74
	text-align:right;
75
}
76
.textfield {
77
	font-size: 12px;
78
	width: 200px;
79
}
80
.textarea {
81
	font-size: 12px;
82
	width: 90%;
83
	height: 100px;
84
}
85
.field_heading {
86
	font-size: 12px;
87
	font-weight: bold;
88
	border-bottom-width: 2px;
89
	border-bottom-style: solid;
90
	border-bottom-color: #666666;
91
	padding-top: 10px;
92
	color: #666666;
93
}
94
.select {
95
	font-size: 12px;
96
}
97
.checkbox_label {
98
	font-size: 11px;
99
	cursor: pointer;
100
}
101
.radio_label {
102
	font-size: 11px;
103
	cursor: pointer;
104
}
105
.email {
106
	font-size: 12px;
107
	width: 200px;
108
}
109
</style>
110
<?php
111

  
112
// Get settings
113
$query_settings = $database->query("SELECT header,field_loop,footer FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
114
if($query_settings->numRows() > 0) {
115
	$fetch_settings = $query_settings->fetchRow();
116
	$header = $this->strip_slashes_dummy($fetch_settings['header']);
117
	$field_loop = $this->strip_slashes_dummy($fetch_settings['field_loop']);
118
	$footer = $this->strip_slashes_dummy($fetch_settings['footer']);
119
} else {
120
	$header = '';
121
	$field_loop = '';
122
	$footer = '';
123
}
124

  
125
// Add form starter code
126
?>
127
<form name="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
128
<?php
129

  
130
// Print header
131
echo $header;
132

  
133
// Get list of fields
134
$query_fields = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' ORDER BY position ASC");
135
if($query_fields->numRows() > 0) {
136
	while($field = $query_fields->fetchRow()) {
137
		// Set field values
138
		$field_id = $field['field_id'];
139
		$value = $this->strip_slashes_dummy($field['value']);
140
		// Print field_loop after replacing vars with values
141
		$vars = array('{TITLE}', '{REQUIRED}');
142
		$values = array($field['title']);
143
		if($field['required'] == 1) {
144
			$values[] = '<font class="required">*</font>';
145
		} else {
146
			$values[] = '';
147
		}
148
		if($field['type'] == 'textfield') {
149
			$vars[] = '{FIELD}';
150
			$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'" maxlength="'.$field['extra'].'" value="'.$value.'" class="textfield" />';
151
		} elseif($field['type'] == 'textarea') {
152
			$vars[] = '{FIELD}';
153
			$values[] = '<textarea name="field'.$field_id.'" id="field'.$field_id.'" class="textarea">'.$value.'</textarea>';
154
		} elseif($field['type'] == 'select') {
155
			$vars[] = '{FIELD}';
156
			$options = explode(',', $value);
157
			array_walk($options, 'make_option');
158
			$field['extra'] = explode(',',$field['extra']); 
159
			$values[] = '<select name="field'.$field_id.'[]" id="field'.$field_id.'" size="'.$field['extra'][0].'" '.$field['extra'][1].' class="select">'.implode($options).'</select>';
160
		} elseif($field['type'] == 'heading') {
161
			$vars[] = '{FIELD}';
162
			$values[] = '<input type="hidden" name="field'.$field_id.'" id="field'.$field_id.'" value="===['.$field['title'].']===" />';
163
			$tmp_field_loop = $field_loop;		// temporarily modify the field loop template
164
			$field_loop = $field['extra'];
165
		} elseif($field['type'] == 'checkbox') {
166
			$vars[] = '{FIELD}';
167
			$options = explode(',', $value);
168
			array_walk($options, 'make_checkbox',array($field_id,$field['extra']));
169
			$values[] = implode($options);
170
		} elseif($field['type'] == 'radio') {
171
			$vars[] = '{FIELD}';
172
			$options = explode(',', $value);
173
			array_walk($options, 'make_radio',array($field_id,$field['title'],$field['extra']));
174
			$values[] = implode($options);
175
		} elseif($field['type'] == 'email') {
176
			$vars[] = '{FIELD}';
177
			$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'" maxlength="'.$field['extra'].'" class="email" />';
178
		}
179
		if($field['type'] != '') {
180
			echo str_replace($vars, $values, $field_loop);
181
		}
182
		if (isset($tmp_field_loop)) $field_loop = $tmp_field_loop;
183
	}
184
}
185

  
186
// Print footer
187
echo $footer;
188

  
189
// Add form end code
190
?>
191
</form>
192
<?php
193

  
194
} else {
195
	
196
	// Submit form data
197
	// First start message settings
198
	$query_settings = $database->query("SELECT email_to,email_from,email_subject,success_message,max_submissions,stored_submissions FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
199
	if($query_settings->numRows() > 0) {
200
		$fetch_settings = $query_settings->fetchRow();
201
		$email_to = $this->strip_slashes_dummy($fetch_settings['email_to']);
202
		$email_from = $this->strip_slashes_dummy($fetch_settings['email_from']);
203
		if(substr($email_from, 0, 5) == 'field') {
204
			// Set the email from field to what the user entered in the specified field
205
			$email_from = $this->add_slashes($_POST[$email_from]);
206
		}
207
		$email_subject = $this->strip_slashes_dummy($fetch_settings['email_subject']);
208
		$success_message = $this->strip_slashes_dummy($fetch_settings['success_message']);
209
		$max_submissions = $this->strip_slashes_dummy($fetch_settings['max_submissions']);
210
		$stored_submissions = $this->strip_slashes_dummy($fetch_settings['stored_submissions']);
211
	} else {
212
		exit($TEXT['UNDER_CONSTRUCTION']);
213
	}
214
	$email_body = '';
215
	
216
	// Create blank "required" array
217
	$required = array();
218
	
219
	// Loop through fields and add to message body
220
	// Get list of fields
221
	$query_fields = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' ORDER BY position ASC");
222
	if($query_fields->numRows() > 0) {
223
		while($field = $query_fields->fetchRow()) {
224
			// Add to message body
225
			if($field['type'] != '') {
226
				if(!empty($_POST['field'.$field['field_id']])) {
227
					if($field['type'] == 'heading') {
228
					$email_body .= '
229
					
230
	'.$_POST['field'.$field['field_id']];
231
					} elseif (!is_array($_POST['field'.$field['field_id']])) {
232
					$email_body .= '
233
					
234
	'.$this->strip_slashes_dummy($field['title']).': '.$_POST['field'.$field['field_id']]."\n";
235
					} else {
236
						$email_body .= '
237
					
238
	'.$this->strip_slashes_dummy($field['title']).": \n";
239
						foreach ($_POST['field'.$field['field_id']] as $k=>$v) {
240
							$email_body .= '
241
					
242
	'.$v;
243
						}
244
					}
245
				} elseif($field['required'] == 1) {
246
				$required[] = $this->strip_slashes_dummy($field['title']);
247
				}
248
			}
249
		}
250
	}
251
	
252
	// Addslashes to email body - proposed by Icheb in topic=1170.0
253
	// $email_body = $this->add_slashes($email_body);
254
	
255
	// Check if the user forgot to enter values into all the required fields
256
	if($required != array()) {
257
		if(!isset($MESSAGE['MOD_FORM']['REQUIRED_FIELDS'])) {
258
			echo 'You must enter details for the following fields';
259
		} else {
260
			echo $MESSAGE['MOD_FORM']['REQUIRED_FIELDS'];
261
		}
262
		echo ':<br /><ul>';
263
		foreach($required AS $field_title) {
264
			echo '<li>'.$field_title;
265
		}
266
		echo '</ul><a href="javascript: history.go(-1);">'.$TEXT['BACK'].'</a>';
267
		
268
	} else {
269
		
270
		// Check how many times form has been submitted in last hour
271
		$query_submissions = $database->query("SELECT submission_id FROM ".TABLE_PREFIX."mod_form_submissions WHERE submitted_when >= '3600'");
272
		if($query_submissions->numRows() > $max_submissions) {
273
			// Too many submissions so far this hour
274
			echo $MESSAGE['MOD_FORM']['EXCESS_SUBMISSIONS'];
275
			$success = false;
276
		} else {
277
			// Now send the email
278
			if($email_to != '') {
279
				if($email_from != '') {
280
					if(mail($email_to,$email_subject,str_replace('\n', '', $email_body),"From: ".$email_from)) { $success = true; }
281
				} else {
282
					if(mail($email_to,$email_subject,str_replace('\n', '', $email_body))) { $success = true; }
283
				}
284
			}				
285
			// Write submission to database
286
			if(isset($admin) AND $admin->get_user_id() > 0) {
287
				$admin->get_user_id();
288
			} else {
289
				$submitted_by = 0;
290
			}
291
			$email_body = $this->add_slashes($email_body);
292
			$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_submissions (page_id,section_id,submitted_when,submitted_by,body) VALUES ('".PAGE_ID."','$section_id','".mktime()."','$submitted_by','$email_body')");
293
			// Make sure submissions table isn't too full
294
			$query_submissions = $database->query("SELECT submission_id FROM ".TABLE_PREFIX."mod_form_submissions ORDER BY submitted_when");
295
			$num_submissions = $query_submissions->numRows();
296
			if($num_submissions > $stored_submissions) {
297
				// Remove excess submission
298
				$num_to_remove = $num_submissions-$stored_submissions;
299
				while($submission = $query_submissions->fetchRow()) {
300
					if($num_to_remove > 0) {
301
						$submission_id = $submission['submission_id'];
302
						$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_submissions WHERE submission_id = '$submission_id'");
303
						$num_to_remove = $num_to_remove-1;
304
					}
305
				}
306
			}
307
			if(!$database->is_error()) {
308
				$success = true;
309
			}
310
		}
311
		
312
		// Now check if the email was sent successfully
313
		if(isset($success) AND $success == true) {
314
			echo $success_message;
315
		} else {
316
			echo $TEXT['ERROR'];
317
		}
318
	
319
	}
320
	
321
}
322

  
323
?>
324 0

  
trunk/wb/modules/form/view_submission.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Get id
34
if(!isset($_GET['submission_id']) OR !is_numeric($_GET['submission_id'])) {
35
	header("Location: ".ADMIN_URL."/pages/index.php");
36
} else {
37
	$submission_id = $_GET['submission_id'];
38
}
39

  
40
// Include WB admin wrapper script
41
require(WB_PATH.'/modules/admin.php');
42

  
43
// Get submission details
44
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_submissions WHERE submission_id = '$submission_id'");
45
$submission = $query_content->fetchRow();
46

  
47
// Get the user details of whoever did this submission
48
$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '".$submission['submitted_by']."'";
49
$get_user = $database->query($query_user);
50
if($get_user->numRows() != 0) {
51
	$user = $get_user->fetchRow();
52
} else {
53
	$user['display_name'] = 'Unknown';
54
	$user['username'] = 'unknown';
55
}
56

  
57
?>
58
<table cellpadding="0" cellspacing="0" border="0" width="100%">
59
<tr>
60
	<td><?php echo $TEXT['SUBMISSION_ID']; ?>:</td>
61
	<td><?php echo $submission['submission_id']; ?></td>
62
</tr>
63
<tr>
64
	<td><?php echo $TEXT['SUBMITTED']; ?>:</td>
65
	<td><?php echo gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE); ?></td>
66
</td>
67
<tr>
68
	<td><?php echo $TEXT['USER']; ?>:</td>
69
	<td><?php echo $user['display_name'].' ('.$user['username'].')'; ?></td>
70
</tr>
71
<tr>
72
	<td colspan="2">
73
		<hr />
74
	</td>
75
</tr>
76
<tr>
77
	<td colspan="2">
78
		<?php echo $admin->strip_slashes_dummy(str_replace('\n', '<br />', $submission['body'])); ?>
79
	</td>
80
</tr>
81
</table>
82

  
83
<br />
84

  
85
<input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 150px; margin-top: 5px;" />
86
<input type="button" value="<?php echo $TEXT['DELETE']; ?>" onclick="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_submission.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&submission_id=<?php echo $submission_id; ?>');" style="width: 150px; margin-top: 5px;" />
87
<?php
88

  
89
// Print admin footer
90
$admin->print_footer();
91

  
92
?>
93 0

  
trunk/wb/modules/form/modify.php
1
<?php
2

  
3
// $Id: modify.php,v 1.5 2005/03/28 11:58:04 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
// Must include code to stop this file being access directly
32
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
33

  
34
?>
35
<table cellpadding="0" cellspacing="0" border="0" width="100%">
36
<tr>
37
	<td align="left" width="33%">
38
		<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['FIELD']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/add_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
39
	</td>
40
	<td align="right" width="33%">
41
		<input type="button" value="<?php echo $TEXT['SETTINGS']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/modify_settings.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
42
	</td>
43
</tr>
44
</table>
45

  
46
<br />
47

  
48
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
49
<?php
50

  
51
// Loop through existing fields
52
$query_fields = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_form_fields` WHERE section_id = '$section_id' ORDER BY position ASC");
53
if($query_fields->numRows() > 0) {
54
	$num_fields = $query_fields->numRows();
55
	$row = 'a';
56
	?>
57
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
58
	<?php
59
	while($field = $query_fields->fetchRow()) {
60
		?>
61
		<tr class="row_<?php echo $row; ?>" height="20">
62
			<td width="20" style="padding-left: 5px;">
63
				<a href="<?php echo WB_URL; ?>/modules/form/modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
64
					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
65
				</a>
66
			</td>		
67
			<td>
68
				<a href="<?php echo WB_URL; ?>/modules/form/modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>">
69
					<?php echo $field['title']; ?>
70
				</a>
71
			</td>
72
			<td width="175">
73
				<?php
74
				echo $TEXT['TYPE'].':';
75
				if($field['type'] == 'textfield') {
76
					echo $TEXT['SHORT_TEXT'];
77
				} elseif($field['type'] == 'textarea') {
78
					echo $TEXT['LONG_TEXT'];
79
				} elseif($field['type'] == 'heading') {
80
					echo $TEXT['HEADING'];
81
				} elseif($field['type'] == 'select') {
82
					echo $TEXT['SELECT_BOX'];
83
				} elseif($field['type'] == 'checkbox') {
84
					echo $TEXT['CHECKBOX_GROUP'];
85
				} elseif($field['type'] == 'radio') {
86
					echo $TEXT['RADIO_BUTTON_GROUP'];
87
				} elseif($field['type'] == 'email') {
88
					echo $TEXT['EMAIL_ADDRESS'];
89
				}
90
				?>
91
			</td>
92
			<td width="95">		
-			<?php 
93
			if ($field['type'] != 'group_begin') {
94
				echo $TEXT['REQUIRED'].': '; if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
95
			}
96
			?>
97
			</td>
98
			<td width="110">
99
			<?php
100
			if ($field['type'] == 'select') {
101
				$field['extra'] = explode(',',$field['extra']);
102
				echo $TEXT['MULTISELECT'].': '; if($field['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
103
			}
104
			?>
105
			</td>
106
			<td width="20">
107
			<?php if($field['position'] != 1) { ?>
108
				<a href="<?php echo WB_URL; ?>/modules/form/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
109
					<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
110
				</a>
111
			<?php } ?>
112
			</td>
113
			<td width="20">
114
			<?php if($field['position'] != $num_fields) { ?>
115
				<a href="<?php echo WB_URL; ?>/modules/form/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
116
					<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
117
				</a>
118
			<?php } ?>
119
			</td>
120
			<td width="20">
121
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
122
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
123
				</a>
124
			</td>
125
		</tr>
126
		<?php
127
		// Alternate row color
128
		if($row == 'a') {
129
			$row = 'b';
130
		} else {
131
			$row = 'a';
132
		}
133
	}
134
	?>
135
	</table>
136
	<?php
137
} else {
138
	echo $TEXT['NONE_FOUND'];
139
}
140

  
141
?>
142

  
143
<br /><br />
144

  
145
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
146

  
147
<?php
148

  
149
// Query submissions table
150
$query_submissions = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_form_submissions` WHERE section_id = '$section_id' ORDER BY submitted_when ASC");
151
if($query_submissions->numRows() > 0) {
152
	?>
153
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
154
	<?php
155
	// List submissions
156
	$row = 'a';
157
	while($submission = $query_submissions->fetchRow()) {
158
		?>
159
		<tr class="row_<?php echo $row; ?>" height="20">
160
			<td width="20" style="padding-left: 5px;">
161
				<a href="<?php echo WB_URL; ?>/modules/form/view_submission.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&submission_id=<?php echo $submission['submission_id']; ?>">
162
					<img src="<?php echo ADMIN_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" border="0" />
163
				</a>
164
			</td>
165
			<td width="237"><?php echo $TEXT['SUBMISSION_ID'].': '.$submission['submission_id']; ?></td>
166
			<td><?php echo $TEXT['SUBMITTED'].': '.gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE); ?></td>
167
			<td width="20">
168
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_submission.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&submission_id=<?php echo $submission['submission_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
169
					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
170
				</a>
171
			</td>
172
		</tr>
173
		<?php
174
		// Alternate row color
175
		if($row == 'a') {
176
			$row = 'b';
177
		} else {
178
			$row = 'a';
179
		}
180
	}
181
	?>
182
	</table>
183
	<?php
184
} else {
185
	echo $TEXT['NONE_FOUND'];
186
}
187

  
188
?>
189

  
190
<br />
191 0

  
trunk/wb/modules/form/move_down.php
1
<?php
2

  
3
// $Id: move_down.php,v 1.3 2005/03/28 04:34:45 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Get id
34
if(!isset($_GET['field_id']) OR !is_numeric($_GET['field_id'])) {
35
	header("Location: index.php");
36
} else {
37
	$field_id = $_GET['field_id'];
38
}
39

  
40
// Include WB admin wrapper script
41
require(WB_PATH.'/modules/admin.php');
42

  
43
// Include the ordering class
44
require(WB_PATH.'/framework/class.order.php');
45

  
46
// Create new order object an reorder
47
$order = new order(TABLE_PREFIX.'mod_form_fields', 'position', 'field_id', 'section_id');
48
if($order->move_down($field_id)) {
49
	$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
50
} else {
51
	$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
52
}
53

  
54
// Print admin footer
55
$admin->print_footer();
56

  
57
?>
58 0

  
trunk/wb/modules/form/modify_field.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

  
31
require('../../config.php');
32

  
33
// Get id
34
if(!isset($_GET['field_id']) OR !is_numeric($_GET['field_id'])) {
35
	header("Location: ".ADMIN_URL."/pages/index.php");
36
} else {
37
	$field_id = $_GET['field_id'];
38
}
39

  
40
// Include WB admin wrapper script
41
require(WB_PATH.'/modules/admin.php');
42

  
43
// Get header and footer
44
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE field_id = '$field_id'");
45
$form = $query_content->fetchRow();
46
$type = $form['type'];
47
if($type == '') {
48
	$type = 'none';
49
}
50

  
51
// Set raw html <'s and >'s to be replaced by friendly html code
52
$raw = array('<', '>');
53
$friendly = array('&lt;', '&gt;');
54
?>
55

  
56
<form name="modify" action="<?php echo WB_URL; ?>/modules/form/save_field.php" method="post" style="margin: 0;">
57

  
58
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
59
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
60
<input type="hidden" name="field_id" value="<?php echo $field_id; ?>">
61

  
62
<table cellpadding="4" cellspacing="0" border="0" width="100%">
63
<tr>
64
	<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
65
	<td>
66
		<input type="text" name="title" value="<?php echo htmlspecialchars($admin->strip_slashes_dummy($form['title'])); ?>" style="width: 100%;" maxlength="255" />
67
	</td>
68
</tr>
69
<tr>
70
	<td><?php echo $TEXT['TYPE']; ?>:</td>
71
	<td>
72
		<select name="type" style="width: 100%;">
73
			<option value=""><?php echo $TEXT['PLEASE_SELECT']; ?>...</option>
74
			<option value="heading"<?php if($type == 'heading') { echo ' selected'; } ?>><?php echo $TEXT['HEADING']; ?></option>
75
			<option value="textfield"<?php if($type == 'textfield') { echo ' selected'; } ?>><?php echo $TEXT['SHORT'].' '.$TEXT['TEXT']; ?> (Textfield)</option>
76
			<option value="textarea"<?php if($type == 'textarea') { echo ' selected'; } ?>><?php echo $TEXT['LONG'].' '.$TEXT['TEXT']; ?> (Textarea)</option>
77
			<option value="select"<?php if($type == 'select') { echo ' selected'; } ?>><?php echo $TEXT['SELECT_BOX']; ?></option>
78
			<option value="checkbox"<?php if($type == 'checkbox') { echo ' selected'; } ?>><?php echo $TEXT['CHECKBOX_GROUP']; ?></option>
79
			<option value="radio"<?php if($type == 'radio') { echo ' selected'; } ?>><?php echo $TEXT['RADIO_BUTTON_GROUP']; ?></option>
80
			<option value="email"<?php if($type == 'email') { echo ' selected'; } ?>><?php echo $TEXT['EMAIL_ADDRESS']; ?></option>
81
		</select>
82
	</td>
83
</tr>
84
<?php if($type != 'none' AND $type != 'email') { ?>
85
	<?php if($type == 'heading') { ?>
86
	<tr>
87
		<td valign="top"><?php echo $TEXT['TEMPLATE']; ?>:</td>
88
		<td>
89
		<textarea name="template" style="width: 100%; height: 20px;"><?php echo htmlspecialchars($admin->strip_slashes_dummy($form['extra'])); ?></textarea>
90
		</td>
91
	</tr>
92
	<?php } elseif($type == 'textfield') { ?>
93
	<tr>
94
		<td><?php echo $TEXT['LENGTH']; ?>:</td>
95
		<td>
96
			<input type="text" name="length" value="<?php echo $form['extra']; ?>" style="width: 100%;" maxlength="3" />
97
		</td>
98
	</tr>
99
	<tr>
100
		<td><?php echo $TEXT['DEFAULT_TEXT']; ?>:</td>
101
		<td>
102
			<input type="text" name="value" value="<?php echo $form['value']; ?>" style="width: 100%;" />
103
		</td>
104
	</tr>
105
	<?php } elseif($type == 'textarea') { ?>
106
	<tr>
107
		<td valign="top"><?php echo $TEXT['DEFAULT_TEXT']; ?>:</td>
108
		<td>
109
			<textarea name="value" style="width: 100%; height: 100px;"><?php echo $form['value']; ?></textarea>
110
		</td>
111
	</tr>
112
	<?php } elseif($type == 'select' OR $type = 'radio' OR $type = 'checkbox') { ?>
113
	<tr>
114
		<td valign="top"><?php echo 'List'; ?>:</td>
115
		<td>
116
			<?php
117
			$option_count = 0;
118
			$list = explode(',', $form['value']);
119
			foreach($list AS $option_value) {
120
				$option_count = $option_count+1;
121
				?>
122
				<table cellpadding="3" cellspacing="0" width="100%" border="0">
123
				<tr>
124
					<td width="70"><?php echo $TEXT['OPTION'].' '.$option_count; ?>:</td>
125
					<td>
126
						<input type="text" name="value<?php echo $option_count; ?>" value="<?php echo $option_value; ?>" style="width: 250px;" />
127
					</td>
128
				</tr>
129
				</table>
130
				<?php
131
			}
132
			for($i = 0; $i < 2; $i++) {
133
				$option_count = $option_count+1;
134
				?>
135
				<table cellpadding="3" cellspacing="0" width="100%" border="0">
136
				<tr>
137
					<td width="70"><?php echo $TEXT['OPTION'].' '.$option_count; ?>:</td>
138
					<td>
139
						<input type="text" name="value<?php echo $option_count; ?>" value="" style="width: 250px;" />
140
					</td>
141
				</tr>
142
				</table>
143
				<?php
144
			}
145
			?>
146
			<input type="hidden" name="list_count" value="<?php echo $option_count; ?>" />
147
		</td>
148
	</tr>
149
	<?php } ?>
150
	<?php if($type == 'select') { ?>
151
	<tr>
152
		<td><?php echo $TEXT['SIZE']; ?>:</td>
153
		<td>
154
			<?php $form['extra'] = explode(',',$form['extra']); ?>
155
			<input type="text" name="size" value="<?php echo trim($form['extra'][0]); ?>" style="width: 100%;" maxlength="3" />
156
		</td>
157
	</tr>
158
	<tr>
159
		<td><?php echo $TEXT['ALLOW_MULTIPLE_SELECTIONS']; ?>:</td>
160
		<td>
161
			<input type="radio" name="multiselect" id="multiselect_true" value="multiple" <?php if($form['extra'][1] == 'multiple') { echo ' checked'; } ?> />
162
			<a href="#" onclick="javascript: document.getElementById('multiselect_true').checked = true;">
163
			<?php echo $TEXT['YES']; ?>
164
			</a>
165
			&nbsp;
166
			<input type="radio" name="multiselect" id="multiselect_false" value="" <?php if($form['extra'][1] == '') { echo ' checked'; } ?> />
167
			<a href="#" onclick="javascript: document.getElementById('multiselect_false').checked = true;">
168
			<?php echo $TEXT['NO']; ?>
169
			</a>
170
		</td>
171
	</tr>
172
	<?php } elseif($type == 'checkbox' OR $type == 'radio') { ?>
173
	<tr>
174
		<td valign="top"><?php echo $TEXT['SEPERATOR']; ?>:</td>
175
		<td>
176
			<input type="text" name="seperator" value="<?php echo $form['extra']; ?>" style="width: 100%;" />
177
		</td>
178
	</tr>
179
	<?php } ?>
180
<?php } ?>
181
<?php if($type != 'heading' AND $type != 'none') { ?>
182
<tr>
183
	<td><?php echo $TEXT['REQUIRED']; ?>:</td>
184
	<td>
185
		<input type="radio" name="required" id="required_true" value="1" <?php if($form['required'] == 1) { echo ' checked'; } ?> />
186
		<a href="#" onclick="javascript: document.getElementById('required_true').checked = true;">
187
		<?php echo $TEXT['YES']; ?>
188
		</a>
189
		&nbsp;
190
		<input type="radio" name="required" id="required_false" value="0" <?php if($form['required'] == 0) { echo ' checked'; } ?> />
191
		<a href="#" onclick="javascript: document.getElementById('required_false').checked = true;">
192
		<?php echo $TEXT['NO']; ?>
193
		</a>
194
	</td>
195
</tr>
196
<?php } ?>
197
</table>
198

  
199
<table cellpadding="0" cellspacing="0" border="0" width="100%">
200
<tr>
201
	<td width="90">&nbsp;
202
		
203
	</td>
204
	<td align="left">
205
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE'].' '.$TEXT['FIELD']; ?>" style="width: 200px; margin-top: 5px;"></form>
206
	</td>
207
	<td align="right">
208
		<input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
209
	</td>
210
</tr>
211
</table>
212

  
213
<?php
214

  
215
// Print admin footer
216
$admin->print_footer();
217

  
218
?>
219 0

  
trunk/wb/modules/form/add_field.php
1
<?php
2

  
3
// $Id: add_field.php,v 1.3 2005/03/28 04:34:45 rdjurovich Exp $
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff