/** * generate HTML Pages * * @param Object $postId Post Id * @param Object $formId Form Id * @param String $formName Form Name * @param String $formType Form Type * @param String $topContent Module Top content * @param String $bottomContent Module Bottom Content * @param String $showTitle State Show Title Form * @param String $showDes State Show Description Form * * @return string */ public static function generate_html_pages($postId, $formId, $formName, $formType = '', $topContent = '', $bottomContent = '', $showTitle = false, $showDes = false) { $html = ''; $assets = array(); // add Filter apply assets load_plugin_textdomain(WR_CONTACTFORM_TEXTDOMAIN, false, WR_CONTACTFORM_TEXTDOMAIN . '/frontend/languages/'); //$assets[ ] = 'wr-contactform-jquery-ui-css'; $loadBootstrap = get_option('wr_contactform_load_bootstrap_css', 1); if ($loadBootstrap != '0' && $loadBootstrap != 0) { $assets[] = 'wr-bootstrap2-css'; } $items = get_post_meta((int) $postId); $formPages = self::get_form_content((int) $formId); $scheme = parse_url(get_site_url(), PHP_URL_SCHEME); /* define language */ $arrayTranslated = array('The password must contain minimum %mi% and maximum %mx% character(s)', 'Both email addresses must be the same.', 'The number cannot be less than', 'The number cannot be greater than', 'WR_CONTACTFORM_DATE_HOUR_TEXT', 'WR_CONTACTFORM_DATE_MINUTE_TEXT', 'WR_CONTACTFORM_DATE_CLOSE_TEXT', 'Prev', 'Next', 'Today', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Wk', 'The information cannot contain more than', 'The information cannot contain less than', 'WR_CONTACTFORM_CAPTCHA_PUBLICKEY', 'WR_CONTACTFORM_BUTTON_BACK', 'WR_CONTACTFORM_BUTTON_NEXT', 'WR_CONTACTFORM_BUTTON_RESET', 'WR_CONTACTFORM_BUTTON_SUBMIT', 'This field can not be empty, please enter required information.', 'The information is invalid, please correct.'); /* Check load JS */ $checkLoadJS = array(); $checkLoadJSTipsy = false; $formSettings = !empty($items['form_settings'][0]) ? json_decode($items['form_settings'][0]) : ''; if ($formPages) { $formStyleCustom = new stdClass(); if (!empty($items['form_style'][0])) { $formStyleCustom = json_decode($items['form_style'][0]); } $dataSumbission = ''; $classForm = !empty($formStyleCustom->layout) ? $formStyleCustom->layout : ''; $formTheme = !empty($formStyleCustom->theme) ? $formStyleCustom->theme : ''; if (!$formType) { wp_enqueue_style('contactform_form_' . $formId, site_url() . '/?wr-cf-gadget=contactform-style&action=default&form_id=' . $formId); $html .= "<div class=\"wr-contactform jsn-master\" data-form-name='" . $formName . "' id='wr_form_" . $formId . "'><div class=\"jsn-bootstrap\">"; $html .= $topContent; $html .= "<form name='form_{$formName}' id='form_{$formName}' action=\"" . site_url() . '/?wr-cf-gadget=contactform-frontend&action=default&task=form.save&form_id=' . $formId . "\" method=\"post\" class=\"form-validate {$classForm} \" enctype=\"multipart/form-data\" >"; $html .= "<span class=\"hide wr-language\" style=\"display:none;\" data-value='" . json_encode(WR_Contactform_Helpers_Contactform::get_translated($arrayTranslated)) . "'></span>"; $html .= '<span class="hide wr-base-url" style="display:none;" data-value="' . get_site_url() . '"></span>'; $html .= '<div id="page-loading" class="jsn-bgloading"><i class="jsn-icon32 jsn-icon-loading"></i></div>'; $html .= '<div class="jsn-row-container ' . $formTheme . '">'; } $html .= '<div class="message-contactform"> </div>'; include_once WR_CONTACTFORM_PATH . 'helpers/form.php'; foreach ($formPages as $i => $contentForm) { $pageContainer = !empty($contentForm->page_container) && json_decode($contentForm->page_container) ? $contentForm->page_container : '[[{"columnName":"left","columnClass":"span12"}]]'; $formContent = isset($contentForm->page_content) ? json_decode($contentForm->page_content) : ''; $htmlForm = ''; if (!empty($formContent)) { foreach ($formContent as $content) { if (!empty($content->options->instruction) || !empty($content->instruction)) { $checkLoadJSTipsy = true; } if (!empty($content->type)) { $checkLoadJS[$content->type] = $content->type; } } $htmlForm .= WR_Contactform_Helpers_Form::generate($formContent, $dataSumbission, $pageContainer); } $html .= "<div data-value=\"{$contentForm->page_id}\" class=\"jsn-form-content hide\">{$htmlForm}"; if ($i + 1 == count($formPages)) { $global_captcha_setting = get_option('wr_contactform_global_captcha_setting', 2); if ($global_captcha_setting != 0) { if (!empty($formSettings->form_captcha) && $formSettings->form_captcha == 1) { if ($scheme == 'https') { $html .= '<script type="text/javascript" src="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>'; } else { $html .= '<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>'; } $html .= '<div id="' . md5(date('Y-m-d H:i:s') . $i . $formName) . '" publickey="' . WR_CONTACTFORM_CAPTCHA_PUBLICKEY . '" class="form-captcha control-group"></div>'; } else { if (!empty($formSettings->form_captcha) && $formSettings->form_captcha == 2 || $global_captcha_setting == 1) { include_once WR_CONTACTFORM_PATH . 'libraries/3rd-party/securimage/securimage.php'; $img = new Securimage(); $img->case_sensitive = true; // true to use case sensitve codes - not recommended $img->image_bg_color = new Securimage_Color('#ffffff'); // image background color $img->text_color = new Securimage_Color('#000000'); // captcha text color $img->num_lines = 0; // how many lines to draw over the image $img->line_color = new Securimage_Color('#0000CC'); // color of lines over the image $img->namespace = $formName; $img->signature_color = new Securimage_Color(rand(0, 64), rand(64, 128), rand(128, 255)); // random signature color ob_start(); $img->show(WR_CONTACTFORM_PATH . 'libraries/3rd-party/securimage/backgrounds/bg4.png'); $dataCaptcha = base64_encode(ob_get_clean()); $html .= '<div class="control-group wr-captcha-block"> <div class="controls"> <div class="row-fluid"><img src="data:image/png;base64,' . $dataCaptcha . '" alt="CAPTCHA" /></div> <input type="text" id="wr-captcha" name="captcha" autocomplete="off" placeholder="' . __('Captcha', WR_CONTACTFORM_TEXTDOMAIN) . '"> </div> </div>'; } } } } $html .= '</div>'; } $btnNext = !empty($formSettings->form_btn_next_text) ? $formSettings->form_btn_next_text : 'Next'; $btnPrev = !empty($formSettings->form_btn_prev_text) ? $formSettings->form_btn_prev_text : 'Prev'; $btnSubmit = !empty($formSettings->form_btn_submit_text) ? $formSettings->form_btn_submit_text : 'Submit'; $btnReset = !empty($formSettings->form_btn_reset_text) ? $formSettings->form_btn_reset_text : 'Reset'; $btnNextStyle = !empty($formStyleCustom->button_next_color) ? $formStyleCustom->button_next_color : 'btn btn-primary'; $btnPrevStyle = !empty($formStyleCustom->button_prev_color) ? $formStyleCustom->button_prev_color : 'btn'; $btnSubmitStyle = !empty($formStyleCustom->button_submit_color) ? $formStyleCustom->button_submit_color : 'btn btn-primary'; $btnResetStyle = !empty($formStyleCustom->button_reset_color) ? $formStyleCustom->button_reset_color : 'btn'; $btnPosition = !empty($formStyleCustom->button_position) ? $formStyleCustom->button_position : 'btn-toolbar'; $htmlBtnReset = ''; if (!empty($formSettings->form_state_btn_reset_text) && $formSettings->form_state_btn_reset_text == 'Yes') { $htmlBtnReset = '<button class="' . $btnResetStyle . ' reset" onclick="return false;">' . __($btnReset, WR_CONTACTFORM_TEXTDOMAIN) . '</button>'; } $html .= '<div class="form-actions"> <div class="' . $btnPosition . '"> <button class="' . $btnPrevStyle . ' prev hide" onclick="return false;">' . __($btnPrev, WR_CONTACTFORM_TEXTDOMAIN) . '</button> <button class="' . $btnNextStyle . ' next hide" onclick="return false;">' . __($btnNext, WR_CONTACTFORM_TEXTDOMAIN) . '</button> <button type="submit" class="' . $btnSubmitStyle . ' jsn-form-submit hide" >' . __($btnSubmit, WR_CONTACTFORM_TEXTDOMAIN) . '</button> ' . $htmlBtnReset . ' </div> </div>'; $postAction = isset($items['form_post_action'][0]) ? $items['form_post_action'][0] : ''; $postActionData = isset($items['form_post_action_data'][0]) ? $items['form_post_action_data'][0] : ''; $html .= '<input type="hidden" name="form_name" value="' . $formName . '" />'; if (!$formType) { $html .= '</div>'; $html .= '<input type="hidden" name="form_id" value="' . $formId . '" />'; $html .= '<input type="hidden" id="form_post_action" name="form_post_action" value="' . $postAction . '" />'; $html .= '<input type="hidden" name="form_post_action_data" value=\'' . htmlentities(json_encode(unserialize($postActionData)), ENT_QUOTES, 'UTF-8') . '\' />'; $html .= '</form>'; $html .= $bottomContent; $html .= '</div></div>'; } /* Load JS */ if (!empty($checkLoadJS['date'])) { $assets[] = 'wr-jquery-ui-css'; } wp_enqueue_script('jquery'); //$assets[ ] = 'wr-jquery-json-js'; $assets[] = 'wr-jquery-placeholder-js'; if ($checkLoadJSTipsy) { $assets[] = 'wr-jquery-tipsy-css'; $assets[] = 'wr-jquery-tipsy-js'; } $assets[] = 'wr-jquery-scrollto-js'; $loadBootstrapJs = get_option('wr_contactform_load_bootstrap_js', 1); if ($loadBootstrapJs != '0' && $loadBootstrapJs != 0) { $assets[] = 'wr-frontend-contactform-bootstrap-js'; } if (!empty($checkLoadJS['date'])) { wp_enqueue_script('jquery-ui'); wp_enqueue_script('jquery-ui-datepicker'); $assets[] = 'wr-jquery-daterangepicker-js'; $assets[] = 'wr-jquery-timepicker-js'; } if (!empty($checkLoadJS['google-maps'])) { if ($scheme == 'https') { $assets[] = 'wr-https-googlemaps-api-js'; } else { $assets[] = 'wr-http-googlemaps-api-js'; } $assets[] = 'wr-googlemaps-ui-js'; $assets[] = 'wr-googlemaps-services-js'; $assets[] = 'wr-googlemaps-extensions-js'; } $getFilterAssets = apply_filters('wr_contactform_filter_frontend_load_assets', $assets, $checkLoadJS); if (!empty($getFilterAssets)) { $assets = $getFilterAssets; } $assets[] = 'wr-frontend-contactform-js'; } $assets[] = 'wr-bootstrap2-icomoon-css'; $assets[] = 'wr-bootstrap2-jsn-gui-css'; $assets[] = 'wr-frontend-contactform-css'; WR_CF_Init_Assets::load($assets); return $html; }
<?php /** * Created by JetBrains PhpStorm. * User: thailv * Date: 12/13/13 * Time: 2:38 PM * To change this template use File | Settings | File Templates. */ $action = !empty($_GET['email']) ? $_GET['email'] : 0; $arrayTranslated = array('You must add some form field in your form in order to select it here', 'No form field found', 'You must add some email-type field in your form in order to select it here', '...', 'No email field found', 'Select Field', 'Select Fields', 'e.g. Customer Department', 'e.g. support@yourdomain.com', 'e.g. Thank you for contacting us', 'Click the button on the right to select the form field identifying submitter name', 'Click the button on the right to select the form field identifying submitter email', 'e.g. Contact inquiry'); $languages = WR_Contactform_Helpers_Contactform::get_translated($arrayTranslated); ?> <div class="jsn-master"> <div class="jsn-bootstrap"> <div id="form-loading" class="jsn-bgloading"><i class="jsn-icon32 jsn-icon-loading"></i></div> <form action="" class="form-horizontal hide" method="post" name="adminForm" id="wr_email_settings"> <fieldset> <?php if ($action == 0) { echo '<legend>Edit email content being sent to responder</legend>'; } else { echo '<legend>Edit email content being sent to specified address(es)</legend>'; } ?> <div class="control-group"> <label class="control-label wr-label-des-tipsy" original-title="<?php echo '' . __('WR_CONTACTFORM_EMAIL_SPECIFY_THE_NAME_' . $action, WR_CONTACTFORM_TEXTDOMAIN); ?> "><?php echo '' . __('From', WR_CONTACTFORM_TEXTDOMAIN);