PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / controllers / Wdk_resultitem.php

Wdk_resultitem.php in WP Directory Kit 1.2.3, at application/controllers/Wdk_resultitem.php

102 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly;
3
4 class Wdk_resultitem extends Winter_MVC_Controller {
5
6 public function __construct(){
7 parent::__construct();
8 }
9
10 public function index()
11 {
12 $this->load->model('resultitem_m');
13 $this->load->model('field_m');
14
15 $id = 1;
16 wdk_access_check('resultitem_m', $id);
17 $this->data['db_data'] = NULL;
18
19 $this->data['form'] = &$this->form;
20
21 $this->data['fields'] = $this->field_m->get();
22
23 $rules = array(
24 array(
25 'field' => 'resultitem_name',
26 'label' => __('Name', 'wpdirectorykit'),
27 'rules' => 'required'
28 ),
29 array(
30 'field' => 'is_multiline_enabled',
31 'label' => __('Multiline enabled', 'wpdirectorykit'),
32 'rules' => ''
33 ),
34 array(
35 'field' => 'is_label_disable',
36 'label' => __('Show only icons', 'wpdirectorykit'),
37 'rules' => ''
38 ),
39 array(
40 'field' => 'resultitem_json',
41 'label' => __('Search Form Json/Structure', 'wpdirectorykit'),
42 'rules' => ''
43 ),
44 );
45
46 if($this->form->run($rules))
47 {
48
49 // Check _wpnonce
50 check_admin_referer( 'wdk-resultitem-edit_'.$id, '_wpnonce' );
51
52 // Save procedure for basic data
53 $data = $this->resultitem_m->prepare_data(wdk_get_post(), $rules);
54
55 // Save standard wp post
56
57 if($this->resultitem_m->total() == 0)
58 {
59 $id = NULL;
60 $data['idresultitem'] = 1;
61 }
62
63 $insert_id = $this->resultitem_m->insert($data, $id);
64
65 // redirect
66
67 if(!empty($insert_id) && empty($id))
68 {
69 wp_redirect(admin_url("admin.php?page=wdk_resultitem&id=$insert_id&is_updated=true"));
70 exit;
71 }
72 }
73
74 if(!empty($id))
75 {
76 $this->data['db_data'] = $this->resultitem_m->get($id, TRUE);
77
78 // generate/decode used fields
79 $used_fields = NULL;
80
81 if(is_object($this->data['db_data']))
82 $used_fields = json_decode($this->data['db_data']->resultitem_json);
83 $this->data['used_fields'] = array();
84 $this->data['used_fields_sub'] = array();
85
86 if(is_array($used_fields))
87 foreach($used_fields as $key=>$used_fields_sub)
88 {
89 foreach($used_fields_sub as $used_field)
90 {
91 $this->data['used_fields'][$used_field->field_id] = $used_field;
92 $this->data['used_fields_sub'][$key+1][$used_field->field_id] = $used_field;
93 }
94
95 }
96 }
97
98 $this->load->view('wdk_resultitem/resultitem_edit', $this->data);
99 }
100
101 }
102