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