ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTermsOfServiceTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5
12{
16 protected $ctrl;
17
21 protected $visibleOptionalColumns = array();
22
26 protected $provider;
27
31 protected $optionalColumns = array();
32
36 protected $filter = array();
37
41 protected $optional_filter = array();
42
48 {
49 $this->provider = $provider;
50 }
51
56 public function getProvider()
57 {
58 return $this->provider;
59 }
60
65 protected function isColumnVisible($column)
66 {
67 if(array_key_exists($column, $this->optionalColumns) && !isset($this->visibleOptionalColumns[$column]))
68 {
69 return false;
70 }
71
72 return true;
73 }
74
81 protected function prepareData(array &$data)
82 {
83 }
84
90 protected function prepareRow(array &$row)
91 {
92 }
93
100 protected function formatCellValue($column, array $row)
101 {
102 return $row[$column];
103 }
104
108 final protected function fillRow(array $row)
109 {
110 $this->prepareRow($row);
111
112 foreach($this->getStaticData() as $column)
113 {
114 $value = $this->formatCellValue($column, $row);
115 $this->tpl->setVariable('VAL_' . strtoupper($column), $value);
116 }
117
118 foreach($this->optionalColumns as $index => $definition)
119 {
120 if(!$this->isColumnVisible($index))
121 {
122 continue;
123 }
124
125 $this->tpl->setCurrentBlock('optional_column');
126 $value = $this->formatCellValue($index, $row);
127 if((string)$value === '')
128 {
129 $this->tpl->touchBlock('optional_column');
130 }
131 else
132 {
133 $this->tpl->setVariable('OPTIONAL_COLUMN_VAL', $value);
134 }
135
136 $this->tpl->parseCurrentBlock();
137 }
138 }
139
149 abstract protected function getStaticData();
150
154 public function populate()
155 {
156 if(!$this->getExternalSegmentation() && $this->getExternalSorting())
157 {
158 $this->determineOffsetAndOrder(true);
159 }
160 else if($this->getExternalSegmentation() || $this->getExternalSorting())
161 {
163 }
164
165 $params = array();
166 if($this->getExternalSegmentation())
167 {
168 $params['limit'] = $this->getLimit();
169 $params['offset'] = $this->getOffset();
170 }
171 if($this->getExternalSorting())
172 {
173 $params['order_field'] = $this->getOrderField();
174 $params['order_direction'] = $this->getOrderDirection();
175 }
176
179
180 foreach($this->optional_filter as $key => $value)
181 {
182 if($this->isFilterSelected($key))
183 {
184 $filter[$key] = $value;
185 }
186 }
187
188 $data = $this->getProvider()->getList($params, $filter);
189
190 if(!count($data['items']) && $this->getOffset() > 0 && $this->getExternalSegmentation())
191 {
192 $this->resetOffset();
193 $params['limit'] = $this->getLimit();
194 $params['offset'] = $this->getOffset();
195 $data = $this->getProvider()->getList($params, $filter);
196 }
197
198 $this->prepareData($data);
199
200 $this->setData($data['items']);
201 if($this->getExternalSegmentation())
202 {
203 $this->setMaxCount($data['cnt']);
204 }
205 }
206}
Class ilTable2GUI.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setData($a_data)
set table data @access public
getExternalSorting()
Get external sorting.
getLimit()
Get limit.
resetOffset($a_in_determination=false)
Reset offset.
getExternalSegmentation()
Get external segmentation.
getOffset()
Get offset.
isFilterSelected($a_col)
Is given filter selected?
determineSelectedFilters()
Determine selected filters.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
prepareData(array &$data)
This method can be used to prepare values for sorting (e.g.
formatCellValue($column, array $row)
Define a final formatting for a cell value.
prepareRow(array &$row)
This method can be used to manipulate the data of a row after sorting and segmentation.
getProvider()
Get the registered provider instance.
getStaticData()
Return an array of all static (always visible) data fields in a row.
setProvider(ilTermsOfServiceTableDataProvider $provider)
Set the provider to be used for data retrieval.
$params
Definition: example_049.php:96