PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 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 All 37 releases
← All changes | application/models/Category_m.php +71 -1 1.2.3 → 1.5.9 View file →
@@ -14,13 +14,50 @@
14 14 public $_timestamps = TRUE;
15 15 protected $_primary_filter = 'intval';
16 16 public $form_admin = array();
17 17 public $fields_list = NULL;
18 -
18 + public $allowedOrderBy = array(
19 + 'idcategory',
20 + 'parent_id',
21 + 'page_id',
22 + 'lang_code',
23 + 'date',
24 + 'parent_path',
25 + 'order_index',
26 + 'level',
27 + 'icon_id',
28 + 'image_id',
29 + 'font_icon_code',
30 + 'code',
31 + 'hubspot_id',
32 + 'category_title',
33 + 'marker_image_id',
34 + 'level_0_id',
35 + 'icon_path',
36 + 'image_path',
37 + 'marker_image_path',
38 + 'category_color',
39 + 'titles_for_search',
40 + 'listings_counter'
41 + );
42 +
19 43 public function __construct(){
20 44 parent::__construct();
45 +
46 + // Add allowedOrderBy with table + prefix format
47 + $table_prefix = $this->db->prefix . $this->_table_name . '.';
48 + $updatedAllowedOrderBy = array();
49 + foreach ($this->allowedOrderBy as $col) {
50 + $updatedAllowedOrderBy[] = $col;
51 + $updatedAllowedOrderBy[] = $table_prefix . $col;
52 + }
53 + $this->allowedOrderBy = array_unique($updatedAllowedOrderBy);
21 54 }
22 55
56 + public function getAllowedOrderBy() {
57 + return $this->allowedOrderBy;
58 + }
59 +
23 60 /* [START] For dynamic data table */
24 61
25 62 public function get_available_fields()
26 63 {
@@ -81,8 +118,34 @@
81 118
82 119 return array();
83 120 }
84 121
122 + public function get_pagination_simple($limit, $offset, $where = array(), $order_by = NULL)
123 + {
124 + $this->load->model('listing_m');
125 +
126 + $this->db->from($this->_table_name);
127 +
128 + $this->db->where($where);
129 + $this->db->limit($limit);
130 + $this->db->offset($offset);
131 +
132 + $this->db->group_by('idcategory');
133 +
134 + if(!empty($order_by)){
135 + $this->db->order_by($order_by);
136 + } else {
137 + $this->db->order_by($this->_order_by);
138 + }
139 +
140 + $query = $this->db->get();
141 +
142 + if ($this->db->num_rows() > 0)
143 + return $this->db->results();
144 +
145 + return array();
146 + }
147 +
85 148 public function check_deletable($id)
86 149 {
87 150 return true;
88 151 }
@@ -100,8 +163,9 @@
100 163
101 164 if($this->_timestamps === TRUE && !isset($data['date']))
102 165 $data['date'] = current_time( 'mysql' );
103 166
167 + $data['level_0_id'] = 0;
104 168 $data['level'] = 0;
105 169 $data['parent_path'] = '';
106 170
107 171 if(!empty($data['parent_id']))
@@ -111,8 +175,14 @@
111 175 if(isset($parent[0]))
112 176 {
113 177 $data['level'] = $parent[0]->level + 1;
114 178 $data['parent_path'] = $parent[0]->parent_path.(!empty($parent[0]->parent_path)?',':'').$parent[0]->idcategory;
179 +
180 + if(strpos($data['parent_path'], ',') !== FALSE) {
181 + $data['level_0_id'] = substr($data['parent_path'],0,strpos($data['parent_path'], ','));
182 + } else {
183 + $data['level_0_id'] = $data['parent_path'];
184 + }
115 185 }
116 186 }
117 187
118 188 if(empty($data['order_index']))