PageRenderTime 26ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/magic-fields/RCCWP_CreateCustomFieldPage.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 357 lines | 327 code | 30 blank | 0 comment | 10 complexity | c7ee2f86f1e80dd13989e16e1e41d1d1 MD5 | raw file
  1. <?php
  2. include_once('RCCWP_CustomField.php');
  3. class RCCWP_CreateCustomFieldPage
  4. {
  5. function Main()
  6. {
  7. global $FIELD_TYPES,$mf_domain;
  8. $customGroupID = $_REQUEST['custom-group-id'];
  9. ?>
  10. <div class="wrap">
  11. <h2><?php _e("Create Custom Field", $mf_domain); ?></h2>
  12. <br class="clear" />
  13. <?php
  14. if (isset($_GET['err_msg'])) :
  15. switch ($_GET['err_msg']){
  16. case -1:
  17. ?>
  18. <div class="error"><p> <?php _e('A field with the same name already exists in this write panel. Please choose a different name.',$mf_domain);?></p></div>
  19. <?php
  20. }
  21. endif;
  22. ?>
  23. <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('continue-create-custom-field')?>" method="post" name="create_custom_field_form" id="create-custom-field-form" onsubmit="return checkEmpty();" autocomplete="off">
  24. <?php if(isset($_GET['custom-group-id']) && !empty($_GET['custom-group-id'])) { ?>
  25. <input type="hidden" name="custom-group-id" value="<?php echo $_GET['custom-group-id']?>">
  26. <?php } ?>
  27. <?php if(isset($_POST['custom-group-id']) && !empty($_POST['custom-group-id'])) { ?>
  28. <input type="hidden" name="custom-group-id" value="<?php echo $_POST['custom-group-id']?>">
  29. <?php } ?>
  30. <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
  31. <tbody>
  32. <tr valign="top">
  33. <th scope="row"><?php _e("Name", $mf_domain); ?>:</th>
  34. <td>
  35. <input name="custom-field-name" id="custom-field-name" size="40" type="text" />
  36. <input type="hidden" id="custom-field-name_hidden" name="custom-field-name_hidden" onchange="copyField();">
  37. <p>
  38. <?php _e('Type a unique name for the field, the name must be unique among all fields
  39. in this panel. The name of the field is the key by which you can retrieve
  40. the field value later.',$mf_domain);?>
  41. </p>
  42. </td>
  43. </tr>
  44. <tr valign="top">
  45. <th scope="row"><?php _e("Label", $mf_domain); ?>:</th>
  46. <td>
  47. <input name="custom-field-description" id="custom-field-description" size="40" type="text" />
  48. <p>
  49. <?php _e('Type a label for the field. The label of the field is displayed
  50. beside the field in Write Panel page.',$mf_domain); ?>
  51. </p>
  52. </td>
  53. </tr>
  54. <tr valign="top">
  55. <th scope="row"><?php _e('Help text',$mf_domain); ?>:</th>
  56. <td>
  57. <input name="custom-field-helptext" id="custom-field-helptext" size="40" type="text" /><br/><small><?php _e('If set, this will be displayed in a tooltip next to the field label', $mf_domain); ?></small></td>
  58. </tr>
  59. <tr valign="top">
  60. <th scope="row"><?php _e("Can be duplicated", $mf_domain); ?>:</th>
  61. <td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" /></td>
  62. </tr>
  63. <tr valign="top">
  64. <th scope="row"><?php _e("Order", $mf_domain); ?>:</th>
  65. <td><input type="text" name="custom-field-order" id="custom-field-order" size="2" value="0" /></td>
  66. </tr>
  67. <tr valign="top">
  68. <th scope="row"><?php _e("Required", $mf_domain); ?>:</th>
  69. <td>
  70. <select name="custom-field-required" id="custom-field-required">
  71. <option value="0" selected="selected"><?php _e('Not Required - can be empty',$mf_domain); ?></option>
  72. <option value="1"><?php _e('Required - can not be empty',$mf_domain); ?></option>
  73. </select>
  74. </td>
  75. </tr>
  76. <tr valign="top">
  77. <th scope="row"><?php _e("Type", $mf_domain); ?>:</th>
  78. <td>
  79. <!-- START :: Javascript for Image/Photo' Css Class and for check -->
  80. <script type="text/javascript" language="javascript">
  81. submitForm = false;
  82. function fun(name)
  83. {
  84. if(name == "Image")
  85. {
  86. document.getElementById('divLbl').style.display = 'inline';
  87. document.getElementById('divCSS').style.display = 'inline';
  88. }
  89. else
  90. {
  91. document.getElementById('divLbl').style.display = 'none';
  92. document.getElementById('divCSS').style.display = 'none';
  93. }
  94. }
  95. function checkEmpty()
  96. {
  97. if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){
  98. alert("<?php _e('Please fill in the name and the label of the field',$mf_domain); ?>");
  99. return false;
  100. }
  101. return true;
  102. }
  103. </script>
  104. <!-- END :: Javascript for Image/Photo' Css Class -->
  105. <?php
  106. $field_types = RCCWP_CustomField::GetCustomFieldTypes();
  107. foreach ($field_types as $field) :
  108. $checked = $field->name == "Textbox" ? 'checked="checked"' : '';
  109. ?>
  110. <label><input name="custom-field-type" value="<?php echo $field->id?>" type="radio" <?php echo $checked?> onclick='fun("<?php echo $field->name?>");' /> <!-- Calling Javascript Function -->
  111. <?php echo $field->name?></label><br />
  112. <?php
  113. endforeach;
  114. ?>
  115. </td>
  116. </tr>
  117. <!-- START :: For Image/Photo' Css -->
  118. <tr valign="top">
  119. <th scope="row"><div id="divLbl" style="display:none"><?php _e('Css Class',$mf_domain);?>:</div></th>
  120. <td>
  121. <div id="divCSS" style="display:none">
  122. <input name="custom-field-css" id="custom-field-css" size="40" type="text" value="magicfields" />
  123. </div>
  124. </td>
  125. </tr>
  126. <!-- END :: For Image/Photo' Css -->
  127. </tbody>
  128. </table>
  129. <p class="submit" >
  130. <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field')."&custom-group-id=$customGroupID"?>" class="button"><?php _e('Cancel',$mf_domain); ?></a>
  131. <input type="submit" id="continue-create-custom-field" value='<?php _e("Continue",$mf_domain); ?>' onclick="submitForm=true;"/>
  132. </p>
  133. </form>
  134. </div>
  135. <?php
  136. }
  137. function SetOptions()
  138. {
  139. global $mf_domain;
  140. $current_field = RCCWP_CustomField::GetCustomFieldTypes($_POST['custom-field-type']);
  141. $customGroupID = $_REQUEST['custom-group-id'];
  142. $default = array(
  143. 'custom-group-id' => '',
  144. 'custom-field-name' => '',
  145. 'custom-field-description' => '',
  146. 'custom-field-duplicate' => '',
  147. 'custom-field-order' => '',
  148. 'custom-field-required' => '',
  149. 'custom-field-type' => '',
  150. 'custom-field-helptext' => '',
  151. );
  152. $values = array_merge($default,$_POST);
  153. ?>
  154. <div class="wrap">
  155. <h2><?php _e("Create Custom Field", $mf_domain);?></h2>
  156. <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('finish-create-custom-field')?>" method="post" id="continue-create-new-field-form">
  157. <input type="hidden" name="custom-group-id" value="<?php echo $values['custom-group-id']?>" />
  158. <input type="hidden" name="custom-field-name" value="<?php echo htmlspecialchars($values['custom-field-name'])?>" />
  159. <input type="hidden" name="custom-field-description" value="<?php echo htmlspecialchars($values['custom-field-description'])?>" />
  160. <input type="hidden" name="custom-field-duplicate" value="<?php echo htmlspecialchars($values['custom-field-duplicate'])?>" />
  161. <input type="hidden" name="custom-field-order" value="<?php echo $values['custom-field-order']?>" />
  162. <input type="hidden" name="custom-field-required" value="<?php echo $values['custom-field-required']?>" />
  163. <input type="hidden" name="custom-field-type" value="<?php echo $values['custom-field-type']?>" />
  164. <input type="hidden" name="custom-field-helptext" value="<?php echo $values['custom-field-helptext']?>" />
  165. <!-- Hidden value for Image/Photo' Css Class-->
  166. <input type="hidden" name="custom-field-css" value="<?php echo $_POST['custom-field-css']?>" />
  167. <h3><?php echo $current_field->name?></h3>
  168. <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
  169. <tbody>
  170. <?php
  171. if ($current_field->has_properties == "true") :
  172. ?>
  173. <?php
  174. if (in_array($current_field->name, array('Textbox', 'Listbox'))) :
  175. if ($current_field->name == 'Textbox')
  176. $size = 25;
  177. else if ($current_field->name == 'Listbox')
  178. $size = 3;
  179. ?>
  180. <tr valign="top">
  181. <th scope="row"><?php _e('Size', $mf_domain); ?>:</th>
  182. <td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php echo $size?>" /></td>
  183. </tr>
  184. <?php endif; ?>
  185. <?php
  186. if (in_array($current_field->name, array('Multiline Textbox'))) :
  187. $height = 3;
  188. $width = 23;
  189. ?>
  190. <tr valign="top">
  191. <th scope="row"><?php _e('Height', $mf_domain); ?>:</th>
  192. <td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php echo $height?>" /></td>
  193. </tr>
  194. <tr valign="top">
  195. <th scope="row"><?php _e('Width', $mf_domain); ?>:</th>
  196. <td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php echo $width?>" /></td>
  197. </tr>
  198. <tr valign="top">
  199. <th scope="row"><?php _e('Hide Visual Editor for this field', $mf_domain); ?>:</th>
  200. <td><input name="hide-visual-editor" id="hide-visual-editor" value="1" type="checkbox"></td>
  201. </tr>
  202. <?php endif; ?>
  203. <?php
  204. if (in_array($current_field->name, array('Slider'))) :
  205. $min_val = 0;
  206. $max_val = 10;
  207. $step = 1;
  208. ?>
  209. <tr valign="top">
  210. <th scope="row"><?php _e('Value min', $mf_domain); ?>:</th>
  211. <td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php echo $min_val?>" /></td>
  212. </tr>
  213. <tr valign="top">
  214. <th scope="row"><?php _e('Value max', $mf_domain);?>:</th>
  215. <td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php echo $max_val?>" /></td>
  216. </tr>
  217. <tr valign="top">
  218. <th scope="row"><?php _e('Stepping', $mf_domain);?>:</th>
  219. <td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php echo $step?>" /></td>
  220. </tr>
  221. <?php endif; ?>
  222. <?php
  223. //eeble
  224. if (in_array($current_field->name, array('Related Type'))) :
  225. $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
  226. ?>
  227. <tr valign="top">
  228. <th scope="row"><?php _e('Related Type Panel', $mf_domain); ?>:</th>
  229. <td><select name="custom-field-related-type-panel-id" id="custom-field-related-type-panel-id">
  230. <option value="-4">All Post</option>
  231. <option value="-3">All Page</option>
  232. <option value="-2">All Post with Write Panel</option>
  233. <option value="-1">All Page with Write Panel</option>
  234. <?php foreach ($customWritePanels as $panel): ?>
  235. <option value="<?php echo $panel->id ?>"><?php echo $panel->name ?></option>
  236. <?php endforeach; ?>
  237. </select></td>
  238. </tr>
  239. <?php endif; ?>
  240. <?php
  241. endif; // has_properties
  242. ?>
  243. <?php
  244. if ($current_field->has_options == "true") :
  245. ?>
  246. <tr valign="top">
  247. <th scope="row"><?php _e('Options', $mf_domain);?>:</th>
  248. <td>
  249. <textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"></textarea><br />
  250. <em><?php _e('Separate each option with a newline.', $mf_domain);?></em>
  251. </td>
  252. </tr>
  253. <tr valign="top">
  254. <th scope="row"><?php _e('Default Value', $mf_domain);?>:</th>
  255. <td>
  256. <?php
  257. if ($current_field->allow_multiple_values == "true") :
  258. ?>
  259. <textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"></textarea><br />
  260. <em><?php _e('Separate each value with a newline.', $mf_domain);?></em>
  261. <?php
  262. else :
  263. ?>
  264. <input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" />
  265. <?php
  266. endif;
  267. ?>
  268. </td>
  269. </tr>
  270. <?php endif; ?>
  271. <?php if( $current_field->has_properties && $current_field->name == 'Image' ) : ?>
  272. <tr valign="top">
  273. <th scope="row"><?php _e('Options', $mf_domain);?>:</th>
  274. <td>
  275. <?php _e('Max Height', $mf_domain);?>: <input type="text" name="custom-field-photo-height" id="custom-field-photo-height"/>
  276. <?php _e('Max Width', $mf_domain);?>: <input type="text" name="custom-field-photo-width" id="custom-field-photo-width" />
  277. <?php _e('Custom', $mf_domain);?>: <input type="text" name="custom-field-custom-params" id="custom-field-custom-params" />
  278. </td>
  279. </tr>
  280. <?php endif; ?>
  281. <!-- Date Custom Field -->
  282. <?php if( $current_field->has_properties && $current_field->name == 'Date' ) : ?>
  283. <tr valign="top">
  284. <th scope="row"><?php _e('Options', $mf_domain);?>:</th>
  285. <td>
  286. <?php _e('Format', $mf_domain);?>: <select name="custom-field-date-format" id="custom-field-date-format">
  287. <option value="m/d/Y">4/20/2008</option>
  288. <option value="l, F d, Y">Sunday, April 20, 2008</option>
  289. <option value="F d, Y">April 20, 2008</option>
  290. <option value="m/d/y">4/20/08</option>
  291. <option value="Y-m-d">2008-04-20</option>
  292. <option value="d-M-y">20-Apr-08</option>
  293. <option value="m.d.Y">4.20.2008</option>
  294. <option value="m.d.y">4.20.08</option>
  295. </select>
  296. </td>
  297. </tr>
  298. <?php endif; ?>
  299. <!-- Date Custom Field -->
  300. </tbody>
  301. </table>
  302. <p class="submit" >
  303. <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field')."&custom-group-id=$customGroupID"?>" class="button"><?php _e('Cancel', $mf_domain); ?></a>
  304. <input type="submit" id="finish-create-custom-field" value="<?php _e('Finish', $mf_domain); ?>" />
  305. </p>
  306. </form>
  307. </div>
  308. <?php
  309. }
  310. } //end class