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

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

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