ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./classes/class.ilObjectGUI.php";
5 include_once("./Services/Style/classes/class.ilPageLayout.php");
6 
18 {
19  //page_layout editing
20  var $peditor_active = false;
21  var $pg_id = null;
22 
26  function ilObjStyleSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
27  {
28  global $lng,$ilCtrl;
29 
30  $this->type = "stys";
31 
32  $cmd = $ilCtrl->getCmd();
33 
34  if ($cmd == "editPg") {
35  $this->peditor_active = true;
36  }
37 
38  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
39 
40  $lng->loadLanguageModule("style");
41  }
42 
46  function &executeCommand()
47  {
48  $next_class = $this->ctrl->getNextClass($this);
49  $cmd = $this->ctrl->getCmd();
50 
51  if ($next_class == "ilpagelayoutgui" || $cmd =="createPg") {
52  $this->peditor_active =true;
53  }
54 
55  $this->prepareOutput();
56 
57  switch($next_class)
58  {
59  case 'ilpermissiongui':
60  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
61  $perm_gui =& new ilPermissionGUI($this);
62  $ret =& $this->ctrl->forwardCommand($perm_gui);
63  break;
64 
65  case 'ilpagelayoutgui':
66  include_once("./Services/Style/classes/class.ilPageLayoutGUI.php");
67  $this->tpl->getStandardTemplate();
68  $this->ctrl->setReturn($this, "edit");
69  if ($this->pg_id!=null) {
70  $layout_gui =& new ilPageLayoutGUI($this->type,$this->pg_id);
71  } else {
72  $layout_gui =& new ilPageLayoutGUI($this->type,$_GET["obj_id"]);
73  }
74  $layout_gui->setTabs();
75  $layout_gui->setEditPreview(true);
76  $this->ctrl->saveParameter($this, "obj_id");
77  $ret =& $this->ctrl->forwardCommand($layout_gui);
78  $this->tpl->setContent($ret);
79  break;
80 
81  default:
82  if ($cmd == "" || $cmd == "view")
83  {
84  $cmd = "editBasicSettings";
85  }
86  $cmd .= "Object";
87  $this->$cmd();
88 
89  break;
90  }
91  return true;
92  }
93 
97  function saveObject()
98  {
99  global $rbacadmin;
100 
101  // create and insert forum in objecttree
102  $newObj = parent::saveObject();
103 
104  // put here object specific stuff
105 
106  // always send a message
107  ilUtil::sendInfo($this->lng->txt("object_added"),true);
108 
109  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"","",false,false)));
110  }
111 
116  {
117  global $rbacsystem;
118 
119  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
120  {
121  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
122  }
123 
124  $this->tpl->addBlockfile("ADM_CONTENT", "style_basic_settings", "tpl.stys_basic_settings.html");
125  //$this->tpl->setCurrentBlock("style_settings");
126 
127  $settings = $this->ilias->getAllSettings();
128 
129  if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
130  {
131  $this->tpl->setCurrentBlock("save_but");
132  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
133  $this->tpl->parseCurrentBlock();
134  }
135 
136  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
137 
138  $this->tpl->setVariable("TXT_TREE_FRAME", $this->lng->txt("tree_frame"));
139  $this->tpl->setVariable("TXT_TREE_FRAME_INFO", $this->lng->txt("tree_frame_info"));
140  $this->tpl->setVariable("TXT_FRAME_LEFT", $this->lng->txt("tree_left"));
141  $this->tpl->setVariable("TXT_FRAME_RIGHT", $this->lng->txt("tree_right"));
142 
143  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("basic_settings"));
144  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS", $this->lng->txt("icons_in_typed_lists"));
145  $this->tpl->setVariable("TXT_ICONS_IN_HEADER", $this->lng->txt("icons_in_header"));
146  $this->tpl->setVariable("TXT_ICONS_IN_ITEM_ROWS", $this->lng->txt("icons_in_item_rows"));
147  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS_INFO", $this->lng->txt("icons_in_typed_lists_info"));
148 
149  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS", $this->lng->txt("enable_custom_icons"));
150  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS_INFO", $this->lng->txt("enable_custom_icons_info"));
151  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_BIG", $this->lng->txt("custom_icon_size_big"));
152  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_SMALL", $this->lng->txt("custom_icon_size_standard"));
153  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_TINY", $this->lng->txt("custom_icon_size_tiny"));
154  $this->tpl->setVariable("TXT_WIDTH_X_HEIGHT", $this->lng->txt("width_x_height"));
155 
156  // set current values
157  if ($settings["tree_frame"] == "right")
158  {
159  $this->tpl->setVariable("SEL_FRAME_RIGHT","selected=\"selected\"");
160  }
161  else
162  {
163  $this->tpl->setVariable("SEL_FRAME_LEFT","selected=\"selected\"");
164  }
165 
166  if ($settings["custom_icons"])
167  {
168  $this->tpl->setVariable("CHK_CUSTOM_ICONS","checked=\"checked\"");
169  }
170 /* if ($settings["icon_position_in_lists"] == "item_rows")
171  {
172  $this->tpl->setVariable("SEL_ICON_POS_ITEM_ROWS","selected=\"selected\"");
173  }
174  else
175  {
176  $this->tpl->setVariable("SEL_ICON_POS_HEADER","selected=\"selected\"");
177  }*/
178  $this->tpl->setVariable("CUST_ICON_BIG_WIDTH", $settings["custom_icon_big_width"]);
179  $this->tpl->setVariable("CUST_ICON_BIG_HEIGHT", $settings["custom_icon_big_height"]);
180  $this->tpl->setVariable("CUST_ICON_SMALL_WIDTH", $settings["custom_icon_small_width"]);
181  $this->tpl->setVariable("CUST_ICON_SMALL_HEIGHT", $settings["custom_icon_small_height"]);
182  $this->tpl->setVariable("CUST_ICON_TINY_WIDTH", $settings["custom_icon_tiny_width"]);
183  $this->tpl->setVariable("CUST_ICON_TINY_HEIGHT", $settings["custom_icon_tiny_height"]);
184 
185 // $this->tpl->parseCurrentBlock();
186  }
187 
192  {
193  $this->ilias->setSetting("tree_frame", $_POST["tree_frame"]);
194 // $this->ilias->setSetting("icon_position_in_lists", $_POST["icon_position_in_lists"]);
195  $this->ilias->setSetting("custom_icons", $_POST["custom_icons"]);
196  $this->ilias->setSetting("custom_icon_big_width", (int) $_POST["custom_icon_big_width"]);
197  $this->ilias->setSetting("custom_icon_big_height", (int) $_POST["custom_icon_big_height"]);
198  $this->ilias->setSetting("custom_icon_small_width", (int) $_POST["custom_icon_small_width"]);
199  $this->ilias->setSetting("custom_icon_small_height", (int) $_POST["custom_icon_small_height"]);
200  $this->ilias->setSetting("custom_icon_tiny_width", (int) $_POST["custom_icon_tiny_width"]);
201  $this->ilias->setSetting("custom_icon_tiny_height", (int) $_POST["custom_icon_tiny_height"]);
202  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
203  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editBasicSettings","",false,false));
204  }
205 
210  {
211  global $rbacsystem, $ilias, $tpl, $ilToolbar, $ilCtrl, $lng;
212 
213  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
214  {
215  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
216  }
217 
218  // this may not be cool, if styles are organised as (independent) Service
219  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
220  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
221 
222  $from_styles = $to_styles = $data = array();
223  $styles = $this->object->getStyles();
224 
225  foreach($styles as $style)
226  {
227  $style["active"] = ilObjStyleSheet::_lookupActive($style["id"]);
228  $style["lm_nr"] = ilObjContentObject::_getNrOfAssignedLMs($style["id"]);
229  $data[$style["title"].":".$style["id"]]
230  = $style;
231  if ($style["lm_nr"] > 0)
232  {
233  $from_styles[$style["id"]] = $style["title"];
234  }
235  if ($style["active"] > 0)
236  {
237  $to_styles[$style["id"]] = $style["title"];
238  }
239  }
240 
241  // number of individual styles
242  if ($fixed_style <= 0)
243  {
244  $data[-1] =
245  array("title" => $this->lng->txt("sty_individual_styles"),
246  "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsIndividualStyles());
247  $from_styles[-1] = $this->lng->txt("sty_individual_styles");
248  }
249 
250  // number of default style (fallback default style)
251  if ($default_style <= 0 && $fixed_style <= 0)
252  {
253  $data[0] =
254  array("title" => $this->lng->txt("sty_default_style"),
255  "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsNoStyle());
256  $from_styles[0] = $this->lng->txt("sty_default_style");
257  $to_styles[0] = $this->lng->txt("sty_default_style");
258  }
259 
260  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
261  {
262  $ilToolbar->addButton($lng->txt("sty_add_content_style"),
263  $ilCtrl->getLinkTarget($this, "createStyle"));
264  $ilToolbar->addSeparator();
265  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
266 
267  // from styles selector
268  $si = new ilSelectInputGUI($lng->txt("sty_move_lm_styles").": ".$lng->txt("sty_from"), "from_style");
269  $si->setOptions($from_styles);
270  $ilToolbar->addInputItem($si, true);
271 
272  // from styles selector
273  $si = new ilSelectInputGUI($lng->txt("sty_to"), "to_style");
274  $si->setOptions($to_styles);
275  $ilToolbar->addInputItem($si, true);
276  $ilToolbar->addFormButton($lng->txt("sty_move_style"), "moveLMStyles");
277 
278  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
279  }
280 
281  include_once("./Services/Style/classes/class.ilContentStylesTableGUI.php");
282  $table = new ilContentStylesTableGUI($this, "editContentStyles", $data, $this->object);
283  $tpl->setContent($table->getHTML());
284 
285  }
286 
291  {
292  if ($_POST["from_style"] == -1)
293  {
295  return;
296  }
297 
298  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
299  ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
300  $this->ctrl->redirect($this, "editContentStyles");
301  }
302 
303 
308  {
309  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
310  ilObjContentObject::_moveLMStyles(-1, $_GET["to_style"]);
311  $this->ctrl->redirect($this, "editContentStyles");
312  }
313 
318  {
319  global $ilCtrl, $tpl, $lng;
320 
321  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
322 
323  $ilCtrl->setParameter($this, "to_style", $_POST["to_style"]);
324 
325  $cgui = new ilConfirmationGUI();
326  $cgui->setFormAction($ilCtrl->getFormAction($this));
327  $cgui->setHeaderText($lng->txt("sty_confirm_del_ind_styles").": ".
328  sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
329  ilObject::_lookupTitle($_POST["to_style"])));
330  $cgui->setCancel($lng->txt("cancel"), "editContentStyles");
331  $cgui->setConfirm($lng->txt("ok"), "moveIndividualStyles");
332  $tpl->setContent($cgui->getHTML());
333  }
334 
339  {
340  global $rbacsystem, $ilias, $styleDefinition;;
341 
342  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
343  {
344  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
345  }
346 
347  $this->tpl->addBlockfile("ADM_CONTENT", "style_settings", "tpl.stys_settings.html");
348  $this->tpl->setCurrentBlock("style_settings");
349 
350  $settings = $this->ilias->getAllSettings();
351 
352  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
353  {
354  $this->tpl->setCurrentBlock("save_but");
355  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
356  $this->tpl->parseCurrentBlock();
357  }
358  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
359  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("system_style_settings"));
360  $this->tpl->setVariable("TXT_DEFAULT_SKIN_STYLE", $this->lng->txt("default_skin_style"));
361  $this->tpl->setVariable("TXT_SKIN_STYLE_ACTIVATION", $this->lng->txt("style_activation"));
362  $this->tpl->setVariable("TXT_NUMBER_OF_USERS", $this->lng->txt("num_users"));
363  $this->tpl->setVariable("TXT_MOVE_USERS_TO_STYLE", $this->lng->txt("move_users_to_style"));
364 
365  // get all templates
366  $templates = $styleDefinition->getAllTemplates();
367 
368  $all_styles = array();
369 
370  foreach ($templates as $template)
371  {
372  // get styles definition for template
373  $styleDef =& new ilStyleDefinition($template["id"]);
374  $styleDef->startParsing();
375  $styles = $styleDef->getStyles();
376 
377  foreach ($styles as $style)
378  {
379  if ($this->ilias->ini->readVariable("layout","skin") == $template["id"] &&
380  $this->ilias->ini->readVariable("layout","style") == $style["id"])
381  {
382  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
383  }
384 
385  // default selection list
386  $this->tpl->setCurrentBlock("selectskin");
387  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
388  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
389  $this->tpl->parseCurrentBlock();
390 
391  // can be optimized
392  foreach ($templates as $template2)
393  {
394  // get styles definition for template
395  $styleDef2 =& new ilStyleDefinition($template2["id"]);
396  $styleDef2->startParsing();
397  $styles2 = $styleDef2->getStyles();
398 
399  foreach ($styles2 as $style2)
400  {
401  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
402  {
403  $this->tpl->setCurrentBlock("move_to_skin");
404  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
405  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
406  $this->tpl->parseCurrentBlock();
407  }
408  }
409  }
410 
411  // activation checkbox
412  $this->tpl->setCurrentBlock("activation_checkbox");
413  $this->tpl->setVariable("VAL_SKIN_STYLE", $template["id"].":".$style["id"]);
414  if (ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"]))
415  {
416  $this->tpl->setVariable("CHK_SKIN_STYLE", " checked=\"1\" ");
417  }
418  $this->tpl->parseCurrentBlock();
419 
420  // activation row
421  $this->tpl->setCurrentBlock("style_activation");
422  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", $template["id"].":".$style["id"]);
423  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
424  $styleDef->getTemplateName()." / ".$style["name"]);
425  $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
426  $this->tpl->setVariable("VAL_NUM_USERS", $num_users);
427  $this->tpl->parseCurrentBlock();
428 
429  $all_styles[] = $template["id"].":".$style["id"];
430  }
431  }
432 
433  // get all user assigned styles
434  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
435 
436  // output "other" row for all users, that are not assigned to
437  // any existing style
438  $users_missing_styles = 0;
439  foreach($all_user_styles as $style)
440  {
441  if (!in_array($style, $all_styles))
442  {
443  $style_arr = explode(":", $style);
444  $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
445  }
446  }
447 
448  if ($users_missing_styles > 0)
449  {
450  // can be optimized
451  foreach ($templates as $template2)
452  {
453  // get styles definition for template
454  $styleDef2 =& new ilStyleDefinition($template2["id"]);
455  $styleDef2->startParsing();
456  $styles2 = $styleDef2->getStyles();
457 
458  foreach ($styles2 as $style2)
459  {
460  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
461  {
462  $this->tpl->setCurrentBlock("move_to_skin");
463  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
464  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
465  $this->tpl->parseCurrentBlock();
466  }
467  }
468  }
469 
470  $this->tpl->setCurrentBlock("style_activation");
471  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
472  $this->lng->txt("other"));
473  $this->tpl->setVariable("VAL_NUM_USERS",
474  $users_missing_styles);
475  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", "other");
476  $this->tpl->parseCurrentBlock();
477  }
478 
479  $this->tpl->parseCurrentBlock();
480  }
481 
482 
487  {
488  global $styleDefinition, $ilCtrl;
489 
490  // check if one style is activated
491  if (count($_POST["st_act"]) < 1)
492  {
493  $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
494  }
495 
496  // check if a style should be deactivated, that still has
497  // a user assigned to
498  $templates = $styleDefinition->getAllTemplates();
499  $all_styles = array();
500  foreach ($templates as $template)
501  {
502  // get styles definition for template
503  $styleDef =& new ilStyleDefinition($template["id"]);
504  $styleDef->startParsing();
505  $styles = $styleDef->getStyles();
506  foreach ($styles as $style)
507  {
508  if (!isset($_POST["st_act"][$template["id"].":".$style["id"]]))
509  {
510  if (ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]) > 1)
511  {
512  $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
513  }
514  else
515  {
516  ilObjStyleSettings::_deactivateStyle($template["id"], $style["id"]);
517  }
518  }
519  else
520  {
521  ilObjStyleSettings::_activateStyle($template["id"], $style["id"]);
522  }
523  $all_styles[] = $template["id"].":".$style["id"];
524  }
525  }
526 
527  // move users to other skin
528  foreach($_POST["move_users"] as $key => $value)
529  {
530  if ($value != "")
531  {
532  $to = explode(":", $value);
533 
534  if ($key != "other")
535  {
536  $from = explode(":", $key);
537  ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
538  }
539  else
540  {
541  // get all user assigned styles
542  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
543 
544  // move users that are not assigned to
545  // currently existing style
546  foreach($all_user_styles as $style)
547  {
548  if (!in_array($style, $all_styles))
549  {
550  $style_arr = explode(":", $style);
551  ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
552  }
553  }
554  }
555  }
556  }
557 
558  //set default skin and style
559  if ($_POST["default_skin_style"] != "")
560  {
561  $sknst = explode(":", $_POST["default_skin_style"]);
562 
563  if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
564  $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
565  {
566  $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
567  $this->ilias->ini->setVariable("layout","style",$sknst[1]);
568  }
569  }
570  $this->ilias->ini->write();
571 
572  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
573  $ilCtrl->redirect($this , "editSystemStyles");
574  }
575 
581  function deleteStyleObject($a_error = false)
582  {
583  if (!isset($_POST["id"]))
584  {
585  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
586  }
587 
588  // SAVE POST VALUES
589  $_SESSION["saved_post"] = $_POST["id"];
590 
591  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
592 
593  if(!$a_error)
594  {
595  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
596  }
597 
598  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
599 
600  // BEGIN TABLE HEADER
601  $this->tpl->setCurrentBlock("table_header");
602  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
603  $this->tpl->parseCurrentBlock();
604 
605  // END TABLE HEADER
606 
607  // BEGIN TABLE DATA
608  $counter = 0;
609 
610  foreach ($_POST["id"] as $id)
611  {
612  $this->tpl->setCurrentBlock("table_row");
613  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_sty.gif"));
614  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
615  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
616  $this->tpl->parseCurrentBlock();
617  }
618 
619  // END TABLE DATA
620 
621  // BEGIN OPERATION_BTN
622  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
623  "cancelDelete" => $this->lng->txt("cancel"));
624  foreach ($buttons as $name => $value)
625  {
626  $this->tpl->setCurrentBlock("operation_btn");
627  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
628  $this->tpl->setVariable("BTN_NAME",$name);
629  $this->tpl->setVariable("BTN_VALUE",$value);
630  $this->tpl->parseCurrentBlock();
631  }
632  }
633 
634 
639  {
640  global $ilias;
641 
642  foreach($_SESSION["saved_post"] as $id)
643  {
644  $this->object->removeStyle($id);
645  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
646  $style_obj->delete();
647  }
648  $this->object->update();
649 
650  ilUtil::redirect($this->getReturnLocation("delete",
651  $this->ctrl->getLinkTarget($this,"editContentStyles","",false,false)));
652  }
653 
654 
659  {
660  global $ilSetting, $lng;
661 
662  if ($_GET["id"] > 0)
663  {
664  $ilSetting->delete("fixed_content_style_id");
665  $def_style = $ilSetting->get("default_content_style_id");
666 
667  if ($def_style != $_GET["id"])
668  {
669  $ilSetting->set("default_content_style_id", (int) $_GET["id"]);
670  }
671  else
672  {
673  $ilSetting->delete("default_content_style_id");
674  }
675  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
676  }
677  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
678  }
679 
684  {
685  global $ilSetting, $lng;
686 
687  if ($_GET["id"] > 0)
688  {
689  $ilSetting->delete("default_content_style_id");
690  $fixed_style = $ilSetting->get("fixed_content_style_id");
691  if ($fixed_style == (int) $_GET["id"])
692  {
693  $ilSetting->delete("fixed_content_style_id");
694  }
695  else
696  {
697  $ilSetting->set("fixed_content_style_id", (int) $_GET["id"]);
698  }
699  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
700  }
701  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
702  }
703 
704 
709  {
710  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
711  $styles = $this->object->getStyles();
712  foreach($styles as $style)
713  {
714  if ($_POST["std_".$style["id"]] == 1)
715  {
716  ilObjStyleSheet::_writeActive((int) $style["id"], 1);
717  }
718  else
719  {
720  ilObjStyleSheet::_writeActive((int) $style["id"], 0);
721  }
722  }
723  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
724  }
725 
732  function showActions($with_subobjects = false)
733  {
734 
735  // delete
736  $this->tpl->setCurrentBlock("tbl_action_btn");
737  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
738  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
739  $this->tpl->parseCurrentBlock();
740 
741  // set global default
742  $this->tpl->setCurrentBlock("tbl_action_btn");
743  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
744  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
745  $this->tpl->parseCurrentBlock();
746 
747  // set global default
748  $this->tpl->setCurrentBlock("tbl_action_btn");
749  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
750  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
751  $this->tpl->parseCurrentBlock();
752 
753  // set global default
754  $this->tpl->setCurrentBlock("tbl_action_btn");
755  $this->tpl->setVariable("BTN_NAME", "setScope");
756  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
757  $this->tpl->parseCurrentBlock();
758 
759  // save active styles
760  $this->tpl->setCurrentBlock("tbl_action_btn");
761  $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
762  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
763  $this->tpl->parseCurrentBlock();
764 
765  if ($with_subobjects === true)
766  {
767  $this->showPossibleSubObjects();
768  }
769 
770  $this->tpl->setCurrentBlock("tbl_action_row");
771  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
772  $this->tpl->parseCurrentBlock();
773  }
774 
781  {
782  session_unregister("saved_post");
783 
784  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
785  $this->ctrl->redirect($this, "editContentStyles");
786 
787  }
788 
789  function setScopeObject()
790  {
791  if ($_GET["id"] > 0)
792  {
793  include_once ("./Services/Style/classes/class.ilStyleScopeExplorer.php");
794  $exp = new ilStyleScopeExplorer("repository.php?cmd=goto");
795  $exp->setExpandTarget("repository.php?cmd=showTree");
796  $exp->setTargetGet("ref_id");
797  $exp->setFilterMode(IL_FM_POSITIVE);
798  $exp->forceExpandAll(true, false);
799  $exp->addFilter("root");
800  $exp->addFilter("cat");
801 
802  if ($_GET["expand"] == "")
803  {
804  $expanded = $this->tree->readRootId();
805  }
806  else
807  {
808  $expanded = $_GET["expand"];
809  }
810 
811  $exp->setExpand($expanded);
812 
813  // build html-output
814  $exp->setOutput(0);
815  $output = $exp->getOutput();
816  }
817 
818  $this->tpl->setVariable("ADM_CONTENT", $output);
819  }
820 
824  function saveScopeObject()
825  {
826  global $ilias;
827 
828  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
829  if ($_GET["cat"] == 0)
830  {
831  $_GET["cat"] == "";
832  }
833  ilObjStyleSheet::_writeScope($_GET["style_id"], $_GET["cat"]);
834 
835  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
836  }
837 
838 
843  {
844  global $tpl, $lng, $ilCtrl, $ilTabs, $ilToolbar, $rbacsystem;
845 
846  $ilTabs->setTabActive('page_layouts');
847 
848  // show toolbar, if write permission is given
849  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
850  {
851  $ilToolbar->addButton($lng->txt("sty_add_pgl"),
852  $ilCtrl->getLinkTarget($this, "addPageLayout"));
853  $ilToolbar->addButton($lng->txt("sty_import_page_layout"),
854  $ilCtrl->getLinkTarget($this, "importPageLayoutForm"));
855  }
856 
857  $oa_tpl = new ilTemplate("tpl.stys_pglayout.html", true, true, "Services/Style");
858 
859  include_once("./Services/Style/classes/class.ilPageLayoutTableGUI.php");
860  $pglayout_table = new ilPageLayoutTableGUI($this, "viewPageLayouts");
861  $oa_tpl->setVariable("PGLAYOUT_TABLE", $pglayout_table->getHTML());
862  $tpl->setContent($oa_tpl->get());
863 
864  }
865 
866 
867  function activateObject($a_activate=true){
868  if (!isset($_POST["pglayout"]))
869  {
870  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
871  } else {
872  ilUtil::sendSuccess($this->lng->txt("sty_opt_saved"),true);
873  foreach ($_POST["pglayout"] as $item)
874  {
875  $pg_layout = new ilPageLayout($item);
876  $pg_layout->activate($a_activate);
877  }
878  }
879  $this->ctrl->redirect($this, "viewPageLayouts");
880  }
881 
882  function deactivateObject(){
883  $this->activateObject(false);
884  }
885 
886 
887 
891  function deletePglObject()
892  {
893  global $ilTabs;
894 
895  if(!isset($_POST["pglayout"]))
896  {
897  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
898  }
899 
900  $ilTabs->setTabActive('page_layouts');
901 
902  // SAVE POST VALUES
903  $_SESSION["pglayout_user_delete"] = $_POST["pglayout"];
904 
905  unset($this->data);
906  $this->data["cols"] = array("type","title");
907 
908  foreach($_POST["pglayout"] as $id)
909  {
910  $pg_obj = new ilPageLayout($id);
911  $pg_obj->readObject();
912  $this->data["data"]["$id"] = array(
913  "type" => "stys",
914  "title" => $pg_obj->getTitle()
915  );
916 
917  }
918 
919  $this->data["buttons"] = array( "cancelDeletePg" => $this->lng->txt("cancel"),
920  "confirmedDeletePg" => $this->lng->txt("confirm"));
921 
922  $this->getTemplateFile("confirm");
923 
924  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
925 
926  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
927 
928  // BEGIN TABLE HEADER
929  foreach ($this->data["cols"] as $key)
930  {
931  $this->tpl->setCurrentBlock("table_header");
932  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
933  $this->tpl->parseCurrentBlock();
934  }
935  // END TABLE HEADER
936 
937  // BEGIN TABLE DATA
938  $counter = 0;
939 
940  foreach($this->data["data"] as $key => $value)
941  {
942  // BEGIN TABLE CELL
943  foreach($value as $key => $cell_data)
944  {
945  $this->tpl->setCurrentBlock("table_cell");
946 
947  // CREATE TEXT STRING
948  if($key == "type")
949  {
950  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
951  }
952  else
953  {
954  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
955  }
956  $this->tpl->parseCurrentBlock();
957  }
958 
959  $this->tpl->setCurrentBlock("table_row");
960  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
961  $this->tpl->parseCurrentBlock();
962  // END TABLE CELL
963  }
964  // END TABLE DATA
965 
966  // BEGIN OPERATION_BTN
967  foreach($this->data["buttons"] as $name => $value)
968  {
969  $this->tpl->setCurrentBlock("operation_btn");
970  $this->tpl->setVariable("BTN_NAME",$name);
971  $this->tpl->setVariable("BTN_VALUE",$value);
972  $this->tpl->parseCurrentBlock();
973  }
974  }
975 
976 
981  {
982  session_unregister("pglayout_user_delete");
983  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
984  $this->ctrl->redirect($this, "viewPageLayouts");
985  }
986 
987 
992  {
993  global $ilDB, $ilUser;
994 
995  foreach ($_SESSION["pglayout_user_delete"] as $id)
996  {
997  $pg_obj = new ilPageLayout($id);
998  $pg_obj->delete();
999  }
1000 
1001  $this->ctrl->redirect($this, "viewPageLayouts");
1002  }
1003 
1004  function addPageLayoutObject($a_form = null)
1005  {
1006  global $ilTabs;
1007 
1008  $ilTabs->setTabActive('page_layouts');
1009 
1010  if(!$a_form)
1011  {
1012  $a_form = $this->initAddPageLayoutForm();
1013  }
1014 
1015  $this->tpl->setContent($a_form->getHTML());
1016  }
1017 
1019  {
1020  global $lng, $ilCtrl;
1021 
1022  $lng->loadLanguageModule("content");
1023 
1024  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1025  $form_gui = new ilPropertyFormGUI();
1026  $form_gui->setFormAction($ilCtrl->getFormAction($this));
1027  $form_gui->setTitle($lng->txt("sty_create_pgl"));
1028 
1029  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
1030 
1031 
1032  $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
1033  $title_input->setSize(50);
1034  $title_input->setMaxLength(128);
1035  $title_input->setValue($this->layout_object->title);
1036  $title_input->setTitle($lng->txt("title"));
1037  $title_input->setRequired(true);
1038 
1039  $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
1040  $desc_input->setValue($this->layout_object->description);
1041  $desc_input->setRows(3);
1042  $desc_input->setCols(37);
1043 
1044  // special page?
1045  $options = array(
1046  "0" => $lng->txt("cont_layout_template"),
1047  "1" => $lng->txt("cont_special_page"),
1048  );
1049  $si = new ilSelectInputGUI($this->lng->txt("type"), "special_page");
1050  $si->setOptions($options);
1051 
1052  // modules
1053  $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
1054  // $mods->setRequired(true);
1055  foreach(ilPageLayout::getAvailableModules() as $mod_id => $mod_caption)
1056  {
1057  $mod = new ilCheckboxOption($mod_caption, $mod_id);
1058  $mods->addOption($mod);
1059  }
1060 
1061  $ttype_input = new ilSelectInputGUI($lng->txt("sty_based_on"), "pgl_template");
1062 
1063  $arr_templates = ilPageLayout::getLayouts();
1064  $arr_templates1 = ilPageLayout::getLayouts(false, true);
1065  foreach ($arr_templates1 as $v)
1066  {
1067  $arr_templates[] = $v;
1068  }
1069 
1070  $options = array();
1071  $options['-1'] = $lng->txt("none");
1072 
1073  foreach ($arr_templates as $templ) {
1074  $templ->readObject();
1075  $key = $templ->getId();
1076  $value = $templ->getTitle();
1077  $options[$key] = $value;
1078  }
1079 
1080  $ttype_input->setOptions($options);
1081  $ttype_input->setValue(-1);
1082  $ttype_input->setRequired(true);
1083 
1084  $desc_input->setTitle($lng->txt("description"));
1085  $desc_input->setRequired(false);
1086 
1087  $form_gui->addItem($title_input);
1088  $form_gui->addItem($desc_input);
1089  $form_gui->addItem($si);
1090  $form_gui->addItem($mods);
1091  $form_gui->addItem($ttype_input);
1092 
1093 
1094  $form_gui->addCommandButton("createPg", $lng->txt("save"));
1095  $form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
1096 
1097  return $form_gui;
1098  }
1099 
1100 
1101  function createPgObject()
1102  {
1103  global $ilCtrl;
1104 
1105  $form_gui = $this->initAddPageLayoutForm();
1106  if(!$form_gui->checkInput())
1107  {
1108  $form_gui->setValuesByPost();
1109  return $this->addPageLayoutObject($form_gui);
1110  }
1111 
1112  //create Page-Layout-Object first
1113  $pg_object = new ilPageLayout();
1114  $pg_object->setTitle($form_gui->getInput('pgl_title'));
1115  $pg_object->setDescription($form_gui->getInput('pgl_desc'));
1116  $pg_object->setSpecialPage($form_gui->getInput('special_page'));
1117  $pg_object->setModules($form_gui->getInput('module'));
1118  $pg_object->update();
1119 
1120  include_once("./Services/COPage/classes/class.ilPageObject.php");
1121 
1122  //create Page
1123  if(!is_object($pg_content))
1124  {
1125  $this->pg_content =& new ilPageObject($this->type);
1126  }
1127 
1128  $this->pg_content->setId($pg_object->getId());
1129 
1130  $tmpl = $form_gui->getInput('pgl_template');
1131  if ($tmpl != "-1")
1132  {
1133  $layout_obj = new ilPageLayout($tmpl);
1134  $this->pg_content->setXMLContent($layout_obj->getXMLContent());
1135  $this->pg_content->create(false);
1136  }
1137  else
1138  {
1139  $this->pg_content->create(false);
1140  }
1141 
1142  $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $pg_object->getId());
1143  $ilCtrl->redirectByClass("ilpagelayoutgui", "edit");
1144  }
1145 
1146  function cancelCreateObject() {
1147  $this->viewPageLayoutsObject();
1148  }
1149 
1150  function editPgObject()
1151  {
1152  global $ilCtrl, $rbacsystem;
1153 
1154  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
1155  {
1156  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1157  }
1158 
1159  $ilCtrl->setCmdClass("ilpagelayoutgui");
1160  $ilCtrl->setCmd("edit");
1161  $this->executeCommand();
1162  }
1163 
1164 
1165  function setTabs()
1166  {
1167  echo "settings_setTabs";
1168  }
1169 
1170  function getAdminTabs(&$tabs_gui)
1171  {
1172  $this->getTabs($tabs_gui);
1173  }
1174 
1180  function getTabs(&$tabs_gui)
1181  {
1182  global $rbacsystem, $lng, $ilTabs;
1183 
1184  if ($this->peditor_active) {
1185  $tabs_gui->setBackTarget($this->lng->txt("page_layouts"),
1186  $this->ctrl->getLinkTarget($this, "viewPageLayouts"));
1187  }
1188 
1189  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()) && !$this->peditor_active)
1190  {
1191  $tabs_gui->addTarget("basic_settings",
1192  $this->ctrl->getLinkTarget($this, "editBasicSettings"), array("editBasicSettings","", "view"), "", "");
1193 
1194  $tabs_gui->addTarget("system_styles",
1195  $this->ctrl->getLinkTarget($this, "editSystemStyles"), "editSystemStyles", "", "");
1196 
1197  $tabs_gui->addTarget("content_styles",
1198  $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
1199 
1200  $tabs_gui->addTarget("page_layouts",
1201  $this->ctrl->getLinkTarget($this, "viewPageLayouts"), "viewPageLayouts", "", "");
1202 
1203  }
1204 
1205 
1206  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()) && !$this->peditor_active)
1207  {
1208  $tabs_gui->addTarget("perm_settings",
1209  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1210  }
1211  }
1212 
1217  {
1218  global $ilCtrl;
1219 
1220  $ilCtrl->setParameter($this, "new_type", "sty");
1221  $ilCtrl->redirect($this, "create");
1222  }
1223 
1228  {
1229  global $lng, $ilCtrl;
1230 
1231  include_once("./Services/Style/classes/class.ilPageLayout.php");
1232 
1233  if (is_array($_POST["type"]))
1234  {
1235  foreach($_POST["type"] as $id => $t)
1236  {
1237  if ($id > 0)
1238  {
1239  $l = new ilPageLayout($id);
1240  $l->readObject();
1241  $l->setSpecialPage($t);
1242  if(is_array($_POST["module"][$id]))
1243  {
1244  $l->setModules(array_keys($_POST["module"][$id]));
1245  }
1246  else
1247  {
1248  $l->setModules();
1249  }
1250  $l->update();
1251  }
1252  }
1253 
1254  ilUtil::sendSuccess($lng->txt("msg_obj_modified"));
1255  }
1256 
1257  $ilCtrl->redirect($this, "viewPageLayouts");
1258  }
1259 
1260 
1265  {
1266  include_once("./Services/Export/classes/class.ilExport.php");
1267  $exp = new ilExport();
1268 
1269  $tmpdir = ilUtil::ilTempnam();
1270  ilUtil::makeDir($tmpdir);
1271 
1272  $succ = $exp->exportEntity("pgtp", (int) $_GET["layout_id"], "4.2.0",
1273  "Services/COPage", "Title", $tmpdir);
1274 
1275  if ($succ["success"])
1276  {
1277  ilUtil::deliverFile($succ["directory"]."/".$succ["file"], $succ["file"],
1278  "", false, false, false);
1279  }
1280  if (is_file($succ["directory"]."/".$succ["file"]))
1281  {
1282  unlink($succ["directory"]."/".$succ["file"]);
1283  }
1284  if (is_dir($succ["directory"]))
1285  {
1286  unlink($succ["directory"]);
1287  }
1288  }
1289 
1294  {
1295  global $tpl, $ilTabs;
1296 
1297  $ilTabs->setTabActive('page_layouts');
1298  $form = $this->initPageLayoutImportForm();
1299  $tpl->setContent($form->getHTML());
1300  }
1301 
1305  public function initPageLayoutImportForm()
1306  {
1307  global $lng, $ilCtrl;
1308 
1309  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1310  $form = new ilPropertyFormGUI();
1311 
1312  // template file
1313  $fi = new ilFileInputGUI($lng->txt("file"), "file");
1314  $fi->setSuffixes(array("zip"));
1315  $fi->setRequired(true);
1316  $form->addItem($fi);
1317 
1318  $form->addCommandButton("importPageLayout", $lng->txt("import"));
1319  $form->addCommandButton("viewPageLayouts", $lng->txt("cancel"));
1320 
1321  $form->setTitle($lng->txt("sty_import_page_layout"));
1322  $form->setFormAction($ilCtrl->getFormAction($this));
1323 
1324  return $form;
1325  }
1326 
1330  public function importPageLayoutObject()
1331  {
1332  global $tpl, $lng, $ilCtrl, $ilTabs;
1333 
1334  $form = $this->initPageLayoutImportForm();
1335  if ($form->checkInput())
1336  {
1337  include_once("./Services/Style/classes/class.ilPageLayout.php");
1338  $pg = ilPageLayout::import($_FILES["file"]["name"], $_FILES["file"]["tmp_name"]);
1339  if ($pg > 0)
1340  {
1341  ilUtil::sendSuccess($lng->txt("sty_imported_layout"), true);
1342  }
1343  $ilCtrl->redirect($this, "viewPageLayouts");
1344  }
1345  else
1346  {
1347  $ilTabs->setTabActive('page_layouts');
1348  $form->setValuesByPost();
1349  $tpl->setContent($form->getHtml());
1350  }
1351  }
1352 }
1353 ?>