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 The columns |
35
|
|
|
* |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
2 |
|
public function getSearchConditions($aColumns) |
39
|
|
|
{ |
40
|
2 |
|
$searchConditions = ['OR' => []]; |
41
|
2 |
|
$keys = array_keys($aColumns); |
42
|
2 |
|
$columnsCount = count($aColumns); |
43
|
|
|
|
44
|
2 |
|
if ($this->request->query('sSearch') != '') { |
|
|
|
|
45
|
1 |
|
for ($i = 0; $i < $columnsCount; ++$i) { |
46
|
1 |
|
if ($this->request->query('bSearchable_' . ($i + 1)) == 'true') { |
|
|
|
|
47
|
1 |
|
$searchConditions['OR'][] = [$aColumns[$keys[$i]] . ' LIKE' => '%' . $this->request->query('sSearch') . '%']; |
|
|
|
|
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/* Individual column filtering */ |
53
|
2 |
|
for ($i = 0; $i < $columnsCount; ++$i) { |
54
|
2 |
|
if ($this->request->query('sSearch_' . ($i + 1)) != '') { |
|
|
|
|
55
|
1 |
|
$searchConditions[] = [$aColumns[$keys[$i]] . ' LIKE' => $this->request->query('sSearch_' . ($i + 1))]; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
2 |
|
return $searchConditions; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string[] $aColumns The columns |
64
|
|
|
* |
65
|
|
|
* @return array |
66
|
|
|
*/ |
67
|
2 |
|
public function getOrder($aColumns) |
68
|
|
|
{ |
69
|
2 |
|
if ($this->request->query('iSortCol_0') != null) { |
|
|
|
|
70
|
1 |
|
$order = []; |
71
|
|
|
//Seems like we need to sort with only one column each time, so no need to loop |
72
|
1 |
|
$sort_column_index = intval($this->request->query('iSortCol_0')); |
|
|
|
|
73
|
|
|
|
74
|
1 |
|
$keys = array_keys($aColumns); |
75
|
|
|
|
76
|
1 |
|
if ($sort_column_index > 0 |
77
|
1 |
|
&& $this->request->query('bSortable_' . $sort_column_index) == 'true' |
|
|
|
|
78
|
|
|
) { |
79
|
|
|
$order[$aColumns[$keys[$sort_column_index - 1]]] = $this->request->query('sSortDir_0'); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
1 |
|
return $order; |
83
|
|
|
} |
84
|
|
|
|
85
|
2 |
|
return null; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.