function cp_show_form($catid) { global $wpdb; $fid = ''; // call tinymce init code if html is enabled if (get_option('cp_allow_html') == 'yes') { appthemes_tinymce($width = 540, $height = 200); } //$catid = '129'; // used for testing // get the category ids from all the form_cats fields. // they are stored in a serialized array which is why // we are doing a separate select. If the form is not // active, then don't return any cats. $sql = "SELECT ID, form_cats FROM {$wpdb->cp_ad_forms} WHERE form_status = 'active'"; $results = $wpdb->get_results($sql); if ($results) { // now loop through the recordset foreach ($results as $result) { // put the form_cats into an array $catarray = unserialize($result->form_cats); // now search the array for the $catid which was passed in via the cat drop-down if (in_array($catid, $catarray)) { // when there's a catid match, grab the form id $fid = $result->ID; // put the form id into the post array for step2 $_POST['fid'] = $fid; } } // now we should have the formid so show the form layout based on the category selected $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, f.field_tooltip, f.field_min_length, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid); $results = $wpdb->get_results($sql); if ($results) { // loop through the custom form fields and display them echo cp_formbuilder($results); } else { // display the default form since there isn't a custom form for this cat echo cp_show_default_form(); } } else { // display the default form since there isn't a custom form for this cat echo cp_show_default_form(); } // show the image, featured ad, payment type and other options echo cp_other_fields(); }
while (ws.test(str.charAt(--i))); return str.slice(0, i + 1); } /* Used for enabling the image for uploads */ function enableNextImage($a, $i) { jQuery('#upload'+$i).removeAttr("disabled"); } // ]]> </script> <?php // call tinymce init code if html is enabled if (get_option('cp_allow_html') == 'yes') { appthemes_tinymce(490, 300); } ?> <div class="content"> <div class="content_botbg"> <div class="content_res"> <!-- left block --> <div class="content_left"> <div class="shadowblock_out"> <div class="shadowblock">
function cp_show_form_buyer($catid, $renew = false, $type = 'buyer') { global $wpdb, $cp_options; $fid = ''; // call tinymce init code if html is enabled and user not on mobile device if ($cp_options->allow_html && !wp_is_mobile()) { appthemes_tinymce(490, 300); } // get the category ids from all the form_cats fields. // they are stored in a serialized array which is why // we are doing a separate select. If the form is not // active, then don't return any cats. $sql = "SELECT ID, form_cats,form_name FROM {$wpdb->cp_ad_forms} WHERE form_status = 'active'"; $results = $wpdb->get_results($sql); if ($results) { // now loop through the recordset foreach ($results as $result) { // put the form_cats into an array $catarray = unserialize($result->form_cats); // now search the array for the $catid which was passed in via the cat drop-down if (in_array($catid, $catarray)) { // when there's a catid match, grab the form id $fid = $result->ID; // put the form id into the post array for step2 $_POST['fid'] = $fid; } //code added by rj starts if ($catid == '') { if (strpos($result->form_name, $type) != false) { // when there's a catid match, grab the form id $fid = $result->ID; // put the form id into the post array for step2 $_POST['fid'] = $fid; } } //code added by rj ends } // now we should have the formid so show the form layout based on the category selected $sql = $wpdb->prepare("SELECT * FROM {$wpdb->cp_ad_fields} f INNER JOIN {$wpdb->cp_ad_meta} m ON f.field_id = m.field_id WHERE m.form_id = %s ORDER BY m.field_pos asc", $fid); $results = $wpdb->get_results($sql); if ($results) { // loop through the custom form fields and display them //echo cp_formbuilder($results, $renew); echo cp_formbuilder_buyer($results, $renew); } else { // display the default form since there isn't a custom form for this cat echo cp_show_default_form($renew); } } else { // display the default form since there isn't a custom form for this cat echo cp_show_default_form($renew); } // show the image, featured ad, payment type and other options $renew_id = $renew ? $renew->ID : false; //echo cp_other_fields($renew_id); }
} /* Used for enabling the image for uploads */ function enableNextImage($a, $i) { jQuery('#upload'+$i).removeAttr("disabled"); } // ]]> </script> <?php // call tinymce init code if html is enabled if (get_option('cp_allow_html') == 'yes') { appthemes_tinymce($width = 520, $height = 400); } ?> <script type='text/javascript'> // <![CDATA[ jQuery(document).ready(function(){ /* setup the form validation */ jQuery("#mainform").validate({ errorClass: "invalid" }); }); // ]]>