ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 return false;
69 }
70
71 return true;
72 }
73
80 protected function prepareData(array &$data)
81 {
82 }
83
89 protected function prepareRow(array &$row)
90 {
91 }
92
99 protected function formatCellValue($column, array $row)
100 {
101 return $row[$column];
102 }
103
107 final protected function fillRow($row)
108 {
109 $this->prepareRow($row);
110
111 foreach ($this->getStaticData() as $column) {
112 $value = $this->formatCellValue($column, $row);
113 $this->tpl->setVariable('VAL_' . strtoupper($column), $value);
114 }
115
116 foreach ($this->optionalColumns as $index => $definition) {
117 if (!$this->isColumnVisible($index)) {
118 continue;
119 }
120
121 $this->tpl->setCurrentBlock('optional_column');
122 $value = $this->formatCellValue($index, $row);
123 if ((string) $value === '') {
124 $this->tpl->touchBlock('optional_column');
125 } else {
126 $this->tpl->setVariable('OPTIONAL_COLUMN_VAL', $value);
127 }
128
129 $this->tpl->parseCurrentBlock();
130 }
131 }
132
142 abstract protected function getStaticData();
143
147 public function populate()
148 {
149 if (!$this->getExternalSegmentation() && $this->getExternalSorting()) {
150 $this->determineOffsetAndOrder(true);
151 } elseif ($this->getExternalSegmentation() || $this->getExternalSorting()) {
153 }
154
155 $params = array();
156 if ($this->getExternalSegmentation()) {
157 $params['limit'] = $this->getLimit();
158 $params['offset'] = $this->getOffset();
159 }
160 if ($this->getExternalSorting()) {
161 $params['order_field'] = $this->getOrderField();
162 $params['order_direction'] = $this->getOrderDirection();
163 }
164
167
168 foreach ($this->optional_filter as $key => $value) {
169 if ($this->isFilterSelected($key)) {
170 $filter[$key] = $value;
171 }
172 }
173
174 $data = $this->getProvider()->getList($params, $filter);
175
176 if (!count($data['items']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) {
177 $this->resetOffset();
178 $params['limit'] = $this->getLimit();
179 $params['offset'] = $this->getOffset();
180 $data = $this->getProvider()->getList($params, $filter);
181 }
182
183 $this->prepareData($data);
184
185 $this->setData($data['items']);
186 if ($this->getExternalSegmentation()) {
187 $this->setMaxCount($data['cnt']);
188 }
189 }
190}
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
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.
$key
Definition: croninfo.php:18
$index
Definition: metadata.php:60
$params
Definition: disable.php:11