ILIAS  release_4-3 Revision
 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->setEnabledMaps(false);
53  $this->setPreventHTMLUnmasking(false);
54  $this->setEnabledInternalLinks(false);
55  $this->setEnabledSelfAssessment(false);
56  $this->setStyleId($this->layout_object->getStyleId());
57 
58  //set For GUI and associated object
59  $this->setLayoutMode(true);
60  $this->obj->setLayoutMode(true);
61 
62  $this->slm_id = $a_slm_id;
63 
64  }
65 
66 
67 
68 
72  function &executeCommand()
73  {
74  global $ilCtrl;
75 
76  $next_class = $this->ctrl->getNextClass($this);
77  $cmd = $this->ctrl->getCmd();
78 
79  switch($next_class)
80  {
81  case 'ilmdeditorgui':
82  return parent::executeCommand();
83  break;
84 
85  case "ilpageobjectgui":
86  // "stys" was "sahs" before
87  $page_gui = new ilPageObjectGUI("stys",
88  $this->getPageObject()->getId(), $this->getPageObject()->old_nr);
89  $page_gui->setStyleId($this->getStyleId());
90  $html = $ilCtrl->forwardCommand($page_gui);
91  return $html;
92 
93  default:
94  $html = parent::executeCommand();
95  return $html;
96  }
97  }
98 
99  function create(){
100  $this->properties("insert");
101  }
102 
108  function properties($a_mode="save", $a_form = null)
109  {
110  global $ilTabs;
111 
112  $ilTabs->setTabActive('properties');
113 
114  if(!$a_form)
115  {
116  $a_form = $this->initForm($a_mode);
117  }
118 
119  $this->tpl->setContent($a_form->getHTML());
120  }
121 
122  function initForm($a_mode)
123  {
124  global $ilCtrl, $lng, $ilSetting;
125 
126  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
127  $form_gui = new ilPropertyFormGUI();
128  $form_gui->setFormAction($ilCtrl->getFormAction($this));
129  $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
130 
131  // title
132  $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
133  $title_input->setSize(50);
134  $title_input->setMaxLength(128);
135  $title_input->setValue($this->layout_object->title);
136  $title_input->setTitle($lng->txt("title"));
137  $title_input->setRequired(true);
138 
139  // description
140  $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
141  $desc_input->setValue($this->layout_object->description);
142  $desc_input->setRows(3);
143  $desc_input->setCols(37);
144  $desc_input->setTitle($lng->txt("description"));
145  $desc_input->setRequired(false);
146 
147  // modules
148  $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
149  // $mods->setRequired(true);
150  $mods->setValue($this->layout_object->getModules());
151  foreach(ilPageLayout::getAvailableModules() as $mod_id => $mod_caption)
152  {
153  $mod = new ilCheckboxOption($mod_caption, $mod_id);
154  $mods->addOption($mod);
155  }
156 
157  $form_gui->addItem($title_input);
158  $form_gui->addItem($desc_input);
159  $form_gui->addItem($mods);
160 
161  // style
162  $fixed_style = $ilSetting->get("fixed_content_style_id");
163  $style_id = $this->layout_object->getStyleId();
164 
165  if ($fixed_style > 0)
166  {
167  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
168  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
169  $this->lng->txt("global_fixed").")");
170  $form_gui->addItem($st);
171  }
172  else
173  {
174  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
175  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false);
176  $st_styles[0] = $this->lng->txt("default");
177  ksort($st_styles);
178  $style_sel = new ilSelectInputGUI($lng->txt("obj_sty"), "style_id");
179  $style_sel->setOptions($st_styles);
180  $style_sel->setValue($style_id);
181  $form_gui->addItem($style_sel);
182  }
183 
184  $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
185 
186  return $form_gui;
187  }
188 
192  function updateProperties()
193  {
194  global $lng;
195 
196  $form = $this->initForm("save");
197  if(!$form->checkInput())
198  {
199  $form->setValuesByPost();
200  return $this->properties("save", $form);
201  }
202 
203  $this->layout_object->setTitle($form->getInput('pgl_title'));
204  $this->layout_object->setDescription($form->getInput('pgl_desc'));
205  $this->layout_object->setStyleId($form->getInput('style_id'));
206  $this->layout_object->setModules($form->getInput('module'));
207  $this->layout_object->update();
208 
209  ilUtil::sendInfo($lng->txt("saved_successfully"));
210  $this->properties();
211  }
212 
216  function setTabs()
217  {
218  global $ilTabs, $ilCtrl, $tpl, $lng;
219  $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->id);
220  $ilTabs->addTarget("properties",
221  $ilCtrl->getLinkTarget($this, "properties"), array("properties","", ""), "", "");
222  $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.png"));
223  $tpl->setTitle($this->layout_object->getTitle());
224  $tpl->setDescription("");
225  // $tpl->setTitle(
226  // $lng->txt("sahs_page").": ".$this->node_object->getTitle());
227  }
228 
229 
230 }
231 ?>