ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 require_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 
101  $this->determineOffsetAndOrder();
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  {
109  $data = ilUtil::sortArray($data, $this->getOrderField(),
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 ?>