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/Location_m.php +67 -0 1.2.3 → 1.5.9 View file →
@@ -14,13 +14,49 @@
14 14 public $_timestamps = TRUE;
15 15 protected $_primary_filter = 'intval';
16 16 public $form_admin = array();
17 17 public $fields_list = NULL;
18 + public $allowedOrderBy = array(
19 + 'idlocation',
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 + 'location_title',
33 + 'marker_image_id',
34 + 'level_0_id',
35 + 'icon_path',
36 + 'image_path',
37 + 'marker_image_path',
38 + 'location_color',
39 + 'titles_for_search'
40 + );
18 41
19 42 public function __construct(){
20 43 parent::__construct();
44 +
45 + // Add allowedOrderBy with table + prefix format
46 + $table_prefix = $this->db->prefix . $this->_table_name . '.';
47 + $updatedAllowedOrderBy = array();
48 + foreach ($this->allowedOrderBy as $col) {
49 + $updatedAllowedOrderBy[] = $col;
50 + $updatedAllowedOrderBy[] = $table_prefix . $col;
51 + }
52 + $this->allowedOrderBy = array_unique($updatedAllowedOrderBy);
21 53 }
22 54
55 + public function getAllowedOrderBy() {
56 + return $this->allowedOrderBy;
57 + }
58 +
23 59 /* [START] For dynamic data table */
24 60
25 61 public function get_available_fields()
26 62 {
@@ -80,8 +116,32 @@
80 116
81 117 return array();
82 118 }
83 119
120 + public function get_pagination_simple($limit, $offset, $where = array(), $order_by = NULL)
121 + {
122 + $this->load->model('listing_m');
123 +
124 + $this->db->from($this->_table_name);
125 + $this->db->where($where);
126 + $this->db->limit($limit);
127 + $this->db->offset($offset);
128 + $this->db->group_by('idlocation');
129 +
130 + if(!empty($order_by)){
131 + $this->db->order_by($order_by);
132 + } else {
133 + $this->db->order_by($this->_order_by);
134 + }
135 +
136 + $query = $this->db->get();
137 +
138 + if ($this->db->num_rows() > 0)
139 + return $this->db->results();
140 +
141 + return array();
142 + }
143 +
84 144 public function check_deletable($id)
85 145 {
86 146 return true;
87 147 }
@@ -99,8 +159,9 @@
99 159
100 160 if($this->_timestamps === TRUE && !isset($data['date']))
101 161 $data['date'] = current_time( 'mysql' );
102 162
163 + $data['level_0_id'] = 0;
103 164 $data['level'] = 0;
104 165 $data['parent_path'] = '';
105 166
106 167 if(!empty($data['parent_id']))
@@ -110,8 +171,14 @@
110 171 if(isset($parent[0]))
111 172 {
112 173 $data['level'] = $parent[0]->level + 1;
113 174 $data['parent_path'] = $parent[0]->parent_path.(!empty($parent[0]->parent_path)?',':'').$parent[0]->idlocation;
175 +
176 + if(strpos($data['parent_path'], ',') !== FALSE) {
177 + $data['level_0_id'] = substr($data['parent_path'],0,strpos($data['parent_path'], ','));
178 + } else {
179 + $data['level_0_id'] = $data['parent_path'];
180 + }
114 181 }
115 182 }
116 183
117 184 if(empty($data['order_index']))