Project

General

Profile

1
<?php
2

    
3
// $Id: modify_field.php 1069 2009-07-15 20:28:15Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, 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
	exit(0);
37
} else {
38
	$field_id = $_GET['field_id'];
39
}
40

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

    
44
//overwrite php.ini on Apache servers for valid SESSION ID Separator
45
if(function_exists('ini_set')) {
46
	ini_set('arg_separator.output', '&amp;');
47
}
48

    
49
// Get header and footer
50
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE field_id = '$field_id'");
51
$form = $query_content->fetchRow();
52
$type = $form['type'];
53
if($type == '') {
54
	$type = 'none';
55
}
56

    
57
// Set raw html <'s and >'s to be replaced by friendly html code
58
$raw = array('<', '>');
59
$friendly = array('&lt;', '&gt;');
60
?>
61

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

    
64
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
65
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
66
<input type="hidden" name="field_id" value="<?php echo $field_id; ?>" />
67

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

    
208
<table cellpadding="0" cellspacing="0" border="0" width="100%">
209
	<tr>
210
		<td align="left">
211
			<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
212
		</td>
213
		<?php
214
		// added by John Maats, PCWacht, 12 januar 2006
215
		if ($type<>'none') {
216
		?>
217
		<td align="center">
218
			<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; ?>&amp;section_id=<?php echo $section_id; ?>';" style="width: 200px; margin-top: 5px;" />
219
		</td>
220
		<?php } 
221
		// end addition
222
		?>
223
		<td align="right">
224
			<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;" />
225
		</td>
226
	</tr>
227
</table>
228
</form>
229
<?php
230

    
231
// Print admin footer
232
$admin->print_footer();
233

    
234
?>
(12-12/21)