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_location.php

Wdk_location.php in WP Directory Kit 1.1.0, at application/controllers/Wdk_location.php

114 lines 3.3 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_location extends Winter_MVC_Controller {
5
6 public function __construct(){
7 parent::__construct();
8 }
9
10 public function index()
11 {
12 $this->load->model('location_m');
13
14 $this->data['locations'] = $this->location_m->get_tree_table();
15 // Load view
16 $this->load->view('wdk_location/index', $this->data);
17 }
18
19 public function delete()
20 {
21 $id = (int) $this->input->post_get('id');
22 $paged = (int) $this->input->post_get('paged');
23
24 $this->load->model('location_m');
25
26 $this->location_m->delete($id);
27
28 wp_redirect(admin_url("admin.php?page=wdk_location&paged=$paged"));
29 }
30
31 public function edit()
32 {
33 $this->load->model('location_m');
34
35 $id = $this->input->post_get('id');
36 wdk_access_check('location_m', $id);
37
38 $this->data['db_data'] = NULL;
39
40 $this->data['form'] = &$this->form;
41
42 $this->data['parents'] = $this->location_m->get_parents($id);
43
44 //exit($this->db->last_query());
45
46 $rules = array(
47 array(
48 'field' => 'location_title',
49 'label' => __('Title', 'wpdirectorykit'),
50 'rules' => 'required'
51 ),
52 array(
53 'field' => 'order_index',
54 'label' => __('Order Index', 'wpdirectorykit'),
55 'rules' => ''
56 ),
57 array(
58 'field' => 'parent_id',
59 'label' => __('Parent', 'wpdirectorykit'),
60 'rules' => ''
61 ),
62 array(
63 'field' => 'icon_id',
64 'label' => __('Parent', 'wpdirectorykit'),
65 'rules' => ''
66 ),
67 array(
68 'field' => 'image_id',
69 'label' => __('Parent', 'wpdirectorykit'),
70 'rules' => ''
71 ),
72 );
73
74 if($this->form->run($rules))
75 {
76 // Save procedure for basic data
77 $data = $this->location_m->prepare_data($this->input->post(), $rules);
78
79 // Save standard wp post
80
81 $insert_id = $this->location_m->insert($data, $id);
82
83 //exit($this->db->last_error());
84
85 /* indexes by new order and reorder */
86 $results = $this->location_m->get_tree_table();
87 $values = array();
88 $order_index = 1;
89 foreach( $results as $item)
90 {
91 $values[] = array('order_index' => $order_index, 'idlocation' => $item->idlocation);
92 $order_index++;
93 }
94 $this->db->updateBatch( $this->location_m->_table_name, $values, 'idlocation');
95
96 // redirect
97 if(!empty($insert_id) && empty($id))
98 {
99 wp_redirect(admin_url("admin.php?page=wdk_location&id=$insert_id&is_updated=true"));
100 exit;
101 }
102
103 }
104
105 if(!empty($id))
106 {
107 $this->data['db_data'] = $this->location_m->get($id, TRUE);
108 }
109
110 $this->load->view('wdk_location/location_edit', $this->data);
111 }
112
113 }
114