ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilShopBaseGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  protected $ctrl = null;
15  protected $lng = null;
16  protected $tpl = null;
17  protected $oGeneralSettings = null;
18  protected $section = 0;
19  protected $sub_section = 0;
20 
21  public function __construct()
22  {
23  global $ilCtrl, $lng, $tpl, $ilMainMenu;
24 
25  $this->ctrl = $ilCtrl;
26  $this->tpl = $tpl;
27  $this->lng = $lng;
28 
29  $this->lng->loadLanguageModule('search');
30  $this->lng->loadLanguageModule('payment');
31  $this->oGeneralSettings = ilPaymentSettings::_getInstance();
32  $ilMainMenu->setActive('shop');
33  }
34 
35  protected function prepareOutput()
36  {
37  $this->tpl->getStandardTemplate();
38 
39  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pays_cart_b.png"), $this->lng->txt("search"));
40  $this->tpl->setTitle($this->lng->txt("shop"));
41 
43 
44  $this->buildSubTabs();
45  }
46 
47  protected function addPager($result, $a_session_key)
48  {
49  if(count($result->getResults()) < $result->getMaxHits())
50  {
51  return true;
52  }
53 
54  if($result->getResultPageNumber() > 1)
55  {
56  $this->ctrl->setParameter($this,'page_number', $result->getResultPageNumber() - 1);
57  $this->tpl->setCurrentBlock('prev');
58  $this->tpl->setVariable('PREV_LINK',$this->ctrl->getLinkTarget($this, 'performSearch'));
59  $this->tpl->setVariable('TXT_PREV',$this->lng->txt('search_page_prev'));
60  $this->tpl->parseCurrentBlock();
61  }
62  for($i = 0; $i < ceil(count($result->getResults()) / $result->getMaxHits()); $i++)
63  {
64  if($i + 1 == $result->getResultPageNumber())
65  {
66  $this->tpl->setCurrentBlock('pages_link');
67  $this->tpl->setVariable('NUMBER', $i + 1);
68  $this->tpl->parseCurrentBlock();
69  continue;
70  }
71 
72  $this->ctrl->setParameter($this,'page_number', $i + 1);
73  $link = '<a href="'.$this->ctrl->getLinkTarget($this, 'performSearch').'">'.($i + 1).'</a> ';
74  $this->tpl->setCurrentBlock('pages_link');
75  $this->tpl->setVariable('NUMBER',$link);
76  $this->tpl->parseCurrentBlock();
77  }
78 
79  if($result->getResultPageNumber() < ceil(count($result->getResults()) / $result->getMaxHits()))
80  {
81  $this->tpl->setCurrentBlock('next');
82  $this->ctrl->setParameter($this,'page_number', $result->getResultPageNumber() + 1);
83  $this->tpl->setVariable('NEXT_LINK',$this->ctrl->getLinkTarget($this, 'performSearch'));
84  $this->tpl->setVariable('TXT_NEXT',$this->lng->txt('search_page_next'));
85  $this->tpl->parseCurrentBlock();
86  }
87 
88  $this->tpl->setCurrentBlock('prev_next');
89  $this->tpl->setVariable('SEARCH_PAGE',$this->lng->txt('search_page'));
90  $this->tpl->parseCurrentBlock();
91 
92  $this->ctrl->clearParameters($this);
93  }
94 
95  protected function buildSubTabs()
96  {
97  global $ilUser, $ilTabs;
98 
99  switch($this->getSection())
100  {
101  case 6:
102  if(ilPaymentVendors::_isVendor($ilUser->getId()) ||
104  {
105  $ilTabs->addSubTabTarget('bookings', $this->ctrl->getLinkTargetByClass('ilpaymentstatisticgui'), '', '', '');
106  }
107  if(ilPaymentVendors::_isVendor($ilUser->getId()) ||
108  ilPaymentTrustees::_hasObjectPermission($ilUser->getId()))
109  {
110  $ilTabs->addSubTabTarget('paya_object', $this->ctrl->getLinkTargetByClass('ilpaymentobjectgui'), '', '', '');
111 
112  }
113  if(ilPaymentVendors::_isVendor($ilUser->getId()))
114  {
115  $ilTabs->addSubTabTarget('paya_trustees', $this->ctrl->getLinkTargetByClass('ilpaymenttrusteegui'), '', '', '');
116  }
117  if(!(bool) $this->oGeneralSettings->get('hide_coupons'))
118  {
119  if(ilPaymentVendors::_isVendor($ilUser->getId()) ||
121  {
122  $ilTabs->addSubTabTarget('paya_coupons_coupons', $this->ctrl->getLinkTargetByClass('ilpaymentcoupongui'), '', '', '');
123  }
124  }
125  break;
126 
127  default:
128  break;
129  }
130  }
131 
132  protected function setSection($a_section)
133  {
134  $this->section = $a_section;
135  }
136  protected function getSection()
137  {
138  return $this->section;
139  }
140  protected function setSubSection($a_sub_section)
141  {
142  $this->sub_section = $a_sub_section;
143  }
144  protected function getSubSection()
145  {
146  return $this->sub_section;
147  }
148 
149  protected function showButton($a_cmd, $a_text, $a_target = '')
150  {
151  global $ilToolbar;
152 
153  $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
154  }
155 
156  protected function initTableGUI()
157  {
158  include_once './Services/Table/classes/class.ilTableGUI.php';
159 
160  return new ilTableGUI(0, false);
161  }
162 
163  protected function setTableGUIBasicData($tbl, $result_set, $a_default_order_column = '')
164  {
165  $offset = (int)$_GET['offset'];
166  $order = $_GET['sort_by'];
167  $direction = $_GET['sort_order'];
168 
169  $tbl->setOrderColumn($order,$a_default_order_column);
170  $tbl->setOrderDirection($direction);
171  $tbl->setOffset($offset);
172  $tbl->setLimit((int)$_GET['limit']);
173  $tbl->setMaxCount(count($result_set));
174  $tbl->setFooter('tblfooter', $this->lng->txt('previous'), $this->lng->txt('next'));
175  $tbl->setData($result_set);
176  }
177 }
178 ?>