core = $core; if (isset($_GET['ad_id'])) { $this->ad_id = $_GET['ad_id']; } $this->date_time = $rDateTime = date('Y-m-d H:i:s'); $this->action_by_ip = $_SERVER['REMOTE_ADDR']; $this->check_add_update(); $this->display_form(); } function check_add_update() { $output = ''; if (isset($_POST['msbd_adsmp_save']) && $_POST['msbd_adsmp_save'] == 'save') { $this->sponsor_type = $this->core->msbd_sanitization($_POST['sponsor_type'], 'text'); $this->content_type = $this->core->msbd_sanitization($_POST['content_type'], 'text'); $this->script = $this->core->msbd_sanitization($_POST['script'], 'html_js'); $this->remark = $this->core->msbd_sanitization($_POST['remark'], 'html'); $this->adv_sizes = $this->core->msbd_sanitization($_POST['adv_sizes'], 'text'); $this->width = $this->core->msbd_sanitization($_POST['width'], 'number'); $this->height = $this->core->msbd_sanitization($_POST['height'], 'number'); $this->status = $this->core->msbd_sanitization($_POST['status'], 'text'); $newdata = array( 'date_time' => $this->date_time, 'sponsor_type' => $this->sponsor_type, 'content_type' => $this->content_type, 'script' => $this->script, 'remark' => $this->remark, 'adv_sizes' => $this->adv_sizes, 'width' => $this->width, 'height' => $this->height, 'status' => $this->status, 'action_by_ip' => $this->action_by_ip ); //dump($newdata, 'NEW DATA'); $validData = true; if ($this->adv_sizes=='' && empty($this->width) && empty($this->height) ) { $output .= '
You must choose a predefined size of advertisement or provide width and height combination.
'; $validData = false; } if ($this->sponsor_type == '') { $output .= '
You must choose a type of advertisement.
'; $validData = false; } if ($this->content_type == '') { $output .= '
You must choose a type of advertisement content.
'; $validData = false; } if ($this->script == '') { $output .= '
You must add the script of advertisement.
'; $validData = false; } $var_filter = "sponsor_type='$this->sponsor_type' AND content_type='$this->content_type' AND width='$this->width' AND height='$this->height' AND adv_sizes='$this->adv_sizes'"; if($this->ad_id!="") { $var_filter .= " AND id!='$this->ad_id'"; } /* // After the 0.1 version plugin can create multiple advertisement with same configuration. // So the unique $isExist = $this->core->db->check_exist($var_filter, false); if ($isExist) { $output .= '
Advertisement from the sponsor with same size, and type is exist!
'; $validData = false; } */ if ($validData) { $this->core->db->set_table("main_tbl"); $rs = $this->core->db->save($newdata, $this->ad_id); $output .= '
The advertisement has been saved.
'; $categories = isset($_POST['categories']) ? $_POST['categories'] : array(); if( !empty($categories) ) { if( !empty($this->ad_id) ) { $this->core->db->delete_terms_rel($this->ad_id); } else { $this->ad_id = $rs; } foreach($categories as $i=>$v) { $terms_rel_data = array("adv_id"=>$this->ad_id, "term_id"=>$i, "term_slug"=>$v); $this->core->db->set_table("terms_rel_tbl"); $this->core->db->save($terms_rel_data); } } } //wp_redirect( MSBD_ADSMP_URL."wp-admin/admin.php?page=msbd_adsmp_manage" ); //exit; } echo $output; } function display_form($record = '') { if ($this->ad_id && empty($record)) { $rs = $this->core->db->get_adv_record($this->ad_id, false); $this->display_form($rs); return; } $isEdit = !empty($this->ad_id) ? 1 : 0; $field_read_only = !empty($this->ad_id) ? ' readonly=""' : ''; $field_disable = !empty($this->ad_id) ? ' disabled="true"' : ''; $var_sponsor_type = adsmp_echo( $record, 'adv.sponsor_type', false); $var_content_type = adsmp_echo( $record, 'adv.content_type', false); $var_adv_sizes = adsmp_echo( $record, 'adv.adv_sizes', false); ?>
get_sponsor_options('class="select" type="text" id="sponsor_type"'.$field_disable, $var_sponsor_type ); } else { echo $this->get_sponsor_options('class="select" type="text" name="sponsor_type" id="sponsor_type"', $var_sponsor_type ); } ?>
get_ad_content_type_options('class="select" type="text" id="content_type"'.$field_disable, $var_content_type ); } else { echo $this->get_ad_content_type_options('class="select" type="text" name="content_type" id="content_type"', $var_content_type ); } ?> get_ad_content_type_options('class="select" type="text" name="content_type" id="content_type"'.$field_disable, $var_content_type ); ?>
get_ad_size_options('class="select" type="text" id="adsmp_adv_sizes"'.$field_disable, $var_adv_sizes ); } else { echo $this->get_ad_size_options('class="select" type="text" name="adv_sizes" id="adsmp_adv_sizes"', $var_adv_sizes ); } ?> get_ad_size_options('class="select" type="text" name="adv_sizes" id="adsmp_adv_sizes"'.$field_disable, $var_adv_sizes ); ?>
/>
/>
get_ad_status_options('class="select" type="text" name="status" id="status"', adsmp_echo( $record, 'adv.status', false) ); ?>
term_slug; } } $var_cat = $this->core->hierarchical_category_array( 0 ); //print_r( $var_cat ); foreach($var_cat as $cat) { echo '
    '; echo $this->create_cat_item($cat, $var_terms_slug); echo '
'; } ?>
'; $html = '
  • '; if(!empty($cat['child'])) { $html .= ''; } $html .= '
  • '; //$html .= ''; return $html; } function get_sponsor_options($att, $selVal='') { $html = ''; return $html; } function get_ad_status_options($att, $selVal='') { $html = ''; return $html; } function get_ad_content_type_options($att, $selVal='') { $html = ''; return $html; } function get_ad_size_options($att, $selVal='') { $record =(array) $this->core->db->get_adv_sizes(); $html = ''; return $html; } } /* end of file msbd-ads-admin-add-edit.php */