ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
35 include_once "./classes/class.ilObjectGUI.php";
36 
38 {
43  function ilObjStyleSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
44  {
45  global $lng;
46 
47  $this->type = "stys";
48  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
49 
50  $lng->loadLanguageModule("style");
51  }
52 
53  function &executeCommand()
54  {
55  $next_class = $this->ctrl->getNextClass($this);
56  $cmd = $this->ctrl->getCmd();
57  $this->prepareOutput();
58 
59 //echo "-$next_class-$cmd-"; exit;
60 
61  switch($next_class)
62  {
63  case 'ilpermissiongui':
64  include_once("./classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret =& $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  default:
70  if ($cmd == "" || $cmd == "view")
71  {
72  $cmd = "editBasicSettings";
73  }
74  $cmd .= "Object";
75  $this->$cmd();
76 
77  break;
78  }
79  return true;
80  }
81 
86  function saveObject()
87  {
88  global $rbacadmin;
89 
90  // create and insert forum in objecttree
91  $newObj = parent::saveObject();
92 
93  // setup rolefolder & default local roles
94  //$roles = $newObj->initDefaultRoles();
95 
96  // ...finally assign role to creator of object
97  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
98 
99  // put here object specific stuff
100 
101  // always send a message
102  ilUtil::sendInfo($this->lng->txt("object_added"),true);
103 
104  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
105  }
106 
111  {
112  global $rbacsystem;
113 
114  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
115  {
116  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
117  }
118 
119  $this->tpl->addBlockfile("ADM_CONTENT", "style_basic_settings", "tpl.stys_basic_settings.html");
120  $this->tpl->setCurrentBlock("style_settings");
121 
122  $settings = $this->ilias->getAllSettings();
123 
124  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
125 
126  $this->tpl->setVariable("TXT_TREE_FRAME", $this->lng->txt("tree_frame"));
127  $this->tpl->setVariable("TXT_TREE_FRAME_INFO", $this->lng->txt("tree_frame_info"));
128  $this->tpl->setVariable("TXT_FRAME_LEFT", $this->lng->txt("tree_left"));
129  $this->tpl->setVariable("TXT_FRAME_RIGHT", $this->lng->txt("tree_right"));
130 
131  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("basic_settings"));
132  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS", $this->lng->txt("icons_in_typed_lists"));
133  $this->tpl->setVariable("TXT_ICONS_IN_HEADER", $this->lng->txt("icons_in_header"));
134  $this->tpl->setVariable("TXT_ICONS_IN_ITEM_ROWS", $this->lng->txt("icons_in_item_rows"));
135  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS_INFO", $this->lng->txt("icons_in_typed_lists_info"));
136 
137  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS", $this->lng->txt("enable_custom_icons"));
138  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS_INFO", $this->lng->txt("enable_custom_icons_info"));
139  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_BIG", $this->lng->txt("custom_icon_size_big"));
140  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_SMALL", $this->lng->txt("custom_icon_size_standard"));
141  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_TINY", $this->lng->txt("custom_icon_size_tiny"));
142  $this->tpl->setVariable("TXT_WIDTH_X_HEIGHT", $this->lng->txt("width_x_height"));
143  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
144 
145  // set current values
146  if ($settings["tree_frame"] == "right")
147  {
148  $this->tpl->setVariable("SEL_FRAME_RIGHT","selected=\"selected\"");
149  }
150  else
151  {
152  $this->tpl->setVariable("SEL_FRAME_LEFT","selected=\"selected\"");
153  }
154 
155  if ($settings["custom_icons"])
156  {
157  $this->tpl->setVariable("CHK_CUSTOM_ICONS","checked=\"checked\"");
158  }
159  if ($settings["icon_position_in_lists"] == "item_rows")
160  {
161  $this->tpl->setVariable("SEL_ICON_POS_ITEM_ROWS","selected=\"selected\"");
162  }
163  else
164  {
165  $this->tpl->setVariable("SEL_ICON_POS_HEADER","selected=\"selected\"");
166  }
167  $this->tpl->setVariable("CUST_ICON_BIG_WIDTH", $settings["custom_icon_big_width"]);
168  $this->tpl->setVariable("CUST_ICON_BIG_HEIGHT", $settings["custom_icon_big_height"]);
169  $this->tpl->setVariable("CUST_ICON_SMALL_WIDTH", $settings["custom_icon_small_width"]);
170  $this->tpl->setVariable("CUST_ICON_SMALL_HEIGHT", $settings["custom_icon_small_height"]);
171  $this->tpl->setVariable("CUST_ICON_TINY_WIDTH", $settings["custom_icon_tiny_width"]);
172  $this->tpl->setVariable("CUST_ICON_TINY_HEIGHT", $settings["custom_icon_tiny_height"]);
173 
174 // $this->tpl->parseCurrentBlock();
175  }
176 
181  {
182  $this->ilias->setSetting("tree_frame", $_POST["tree_frame"]);
183  $this->ilias->setSetting("icon_position_in_lists", $_POST["icon_position_in_lists"]);
184  $this->ilias->setSetting("custom_icons", $_POST["custom_icons"]);
185  $this->ilias->setSetting("custom_icon_big_width", (int) $_POST["custom_icon_big_width"]);
186  $this->ilias->setSetting("custom_icon_big_height", (int) $_POST["custom_icon_big_height"]);
187  $this->ilias->setSetting("custom_icon_small_width", (int) $_POST["custom_icon_small_width"]);
188  $this->ilias->setSetting("custom_icon_small_height", (int) $_POST["custom_icon_small_height"]);
189  $this->ilias->setSetting("custom_icon_tiny_width", (int) $_POST["custom_icon_tiny_width"]);
190  $this->ilias->setSetting("custom_icon_tiny_height", (int) $_POST["custom_icon_tiny_height"]);
191  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
192  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editBasicSettings"));
193  }
194 
199  {
200  global $rbacsystem, $ilias;
201 
202  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
203  {
204  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
205  }
206 
207  include_once "./Services/Table/classes/class.ilTableGUI.php";
208 
209  // load template content style settings
210  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.styf_content_styles.html");
211 
212  // load template for table
213  $this->tpl->addBlockfile("STYLE_TABLE", "style_table", "tpl.table.html");
214 
215  // load template for table content data
216  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
217 
218  $num = 0;
219 
220  $this->tpl->setVariable("FORMACTION",
221  $this->ctrl->getFormAction($this));
222 
223  // create table
224  $tbl = new ilTableGUI();
225 
226  // title & header columns
227  $tbl->setTitle($this->lng->txt("content_styles"),"icon_sty.gif",
228  $this->lng->txt("content_styles"));
229 
230  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
231 
232  // title
233  $header_names = array("", $this->lng->txt("title"),
234  $this->lng->txt("sty_nr_learning_modules"),
235  $this->lng->txt("purpose"), $this->lng->txt("sty_scope"),
236  $this->lng->txt("active"));
237  $tbl->setHeaderNames($header_names);
238 
239  $header_params = array("ref_id" => $this->ref_id);
240  $tbl->setHeaderVars(array("", "title", "nr_lms", "purpose", "scope", "active"), $header_params);
241  $tbl->setColumnWidth(array("1px", "", "", "", ""));
242 
243  // control
244  $tbl->setOrderColumn($_GET["sort_by"]);
245  $tbl->setOrderDirection($_GET["sort_order"]);
246  $tbl->setLimit($_GET["limit"]);
247  $tbl->setOffset($_GET["offset"]);
248  $tbl->disable("sort");
249 
250  // get style ids
251  $style_entries = array();
252  $styles = $this->object->getStyles();
253  foreach($styles as $style)
254  {
255  $style_entries[$style["title"].":".$style["id"]]
256  = $style;
257  }
258  ksort($style_entries);
259  $from_styles = $to_styles = array();
260  // this may not be cool, if styles are organised as (independent) Service
261  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
262 
263  // number of individual styles
264  if ($fixed_style <= 0)
265  {
266  $style_entries[-1] =
267  array("title" => $this->lng->txt("sty_individual_styles"),
268  "id" => 0, "nr" => ilObjContentObject::_getNrLMsIndividualStyles());
269  $from_styles[-1] = $this->lng->txt("sty_individual_styles");
270  }
271 
272  // number of default style (fallback default style)
273  if ($default_style <= 0 && $fixed_style <= 0)
274  {
275  $style_entries[0] =
276  array("title" => $this->lng->txt("sty_default_style"),
277  "id" => 0, "nr" => ilObjContentObject::_getNrLMsNoStyle());
278  $from_styles[0] = $this->lng->txt("sty_default_style");
279  $to_styles[0] = $this->lng->txt("sty_default_style");
280  }
281 
282  // todo
283  $tbl->setMaxCount(count($style_entries));
284 
285  $this->tpl->setVariable("COLUMN_COUNTS", 6);
286 
287  // footer
288  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
289 
290  $this->showActions(true);
291  $table_empty = true;
292 
293  include_once ("./Services/Style/classes/class.ilObjStyleSheet.php");
294 
295  $fixed_style = $ilias->getSetting("fixed_content_style_id");
296  $default_style = $ilias->getSetting("default_content_style_id");
297 
298  foreach ($style_entries as $style)
299  {
300  // color changing
301  $css_row = ($css_row == "tblrow2")
302  ? "tblrow1"
303  : "tblrow2";
304 
305  // command checkbox
306  if ($style["id"] > 0)
307  {
308  $this->tpl->setCurrentBlock("check_box");
309  $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
310  $this->tpl->parseCurrentBlock();
311  }
312 
313  // activation checkbox
314  if ($fixed_style <= 0 && $style["id"] > 0)
315  {
316  $this->tpl->setCurrentBlock("active_box");
317  if (ilObjStyleSheet::_lookupActive($style["id"]))
318  {
319  $this->tpl->setVariable("CHECKED_STY", 'checked="checked"');
320  }
321  $this->tpl->setVariable("ACTIVE_ID", $style["id"]);
322  $this->tpl->parseCurrentBlock();
323  }
324 
325  // link to style edit screen
326  if ($style["id"] > 0)
327  {
328  $this->ctrl->setParameterByClass("ilobjstylesheetgui", "obj_id", $style["id"]);
329  $this->tpl->setCurrentBlock("linka");
330  $this->tpl->setVariable("TXT_TITLE", $style["title"]);
331  $this->tpl->setVariable("LINK_STYLE",
332  $this->ctrl->getLinkTargetByClass("ilobjstylesheetgui"), "view");
333  $this->tpl->parseCurrentBlock();
334  }
335  else
336  {
337  $this->tpl->setCurrentBlock("texta");
338  $this->tpl->setVariable("TXT_TEXT", $style["title"]);
339  $this->tpl->parseCurrentBlock();
340  }
341 
342  $this->tpl->setCurrentBlock("style_row");
343 
344  // number of assigned lms
345  if ($style["id"] > 0)
346  {
347  $nr_lm = ilObjContentObject::_getNrOfAssignedLMs($style["id"]);
348 
349  // fill from/to array
350  if ($nr_lm > 0)
351  {
352  $from_styles[$style["id"]] = $style["title"];
353  }
354  if (ilObjStyleSheet::_lookupActive($style["id"]))
355  {
356  $to_styles[$style["id"]] = $style["title"];
357  }
358 
359  $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $nr_lm);
360  $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
361  }
362  else
363  {
364  $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $style["nr"]);
365  }
366 
367  $this->tpl->setVariable("ROWCOL", $css_row);
368 
369  // purpose and scope
370  if ($style["id"] > 0)
371  {
372  if ($style["id"] == $fixed_style)
373  {
374  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
375  }
376  if ($style["id"] == $default_style)
377  {
378  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
379  }
380  if ($style["category"] > 0)
381  {
382  $this->tpl->setVariable("TXT_SCOPE",
384  ilObject::_lookupObjId($style["category"])
385  ));
386  }
387  }
388  $this->tpl->parseCurrentBlock();
389 
390  $this->tpl->setCurrentBlock("tbl_content");
391  $this->tpl->parseCurrentBlock();
392 
393  } //if is_array
394 
395  if (count($style_entries) == 0)
396  {
397  $tbl->disable("header");
398  $tbl->disable("footer");
399 
400  $this->tpl->setCurrentBlock("text");
401  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
402  $this->tpl->parseCurrentBlock();
403 
404  $this->tpl->setCurrentBlock("tbl_content");
405  $this->tpl->parseCurrentBlock();
406  }
407 
408  // render table
409  $tbl->render();
410 
411 
412  // move form
413  $this->tpl->setCurrentBlock("adm_content");
414  $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
415  $this->tpl->setVariable("TXT_FROM", $this->lng->txt("from"));
416  $this->tpl->setVariable("TXT_TO", $this->lng->txt("to"));
417  $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
418  $this->tpl->setVariable("TXT_MOVE_STYLE", $this->lng->txt("sty_move_style"));
419  $this->tpl->setVariable("SELECT_FROM",
420  ilUtil::formSelect("", "from_style", $from_styles, false, true));
421  $this->tpl->setVariable("SELECT_TO",
422  ilUtil::formSelect("", "to_style", $to_styles, false, true));
423  $this->tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
424  $this->tpl->parseCurrentBlock();
425  }
426 
431  {
432  if ($_POST["from_style"] == -1)
433  {
435  return;
436  }
437 
438  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
439  ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
440  $this->ctrl->redirect($this, "editContentStyles");
441  }
442 
443 
448  {
449  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
450  ilObjContentObject::_moveLMStyles(-1, $_GET["to_style"]);
451  $this->ctrl->redirect($this, "editContentStyles");
452  }
453 
454 
459  {
460  // load template content style settings
461  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
462  $this->tpl->setVariable("CMD_OK", "moveIndividualStyles");
463  $this->tpl->setVariable("TXT_OK", $this->lng->txt("ok"));
464  $this->tpl->setVariable("CMD_CANCEL", "editContentStyles");
465  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
466  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("sty_confirm_del_ind_styles"));
467  $this->tpl->setVariable("TXT_CONTENT",
468  sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
469  ilObject::_lookupTitle($_POST["to_style"])));
470  $this->ctrl->setParameter($this, "to_style", $_POST["to_style"]);
471  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
472  $this->tpl->parseCurrentBlock();
473  }
474 
475 
480  {
481  global $rbacsystem, $ilias, $styleDefinition;;
482 
483  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
484  {
485  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
486  }
487 
488  $this->tpl->addBlockfile("ADM_CONTENT", "style_settings", "tpl.stys_settings.html");
489  $this->tpl->setCurrentBlock("style_settings");
490 
491  $settings = $this->ilias->getAllSettings();
492 
493  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
494  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("system_style_settings"));
495  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
496  $this->tpl->setVariable("TXT_DEFAULT_SKIN_STYLE", $this->lng->txt("default_skin_style"));
497  $this->tpl->setVariable("TXT_SKIN_STYLE_ACTIVATION", $this->lng->txt("style_activation"));
498  $this->tpl->setVariable("TXT_NUMBER_OF_USERS", $this->lng->txt("num_users"));
499  $this->tpl->setVariable("TXT_MOVE_USERS_TO_STYLE", $this->lng->txt("move_users_to_style"));
500 
501  // get all templates
502  $templates = $styleDefinition->getAllTemplates();
503 
504  $all_styles = array();
505 
506  foreach ($templates as $template)
507  {
508  // get styles definition for template
509  $styleDef =& new ilStyleDefinition($template["id"]);
510  $styleDef->startParsing();
511  $styles = $styleDef->getStyles();
512 
513  foreach ($styles as $style)
514  {
515  if ($this->ilias->ini->readVariable("layout","skin") == $template["id"] &&
516  $this->ilias->ini->readVariable("layout","style") == $style["id"])
517  {
518  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
519  }
520 
521  // default selection list
522  $this->tpl->setCurrentBlock("selectskin");
523  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
524  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
525  $this->tpl->parseCurrentBlock();
526 
527  // can be optimized
528  foreach ($templates as $template2)
529  {
530  // get styles definition for template
531  $styleDef2 =& new ilStyleDefinition($template2["id"]);
532  $styleDef2->startParsing();
533  $styles2 = $styleDef2->getStyles();
534 
535  foreach ($styles2 as $style2)
536  {
537  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
538  {
539  $this->tpl->setCurrentBlock("move_to_skin");
540  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
541  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
542  $this->tpl->parseCurrentBlock();
543  }
544  }
545  }
546 
547  // activation checkbox
548  $this->tpl->setCurrentBlock("activation_checkbox");
549  $this->tpl->setVariable("VAL_SKIN_STYLE", $template["id"].":".$style["id"]);
550  if (ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"]))
551  {
552  $this->tpl->setVariable("CHK_SKIN_STYLE", " checked=\"1\" ");
553  }
554  $this->tpl->parseCurrentBlock();
555 
556  // activation row
557  $this->tpl->setCurrentBlock("style_activation");
558  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", $template["id"].":".$style["id"]);
559  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
560  $styleDef->getTemplateName()." / ".$style["name"]);
561  $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
562  $this->tpl->setVariable("VAL_NUM_USERS", $num_users);
563  $this->tpl->parseCurrentBlock();
564 
565  $all_styles[] = $template["id"].":".$style["id"];
566  }
567  }
568 
569  // get all user assigned styles
570  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
571 
572  // output "other" row for all users, that are not assigned to
573  // any existing style
574  $users_missing_styles = 0;
575  foreach($all_user_styles as $style)
576  {
577  if (!in_array($style, $all_styles))
578  {
579  $style_arr = explode(":", $style);
580  $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
581  }
582  }
583 
584  if ($users_missing_styles > 0)
585  {
586  // can be optimized
587  foreach ($templates as $template2)
588  {
589  // get styles definition for template
590  $styleDef2 =& new ilStyleDefinition($template2["id"]);
591  $styleDef2->startParsing();
592  $styles2 = $styleDef2->getStyles();
593 
594  foreach ($styles2 as $style2)
595  {
596  if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
597  {
598  $this->tpl->setCurrentBlock("move_to_skin");
599  $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
600  $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
601  $this->tpl->parseCurrentBlock();
602  }
603  }
604  }
605 
606  $this->tpl->setCurrentBlock("style_activation");
607  $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
608  $this->lng->txt("other"));
609  $this->tpl->setVariable("VAL_NUM_USERS",
610  $users_missing_styles);
611  $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", "other");
612  $this->tpl->parseCurrentBlock();
613  }
614 
615  $this->tpl->parseCurrentBlock();
616  }
617 
618 
623  {
624  global $styleDefinition;
625 
626  // check if one style is activated
627  if (count($_POST["st_act"]) < 1)
628  {
629  $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
630  }
631 
632  // check if a style should be deactivated, that still has
633  // a user assigned to
634  $templates = $styleDefinition->getAllTemplates();
635  $all_styles = array();
636  foreach ($templates as $template)
637  {
638  // get styles definition for template
639  $styleDef =& new ilStyleDefinition($template["id"]);
640  $styleDef->startParsing();
641  $styles = $styleDef->getStyles();
642  foreach ($styles as $style)
643  {
644  if (!isset($_POST["st_act"][$template["id"].":".$style["id"]]))
645  {
646  if (ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]) > 1)
647  {
648  $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
649  }
650  else
651  {
652  ilObjStyleSettings::_deactivateStyle($template["id"], $style["id"]);
653  }
654  }
655  else
656  {
657  ilObjStyleSettings::_activateStyle($template["id"], $style["id"]);
658  }
659  $all_styles[] = $template["id"].":".$style["id"];
660  }
661  }
662 
663  // move users to other skin
664  foreach($_POST["move_users"] as $key => $value)
665  {
666  if ($value != "")
667  {
668  $to = explode(":", $value);
669 
670  if ($key != "other")
671  {
672  $from = explode(":", $key);
673  ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
674  }
675  else
676  {
677  // get all user assigned styles
678  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
679 
680  // move users that are not assigned to
681  // currently existing style
682  foreach($all_user_styles as $style)
683  {
684  if (!in_array($style, $all_styles))
685  {
686  $style_arr = explode(":", $style);
687  ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
688  }
689  }
690  }
691  }
692  }
693 
694  //set default skin and style
695  if ($_POST["default_skin_style"] != "")
696  {
697  $sknst = explode(":", $_POST["default_skin_style"]);
698 
699  if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
700  $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
701  {
702  $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
703  $this->ilias->ini->setVariable("layout","style",$sknst[1]);
704  }
705  }
706  $this->ilias->ini->write();
707 //echo "redirect-".$this->ctrl->getLinkTarget($this,"editSystemStyles")."-";
708  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
709  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editSystemStyles"));
710  }
711 
717  function deleteStyleObject($a_error = false)
718  {
719  if (!isset($_POST["id"]))
720  {
721  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
722  }
723 
724  // SAVE POST VALUES
725  $_SESSION["saved_post"] = $_POST["id"];
726 
727  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
728 
729  if(!$a_error)
730  {
731  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
732  }
733 
734  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
735 
736  // BEGIN TABLE HEADER
737  $this->tpl->setCurrentBlock("table_header");
738  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
739  $this->tpl->parseCurrentBlock();
740 
741  // END TABLE HEADER
742 
743  // BEGIN TABLE DATA
744  $counter = 0;
745 
746  foreach ($_POST["id"] as $id)
747  {
748  $this->tpl->setCurrentBlock("table_row");
749  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_sty.gif"));
750  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
751  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
752  $this->tpl->parseCurrentBlock();
753  }
754 
755  // END TABLE DATA
756 
757  // BEGIN OPERATION_BTN
758  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
759  "cancelDelete" => $this->lng->txt("cancel"));
760  foreach ($buttons as $name => $value)
761  {
762  $this->tpl->setCurrentBlock("operation_btn");
763  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
764  $this->tpl->setVariable("BTN_NAME",$name);
765  $this->tpl->setVariable("BTN_VALUE",$value);
766  $this->tpl->parseCurrentBlock();
767  }
768  }
769 
770 
775  {
776  global $ilias;
777 
778  foreach($_SESSION["saved_post"] as $id)
779  {
780  $this->object->removeStyle($id);
781  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
782  $style_obj->delete();
783  }
784  $this->object->update();
785 
786  ilUtil::redirect($this->getReturnLocation("delete",
787  $this->ctrl->getLinkTarget($this,"editContentStyles")));
788  }
789 
790 
797  {
798  global $ilias;
799 
800  if (!isset($_POST["id"]))
801  {
802  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
803  }
804  if(count($_POST["id"]) > 1)
805  {
806  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
807  }
808 
809  $ilias->deleteSetting("fixed_content_style_id");
810  $def_style = $ilias->getSetting("default_content_style_id");
811 
812  if ($def_style != $_POST["id"][0])
813  {
814  $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
815  }
816  else
817  {
818  $ilias->deleteSetting("default_content_style_id");
819  }
820 
821  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
822  }
823 
830  {
831  global $ilias;
832 
833  if (!isset($_POST["id"]))
834  {
835  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
836  }
837  if(count($_POST["id"]) > 1)
838  {
839  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
840  }
841 
842  $ilias->deleteSetting("default_content_style_id");
843  $fixed_style = $ilias->getSetting("fixed_content_style_id");
844  if ($fixed_style == $_POST["id"][0])
845  {
846  $ilias->deleteSetting("fixed_content_style_id");
847  }
848  else
849  {
850  $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
851  }
852  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
853  }
854 
855 
860  {
861  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
862  $styles = $this->object->getStyles();
863  foreach($styles as $style)
864  {
865  if ($_POST["std_".$style["id"]] == 1)
866  {
867  ilObjStyleSheet::_writeActive($style["id"], 1);
868  }
869  else
870  {
871  ilObjStyleSheet::_writeActive($style["id"], 0);
872  }
873  }
874  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
875  }
876 
883  function showActions($with_subobjects = false)
884  {
885 
886  // delete
887  $this->tpl->setCurrentBlock("tbl_action_btn");
888  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
889  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
890  $this->tpl->parseCurrentBlock();
891 
892  // set global default
893  $this->tpl->setCurrentBlock("tbl_action_btn");
894  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
895  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
896  $this->tpl->parseCurrentBlock();
897 
898  // set global default
899  $this->tpl->setCurrentBlock("tbl_action_btn");
900  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
901  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
902  $this->tpl->parseCurrentBlock();
903 
904  // set global default
905  $this->tpl->setCurrentBlock("tbl_action_btn");
906  $this->tpl->setVariable("BTN_NAME", "setScope");
907  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
908  $this->tpl->parseCurrentBlock();
909 
910  // save active styles
911  $this->tpl->setCurrentBlock("tbl_action_btn");
912  $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
913  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
914  $this->tpl->parseCurrentBlock();
915 
916  if ($with_subobjects === true)
917  {
918  $this->showPossibleSubObjects();
919  }
920 
921  $this->tpl->setCurrentBlock("tbl_action_row");
922  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
923  $this->tpl->parseCurrentBlock();
924  }
925 
932  {
933  session_unregister("saved_post");
934 
935  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
936  $this->ctrl->redirect($this, "editContentStyles");
937 
938  }
939 
940  function setScopeObject()
941  {
942  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
943  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.explorer.html");
944 
945  include_once ("./Services/Style/classes/class.ilStyleScopeExplorer.php");
946  $exp = new ilStyleScopeExplorer("repository.php?cmd=goto");
947  $exp->setExpandTarget("repository.php?cmd=showTree");
948  $exp->setTargetGet("ref_id");
949  $exp->setFilterMode(IL_FM_POSITIVE);
950  $exp->forceExpandAll(true, false);
951  $exp->addFilter("root");
952  $exp->addFilter("cat");
953 
954  if ($_GET["expand"] == "")
955  {
956  $expanded = $this->tree->readRootId();
957  }
958  else
959  {
960  $expanded = $_GET["expand"];
961  }
962 
963  $exp->setExpand($expanded);
964 
965  // build html-output
966  $exp->setOutput(0);
967  $output = $exp->getOutput();
968 
969  $this->tpl->setVariable("ADM_CONTENT", $output);
970  }
971 
975  function saveScopeObject()
976  {
977  global $ilias;
978 
979  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
980  if ($_GET["cat"] == 0)
981  {
982  $_GET["cat"] == "";
983  }
984  ilObjStyleSheet::_writeScope($_GET["style_id"], $_GET["cat"]);
985 
986  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
987  }
988 
989 
990  function setTabs()
991  {
992  echo "settings_setTabs";
993  }
994 
995  function getAdminTabs(&$tabs_gui)
996  {
997  $this->getTabs($tabs_gui);
998  }
999 
1005  function getTabs(&$tabs_gui)
1006  {
1007  global $rbacsystem;
1008 
1009  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
1010  {
1011  $tabs_gui->addTarget("basic_settings",
1012  $this->ctrl->getLinkTarget($this, "editBasicSettings"), array("editBasicSettings","", "view"), "", "");
1013 
1014  $tabs_gui->addTarget("system_styles",
1015  $this->ctrl->getLinkTarget($this, "editSystemStyles"), "editSystemStyles", "", "");
1016 
1017  $tabs_gui->addTarget("content_styles",
1018  $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
1019  }
1020 
1021  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1022  {
1023  $tabs_gui->addTarget("perm_settings",
1024  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1025  }
1026  }
1027 
1028 } // END class.ilObjStyleSettingsGUI
1029 ?>