| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        module
 | 
  
    | 5 |  * @package         Form
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       2009-2013, WebsiteBaker Org. e.V.
 | 
  
    | 8 |  * @link            http://www.websitebaker.org/
 | 
  
    | 9 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 10 |  * @platform        WebsiteBaker 2.8.x
 | 
  
    | 11 |  * @requirements    PHP 5.2.2 and higher
 | 
  
    | 12 |  * @version         $Id: modify_field.php 2 2017-07-02 15:14:29Z Manuela $
 | 
  
    | 13 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/form/modify_field.php $
 | 
  
    | 14 |  * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
 | 
  
    | 15 |  * @description
 | 
  
    | 16 |  */
 | 
  
    | 17 | 
 | 
  
    | 18 | if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
 | 
  
    | 19 | 
 | 
  
    | 20 | $print_info_banner = true;
 | 
  
    | 21 | // Tells script to update when this page was last updated
 | 
  
    | 22 | $update_when_modified = false;
 | 
  
    | 23 | // Include WB admin wrapper script
 | 
  
    | 24 | require(WB_PATH.'/modules/admin.php');
 | 
  
    | 25 | 
 | 
  
    | 26 | $sSectionIdPrefix = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
 | 
  
    | 27 | /* */
 | 
  
    | 28 | // Get id
 | 
  
    | 29 | $field_id = intval($admin->checkIDKEY('field_id', false, 'GET'));
 | 
  
    | 30 | if (!$field_id) {
 | 
  
    | 31 |  $admin->print_error('IDKEY:: '.$MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id);
 | 
  
    | 32 | }
 | 
  
    | 33 | // load module language file
 | 
  
    | 34 | $sAddonName = basename(__DIR__);
 | 
  
    | 35 | require(__DIR__.'/languages/EN.php');
 | 
  
    | 36 | if(file_exists(__DIR__.'/languages/'.LANGUAGE .'.php')) {
 | 
  
    | 37 |     require(__DIR__.'/languages/'.LANGUAGE .'.php');
 | 
  
    | 38 | }
 | 
  
    | 39 | 
 | 
  
    | 40 | $type = 'none';
 | 
  
    | 41 | // Get header and footer
 | 
  
    | 42 | $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` ';
 | 
  
    | 43 | $sql .= 'WHERE `field_id` = '.$field_id.'';
 | 
  
    | 44 | $sql .= '';
 | 
  
    | 45 | if($query_content = $database->query($sql)) {
 | 
  
    | 46 |     $form = $query_content->fetchRow(MYSQL_ASSOC);
 | 
  
    | 47 |     $type = (($form['type'] == '') ? 'none' : $form['type']);
 | 
  
    | 48 | }
 | 
  
    | 49 | // set new idkey for save_field
 | 
  
    | 50 | $field_id = $admin->getIDKEY($form['field_id']);
 | 
  
    | 51 | // Set raw html <'s and >'s to be replaced by friendly html code
 | 
  
    | 52 | $raw = array('<', '>');
 | 
  
    | 53 | $friendly = array('<', '>');
 | 
  
    | 54 | $aFtan = $admin->getFTAN('');
 | 
  
    | 55 | $sToken = $aFtan['name'].'='.$aFtan['value'];
 | 
  
    | 56 | ?><form name="modify" action="<?php echo WB_URL; ?>/modules/form/save_field_new.php" method="post" style="margin: 0;">
 | 
  
    | 57 | <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
 | 
  
    | 58 | <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
 | 
  
    | 59 | <input type="hidden" name="field_id" value="<?php echo $field_id; ?>" />
 | 
  
    | 60 | <input type="hidden" name="<?php echo $aFtan['name']; ?>" value="<?php echo $aFtan['value']; ?>">
 | 
  
    | 61 | 
 | 
  
    | 62 | <table class="frm-table">
 | 
  
    | 63 |     <tr>
 | 
  
    | 64 |         <td colspan="2"><strong><?php echo $TEXT['MODIFY'].' '.$TEXT['FIELD']; ?></strong></td>
 | 
  
    | 65 |     </tr>
 | 
  
    | 66 |     <tr>
 | 
  
    | 67 |         <td width="20%"><?php echo $TEXT['TITLE']; ?>:</td>
 | 
  
    | 68 |         <td>
 | 
  
    | 69 |             <input type="text" name="title" value="<?php echo htmlspecialchars(($form['title'])); ?>" style="width: 98%;" maxlength="255" />
 | 
  
    | 70 |         </td>
 | 
  
    | 71 |     </tr>
 | 
  
    | 72 |     <tr>
 | 
  
    | 73 |         <td><?php echo $TEXT['TYPE']; ?>:</td>
 | 
  
    | 74 |         <td>
 | 
  
    | 75 |             <select name="type" style="width: 98%;">
 | 
  
    | 76 |                 <option value=""><?php echo $TEXT['PLEASE_SELECT']; ?>...</option>
 | 
  
    | 77 |                 <option value="heading"<?php if($type == 'heading') { echo ' selected="selected"'; } ?>><?php echo $TEXT['HEADING']; ?></option>
 | 
  
    | 78 |                 <option value="textfield"<?php if($type == 'textfield') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SHORT'].' '.$TEXT['TEXT']; ?> (input)</option>
 | 
  
    | 79 |                 <option value="textarea"<?php if($type == 'textarea') { echo ' selected="selected"'; } ?>><?php echo $TEXT['LONG'].' '.$TEXT['TEXT']; ?> (textarea)</option>
 | 
  
    | 80 |                 <option value="select"<?php if($type == 'select') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SELECT_BOX']; ?> (select)</option>
 | 
  
    | 81 |                 <option value="checkbox"<?php if($type == 'checkbox') { echo ' selected="selected"'; } ?>><?php echo $TEXT['CHECKBOX_GROUP']; ?> (checkbox)</option>
 | 
  
    | 82 |                 <option value="radio"<?php if($type == 'radio') { echo ' selected="selected"'; } ?>><?php echo $TEXT['RADIO_BUTTON_GROUP']; ?> (radiobox)</option>
 | 
  
    | 83 |                 <option value="email"<?php if($type == 'email') { echo ' selected="selected"'; } ?>><?php echo $TEXT['EMAIL_ADDRESS']; ?></option>
 | 
  
    | 84 |             </select>
 | 
  
    | 85 |         </td>
 | 
  
    | 86 |     </tr>
 | 
  
    | 87 | <?php if($type != 'none' AND $type != 'email') { ?>
 | 
  
    | 88 |     <?php if($type == 'heading') { ?>
 | 
  
    | 89 |     <tr>
 | 
  
    | 90 |         <td valign="top"><?php echo $TEXT['TEMPLATE']; ?>:</td>
 | 
  
    | 91 |         <td>
 | 
  
    | 92 |             <textarea name="template" style="width: 98%; height: 20px;"><?php echo htmlspecialchars(($form['extra'])); ?></textarea>
 | 
  
    | 93 |         </td>
 | 
  
    | 94 |     </tr>
 | 
  
    | 95 |     <?php } elseif($type == 'textfield') { ?>
 | 
  
    | 96 |     <tr>
 | 
  
    | 97 |         <td><?php echo $TEXT['LENGTH']; ?>:</td>
 | 
  
    | 98 |         <td>
 | 
  
    | 99 |             <input type="text" name="length" value="<?php echo $form['extra']; ?>" style="width: 98%;" maxlength="3" />
 | 
  
    | 100 |         </td>
 | 
  
    | 101 |     </tr>
 | 
  
    | 102 |     <tr>
 | 
  
    | 103 |         <td><?php echo $TEXT['DEFAULT_TEXT']; ?>:</td>
 | 
  
    | 104 |         <td>
 | 
  
    | 105 |             <input type="text" name="value" value="<?php echo $form['value']; ?>" style="width: 98%;" />
 | 
  
    | 106 |         </td>
 | 
  
    | 107 |     </tr>
 | 
  
    | 108 |     <?php } elseif($type == 'textarea') { ?>
 | 
  
    | 109 |     <tr>
 | 
  
    | 110 |         <td valign="top"><?php echo $TEXT['DEFAULT_TEXT']; ?>:</td>
 | 
  
    | 111 |         <td>
 | 
  
    | 112 |             <textarea name="value" style="width: 98%; height: 100px;"><?php echo $form['value']; ?></textarea>
 | 
  
    | 113 |         </td>
 | 
  
    | 114 |     </tr>
 | 
  
    | 115 |     <?php } elseif($type == 'select' OR $type = 'radio' OR $type = 'checkbox') { ?>
 | 
  
    | 116 |     <tr>
 | 
  
    | 117 |         <td valign="top"><?php echo $TEXT['LIST_OPTIONS']; ?>:</td>
 | 
  
    | 118 |         <td>
 | 
  
    | 119 |             <table >
 | 
  
    | 120 | <?php
 | 
  
    | 121 |             $option_count = 0;
 | 
  
    | 122 |             $list = explode(',', $form['value']);
 | 
  
    | 123 |             foreach($list AS $option_value) {
 | 
  
    | 124 |                 $option_count = $option_count+1;
 | 
  
    | 125 | ?>
 | 
  
    | 126 |                 <tr>
 | 
  
    | 127 |                     <td width="70"><?php echo $TEXT['OPTION'].' '.$option_count; ?>:</td>
 | 
  
    | 128 |                     <td>
 | 
  
    | 129 |                         <input type="text" name="value<?php echo $option_count; ?>" value="<?php echo $option_value; ?>" style="width: 250px;" />
 | 
  
    | 130 |                     </td>
 | 
  
    | 131 |                 </tr>
 | 
  
    | 132 |                 <?php
 | 
  
    | 133 |             }
 | 
  
    | 134 |             for($i = 0; $i < 2; $i++) {
 | 
  
    | 135 |                 $option_count = $option_count+1;
 | 
  
    | 136 | ?>
 | 
  
    | 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 |                 <?php
 | 
  
    | 144 |             }
 | 
  
    | 145 | ?>
 | 
  
    | 146 |                 </table>
 | 
  
    | 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
 | 
  
    | 156 |             $form['extra'] = explode(',',$form['extra']);
 | 
  
    | 157 |             $form['extra'][0] = (@$form['extra'][0]?:3);
 | 
  
    | 158 |             ?>
 | 
  
    | 159 |             <input type="text" name="size" value="<?php echo trim($form['extra'][0]); ?>" style="width: 98%;" maxlength="3" />
 | 
  
    | 160 |         </td>
 | 
  
    | 161 |     </tr>
 | 
  
    | 162 |     <tr>
 | 
  
    | 163 |         <td><?php echo $TEXT['ALLOW_MULTIPLE_SELECTIONS']; ?>:</td>
 | 
  
    | 164 |         <td>
 | 
  
    | 165 |             <input type="radio" name="multiselect" id="multiselect_true" value="multiple" <?php if($form['extra'][1] == 'multiple') { echo ' checked="checked"'; } ?> />
 | 
  
    | 166 |             <a href="#" onclick="javascript:document.getElementById('multiselect_true').checked = true;">
 | 
  
    | 167 |             <?php echo $TEXT['YES']; ?>
 | 
  
    | 168 |             </a>
 | 
  
    | 169 |              
 | 
  
    | 170 |             <input type="radio" name="multiselect" id="multiselect_false" value="" <?php if($form['extra'][1] == '') { echo ' checked="checked"'; } ?> />
 | 
  
    | 171 |             <a href="#" onclick="javascript:document.getElementById('multiselect_false').checked = true;">
 | 
  
    | 172 |             <?php echo $TEXT['NO']; ?>
 | 
  
    | 173 |             </a>
 | 
  
    | 174 |         </td>
 | 
  
    | 175 |     </tr>
 | 
  
    | 176 |     <?php } elseif($type == 'checkbox' OR $type == 'radio') { ?>
 | 
  
    | 177 |     <tr>
 | 
  
    | 178 |         <td valign="top"><?php echo $TEXT['SEPERATOR']; ?>:</td>
 | 
  
    | 179 |         <td>
 | 
  
    | 180 |             <input type="text" name="seperator" value="<?php echo $form['extra']; ?>" style="width: 98%;" />
 | 
  
    | 181 |         </td>
 | 
  
    | 182 |     </tr>
 | 
  
    | 183 |     <?php } ?>
 | 
  
    | 184 | <?php } ?>
 | 
  
    | 185 | <?php if($type != 'heading' AND $type != 'none') { ?>
 | 
  
    | 186 |     <tr>
 | 
  
    | 187 |         <td><?php echo $TEXT['REQUIRED']; ?>:</td>
 | 
  
    | 188 |         <td>
 | 
  
    | 189 |             <input type="radio" name="required" id="required_true" value="1" <?php if($form['required'] == 1) { echo ' checked="checked"'; } ?> />
 | 
  
    | 190 |             <label for="required_true">
 | 
  
    | 191 |             <?php echo $TEXT['YES']; ?>
 | 
  
    | 192 |             </label>
 | 
  
    | 193 |              
 | 
  
    | 194 |             <input type="radio" name="required" id="required_false" value="0" <?php if($form['required'] == 0) { echo ' checked="checked"'; } ?> />
 | 
  
    | 195 |             <label for="required_false">
 | 
  
    | 196 |             <?php echo $TEXT['NO']; ?>
 | 
  
    | 197 |             </label>
 | 
  
    | 198 |         </td>
 | 
  
    | 199 |     </tr>
 | 
  
    | 200 | <?php } ?>
 | 
  
    | 201 | </table>
 | 
  
    | 202 | 
 | 
  
    | 203 | <table>
 | 
  
    | 204 |     <tr>
 | 
  
    | 205 |         <td align="left">
 | 
  
    | 206 |             <input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
 | 
  
    | 207 |         </td>
 | 
  
    | 208 |         <td align="right">
 | 
  
    | 209 |             <input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id.'#'.$sSectionIdPrefix.$section_id; ?>';" style="width: 100px; margin-top: 5px;" />
 | 
  
    | 210 |         </td>
 | 
  
    | 211 |     </tr>
 | 
  
    | 212 | </table>
 | 
  
    | 213 | </form>
 | 
  
    | 214 | <?php
 | 
  
    | 215 | 
 | 
  
    | 216 | // Print admin footer
 | 
  
    | 217 | $admin->print_footer();
 |