PluginProbe
WP Directory Kit / 1.1.0
WP Directory Kit v1.1.0
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.1.0, at application/controllers/Wdk_resultitem.php

88 lines 2.6 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' => 'resultitem_json',
31 'label' => __('Search Form Json/Structure', 'wpdirectorykit'),
32 'rules' => ''
33 ),
34 );
35
36 if($this->form->run($rules))
37 {
38 // Save procedure for basic data
39 $data = $this->resultitem_m->prepare_data($this->input->post(), $rules);
40
41 // Save standard wp post
42
43 if($this->resultitem_m->total() == 0)
44 {
45 $id = NULL;
46 $data['idresultitem'] = 1;
47 }
48
49 $insert_id = $this->resultitem_m->insert($data, $id);
50
51 // redirect
52
53 if(!empty($insert_id) && empty($id))
54 {
55 wp_redirect(admin_url("admin.php?page=wdk_resultitem&id=$insert_id&is_updated=true"));
56 exit;
57 }
58 }
59
60 if(!empty($id))
61 {
62 $this->data['db_data'] = $this->resultitem_m->get($id, TRUE);
63
64 // generate/decode used fields
65 $used_fields = NULL;
66
67 if(is_object($this->data['db_data']))
68 $used_fields = json_decode($this->data['db_data']->resultitem_json);
69 $this->data['used_fields'] = array();
70 $this->data['used_fields_sub'] = array();
71
72 if(is_array($used_fields))
73 foreach($used_fields as $key=>$used_fields_sub)
74 {
75 foreach($used_fields_sub as $used_field)
76 {
77 $this->data['used_fields'][$used_field->field_id] = $used_field;
78 $this->data['used_fields_sub'][$key+1][$used_field->field_id] = $used_field;
79 }
80
81 }
82 }
83
84 $this->load->view('wdk_resultitem/resultitem_edit', $this->data);
85 }
86
87 }
88