Project

General

Profile

1
<?php
2

    
3
// $Id: modify_field.php 116 2005-09-16 21:20:22Z stefan $
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(($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(($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
?>
(10-10/17)