Project

General

Profile

1
<?php
2

    
3
// $Id: modify_field.php 399 2006-12-24 07:50:44Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2007, 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
// Get header and footer
45
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE field_id = '$field_id'");
46
$form = $query_content->fetchRow();
47
$type = $form['type'];
48
if($type == '') {
49
	$type = 'none';
50
}
51

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

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

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

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

    
200
<table cellpadding="0" cellspacing="0" border="0" width="100%">
201
<tr>
202
	<td width="90">&nbsp;
203
		
204
	</td>
205
	<td align="left">
206
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE'].' '.$TEXT['FIELD']; ?>" style="width: 200px; margin-top: 5px;"></form>
207
	</td>
208
	<td align="right">
209
		<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;" />
210
	</td>
211
</tr>
212
</table>
213

    
214
<?php
215

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

    
219
?>
(10-10/17)