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