ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilShoppingCartTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5
17{
18 private $total_data = array();
19
26 public function __construct($a_parent_obj, $a_parent_cmd = "")
27 {
28
29 global $lng,$ilCtrl;
30
31 $this->lng = $lng;
32 $this->ctrl = $ilCtrl;
33
34 parent::__construct($a_parent_obj, $a_parent_cmd);
35
36
37 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
38 }
39
47 public function fillRow($a_set)
48 {
49 foreach ($a_set as $key => $value)
50 {
51 $this->tpl->setVariable("VAL_".strtoupper($key), $value);
52 }
53 }
63 public function setTotalData($a_key , $a_value)
64 {
65 $this->total_data[$a_key] = $a_value;
66 }
67
68
69 public function getTotalData()
70 {
71 return $this->total_data;
72 }
73
79 public function getCartHTML()
80 {
81
82 global $lng, $ilCtrl, $ilUser;
83
84 $this->prepareOutput();
85
86 if (is_object($ilCtrl) && $this->getId() == "")
87 {
88 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
89 }
90
91 if(!$this->enabled['content'])
92 {
93 return $this->render();
94 }
95
96 if (!$this->getExternalSegmentation())
97 {
98 $this->setMaxCount(count($this->row_data));
99 }
100
102
103 $this->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
104
105 // sort
106 $data = $this->getData();
107 if (!$this->getExternalSorting())
108 {
110 $this->getOrderDirection(), $this->numericOrdering($this->getOrderField()));
111 }
112
113 // slice
114 if (!$this->getExternalSegmentation())
115 {
116 $data = array_slice($data, $this->getOffset(), $this->getLimit());
117 }
118
119 // fill rows
120 if(count($data) > 0)
121 {
122 $this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", $this->row_template,
123 $this->row_template_dir);
124
125 foreach($data as $set)
126 {
127 $this->tpl->setCurrentBlock("tbl_content");
128 $this->css_row = ($this->css_row != "tblrow1")
129 ? "tblrow1"
130 : "tblrow2";
131 $this->tpl->setVariable("CSS_ROW", $this->css_row);
132
133 $this->fillRow($set);
134 $this->tpl->setCurrentBlock("tbl_content");
135 $this->tpl->parseCurrentBlock();
136 }
137 // Rows for Total Amounts
138 $this->css_row_2 = ($this->css_row == "tblrow1")
139 ? "tblrow2"
140 : "tblrow1";
141
142 $this->tpl->setCurrentBlock('totals_row');
143
144 foreach($this->total_data as $key => $value)
145 {
146 $this->tpl->setVariable('CSS_ROW_2', $this->css_row_2);
147 $this->tpl->setVariable($key, $value);
148 }
149 $this->tpl->parseCurrentBlock();
150 // */
151 }
152 else
153 {
154 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
155 $no_items_text = (trim($this->getNoEntriesText()) != '')
156 ? $this->getNoEntriesText()
157 : $lng->txt("no_items");
158
159 $this->css_row = ($this->css_row != "tblrow1")
160 ? "tblrow1"
161 : "tblrow2";
162
163 $this->tpl->setCurrentBlock("tbl_no_entries");
164 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
165 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
166 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
167 $this->tpl->parseCurrentBlock();
168 }
169
170 // set form action
171 if ($this->form_action != "")
172 {
173 $hash = "";
174 if (is_object($ilUser) && $ilUser->prefs["screen_reader_optimization"])
175 {
176 $hash = "#".$this->getTopAnchor();
177 }
178
179 $this->tpl->setCurrentBlock("tbl_form_header");
180 $this->tpl->setVariable("FORMACTION", $this->getFormAction().$hash);
181 $this->tpl->setVariable("FORMNAME", $this->getFormName());
182 $this->tpl->parseCurrentBlock();
183 $this->tpl->touchBlock("tbl_form_footer");
184 }
185
186 // fill Totals Row
187 $this->fillFooter();
188
189 $this->fillHiddenRow();
190
191 $this->fillActionRow();
192
193 $this->storeNavParameter();
194
195 return $this->render();
196 }
197}
198?>
Class ilShoppingCartTableGUI.
getCartHTML()
Get HTML: only for shoppingcarts does the same as getHTML of table2gui but additional.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
setTotalData($a_key, $a_value)
set total data
Class ilTable2GUI.
getFormName()
Get Form name.
prepareOutput()
Anything that must be done before HTML is generated.
getNoEntriesText()
Get text for an empty table.
getParentObject()
Get parent object.
getFormAction()
Get Form action parameter.
render()
render table @access public
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
getId()
Get element id.
getExternalSorting()
Get external sorting.
getLimit()
Get limit.
fillFooter()
Fill footer row.
getExternalSegmentation()
Get external segmentation.
getOffset()
Get offset.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
fillActionRow()
Fill Action Row.
numericOrdering($a_field)
Should this field be sorted numeric?
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
setFooter($a_style, $a_previous=0, $a_next=0)
set order direction @access public
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15