1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
4
|
|
|
/** |
5
|
|
|
* Order and search component handling generation of ordering and |
6
|
|
|
* searching conditions in loading data tables. |
7
|
|
|
* |
8
|
|
|
* phpMyAdmin Error reporting server |
9
|
|
|
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
10
|
|
|
* |
11
|
|
|
* Licensed under The MIT License |
12
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
13
|
|
|
* Redistributions of files must retain the above copyright notice. |
14
|
|
|
* |
15
|
|
|
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
16
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License |
17
|
|
|
* |
18
|
|
|
* @see https://www.phpmyadmin.net/ |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace App\Controller\Component; |
22
|
|
|
|
23
|
|
|
use Cake\Controller\Component; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Github api component handling comunication with github. |
27
|
|
|
*/ |
28
|
|
|
class OrderSearchComponent extends Component |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Indexes are +1'ed because first column is of checkboxes |
32
|
|
|
* and hence it should be ingnored. |
33
|
|
|
* |
34
|
|
|
* @param string[] $aColumns |
35
|
|
|
* |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
1 |
|
public function getSearchConditions($aColumns) |
39
|
|
|
{ |
40
|
1 |
|
$searchConditions = array('OR' => array()); |
41
|
1 |
|
$keys = array_keys($aColumns); |
42
|
|
|
|
43
|
1 |
|
if ($this->request->query('sSearch') != '') { |
|
|
|
|
44
|
1 |
|
for ($i = 0; $i < count($aColumns); ++$i) { |
|
|
|
|
45
|
1 |
|
if ($this->request->query('bSearchable_' . ($i + 1)) == 'true') { |
|
|
|
|
46
|
1 |
|
$searchConditions['OR'][] = array($aColumns[$keys[$i]] . ' LIKE' => '%' . $this->request->query('sSearch') . '%'); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/* Individual column filtering */ |
52
|
1 |
|
for ($i = 0; $i < count($aColumns); ++$i) { |
|
|
|
|
53
|
1 |
|
if ($this->request->query('sSearch_' . ($i + 1)) != '') { |
|
|
|
|
54
|
1 |
|
$searchConditions[] = array($aColumns[$keys[$i]] . ' LIKE' => $this->request->query('sSearch_' . ($i + 1))); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
return $searchConditions; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string[] $aColumns |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
1 |
|
public function getOrder($aColumns) |
67
|
|
|
{ |
68
|
1 |
|
if ($this->request->query('iSortCol_0') != null) { |
|
|
|
|
69
|
1 |
|
$order = array(); |
70
|
|
|
//Seems like we need to sort with only one column each time, so no need to loop |
71
|
1 |
|
$sort_column_index = intval($this->request->query('iSortCol_0')); |
|
|
|
|
72
|
|
|
|
73
|
1 |
|
$keys = array_keys($aColumns); |
74
|
|
|
|
75
|
1 |
|
if ($sort_column_index > 0 |
76
|
1 |
|
&& $this->request->query('bSortable_' . $sort_column_index) == 'true' |
|
|
|
|
77
|
|
|
) { |
78
|
|
|
$order[$aColumns[$keys[$sort_column_index - 1]]] = $this->request->query('sSortDir_0'); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
1 |
|
return $order; |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
return null; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.