ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTermsConditionsGUI.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 include_once './Services/Payment/classes/class.ilShopPageGUI.php';
5 include_once 'Services/Payment/classes/class.ilShopBaseGUI.php';
6 
7 
17 {
18  const SHOP_PAGE_EDITOR_PAGE_ID = 99999997;
19 
20  public function __construct()
21  {
23  }
24 
25  function executeCommand()
26  {
27  $next_class = $this->ctrl->getNextClass($this);
28  $cmd = $this->ctrl->getCmd();
29 
30  switch($next_class)
31  {
32  case 'ilshoppagegui':
33  $this->prepareOutput();
34  $ret = $this->forwardToPageObject();
35  if($ret != '')
36  {
37  $this->tpl->setContent($ret);
38  }
39  break;
40  default:
41  if(!$cmd)
42  {
43  $cmd = 'showInfo';
44  }
45  $this->prepareOutput();
46  $this->$cmd();
47 
48  break;
49  }
50 
51  return true;
52  }
53 
54  public function getPageHTML()
55  {
56  // page object
57  include_once 'Services/Payment/classes/class.ilShopPage.php';
58  include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
59 
60  // if page does not exist, return nothing
61  if(!ilShopPage::_exists('shop', self::SHOP_PAGE_EDITOR_PAGE_ID))
62  {
63  return '';
64  }
65 
66  include_once 'Services/Style/classes/class.ilObjStyleSheet.php';
67  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
68 
69  // get page object
70  $page_gui = new ilShopPageGUI(self::SHOP_PAGE_EDITOR_PAGE_ID);
71 
72  return $page_gui->showPage();
73  }
74 
75  public function forwardToPageObject()
76  {
77  global $lng, $ilTabs;
78 
79  $ilTabs->clearTargets();
80  $ilTabs->setBackTarget($lng->txt('back'), $this->ctrl->getLinkTarget($this), '_top');
81 
82  // page object
83  include_once 'Services/Payment/classes/class.ilShopPage.php';
84  include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
85 
86  $lng->loadLanguageModule('content');
87 
88  include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
89  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
90 
91  if(!ilShopPage::_exists('shop', self::SHOP_PAGE_EDITOR_PAGE_ID))
92  {
93  // doesn't exist -> create new one
94  $new_page_object = new ilShopPage();
95  $new_page_object->setParentId(0);
96  $new_page_object->setId(self::SHOP_PAGE_EDITOR_PAGE_ID);
97  $new_page_object->createFromXML();
98  }
99 
100  $this->ctrl->setReturnByClass('ilshoppagegui', 'edit');
101 
102  $page_gui = new ilShopPageGUI(self::SHOP_PAGE_EDITOR_PAGE_ID);
103 
104  return $this->ctrl->forwardCommand($page_gui);
105  }
106 
107  public function showInfo()
108  {
109  global $ilUser, $rbacreview, $ilToolbar;
110 
111  if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
112  {
113  $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
114  }
115 
116  $this->tpl->setVariable('ADM_CONTENT', $this->getPageHTML());
117  }
118 
119  protected function prepareOutput()
120  {
121  global $ilTabs;
122 
124 
125  $ilTabs->setTabActive('terms_conditions');
126  }
127 }
128 ?>