|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Boduch\Grid; |
|
4
|
|
|
|
|
5
|
|
|
if (!function_exists('grid')) { |
|
6
|
|
|
/** |
|
7
|
|
|
* @param Grid\Grid $grid |
|
8
|
|
|
* @return string |
|
9
|
|
|
*/ |
|
10
|
|
|
function grid(Grid\Grid $grid) |
|
11
|
|
|
{ |
|
12
|
|
|
return $grid->render(); |
|
13
|
|
|
} |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
if (!function_exists('grid_column')) { |
|
17
|
|
|
/** |
|
18
|
|
|
* @param Grid\Column $column |
|
19
|
|
|
* @return string |
|
20
|
|
|
*/ |
|
21
|
|
|
function grid_column(Grid\Column $column) |
|
22
|
|
|
{ |
|
23
|
|
|
if ($column->isSortable()) { |
|
24
|
|
|
$order = $column->getGrid()->getOrder(); |
|
25
|
|
|
|
|
26
|
|
|
$parameters = array_merge($column->getGrid()->getGridHelper()->getRequest()->all(), [ |
|
27
|
|
|
'column' => $column->getName(), |
|
28
|
|
|
'direction' => $order->getDirection() == 'desc' ? 'asc' : 'desc' |
|
29
|
|
|
]); |
|
30
|
|
|
|
|
31
|
|
|
$text = link_to( |
|
32
|
|
|
$column->getGrid()->getGridHelper()->getRequest()->path() . '?' . http_build_query($parameters), |
|
33
|
|
|
$column->getTitle(), |
|
34
|
|
|
['class' => 'sort ' . ($order->getColumn() == $column->getName() ? strtolower($order->getDirection()) : '')] |
|
35
|
|
|
); |
|
36
|
|
|
} else { |
|
37
|
|
|
$text = $column->getTitle(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
return $column->getGrid()->getGridHelper()->tag('th', (string) $text); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
if (!function_exists('grid_filter')) { |
|
45
|
|
|
/** |
|
46
|
|
|
* @param Grid\Column $column |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
function grid_filter(Grid\Column $column) |
|
50
|
|
|
{ |
|
51
|
|
|
$filter = ''; |
|
52
|
|
|
|
|
53
|
|
|
if ($column->isFilterable()) { |
|
54
|
|
|
$filter = (string) $column->getFilter()->render(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $column->getGrid()->getGridHelper()->tag('th', (string) $filter); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if (!function_exists('grid_row')) { |
|
62
|
|
|
/** |
|
63
|
|
|
* @param Grid\Row $row |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
|
|
function grid_row(Grid\Row $row) |
|
67
|
|
|
{ |
|
68
|
|
|
$cells = ''; |
|
69
|
|
|
foreach ($row as $cell) { |
|
70
|
|
|
$cells .= grid_cell($cell); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
return $row->getGrid()->getGridHelper()->tag('tr', $cells, (array) $row->attributes()->all()); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if (!function_exists('grid_cell')) { |
|
78
|
|
|
/** |
|
79
|
|
|
* @param Grid\CellInterface $cell |
|
80
|
|
|
* @return string |
|
81
|
|
|
*/ |
|
82
|
|
|
function grid_cell(Grid\CellInterface $cell) |
|
83
|
|
|
{ |
|
84
|
|
|
return $cell->getColumn()->getGrid()->getGridHelper()->tag( |
|
85
|
|
|
'td', |
|
86
|
|
|
(string) $cell->getValue(), |
|
87
|
|
|
(array) $cell->attributes()->all() |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if (!function_exists('grid_empty')) { |
|
93
|
|
|
/** |
|
94
|
|
|
* @param Grid\Grid $grid |
|
95
|
|
|
* @return \Illuminate\Support\HtmlString |
|
96
|
|
|
*/ |
|
97
|
|
|
function grid_empty(Grid\Grid $grid) |
|
98
|
|
|
{ |
|
99
|
|
|
return $grid->getGridHelper()->tag( |
|
100
|
|
|
'td', |
|
101
|
|
|
(string) $grid->getEmptyMessage(), |
|
102
|
|
|
['colspan' => count($grid->getColumns()), 'style' => 'text-align: center'] |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|