ILIAS  Release_4_0_x_branch Revision 61816
 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 
15 include_once "./classes/class.ilObjectGUI.php";
16 include_once("./Services/Style/classes/class.ilPageLayout.php");
17 
18 
20 {
28  //page_layout editing
29  var $peditor_active = false;
30  var $pg_id = null;
31 
32  function ilObjStyleSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
33  {
34  global $lng,$ilCtrl;
35 
36  $this->type = "stys";
37 
38  $cmd = $ilCtrl->getCmd();
39 
40  if ($cmd == "editPg") {
41  $this->peditor_active = true;
42  }
43 
44  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
45 
46  $lng->loadLanguageModule("style");
47  }
48 
49  function &executeCommand()
50  {
51  $next_class = $this->ctrl->getNextClass($this);
52  $cmd = $this->ctrl->getCmd();
53 
54  if ($next_class == "ilpagelayoutgui" || $cmd =="createPg") {
55  $this->peditor_active =true;
56  }
57 
58  $this->prepareOutput();
59 
60 
61  switch($next_class)
62  {
63  case 'ilpermissiongui':
64  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret =& $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  case 'ilpagelayoutgui':
70  include_once("./Services/Style/classes/class.ilPageLayoutGUI.php");
71  $this->tpl->getStandardTemplate();
72  $this->ctrl->setReturn($this, "edit");
73  if ($this->pg_id!=null) {
74  $layout_gui =& new ilPageLayoutGUI($this->type,$this->pg_id);
75  } else {
76  $layout_gui =& new ilPageLayoutGUI($this->type,$_GET["obj_id"]);
77  }
78  $layout_gui->setTabs();
79  $layout_gui->setEditPreview(true);
80  $this->ctrl->saveParameter($this, "obj_id");
81  $ret =& $this->ctrl->forwardCommand($layout_gui);
82  $this->tpl->setContent($ret);
83  break;
84 
85  default:
86  if ($cmd == "" || $cmd == "view")
87  {
88  $cmd = "editBasicSettings";
89  }
90  $cmd .= "Object";
91  $this->$cmd();
92 
93  break;
94  }
95  return true;
96  }
97 
102  function saveObject()
103  {
104  global $rbacadmin;
105 
106  // create and insert forum in objecttree
107  $newObj = parent::saveObject();
108 
109  // setup rolefolder & default local roles
110  //$roles = $newObj->initDefaultRoles();
111 
112  // ...finally assign role to creator of object
113  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
114 
115  // put here object specific stuff
116 
117  // always send a message
118  ilUtil::sendInfo($this->lng->txt("object_added"),true);
119 
120  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
121  }
122 
127  {
128  global $rbacsystem;
129 
130  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
131  {
132  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
133  }
134 
135  $this->tpl->addBlockfile("ADM_CONTENT", "style_basic_settings", "tpl.stys_basic_settings.html");
136  $this->tpl->setCurrentBlock("style_settings");
137 
138  $settings = $this->ilias->getAllSettings();
139 
140  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
141 
142  $this->tpl->setVariable("TXT_TREE_FRAME", $this->lng->txt("tree_frame"));
143  $this->tpl->setVariable("TXT_TREE_FRAME_INFO", $this->lng->txt("tree_frame_info"));
144  $this->tpl->setVariable("TXT_FRAME_LEFT", $this->lng->txt("tree_left"));
145  $this->tpl->setVariable("TXT_FRAME_RIGHT", $this->lng->txt("tree_right"));
146 
147  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("basic_settings"));
148  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS", $this->lng->txt("icons_in_typed_lists"));
149  $this->tpl->setVariable("TXT_ICONS_IN_HEADER", $this->lng->txt("icons_in_header"));
150  $this->tpl->setVariable("TXT_ICONS_IN_ITEM_ROWS", $this->lng->txt("icons_in_item_rows"));
151  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS_INFO", $this->lng->txt("icons_in_typed_lists_info"));
152 
153  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS", $this->lng->txt("enable_custom_icons"));
154  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS_INFO", $this->lng->txt("enable_custom_icons_info"));
155  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_BIG", $this->lng->txt("custom_icon_size_big"));
156  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_SMALL", $this->lng->txt("custom_icon_size_standard"));
157  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_TINY", $this->lng->txt("custom_icon_size_tiny"));
158  $this->tpl->setVariable("TXT_WIDTH_X_HEIGHT", $this->lng->txt("width_x_height"));
159  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
160 
161  // set current values
162  if ($settings["tree_frame"] == "right")
163  {
164  $this->tpl->setVariable("SEL_FRAME_RIGHT","selected=\"selected\"");
165  }
166  else
167  {
168  $this->tpl->setVariable("SEL_FRAME_LEFT","selected=\"selected\"");
169  }
170 
171  if ($settings["custom_icons"])
172  {
173  $this->tpl->setVariable("CHK_CUSTOM_ICONS","checked=\"checked\"");
174  }
175 /* if ($settings["icon_position_in_lists"] == "item_rows")
176  {
177  $this->tpl->setVariable("SEL_ICON_POS_ITEM_ROWS","selected=\"selected\"");
178  }
179  else
180  {
181  $this->tpl->setVariable("SEL_ICON_POS_HEADER","selected=\"selected\"");
182  }*/
183  $this->tpl->setVariable("CUST_ICON_BIG_WIDTH", $settings["custom_icon_big_width"]);
184  $this->tpl->setVariable("CUST_ICON_BIG_HEIGHT", $settings["custom_icon_big_height"]);
185  $this->tpl->setVariable("CUST_ICON_SMALL_WIDTH", $settings["custom_icon_small_width"]);
186  $this->tpl->setVariable("CUST_ICON_SMALL_HEIGHT", $settings["custom_icon_small_height"]);
187  $this->tpl->setVariable("CUST_ICON_TINY_WIDTH", $settings["custom_icon_tiny_width"]);
188  $this->tpl->setVariable("CUST_ICON_TINY_HEIGHT", $settings["custom_icon_tiny_height"]);
189 
190 // $this->tpl->parseCurrentBlock();
191  }
192 
197  {
198  $this->ilias->setSetting("tree_frame", $_POST["tree_frame"]);
199 // $this->ilias->setSetting("icon_position_in_lists", $_POST["icon_position_in_lists"]);
200  $this->ilias->setSetting("custom_icons", $_POST["custom_icons"]);
201  $this->ilias->setSetting("custom_icon_big_width", (int) $_POST["custom_icon_big_width"]);
202  $this->ilias->setSetting("custom_icon_big_height", (int) $_POST["custom_icon_big_height"]);
203  $this->ilias->setSetting("custom_icon_small_width", (int) $_POST["custom_icon_small_width"]);
204  $this->ilias->setSetting("custom_icon_small_height", (int) $_POST["custom_icon_small_height"]);
205  $this->ilias->setSetting("custom_icon_tiny_width", (int) $_POST["custom_icon_tiny_width"]);
206  $this->ilias->setSetting("custom_icon_tiny_height", (int) $_POST["custom_icon_tiny_height"]);
207  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
208  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editBasicSettings"));
209  }
210 
215  {
216  global $rbacsystem, $ilias;
217 
218  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
219  {
220  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
221  }
222 
223  include_once "./Services/Table/classes/class.ilTableGUI.php";
224 
225  // load template content style settings
226  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.styf_content_styles.html");
227 
228  // load template for table
229  $this->tpl->addBlockfile("STYLE_TABLE", "style_table", "tpl.table.html");
230 
231  // load template for table content data
232  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
233 
234  $num = 0;
235 
236  $this->tpl->setVariable("FORMACTION",
237  $this->ctrl->getFormAction($this));
238 
239  // create table
240  $tbl = new ilTableGUI();
241 
242  // title & header columns
243  $tbl->setTitle($this->lng->txt("content_styles"),"icon_sty.gif",
244  $this->lng->txt("content_styles"));
245 
246  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
247 
248  // title
249  $header_names = array("", $this->lng->txt("title"),
250  $this->lng->txt("sty_nr_learning_modules"),
251  $this->lng->txt("purpose"), $this->lng->txt("sty_scope"),
252  $this->lng->txt("active"));
253  $tbl->setHeaderNames($header_names);
254 
255  $header_params = array("ref_id" => $this->ref_id);
256  $tbl->setHeaderVars(array("", "title", "nr_lms", "purpose", "scope", "active"), $header_params);
257  $tbl->setColumnWidth(array("1px", "", "", "", ""));
258 
259  // control
260  $tbl->setOrderColumn($_GET["sort_by"]);
261  $tbl->setOrderDirection($_GET["sort_order"]);
262  $tbl->setLimit($_GET["limit"]);
263  $tbl->setOffset($_GET["offset"]);
264  $tbl->disable("sort");
265 
266  // get style ids
267  $style_entries = array();
268  $styles = $this->object->getStyles();
269  foreach($styles as $style)
270  {
271  $style_entries[$style["title"].":".$style["id"]]
272  = $style;
273  }
274  ksort($style_entries);
275  $from_styles = $to_styles = array();
276  // this may not be cool, if styles are organised as (independent) Service
277  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
278 
279  // number of individual styles
280  if ($fixed_style <= 0)
281  {
282  $style_entries[-1] =
283  array("title" => $this->lng->txt("sty_individual_styles"),
284  "id" => 0, "nr" => ilObjContentObject::_getNrLMsIndividualStyles());
285  $from_styles[-1] = $this->lng->txt("sty_individual_styles");
286  }
287 
288  // number of default style (fallback default style)
289  if ($default_style <= 0 && $fixed_style <= 0)
290  {
291  $style_entries[0] =
292  array("title" => $this->lng->txt("sty_default_style"),
293  "id" => 0, "nr" => ilObjContentObject::_getNrLMsNoStyle());
294  $from_styles[0] = $this->lng->txt("sty_default_style");
295  $to_styles[0] = $this->lng->txt("sty_default_style");
296  }
297 
298  // todo
299  $tbl->setMaxCount(count($style_entries));
300 
301  $this->tpl->setVariable("COLUMN_COUNTS", 6);
302 
303  // footer
304  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
305 
306  $this->showActions(true);
307  $table_empty = true;
308 
309  include_once ("./Services/Style/classes/class.ilObjStyleSheet.php");
310 
311  $fixed_style = $ilias->getSetting("fixed_content_style_id");
312  $default_style = $ilias->getSetting("default_content_style_id");
313 
314  foreach ($style_entries as $style)
315  {
316  // color changing
317  $css_row = ($css_row == "tblrow2")
318  ? "tblrow1"
319  : "tblrow2";
320 
321  // command checkbox
322  if ($style["id"] > 0)
323  {
324  $this->tpl->setCurrentBlock("check_box");
325  $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
326  $this->tpl->parseCurrentBlock();
327  }
328 
329  // activation checkbox
330  if ($fixed_style <= 0 && $style["id"] > 0)
331  {
332  $this->tpl->setCurrentBlock("active_box");
333  if (ilObjStyleSheet::_lookupActive($style["id"]))
334  {
335  $this->tpl->setVariable("CHECKED_STY", 'checked="checked"');
336  }
337  $this->tpl->setVariable("ACTIVE_ID", $style["id"]);
338  $this->tpl->parseCurrentBlock();
339  }
340 
341  // link to style edit screen
342  if ($style["id"] > 0)
343  {
344  $this->ctrl->setParameterByClass("ilobjstylesheetgui", "obj_id", $style["id"]);
345  $this->tpl->setCurrentBlock("linka");
346  $this->tpl->setVariable("TXT_TITLE", $style["title"]);
347  $this->tpl->setVariable("LINK_STYLE",
348  $this->ctrl->getLinkTargetByClass("ilobjstylesheetgui"), "view");
349  $this->tpl->parseCurrentBlock();
350  }
351  else
352  {
353  $this->tpl->setCurrentBlock("texta");
354  $this->tpl->setVariable("TXT_TEXT", $style["title"]);
355  $this->tpl->parseCurrentBlock();
356  }
357 
358  $this->tpl->setCurrentBlock("style_row");
359 
360  // number of assigned lms
361  if ($style["id"] > 0)
362  {
363  $nr_lm = ilObjContentObject::_getNrOfAssignedLMs($style["id"]);
364 
365  // fill from/to array
366  if ($nr_lm > 0)
367  {
368  $from_styles[$style["id"]] = $style["title"];
369  }
370  if (ilObjStyleSheet::_lookupActive($style["id"]))
371  {
372  $to_styles[$style["id"]] = $style["title"];
373  }
374 
375  $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $nr_lm);
376  $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
377  }
378  else
379  {
380  $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $style["nr"]);
381  }
382 
383  $this->tpl->setVariable("ROWCOL", $css_row);
384 
385  // purpose and scope
386  if ($style["id"] > 0)
387  {
388  if ($style["id"] == $fixed_style)
389  {
390  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
391  }
392  if ($style["id"] == $default_style)
393  {
394  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
395  }
396  if ($style["category"] > 0)
397  {
398  $this->tpl->setVariable("TXT_SCOPE",
400  ilObject::_lookupObjId($style["category"])
401  ));
402  }
403  }
404  $this->tpl->parseCurrentBlock();
405 
406  $this->tpl->setCurrentBlock("tbl_content");
407  $this->tpl->parseCurrentBlock();
408 
409  } //if is_array
410 
411  if (count($style_entries) == 0)
412  {
413  $tbl->disable("header");
414  $tbl->disable("footer");
415 
416  $this->tpl->setCurrentBlock("text");
417  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
418  $this->tpl->parseCurrentBlock();
419 
420  $this->tpl->setCurrentBlock("tbl_content");
421  $this->tpl->parseCurrentBlock();
422  }
423 
424  // render table
425  $tbl->render();
426 
427 
428  // move form
429  $this->tpl->setCurrentBlock("adm_content");
430  $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
431  $this->tpl->setVariable("TXT_FROM", $this->lng->txt("from"));
432  $this->tpl->setVariable("TXT_TO", $this->lng->txt("to"));
433  $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
434  $this->tpl->setVariable("TXT_MOVE_STYLE", $this->lng->txt("sty_move_style"));
435  $this->tpl->setVariable("SELECT_FROM",
436  ilUtil::formSelect("", "from_style", $from_styles, false, true));
437  $this->tpl->setVariable("SELECT_TO",
438  ilUtil::formSelect("", "to_style", $to_styles, false, true));
439  $this->tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
440  $this->tpl->parseCurrentBlock();
441  }
442 
447  {
448  if ($_POST["from_style"] == -1)
449  {
451  return;
452  }
453 
454  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
455  ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
456  $this->ctrl->redirect($this, "editContentStyles");
457  }
458 
459 
464  {
465  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
466  ilObjContentObject::_moveLMStyles(-1, $_GET["to_style"]);
467  $this->ctrl->redirect($this, "editContentStyles");
468  }
469 
470 
475  {
476  // load template content style settings
477  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
478  $this->tpl->setVariable("CMD_OK", "moveIndividualStyles");
479  $this->tpl->setVariable("TXT_OK", $this->lng->txt("ok"));
480  $this->tpl->setVariable("CMD_CANCEL", "editContentStyles");
481  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
482  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("sty_confirm_del_ind_styles"));
483  $this->tpl->setVariable("TXT_CONTENT",
484  sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
485  ilObject::_lookupTitle($_POST["to_style"])));
486  $this->ctrl->setParameter($this, "to_style", $_POST["to_style"]);
487  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
488  $this->tpl->parseCurrentBlock();
489  }
490 
491 
496  {
497  global $rbacsystem, $ilias, $styleDefinition;;
498 
499  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
500  {
501  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
502  }
503 
504  $this->tpl->addBlockfile("ADM_CONTENT", "style_settings", "tpl.stys_settings.html");
505  $this->tpl->setCurrentBlock("style_settings");
506 
507  $settings = $this->ilias->getAllSettings();
508 
509  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
510  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("system_style_settings"));
511  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
512  $this->tpl->setVariable("TXT_DEFAULT_SKIN_STYLE", $this->lng->txt("default_skin_style"));
513  $this->tpl->setVariable("TXT_SKIN_STYLE_ACTIVATION", $this->lng->txt("style_activation"));
514  $this->tpl->setVariable("TXT_NUMBER_OF_USERS", $this->lng->txt("num_users"));
515  $this->tpl->setVariable("TXT_MOVE_USERS_TO_STYLE", $this->lng->txt("move_users_to_style"));
516 
517  // get all templates
518  $templates = $styleDefinition->getAllTemplates();
519 
520  $all_styles = array();
521 
522  foreach ($templates as $template)
523  {
524  // get styles definition for template
525  $styleDef =& new ilStyleDefinition($template["id"]);
526  $styleDef->startParsing();
527  $styles = $styleDef->getStyles();
528 
529  foreach ($styles as $style)
530  {
531  if ($this->ilias->ini->readVariable("layout","skin") == $template["id"] &&
532  $this->ilias->ini->readVariable("layout","style") == $style["id"])
533  {
534  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
535  }
536 
537  // default selection list
538  $this->tpl->setCurrentBlock("selectskin");
539  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
540  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
541  $this->tpl->parseCurrentBlock();
542 
543  // can be optimized
544  foreach ($templates as $template2)
545  {
546  // get styles definition for template
547  $styleDef2 =& new ilStyleDefinition($template2["id"]);
548  $styleDef2->startParsing();
549  $styles2 = $styleDef2->getStyles();
550 
551  foreach ($styles2 as $style2)
552  {
553  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
554  {
555  $this->tpl->setCurrentBlock("move_to_skin");
556  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
557  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
558  $this->tpl->parseCurrentBlock();
559  }
560  }
561  }
562 
563  // activation checkbox
564  $this->tpl->setCurrentBlock("activation_checkbox");
565  $this->tpl->setVariable("VAL_SKIN_STYLE", $template["id"].":".$style["id"]);
566  if (ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"]))
567  {
568  $this->tpl->setVariable("CHK_SKIN_STYLE", " checked=\"1\" ");
569  }
570  $this->tpl->parseCurrentBlock();
571 
572  // activation row
573  $this->tpl->setCurrentBlock("style_activation");
574  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", $template["id"].":".$style["id"]);
575  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
576  $styleDef->getTemplateName()." / ".$style["name"]);
577  $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
578  $this->tpl->setVariable("VAL_NUM_USERS", $num_users);
579  $this->tpl->parseCurrentBlock();
580 
581  $all_styles[] = $template["id"].":".$style["id"];
582  }
583  }
584 
585  // get all user assigned styles
586  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
587 
588  // output "other" row for all users, that are not assigned to
589  // any existing style
590  $users_missing_styles = 0;
591  foreach($all_user_styles as $style)
592  {
593  if (!in_array($style, $all_styles))
594  {
595  $style_arr = explode(":", $style);
596  $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
597  }
598  }
599 
600  if ($users_missing_styles > 0)
601  {
602  // can be optimized
603  foreach ($templates as $template2)
604  {
605  // get styles definition for template
606  $styleDef2 =& new ilStyleDefinition($template2["id"]);
607  $styleDef2->startParsing();
608  $styles2 = $styleDef2->getStyles();
609 
610  foreach ($styles2 as $style2)
611  {
612  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
613  {
614  $this->tpl->setCurrentBlock("move_to_skin");
615  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
616  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
617  $this->tpl->parseCurrentBlock();
618  }
619  }
620  }
621 
622  $this->tpl->setCurrentBlock("style_activation");
623  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
624  $this->lng->txt("other"));
625  $this->tpl->setVariable("VAL_NUM_USERS",
626  $users_missing_styles);
627  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", "other");
628  $this->tpl->parseCurrentBlock();
629  }
630 
631  $this->tpl->parseCurrentBlock();
632  }
633 
634 
639  {
640  global $styleDefinition;
641 
642  // check if one style is activated
643  if (count($_POST["st_act"]) < 1)
644  {
645  $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
646  }
647 
648  // check if a style should be deactivated, that still has
649  // a user assigned to
650  $templates = $styleDefinition->getAllTemplates();
651  $all_styles = array();
652  foreach ($templates as $template)
653  {
654  // get styles definition for template
655  $styleDef =& new ilStyleDefinition($template["id"]);
656  $styleDef->startParsing();
657  $styles = $styleDef->getStyles();
658  foreach ($styles as $style)
659  {
660  if (!isset($_POST["st_act"][$template["id"].":".$style["id"]]))
661  {
662  if (ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]) > 1)
663  {
664  $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
665  }
666  else
667  {
668  ilObjStyleSettings::_deactivateStyle($template["id"], $style["id"]);
669  }
670  }
671  else
672  {
673  ilObjStyleSettings::_activateStyle($template["id"], $style["id"]);
674  }
675  $all_styles[] = $template["id"].":".$style["id"];
676  }
677  }
678 
679  // move users to other skin
680  foreach($_POST["move_users"] as $key => $value)
681  {
682  if ($value != "")
683  {
684  $to = explode(":", $value);
685 
686  if ($key != "other")
687  {
688  $from = explode(":", $key);
689  ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
690  }
691  else
692  {
693  // get all user assigned styles
694  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
695 
696  // move users that are not assigned to
697  // currently existing style
698  foreach($all_user_styles as $style)
699  {
700  if (!in_array($style, $all_styles))
701  {
702  $style_arr = explode(":", $style);
703  ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
704  }
705  }
706  }
707  }
708  }
709 
710  //set default skin and style
711  if ($_POST["default_skin_style"] != "")
712  {
713  $sknst = explode(":", $_POST["default_skin_style"]);
714 
715  if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
716  $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
717  {
718  $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
719  $this->ilias->ini->setVariable("layout","style",$sknst[1]);
720  }
721  }
722  $this->ilias->ini->write();
723 //echo "redirect-".$this->ctrl->getLinkTarget($this,"editSystemStyles")."-";
724  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
725  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editSystemStyles"));
726  }
727 
733  function deleteStyleObject($a_error = false)
734  {
735  if (!isset($_POST["id"]))
736  {
737  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
738  }
739 
740  // SAVE POST VALUES
741  $_SESSION["saved_post"] = $_POST["id"];
742 
743  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
744 
745  if(!$a_error)
746  {
747  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
748  }
749 
750  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
751 
752  // BEGIN TABLE HEADER
753  $this->tpl->setCurrentBlock("table_header");
754  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
755  $this->tpl->parseCurrentBlock();
756 
757  // END TABLE HEADER
758 
759  // BEGIN TABLE DATA
760  $counter = 0;
761 
762  foreach ($_POST["id"] as $id)
763  {
764  $this->tpl->setCurrentBlock("table_row");
765  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_sty.gif"));
766  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
767  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
768  $this->tpl->parseCurrentBlock();
769  }
770 
771  // END TABLE DATA
772 
773  // BEGIN OPERATION_BTN
774  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
775  "cancelDelete" => $this->lng->txt("cancel"));
776  foreach ($buttons as $name => $value)
777  {
778  $this->tpl->setCurrentBlock("operation_btn");
779  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
780  $this->tpl->setVariable("BTN_NAME",$name);
781  $this->tpl->setVariable("BTN_VALUE",$value);
782  $this->tpl->parseCurrentBlock();
783  }
784  }
785 
786 
791  {
792  global $ilias;
793 
794  foreach($_SESSION["saved_post"] as $id)
795  {
796  $this->object->removeStyle($id);
797  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
798  $style_obj->delete();
799  }
800  $this->object->update();
801 
802  ilUtil::redirect($this->getReturnLocation("delete",
803  $this->ctrl->getLinkTarget($this,"editContentStyles")));
804  }
805 
806 
813  {
814  global $ilias;
815 
816  if (!isset($_POST["id"]))
817  {
818  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
819  }
820  if(count($_POST["id"]) > 1)
821  {
822  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
823  }
824 
825  $ilias->deleteSetting("fixed_content_style_id");
826  $def_style = $ilias->getSetting("default_content_style_id");
827 
828  if ($def_style != $_POST["id"][0])
829  {
830  $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
831  }
832  else
833  {
834  $ilias->deleteSetting("default_content_style_id");
835  }
836 
837  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
838  }
839 
846  {
847  global $ilias;
848 
849  if (!isset($_POST["id"]))
850  {
851  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
852  }
853  if(count($_POST["id"]) > 1)
854  {
855  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
856  }
857 
858  $ilias->deleteSetting("default_content_style_id");
859  $fixed_style = $ilias->getSetting("fixed_content_style_id");
860  if ($fixed_style == $_POST["id"][0])
861  {
862  $ilias->deleteSetting("fixed_content_style_id");
863  }
864  else
865  {
866  $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
867  }
868  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
869  }
870 
871 
876  {
877  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
878  $styles = $this->object->getStyles();
879  foreach($styles as $style)
880  {
881  if ($_POST["std_".$style["id"]] == 1)
882  {
883  ilObjStyleSheet::_writeActive($style["id"], 1);
884  }
885  else
886  {
887  ilObjStyleSheet::_writeActive($style["id"], 0);
888  }
889  }
890  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
891  }
892 
899  function showActions($with_subobjects = false)
900  {
901 
902  // delete
903  $this->tpl->setCurrentBlock("tbl_action_btn");
904  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
905  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
906  $this->tpl->parseCurrentBlock();
907 
908  // set global default
909  $this->tpl->setCurrentBlock("tbl_action_btn");
910  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
911  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
912  $this->tpl->parseCurrentBlock();
913 
914  // set global default
915  $this->tpl->setCurrentBlock("tbl_action_btn");
916  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
917  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
918  $this->tpl->parseCurrentBlock();
919 
920  // set global default
921  $this->tpl->setCurrentBlock("tbl_action_btn");
922  $this->tpl->setVariable("BTN_NAME", "setScope");
923  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
924  $this->tpl->parseCurrentBlock();
925 
926  // save active styles
927  $this->tpl->setCurrentBlock("tbl_action_btn");
928  $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
929  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
930  $this->tpl->parseCurrentBlock();
931 
932  if ($with_subobjects === true)
933  {
934  $this->showPossibleSubObjects();
935  }
936 
937  $this->tpl->setCurrentBlock("tbl_action_row");
938  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
939  $this->tpl->parseCurrentBlock();
940  }
941 
948  {
949  session_unregister("saved_post");
950 
951  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
952  $this->ctrl->redirect($this, "editContentStyles");
953 
954  }
955 
956  function setScopeObject()
957  {
958  if (!isset($_POST["id"]))
959  {
960  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
961  }
962 
963 
964  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
965  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.explorer.html");
966 
967  include_once ("./Services/Style/classes/class.ilStyleScopeExplorer.php");
968  $exp = new ilStyleScopeExplorer("repository.php?cmd=goto");
969  $exp->setExpandTarget("repository.php?cmd=showTree");
970  $exp->setTargetGet("ref_id");
971  $exp->setFilterMode(IL_FM_POSITIVE);
972  $exp->forceExpandAll(true, false);
973  $exp->addFilter("root");
974  $exp->addFilter("cat");
975 
976  if ($_GET["expand"] == "")
977  {
978  $expanded = $this->tree->readRootId();
979  }
980  else
981  {
982  $expanded = $_GET["expand"];
983  }
984 
985  $exp->setExpand($expanded);
986 
987  // build html-output
988  $exp->setOutput(0);
989  $output = $exp->getOutput();
990 
991  $this->tpl->setVariable("ADM_CONTENT", $output);
992  }
993 
997  function saveScopeObject()
998  {
999  global $ilias;
1000 
1001  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1002  if ($_GET["cat"] == 0)
1003  {
1004  $_GET["cat"] == "";
1005  }
1006  ilObjStyleSheet::_writeScope($_GET["style_id"], $_GET["cat"]);
1007 
1008  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
1009  }
1010 
1011 
1016  {
1017 
1018  global $tpl, $lng, $ilCtrl, $ilTabs;
1019 
1020  $ilTabs->setTabActive('page_layouts');
1021 
1022  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1023 
1024  $tpl->setCurrentBlock("btn_cell");
1025  $tpl->setVariable("BTN_LINK",
1026  $ilCtrl->getLinkTarget($this, "createPgGUI"));
1027  $tpl->setVariable("BTN_TXT",$lng->txt("sty_add_pgl"));
1028  $tpl->parseCurrentBlock();
1029 
1030  $oa_tpl = new ilTemplate("tpl.stys_pglayout.html", true, true, "Services/Style");
1031 
1032  include_once("./Services/Style/classes/class.ilPageLayoutTableGUI.php");
1033  $pglayout_table = new ilPageLayoutTableGUI($this, "viewPageLayouts");
1034  $oa_tpl->setVariable("PGLAYOUT_TABLE", $pglayout_table->getHTML());
1035  $tpl->setContent($oa_tpl->get());
1036 
1037  }
1038 
1039 
1040  function activateObject($a_activate=true){
1041  if (!isset($_POST["pglayout"]))
1042  {
1043  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1044  } else {
1045  ilUtil::sendSuccess($this->lng->txt("sty_opt_saved"),true);
1046  foreach ($_POST["pglayout"] as $item)
1047  {
1048  $pg_layout = new ilPageLayout($item);
1049  $pg_layout->activate($a_activate);
1050  }
1051  }
1052  $this->ctrl->redirect($this, "viewPageLayouts");
1053  }
1054 
1055  function deactivateObject(){
1056  $this->activateObject(false);
1057  }
1058 
1059 
1060 
1064  function deletePglObject()
1065  {
1066  global $ilTabs;
1067 
1068  if(!isset($_POST["pglayout"]))
1069  {
1070  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1071  }
1072 
1073  $ilTabs->setTabActive('page_layouts');
1074 
1075  // SAVE POST VALUES
1076  $_SESSION["pglayout_user_delete"] = $_POST["pglayout"];
1077 
1078  unset($this->data);
1079  $this->data["cols"] = array("type","title");
1080 
1081  foreach($_POST["pglayout"] as $id)
1082  {
1083  $pg_obj = new ilPageLayout($id);
1084  $pg_obj->readObject();
1085  $this->data["data"]["$id"] = array(
1086  "type" => "stys",
1087  "title" => $pg_obj->getTitle()
1088  );
1089 
1090  }
1091 
1092  $this->data["buttons"] = array( "cancelDeletePg" => $this->lng->txt("cancel"),
1093  "confirmedDeletePg" => $this->lng->txt("confirm"));
1094 
1095  $this->getTemplateFile("confirm");
1096 
1097  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
1098 
1099  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1100 
1101  // BEGIN TABLE HEADER
1102  foreach ($this->data["cols"] as $key)
1103  {
1104  $this->tpl->setCurrentBlock("table_header");
1105  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1106  $this->tpl->parseCurrentBlock();
1107  }
1108  // END TABLE HEADER
1109 
1110  // BEGIN TABLE DATA
1111  $counter = 0;
1112 
1113  foreach($this->data["data"] as $key => $value)
1114  {
1115  // BEGIN TABLE CELL
1116  foreach($value as $key => $cell_data)
1117  {
1118  $this->tpl->setCurrentBlock("table_cell");
1119 
1120  // CREATE TEXT STRING
1121  if($key == "type")
1122  {
1123  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
1124  }
1125  else
1126  {
1127  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
1128  }
1129  $this->tpl->parseCurrentBlock();
1130  }
1131 
1132  $this->tpl->setCurrentBlock("table_row");
1133  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1134  $this->tpl->parseCurrentBlock();
1135  // END TABLE CELL
1136  }
1137  // END TABLE DATA
1138 
1139  // BEGIN OPERATION_BTN
1140  foreach($this->data["buttons"] as $name => $value)
1141  {
1142  $this->tpl->setCurrentBlock("operation_btn");
1143  $this->tpl->setVariable("BTN_NAME",$name);
1144  $this->tpl->setVariable("BTN_VALUE",$value);
1145  $this->tpl->parseCurrentBlock();
1146  }
1147  }
1148 
1149 
1154  {
1155  session_unregister("pglayout_user_delete");
1156  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
1157  $this->ctrl->redirect($this, "viewPageLayouts");
1158  }
1159 
1160 
1165  {
1166  global $ilDB, $ilUser;
1167 
1168 
1169 
1170  foreach ($_SESSION["pglayout_user_delete"] as $id)
1171  {
1172  $pg_obj = new ilPageLayout($id);
1173  $pg_obj->delete();
1174 
1175  }
1176 
1177  $this->ctrl->redirect($this, "viewPageLayouts");
1178  }
1179 
1181  {
1182  global $ilCtrl, $lng, $ilTabs;
1183 
1184  $ilTabs->setTabActive('page_layouts');
1185 
1186  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1187  $this->form_gui = new ilPropertyFormGUI();
1188  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1189  $this->form_gui->setTitle($lng->txt("sty_create_pgl"));
1190 
1191  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
1192 
1193 
1194  $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
1195  $title_input->setSize(50);
1196  $title_input->setMaxLength(128);
1197  $title_input->setValue($this->layout_object->title);
1198  $title_input->setTitle($lng->txt("title"));
1199  $title_input->setRequired(true);
1200 
1201  $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
1202  $desc_input->setValue($this->layout_object->description);
1203  $desc_input->setRows(3);
1204  $desc_input->setCols(37);
1205 
1206  $ttype_input = new ilSelectInputGUI($lng->txt("sty_based_on"), "pgl_template");
1207 
1208  $arr_templates = ilPageLayout::getLayouts();
1209 
1210  $options = array();
1211  $options['-1'] = $lng->txt("none");
1212 
1213  foreach ($arr_templates as $templ) {
1214  $templ->readObject();
1215  $key = $templ->getId();
1216  $value = $templ->getTitle();
1217  $options[$key] = $value;
1218  }
1219 
1220  $ttype_input->setOptions($options);
1221  $ttype_input->setValue(-1);
1222  $ttype_input->setRequired(true);
1223 
1224  $desc_input->setTitle($lng->txt("description"));
1225  $desc_input->setRequired(false);
1226 
1227  $this->form_gui->addItem($title_input);
1228  $this->form_gui->addItem($desc_input);
1229  $this->form_gui->addItem($ttype_input);
1230 
1231 
1232  $this->form_gui->addCommandButton("createPg", $lng->txt("save"));
1233  $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
1234 
1235  $this->tpl->setContent($this->form_gui->getHTML());
1236  }
1237 
1238 
1239  function createPgObject()
1240  {
1241  global $ilCtrl;
1242 
1243  if($_POST["pgl_title"] == "")
1244  {
1245  $this->ilias->raiseError($this->lng->txt("no_title"),$this->ilias->error_obj->MESSAGE);
1246  $this->createPgGUIObject();
1247  exit;
1248  }
1249  //create Page-Layout-Object first
1250  $pg_object = new ilPageLayout();
1251  $pg_object->setTitle($_POST['pgl_title']);
1252  $pg_object->setDescription($_POST['pgl_desc']);
1253  $pg_object->update();
1254 
1255  include_once("./Services/COPage/classes/class.ilPageObject.php");
1256 
1257  //create Page
1258  if(!is_object($pg_content))
1259  {
1260  $this->pg_content =& new ilPageObject($this->type);
1261  }
1262 
1263  $this->pg_content->setId($pg_object->getId());
1264 
1265  if ($_POST['pgl_template'] != "-1") {
1266  $layout_obj = new ilPageLayout($_POST['pgl_template']);
1267  $this->pg_content->setXMLContent($layout_obj->getXMLContent());
1268  $this->pg_content->create(false);
1269  } else {
1270  $this->pg_content->create(false);
1271  }
1272 
1273  $this->pg_id = $pg_object->getId();
1274 
1275  $ilCtrl->setCmdClass("ilpagelayoutgui");
1276  $ilCtrl->setCmd("edit");
1277  $this->executeCommand();
1278  }
1279 
1280  function cancelCreateObject() {
1281  $this->viewPageLayoutsObject();
1282  }
1283 
1284  function editPgObject()
1285  {
1286  global $ilCtrl;
1287 
1288  $ilCtrl->setCmdClass("ilpagelayoutgui");
1289  $ilCtrl->setCmd("edit");
1290  $this->executeCommand();
1291  }
1292 
1293 
1294  function setTabs()
1295  {
1296  echo "settings_setTabs";
1297  }
1298 
1299  function getAdminTabs(&$tabs_gui)
1300  {
1301  $this->getTabs($tabs_gui);
1302  }
1303 
1309  function getTabs(&$tabs_gui)
1310  {
1311  global $rbacsystem, $lng, $ilTabs;
1312 
1313  if ($this->peditor_active) {
1314  $tabs_gui->setBackTarget($this->lng->txt("page_layouts"),
1315  $this->ctrl->getLinkTarget($this, "viewPageLayouts"));
1316  }
1317 
1318  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()) && !$this->peditor_active)
1319  {
1320  $tabs_gui->addTarget("basic_settings",
1321  $this->ctrl->getLinkTarget($this, "editBasicSettings"), array("editBasicSettings","", "view"), "", "");
1322 
1323  $tabs_gui->addTarget("system_styles",
1324  $this->ctrl->getLinkTarget($this, "editSystemStyles"), "editSystemStyles", "", "");
1325 
1326  $tabs_gui->addTarget("content_styles",
1327  $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
1328 
1329  $tabs_gui->addTarget("page_layouts",
1330  $this->ctrl->getLinkTarget($this, "viewPageLayouts"), "viewPageLayouts", "", "");
1331 
1332  }
1333 
1334 
1335  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()) && !$this->peditor_active)
1336  {
1337  $tabs_gui->addTarget("perm_settings",
1338  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1339  }
1340  }
1341 
1342 } // END class.ilObjStyleSettingsGUI
1343 ?>