ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageLayoutGUI.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/COPage/classes/class.ilPageObjectGUI.php");
5 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
6 
18 {
23  var $layout_object = null;
24 
25 
26  function __construct($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_slm_id = 0)
27  {
28  global $tpl,$ilCtrl;
29 
30  parent::__construct($a_parent_type, $a_id, $a_old_nr);
31 
32  //associated object
33  include_once("./Services/Style/classes/class.ilPageLayout.php");
34 
35  $this->layout_object = new ilPageLayout($a_id);
36  $this->layout_object->readObject();
37 
38  // content style
39  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
40  $tpl->setCurrentBlock("ContentStyle");
41  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
42  ilObjStyleSheet::getContentStylePath($this->layout_object->getStyleId()));
43  $tpl->parseCurrentBlock();
44 
45  $tpl->setCurrentBlock("SyntaxStyle");
46  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
48  $tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET",
50  $tpl->parseCurrentBlock();
51 
52  $this->setStyleId($this->layout_object->getStyleId());
53 
54  $this->slm_id = $a_slm_id;
55 
56  }
57 
61  function &executeCommand()
62  {
63  global $ilCtrl;
64 
65  $next_class = $this->ctrl->getNextClass($this);
66  $cmd = $this->ctrl->getCmd();
67 
68  switch($next_class)
69  {
70  case 'ilmdeditorgui':
71  return parent::executeCommand();
72  break;
73 
74  case "ilpageobjectgui":
75 die("ilPageLayoutGUI forward to ilpageobjectgui error.");
76  return;
77 
78  default:
79  $html = parent::executeCommand();
80  return $html;
81  }
82  }
83 
84  function create(){
85  $this->properties("insert");
86  }
87 
93  function properties($a_mode="save", $a_form = null)
94  {
95  global $ilTabs;
96 
97  $ilTabs->setTabActive('properties');
98 
99  if(!$a_form)
100  {
101  $a_form = $this->initForm($a_mode);
102  }
103 
104  $this->tpl->setContent($a_form->getHTML());
105  }
106 
107  function initForm($a_mode)
108  {
109  global $ilCtrl, $lng, $ilSetting;
110 
111  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
112  $form_gui = new ilPropertyFormGUI();
113  $form_gui->setFormAction($ilCtrl->getFormAction($this));
114  $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
115 
116  // title
117  $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
118  $title_input->setSize(50);
119  $title_input->setMaxLength(128);
120  $title_input->setValue($this->layout_object->title);
121  $title_input->setTitle($lng->txt("title"));
122  $title_input->setRequired(true);
123 
124  // description
125  $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
126  $desc_input->setValue($this->layout_object->description);
127  $desc_input->setRows(3);
128  $desc_input->setCols(37);
129  $desc_input->setTitle($lng->txt("description"));
130  $desc_input->setRequired(false);
131 
132  // modules
133  $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
134  // $mods->setRequired(true);
135  $mods->setValue($this->layout_object->getModules());
136  foreach(ilPageLayout::getAvailableModules() as $mod_id => $mod_caption)
137  {
138  $mod = new ilCheckboxOption($mod_caption, $mod_id);
139  $mods->addOption($mod);
140  }
141 
142  $form_gui->addItem($title_input);
143  $form_gui->addItem($desc_input);
144  $form_gui->addItem($mods);
145 
146  // style
147  $fixed_style = $ilSetting->get("fixed_content_style_id");
148  $style_id = $this->layout_object->getStyleId();
149 
150  if ($fixed_style > 0)
151  {
152  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
153  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
154  $this->lng->txt("global_fixed").")");
155  $form_gui->addItem($st);
156  }
157  else
158  {
159  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
160  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false);
161  $st_styles[0] = $this->lng->txt("default");
162  ksort($st_styles);
163  $style_sel = new ilSelectInputGUI($lng->txt("obj_sty"), "style_id");
164  $style_sel->setOptions($st_styles);
165  $style_sel->setValue($style_id);
166  $form_gui->addItem($style_sel);
167  }
168 
169  $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
170 
171  return $form_gui;
172  }
173 
177  function updateProperties()
178  {
179  global $lng;
180 
181  $form = $this->initForm("save");
182  if(!$form->checkInput())
183  {
184  $form->setValuesByPost();
185  return $this->properties("save", $form);
186  }
187 
188  $this->layout_object->setTitle($form->getInput('pgl_title'));
189  $this->layout_object->setDescription($form->getInput('pgl_desc'));
190  $this->layout_object->setStyleId($form->getInput('style_id'));
191  $this->layout_object->setModules($form->getInput('module'));
192  $this->layout_object->update();
193 
194  ilUtil::sendInfo($lng->txt("saved_successfully"));
195  $this->properties();
196  }
197 
201  function setTabs()
202  {
203  global $ilTabs, $ilCtrl, $tpl, $lng;
204  $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->id);
205  $ilTabs->addTarget("properties",
206  $ilCtrl->getLinkTarget($this, "properties"), array("properties","", ""), "", "");
207  $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
208  $tpl->setTitle($this->layout_object->getTitle());
209  $tpl->setDescription("");
210  // $tpl->setTitle(
211  // $lng->txt("sahs_page").": ".$this->node_object->getTitle());
212  }
213 
214 
215 }
216 ?>