| [21] | 1 | <?php |
|---|
| 2 | class RCCWP_CustomFieldPage |
|---|
| 3 | { |
|---|
| 4 | function Edit() |
|---|
| 5 | { |
|---|
| 6 | global $FIELD_TYPES; |
|---|
| 7 | $custom_field = RCCWP_CustomField::Get((int)$_GET['custom-field-id']); |
|---|
| 8 | $customGroupID = $custom_field->group_id; |
|---|
| 9 | |
|---|
| 10 | if (in_array($custom_field->type, array('Image'))) $cssVlaue = $custom_field->CSS; |
|---|
| 11 | |
|---|
| 12 | ?> |
|---|
| 13 | |
|---|
| 14 | <div class="wrap"> |
|---|
| 15 | <h2>Edit Custom Field - <?php echo $custom_field->description ?></h2> |
|---|
| 16 | |
|---|
| 17 | <br class="clear" /> |
|---|
| 18 | <?php |
|---|
| 19 | if (isset($_GET['err_msg'])) : |
|---|
| 20 | switch ($_GET['err_msg']){ |
|---|
| 21 | case -1: |
|---|
| 22 | ?> |
|---|
| 23 | <div class="error"><p> A field with the same name already exists in this write panel. Please choose a different name.</p></div> |
|---|
| 24 | <?php |
|---|
| 25 | } |
|---|
| 26 | endif; |
|---|
| 27 | ?> |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('submit-edit-custom-field')."&custom-group-id=$customGroupID"?>" method="post" id="edit-custom-field-form" onsubmit="return checkEmpty();"> |
|---|
| 31 | <input type="hidden" name="custom-field-id" value="<?php echo $custom_field->id?>"> |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> |
|---|
| 35 | <tbody> |
|---|
| 36 | <tr valign="top"> |
|---|
| 37 | <th scope="row">Name:</th> |
|---|
| 38 | <td><input name="custom-field-name" id="custom-field-name" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->name)?>" /></td> |
|---|
| 39 | </tr> |
|---|
| 40 | <tr valign="top"> |
|---|
| 41 | <th scope="row">Label:</th> |
|---|
| 42 | <td><input name="custom-field-description" id="custom-field-description" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->description)?>" /></td> |
|---|
| 43 | </tr> |
|---|
| 44 | |
|---|
| 45 | <tr valign="top"> |
|---|
| 46 | <th scope="row">Can be duplicated:</th> |
|---|
| 47 | <td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" <?php echo $custom_field->duplicate==0 ? "":"checked" ?>/></td> |
|---|
| 48 | </tr> |
|---|
| 49 | <tr valign="top"> |
|---|
| 50 | <th scope="row">Order:</th> |
|---|
| 51 | <td> |
|---|
| 52 | <input name="custom-field-order" id="custom-field-order" size="2" type="text" value="<?php echo $custom_field->display_order?>" /> |
|---|
| 53 | </td> |
|---|
| 54 | </tr> |
|---|
| 55 | |
|---|
| 56 | <?php if (in_array($custom_field->type_id, |
|---|
| 57 | array( $FIELD_TYPES['textbox'], |
|---|
| 58 | $FIELD_TYPES['multiline_textbox'], |
|---|
| 59 | $FIELD_TYPES['dropdown_list'], |
|---|
| 60 | $FIELD_TYPES['listbox'], |
|---|
| 61 | $FIELD_TYPES['file'], |
|---|
| 62 | $FIELD_TYPES['image'], |
|---|
| 63 | $FIELD_TYPES['audio'] |
|---|
| 64 | ))){ ?> |
|---|
| 65 | <tr valign="top"> |
|---|
| 66 | <th scope="row">Required:</th> |
|---|
| 67 | <td> |
|---|
| 68 | <select name="custom-field-required" id="custom-field-required"> |
|---|
| 69 | <option value="0" <?php echo ($custom_field->required_field == 0 ? 'selected="selected"' : ''); ?> >Not Required - can be empty</option> |
|---|
| 70 | <option value="1" <?php echo ($custom_field->required_field == 1 ? 'selected="selected"' : ''); ?> >Required - can not be empty</option> |
|---|
| 71 | </select> |
|---|
| 72 | </td> |
|---|
| 73 | </tr> |
|---|
| 74 | |
|---|
| 75 | <?php } ?> |
|---|
| 76 | |
|---|
| 77 | <?php if (in_array($custom_field->type, array('Textbox', 'Listbox'))) : ?> |
|---|
| 78 | <tr valign="top"> |
|---|
| 79 | <th scope="row">Size:</th> |
|---|
| 80 | <td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php echo $custom_field->properties['size']?>" /></td> |
|---|
| 81 | </tr> |
|---|
| 82 | <?php endif; ?> |
|---|
| 83 | |
|---|
| 84 | <?php if (in_array($custom_field->type, array('Multiline Textbox'))) : ?> |
|---|
| 85 | <tr valign="top"> |
|---|
| 86 | <th scope="row">Height:</th> |
|---|
| 87 | <td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php echo $custom_field->properties['height']?>" /></td> |
|---|
| 88 | </tr> |
|---|
| 89 | <tr valign="top"> |
|---|
| 90 | <th scope="row">Width:</th> |
|---|
| 91 | <td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php echo $custom_field->properties['width']?>" /></td> |
|---|
| 92 | </tr> |
|---|
| 93 | <?php endif; ?> |
|---|
| 94 | |
|---|
| 95 | <?php if (in_array($custom_field->type, array('Date'))) : ?> |
|---|
| 96 | <tr valign="top"> |
|---|
| 97 | <th scope="row">Format:</th> |
|---|
| 98 | <td> |
|---|
| 99 | <select name="custom-field-date-format" id="custom-field-date-format"> |
|---|
| 100 | <option value="m/d/Y" <?php if ($custom_field->properties['format'] == "m/d/Y" ) echo " selected ";?>>4/20/2008</option> |
|---|
| 101 | <option value="l, F d, Y" <?php if ($custom_field->properties['format'] == "l, F d, Y" ) echo " selected ";?>>Sunday, April 20, 2008</option> |
|---|
| 102 | <option value="F d, Y" <?php if ($custom_field->properties['format'] == "F d, Y" ) echo " selected ";?>>April 20, 2008</option> |
|---|
| 103 | <option value="m/d/y" <?php if ($custom_field->properties['format'] == "m/d/y" ) echo " selected ";?>>4/20/08</option> |
|---|
| 104 | <option value="Y-d-m" <?php if ($custom_field->properties['format'] == "Y-m-d" ) echo " selected ";?>>2008-04-20</option> |
|---|
| 105 | <option value="d-M-y" <?php if ($custom_field->properties['format'] == "d-M-y" ) echo " selected ";?>>20-Apr-08</option> |
|---|
| 106 | <option value="m.d.Y" <?php if ($custom_field->properties['format'] == "m.d.Y" ) echo " selected ";?>>4.20.2008</option> |
|---|
| 107 | <option value="m.d.y" <?php if ($custom_field->properties['format'] == "m.d.y" ) echo " selected ";?>>4.20.08</option> |
|---|
| 108 | </select> |
|---|
| 109 | </td> |
|---|
| 110 | </tr> |
|---|
| 111 | <?php endif; ?> |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | <?php |
|---|
| 115 | if ($custom_field->has_options == "true") : |
|---|
| 116 | $options = implode("\n", (array)$custom_field->options) |
|---|
| 117 | ?> |
|---|
| 118 | <tr valign="top"> |
|---|
| 119 | <th scope="row">Options:</th> |
|---|
| 120 | <td> |
|---|
| 121 | <textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"><?php echo htmlspecialchars($options)?></textarea><br /> |
|---|
| 122 | <em>Separate each option with a newline.</em> |
|---|
| 123 | </td> |
|---|
| 124 | </tr> |
|---|
| 125 | <tr valign="top"> |
|---|
| 126 | <th scope="row">Default Value:</th> |
|---|
| 127 | <td> |
|---|
| 128 | <?php |
|---|
| 129 | $default_value = implode("\n", (array)$custom_field->default_value); |
|---|
| 130 | if ($custom_field->allow_multiple_values == "true") : |
|---|
| 131 | ?> |
|---|
| 132 | <textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"><?php echo htmlspecialchars($default_value)?></textarea><br /> |
|---|
| 133 | <em>Separate each value with a newline.</em> |
|---|
| 134 | <?php |
|---|
| 135 | else: |
|---|
| 136 | ?> |
|---|
| 137 | <input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" value="<?php echo htmlspecialchars($default_value)?>" /> |
|---|
| 138 | <?php |
|---|
| 139 | endif; |
|---|
| 140 | ?> |
|---|
| 141 | </td> |
|---|
| 142 | </tr> |
|---|
| 143 | <?php |
|---|
| 144 | endif; |
|---|
| 145 | ?> |
|---|
| 146 | |
|---|
| 147 | <tr valign="top"> |
|---|
| 148 | <th scope="row">Type:</th> |
|---|
| 149 | <td> |
|---|
| 150 | |
|---|
| 151 | <!-- START :: Javascript for Image/Photo' Css Class --> |
|---|
| 152 | <script type="text/javascript" language="javascript"> |
|---|
| 153 | submitForm = false; |
|---|
| 154 | function fun(name) |
|---|
| 155 | { |
|---|
| 156 | if(name == "Image") |
|---|
| 157 | { |
|---|
| 158 | document.getElementById('divCSS').style.display = 'inline'; |
|---|
| 159 | document.getElementById('divLbl').style.display = 'inline'; |
|---|
| 160 | document.getElementById('lblHeight').style.display = 'inline'; |
|---|
| 161 | document.getElementById('txtHeight').style.display = 'inline'; |
|---|
| 162 | document.getElementById('lblWidth').style.display = 'inline'; |
|---|
| 163 | document.getElementById('txtWidth').style.display = 'inline'; |
|---|
| 164 | } |
|---|
| 165 | else |
|---|
| 166 | { |
|---|
| 167 | document.getElementById('divCSS').style.display = 'none'; |
|---|
| 168 | document.getElementById('divLbl').style.display = 'none'; |
|---|
| 169 | document.getElementById('lblHeight').style.display = 'none'; |
|---|
| 170 | document.getElementById('txtHeight').style.display = 'none'; |
|---|
| 171 | document.getElementById('lblWidth').style.display = 'none'; |
|---|
| 172 | document.getElementById('txtWidth').style.display = 'none'; |
|---|
| 173 | } |
|---|
| 174 | } |
|---|
| 175 | function checkEmpty() |
|---|
| 176 | { |
|---|
| 177 | if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){ |
|---|
| 178 | alert("Please fill in the name and the label of the field"); |
|---|
| 179 | return false; |
|---|
| 180 | } |
|---|
| 181 | return true; |
|---|
| 182 | |
|---|
| 183 | } |
|---|
| 184 | </script> |
|---|
| 185 | <!-- END :: Javascript for Image/Photo' Css Class --> |
|---|
| 186 | |
|---|
| 187 | <?php |
|---|
| 188 | $field_types = RCCWP_CustomField::GetCustomFieldTypes(); |
|---|
| 189 | foreach ($field_types as $field) : |
|---|
| 190 | $checked = |
|---|
| 191 | $field->name == $custom_field->type ? |
|---|
| 192 | 'checked="checked"' : ''; |
|---|
| 193 | ?> |
|---|
| 194 | <label><input name="custom-field-type" value="<?php echo $field->id?>" type="radio" <?php echo $checked?> onclick='fun("<?php echo $field->name?>");'/> |
|---|
| 195 | <?php echo $field->name?></label><br /> |
|---|
| 196 | <?php |
|---|
| 197 | endforeach; |
|---|
| 198 | ?> |
|---|
| 199 | </td> |
|---|
| 200 | </tr> |
|---|
| 201 | <!-- START :: For Image/Photo' Css --> |
|---|
| 202 | <?php |
|---|
| 203 | $isDisplay = $custom_field->type == "Image" ? 'display:inline;' : 'display:none;'; |
|---|
| 204 | ?> |
|---|
| 205 | <?php |
|---|
| 206 | $size = explode("&",$custom_field->properties['params']); |
|---|
| 207 | |
|---|
| 208 | if (substr($size[1],0 ,1) == "h"){ |
|---|
| 209 | $h = substr($size[1], 2); |
|---|
| 210 | } |
|---|
| 211 | elseif (substr($size[1],0 ,1) == "w"){ |
|---|
| 212 | $w = substr($size[1], 2); |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | if (substr($size[2],0 ,1) == "h"){ |
|---|
| 216 | $h = substr($size[2], 2); |
|---|
| 217 | } |
|---|
| 218 | elseif (substr($size[2],0 ,1) == "w"){ |
|---|
| 219 | $w = substr($size[2], 2); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | $cssVlaue = $custom_field->CSS; |
|---|
| 223 | ?> |
|---|
| 224 | <tr valign="top"> |
|---|
| 225 | <th scope="row"><span id="lblHeight" style="<?php echo $isDisplay;?>">Max Height:</span></th> |
|---|
| 226 | <td><span id="txtHeight" style="<?php echo $isDisplay;?>"><input type="text" name="custom-field-photo-height" id="custom-field-photo-height" size="3" value="<?php echo $h; ?>" /></span></td> |
|---|
| 227 | </tr> |
|---|
| 228 | <tr valign="top"> |
|---|
| 229 | <th scope="row"><span id="lblWidth" style="<?php echo $isDisplay;?>">Max Width:</span></th> |
|---|
| 230 | <td><span id="txtWidth" style="<?php echo $isDisplay;?>"><input type="text" name="custom-field-photo-width" id="custom-field-photo-width" size="3" value="<?php echo $w; ?>" /></span></td> |
|---|
| 231 | </tr> |
|---|
| 232 | <tr valign="top"> |
|---|
| 233 | <th scope="row"><div id="divLbl" style="<?php echo $isDisplay;?>">Css Class:</div></th> |
|---|
| 234 | <td> |
|---|
| 235 | <div id="divCSS" style="<?php echo $isDisplay;?>"> |
|---|
| 236 | <input name="custom-field-css" id="custom-field-css" size="40" type="text" value="<?php echo $cssVlaue?>" /> |
|---|
| 237 | </div> |
|---|
| 238 | </td> |
|---|
| 239 | </tr> |
|---|
| 240 | |
|---|
| 241 | <!-- END :: For Image/Photo' Css --> |
|---|
| 242 | </tbody> |
|---|
| 243 | </table> |
|---|
| 244 | |
|---|
| 245 | <input name="flutter_action" type="hidden" value="submit-edit-custom-field" /> |
|---|
| 246 | <p class="submit" > |
|---|
| 247 | <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field')."&custom-group-id=$customGroupID"?>" class="button"><?php _e('Cancel'); ?></a> |
|---|
| 248 | <input type="submit" id="submit-edit-custom-field" value="Update" onclick="submitForm=true;" /> |
|---|
| 249 | </p> |
|---|
| 250 | |
|---|
| 251 | </form> |
|---|
| 252 | |
|---|
| 253 | </div> |
|---|
| 254 | |
|---|
| 255 | <?php |
|---|
| 256 | } |
|---|
| 257 | } |
|---|
| 258 | ?> |
|---|