function custom_contact_get_form() { $fields = custom_contact_get_field_defs(); $html = '<div class="custom_contact_form">' . "\n"; foreach ($fields as $field) { if ($field->required == 1) { $required_subclass = '_required'; } else { $required_subclass = ''; } $html .= '<div class="custom_contact_row">' . "\n"; if ($field->input_type != CC_CHECKBOX_FIELD) { $html .= '<div class="custom_contact_label' . $required_subclass . '">'; $html .= xyooj_unesc_quote($field->label); $html .= '</div><!-- label -->'; } $html .= '<div class="custom_contact_data">'; if ($field->input_type == CC_TEXT_FIELD) { $html .= '<input type="text" id="field_' . $field->id . '" name="field_' . $field->id . '" />'; } else { if ($field->input_type == CC_TEXTAREA_FIELD) { $html .= '<textarea id="field_' . $field->id . '" name="field_' . $field->id . '" rows="3" cols="50"></textarea>'; } else { if ($field->input_type == CC_CHECKBOX_FIELD) { $html .= '<input type="checkbox" value="Yes" id="field_' . $field->id . '" name="field_' . $field->id . '" />'; } else { if ($field->input_type == CC_SELECT_FIELD) { $html .= '<select id="field_' . $field->id . '" name="field_' . $field->id . '" >'; $options = explode(',', xyooj_unesc_quote($field->options)); foreach ($options as $option) { $html .= '<option value="' . $option . '">' . $option . '</option>'; } $html .= '</select>'; } } } } $html .= '</div><!-- data -->'; if ($field->input_type == CC_CHECKBOX_FIELD) { $html .= '<div class="custom_contact_label' . $required_subclass . '">'; $html .= xyooj_unesc_quote($field->label); $html .= '</div><!-- label -->'; } $html .= "\n</div><!-- row --><br/>\n"; } $html .= '<div class="custom_contact_buttons"><input type="button" value="Senden" onclick="customContactEmail(); return false;"/></div>' . "\n"; $html .= '</div><!-- form -->'; return $html; }
function custom_contact_build_field_form($custom_contact_field, $custom_contact_action) { ?> <form name="custom_contact_options" method="post"> <input type="hidden" name="action" value="<?php echo $custom_contact_action; ?> " /> <input type="hidden" name="id" value="<?php echo $custom_contact_field->id; ?> " /> <fieldset name="new" class="options"> <table summary="Field" class="editform" cellpadding="5" cellspacing="2" style="width:100%;vertical-align:top;"> <tr> <th scope="row">Field Label: </th> <td><input name="label" max_length="64" value="<?php if ($custom_contact_field != null) { echo xyooj_unesc_quote($custom_contact_field->label); } ?> " size="40" class="code" type="text" /> </td> </tr> <tr> <th scope="row">Required: </th> <td> <input type="checkbox" name="required" value="true" <?php if ($custom_contact_field != null && $custom_contact_field->required == 1) { echo "checked='checked'"; } ?> /> </td> </tr> <tr> <th scope="row">Input Type: </th> <td> <select name="input_type"> <option value="0" <?php if ($custom_contact_field != null && $custom_contact_field->input_type == '0') { echo 'selected="selected"'; } ?> >Text Box</option> <option value="1" <?php if ($custom_contact_field != null && $custom_contact_field->input_type == '1') { echo 'selected="selected"'; } ?> >Text Area</option> <option value="2" <?php if ($custom_contact_field != null && $custom_contact_field->input_type == '2') { echo 'selected="selected"'; } ?> >Select/Option</option> <option value="3" <?php if ($custom_contact_field != null && $custom_contact_field->input_type == '3') { echo 'selected="selected"'; } ?> >Checkbox</option> </select> Options: <input type="text" name="options" value="<?php if ($custom_contact_field != null) { echo $custom_contact_field->options; } ?> "/> comma separated, i.e. Sales,Marketing,Tech Support,Press Contact,Other </td> </tr> <tr> <th scope="row">Form Position: </th> <td> <input type="text" name="form_position" value="<?php if ($custom_contact_field == null) { echo "0"; } else { echo $custom_contact_field->form_position; } ?> " size="4" maxlength="4" class="code" /> </td> </tr> <!--tr> <th scope="row">Text Max Num Characters: </th> <td> <input type="text" name="text_max_chars" value="<?php if ($custom_contact_field == null) { echo "4096"; } else { echo $custom_contact_field->text_max_chars; } ?> " size="9" maxlength="4" class="code" /> </td> </tr--> </table> </fieldset> <div class="submit"> <?php if ($custom_contact_field != null) { ?> <input type="submit" name="delete" value="<?php _e('Delete Field', 'Localization name'); ?> " title="Delete Field" onclick="javascript: return confirm('Are you sure ?');" /> <?php } ?> <input type="submit" name="update_options" value="<?php _e($custom_contact_action == 'add' ? 'Add Field' : 'Modify Field', 'Localization name'); ?> " title="Submit and saves changes" /> </div> </form> <?php if ($custom_contact_field != null) { echo "<hr/>"; } ?> <?php }
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once '../../../wp-blog-header.php'; require_once 'custom-contact.php'; custom_contact_init(); header("Content-type: text/xml;"); $fields = custom_contact_get_field_defs(); $email_body = ""; foreach ($fields as $field) { $field_value = $_REQUEST['field_' . $field->id]; if ($field->required == 1 && $field_value == null) { return_required_msg(); return; } $email_body .= xyooj_unesc_quote($field->label) . ": " . $field_value . "\n"; } $email_subject = get_option('custom_contact_email_subject'); wp_mail(get_settings('admin_email'), "{$email_subject}", $email_body); return_success_msg(); function return_success_msg() { $msg = get_option('custom_contact_success_msg'); echo "<response><code>0</code><message>{$msg}</message></response>"; } function return_required_msg() { $msg = get_option('custom_contact_required_msg'); echo "<response><code>-1</code><message>{$msg}</message></response>"; }