ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSheetGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
16 require_once "./Services/Object/classes/class.ilObjectGUI.php";
17 require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
18 
20 {
25 
30  function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
31  {
32  global $ilCtrl, $lng, $tpl;
33 
34  $this->ctrl =& $ilCtrl;
35  $this->lng =& $lng;
36  $this->lng->loadLanguageModule("style");
37  $ilCtrl->saveParameter($this, array("tag", "style_type", "temp_type"));
38  if ($_GET["style_type"] != "")
39  {
40  $this->super_type = ilObjStyleSheet::_getStyleSuperTypeForType($_GET["style_type"]);
41  }
42 
43  $this->type = "sty";
44  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
45  }
46 
50  function &executeCommand()
51  {
52  $next_class = $this->ctrl->getNextClass($this);
53  $cmd = $this->ctrl->getCmd("edit");
54 
55  // #9440/#9489: prepareOutput will fail if not set properly
56  if(!$this->object)
57  {
58  $this->setCreationMode(true);
59  }
60 
61  $this->prepareOutput();
62  switch($next_class)
63  {
64  default:
65  $cmd.= "Object";
66  $ret =& $this->$cmd();
67  break;
68  }
69 
70  return $ret;
71  }
72 
73  function viewObject()
74  {
75  $this->editObject();
76  }
77 
81  function createObject()
82  {
83  global $rbacsystem, $lng, $tpl, $ilHelp;
84 
85  $forms = array();
86 
87 
88  $ilHelp->setScreenIdComponent("sty");
89  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "create");
90 
91  // --- create
92 
93  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
94  $form = new ilPropertyFormGUI();
95  $form->setFormAction($this->ctrl->getFormAction($this));
96  $form->setTitle($this->lng->txt("sty_create_new_stylesheet"));
97 
98  // title
99  $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
100  $ti->setMaxLength(128);
101  $ti->setSize(40);
102  $ti->setRequired(true);
103  $form->addItem($ti);
104 
105  // description
106  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
107  $ta->setCols(40);
108  $ta->setRows(2);
109  $form->addItem($ta);
110 
111  $form->addCommandButton("save", $this->lng->txt("save"));
112  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
113 
114  $forms[] = $form;
115 
116 
117  // --- import
118 
119  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
120  $form = new ilPropertyFormGUI();
121  $form->setFormAction($this->ctrl->getFormAction($this));
122  $form->setTitle($this->lng->txt("sty_import_stylesheet"));
123 
124  // title
125  $ti = new ilFileInputGUI($this->lng->txt("import_file"), "stylefile");
126  $ti->setRequired(true);
127  $form->addItem($ti);
128 
129  $form->addCommandButton("importStyle", $this->lng->txt("import"));
130  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
131 
132  $forms[] = $form;
133 
134 
135  // --- clone
136 
137  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
138  $form = new ilPropertyFormGUI();
139  $form->setFormAction($this->ctrl->getFormAction($this));
140  $form->setTitle($this->lng->txt("sty_copy_other_stylesheet"));
141 
142  // source
143  $ti = new ilSelectInputGUI($this->lng->txt("sty_source"), "source_style");
144  $ti->setRequired(true);
146  $form->addItem($ti);
147 
148  $form->addCommandButton("copyStyle", $this->lng->txt("copy"));
149  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
150 
151  $forms[] = $form;
152 
153 
154  $this->tpl->setContent($this->getCreationFormsHTML($forms));
155  }
156 
160  function includeCSS()
161  {
162  // set style sheet
163  $this->tpl->setCurrentBlock("ContentStyle");
164  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
165  $this->object->getContentStylePath($this->object->getId()));
166  $this->tpl->parseCurrentBlock();
167  }
168 
172  function editObject()
173  {
174  global $rbacsystem, $lng, $ilTabs, $ilCtrl, $ilToolbar, $tpl;
175 
176  $this->setSubTabs();
177 
178  $this->includeCSS();
179 
180  $ctpl = new ilTemplate("tpl.sty_classes.html", true, true, "Services/Style");
181 
182  // output characteristics
183  $chars = $this->object->getCharacteristics();
184 
185  $style_type = ($this->super_type != "")
186  ? $this->super_type
187  : "text_block";
188  $ilCtrl->setParameter($this, "style_type", $style_type);
189  $ilTabs->setSubTabActive("sty_".$style_type."_char");
190 
191  // workaround to include default rte styles
192  if ($this->super_type == "rte")
193  {
194  $tpl->addCss("Modules/Scorm2004/templates/default/player.css");
195  include_once("./Modules/Scorm2004/classes/ilSCORM13Player.php");
196  $tpl->addInlineCss(ilSCORM13Player::getInlineCss());
197  }
198 
199  // add new style?
200  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
201  $subtypes = $all_super_types[$style_type];
202  $expandable = false;
203  foreach ($subtypes as $t)
204  {
206  {
207  $expandable = true;
208  }
209  }
210  if ($expandable && $rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
211  {
212  $ilToolbar->addButton($lng->txt("sty_add_characteristic"),
213  $ilCtrl->getLinkTarget($this, "addCharacteristicForm"));
214  }
215 
216  if ($_SESSION["sty_copy"] != "")
217  {
218  $style_cp = explode(":::", $_SESSION["sty_copy"]);
219  if ($style_cp[1] == $_GET["style_type"])
220  {
221  if ($expandable)
222  {
223  $ilToolbar->addSeparator();
224  }
225  $ilToolbar->addButton($lng->txt("sty_paste_style_classes"),
226  $ilCtrl->getLinkTarget($this, "pasteCharacteristicsOverview"));
227  }
228  }
229 
230  include_once("./Services/Style/classes/class.ilStyleTableGUI.php");
231  $table_gui = new ilStyleTableGUI($this, "edit", $chars, $style_type,
232  $this->object);
233 
234  $ctpl->setCurrentBlock("style_table");
235  $ctpl->setVariable("STYLE_TABLE", $table_gui->getHTML());
236  $ctpl->parseCurrentBlock();
237 
238  $this->tpl->setContent($ctpl->get());
239  }
240 
244  function propertiesObject()
245  {
246  global $rbacsystem, $lng, $ilToolbar;
247 
248  // set style sheet
249  $this->tpl->setCurrentBlock("ContentStyle");
250  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
251  $this->object->getContentStylePath($this->object->getId()));
252  $this->tpl->parseCurrentBlock();
253 
254  // export button
255  $ilToolbar->addButton($this->lng->txt("export"),
256  $this->ctrl->getLinkTarget($this, "exportStyle"));
257 
258  $this->initPropertiesForm();
259  $this->getPropertiesValues();
260  $this->tpl->setContent($this->form->getHTML());
261  }
262 
267  public function getPropertiesValues()
268  {
269  $values = array();
270 
271  $values["style_title"] = $this->object->getTitle();
272  $values["style_description"] = $this->object->getDescription();
273  $values["disable_auto_margins"] = (int) $this->object->lookupStyleSetting("disable_auto_margins");
274 
275  $this->form->setValuesByArray($values);
276  }
277 
283  public function initPropertiesForm($a_mode = "edit")
284  {
285  global $lng, $rbacsystem;
286 
287  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
288  $this->form = new ilPropertyFormGUI();
289 
290  // title
291  $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
292  $ti->setMaxLength(128);
293  $ti->setSize(40);
294  $ti->setRequired(true);
295  $this->form->addItem($ti);
296 
297  // description
298  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
299  //$ta->setCols();
300  //$ta->setRows();
301  $this->form->addItem($ta);
302 
303  // disable automatic margins for left/right alignment
304  $cb = new ilCheckboxInputGUI($this->lng->txt("sty_disable_auto_margins"), "disable_auto_margins");
305  $cb->setInfo($this->lng->txt("sty_disable_auto_margins_info"));
306  $this->form->addItem($cb);
307 
308  // save and cancel commands
309 
310  if ($a_mode == "create")
311  {
312  $this->form->addCommandButton("save", $lng->txt("save"));
313  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
314  }
315  else
316  {
317  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
318  {
319  $this->form->addCommandButton("update", $lng->txt("save"));
320  }
321  }
322 
323  $this->form->setTitle($lng->txt("edit_stylesheet"));
324  $this->form->setFormAction($this->ctrl->getFormAction($this));
325 
326  }
327 
331  function updateObject()
332  {
333  global $lng, $ilCtrl, $tpl;
334 
335  $this->initPropertiesForm("edit");
336  if ($this->form->checkInput())
337  {
338  $this->object->setTitle($this->form->getInput("style_title"));
339  $this->object->setDescription($this->form->getInput("style_description"));
340  $this->object->writeStyleSetting("disable_auto_margins",
341  $this->form->getInput("disable_auto_margins"));
342  $this->object->update();
343  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
344  $ilCtrl->redirect($this, "properties");
345  }
346  else
347  {
348  $this->form->setValuesByPost();
349  $tpl->setContent($this->form->getHtml());
350  }
351  }
352 
357  {
358  global $ilCtrl;
359 
360  $cur = explode(".",$_GET["tag"]);
361  $cur_tag = $cur[0];
362  $cur_class = $cur[1];
363 
364  $this->initTagStyleForm("edit", $cur_tag);
365 
366  if ($this->form_gui->checkInput())
367  {
368  $this->saveTagStyle();
369  $ilCtrl->redirect($this, "editTagStyle");
370  }
371  else
372  {
373  $this->form_gui->setValuesByPost();
374  $this->outputTagStyleEditScreen();
375  }
376  }
377 
382  {
383  global $ilCtrl;
384 
385  $cur = explode(".",$_GET["tag"]);
386  $cur_tag = $cur[0];
387  $cur_class = $cur[1];
388 
389  $this->initTagStyleForm("edit", $cur_tag);
390  if ($this->form_gui->checkInput())
391  {
392  $this->saveTagStyle();
393  $ilCtrl->redirect($this, "edit");
394  }
395  else
396  {
397  $this->form_gui->setValuesByPost();
398  $this->outputTagStyleEditScreen();
399  }
400  }
401 
405  function saveTagStyle()
406  {
407  $cur = explode(".", $_GET["tag"]);
408  $cur_tag = $cur[0];
409  $cur_class = $cur[1];
410  $avail_pars = ilObjStyleSheet::_getStyleParameters($cur_tag);
411  foreach ($avail_pars as $par => $v)
412  {
413  $var = str_replace("-", "_", $par);
414  $basepar_arr = explode(".", $par);
415  $basepar = $basepar_arr[0];
416  if ($basepar_arr[1] != "" && $basepar_arr[1] != $cur_tag)
417  {
418  continue;
419  }
420 
421  switch ($v["input"])
422  {
423  case "fontsize":
424  case "numeric_no_perc":
425  case "numeric":
426  case "background_image":
427  $in = $this->form_gui->getItemByPostVar($basepar);
428 //echo "<br>-".$cur_tag."-".$cur_class."-".$basepar."-".$_GET["style_type"]."-";
429  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
430  break;
431 
432  case "color":
433  $color = trim($_POST[$basepar]);
434  if ($color != "" && trim(substr($color,0,1) != "!"))
435  {
436  $color = "#".$color;
437  }
438  $this->writeStylePar($cur_tag, $cur_class, $basepar, $color, $_GET["style_type"]);
439  break;
440 
441  case "trbl_numeric":
442  case "border_width":
443  case "border_style":
444  $in = $this->form_gui->getItemByPostVar($basepar);
445  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0], $in->getAllValue(), $_GET["style_type"]);
446  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1], $in->getTopValue(), $_GET["style_type"]);
447  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2], $in->getRightValue(), $_GET["style_type"]);
448  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3], $in->getBottomValue(), $_GET["style_type"]);
449  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4], $in->getLeftValue(), $_GET["style_type"]);
450  break;
451 
452  case "trbl_color":
453  $in = $this->form_gui->getItemByPostVar($basepar);
454  $tblr_p = array (0 => "getAllValue", 1 => "getTopValue", 2 => "getRightValue",
455  3 => "getBottomValue", 4 => "getLeftValue");
456  foreach ($tblr_p as $k => $func)
457  {
458  $val = trim($in->$func());
459  $val = (($in->getAcceptNamedColors() && substr($val, 0, 1) == "!")
460  || $val == "")
461  ? $val
462  : "#".$val;
463  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][$k], $val, $_GET["style_type"]);
464  }
465  /*$this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0],
466  trim($in->getAllValue() != "") ? "#".$in->getAllValue() : "", $_GET["style_type"]);
467  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1],
468  trim($in->getTopValue() != "") ? "#".$in->getTopValue() : "", $_GET["style_type"]);
469  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2],
470  trim($in->getRightValue() != "") ? "#".$in->getRightValue() : "", $_GET["style_type"]);
471  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3],
472  trim($in->getBottomValue() != "") ? "#".$in->getBottomValue() : "", $_GET["style_type"]);
473  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4],
474  trim($in->getLeftValue() != "") ? "#".$in->getLeftValue() : "", $_GET["style_type"]);
475  */
476  break;
477 
478  case "background_position":
479  $in = $this->form_gui->getItemByPostVar($basepar);
480  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
481  break;
482 
483  default:
484  $this->writeStylePar($cur_tag, $cur_class, $basepar, $_POST[$basepar], $_GET["style_type"]);
485  break;
486  }
487  }
488 
489  $this->object->update();
490  }
491 
492  function writeStylePar($cur_tag, $cur_class, $par, $value, $a_type)
493  {
494  if ($a_type == "")
495  {
496  return;
497  }
498 
499  if ($value != "")
500  {
501  $this->object->replaceStylePar($cur_tag, $cur_class, $par, $value, $a_type);
502  }
503  else
504  {
505  $this->object->deleteStylePar($cur_tag, $cur_class, $par, $a_type);
506  }
507  }
508 
514  {
515  global $tpl;
516 
517  // workaround to include default rte styles
518  //if (in_array($_GET["style_type"], array("rte_menu")))
519  if ($this->super_type == "rte")
520  {
521  $tpl->addCss("Modules/Scorm2004/templates/default/player.css");
522  include_once("./Modules/Scorm2004/classes/ilSCORM13Player.php");
523  $tpl->addInlineCss(ilSCORM13Player::getInlineCss());
524  }
525 
526  $cur = explode(".",$_GET["tag"]);
527  $cur_tag = $cur[0];
528  $cur_class = $cur[1];
529 
530  $this->initTagStyleForm("edit", $cur_tag);
531  $this->getValues();
532  $this->outputTagStyleEditScreen();
533  }
534 
539  {
540  global $tpl, $ilCtrl, $lng;
541 
542  // set style sheet
543  $tpl->setCurrentBlock("ContentStyle");
544  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
545  $this->object->getContentStylePath($this->object->getId()));
546 
547  $ts_tpl = new ilTemplate("tpl.style_tag_edit.html", true, true, "Services/Style");
548 
549  $cur = explode(".",$_GET["tag"]);
550  $cur_tag = $cur[0];
551  $cur_class = $cur[1];
552 
553  $ts_tpl->setVariable("EXAMPLE",
554  ilObjStyleSheetGUI::getStyleExampleHTML($_GET["style_type"], $cur_class));
555 
556  $ts_tpl->setVariable("FORM",
557  $this->form_gui->getHtml());
558 
559  $tpl->setTitle($cur_class." (".$lng->txt("sty_type_".$_GET["style_type"]).")");
560 
561  $tpl->setContent($ts_tpl->get());
562  }
563 
564 
570  public function initTagStyleForm($a_mode, $a_cur_tag)
571  {
572  global $lng;
573 
574  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
575  $this->form_gui = new ilPropertyFormGUI();
576 
577  $avail_pars = $this->object->getAvailableParameters();
578  $groups = $this->object->getStyleParameterGroups();
579 
580  // output select lists
581  foreach ($groups as $k => $group)
582  {
583  // filter groups of properties that should only be
584  // displayed with matching tag
585  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
586  if (is_array($filtered_groups[$k]) && !in_array($a_cur_tag, $filtered_groups[$k]))
587  {
588  continue;
589  }
590 
591  $sh = new ilFormSectionHeaderGUI();
592  $sh->setTitle($lng->txt("sty_".$k));
593  $this->form_gui->addItem($sh);
594 
595  foreach ($group as $par)
596  {
597  $basepar = explode(".", $par);
598  $basepar = $basepar[0];
599 
600  $var = str_replace("-", "_", $basepar);
601  $up_par = strtoupper($var);
602 
604  {
605  case "select":
606  $sel_input = new ilSelectInputGUI($lng->txt("sty_".$var), $basepar);
607  $options = array("" => "");
608  foreach ($avail_pars[$par] as $p)
609  {
610  $options[$p] = $p;
611  }
612  $sel_input->setOptions($options);
613  $this->form_gui->addItem($sel_input);
614  break;
615 
616  case "text":
617  $text_input = new ilTextInputGUI($lng->txt("sty_".$var), $basepar);
618  $text_input->setMaxLength(200);
619  $text_input->setSize(20);
620  $this->form_gui->addItem($text_input);
621  break;
622 
623  case "fontsize":
624  include_once("./Services/Style/classes/class.ilFontSizeInputGUI.php");
625  $fs_input = new ilFontSizeInputGUI($lng->txt("sty_".$var), $basepar);
626  $this->form_gui->addItem($fs_input);
627  break;
628 
629  case "numeric_no_perc":
630  case "numeric":
631  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
632  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
633  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "numeric_no_perc")
634  {
635  $num_input->setAllowPercentage(false);
636  }
637  $this->form_gui->addItem($num_input);
638  break;
639 
640  case "percentage":
641  $per_input = new ilNumberInputGUI($lng->txt("sty_".$var), $basepar);
642  $per_input->setMinValue(0);
643  $per_input->setMaxValue(100);
644  $per_input->setMaxLength(3);
645  $per_input->setSize(3);
646  $this->form_gui->addItem($per_input);
647  break;
648 
649  case "color":
650  //include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
651  $col_input = new ilColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
652  $col_input->setDefaultColor("");
653  $col_input->setAcceptNamedColors(true);
654  $this->form_gui->addItem($col_input);
655  break;
656 
657  case "trbl_numeric":
658  include_once("./Services/Style/classes/class.ilTRBLNumericStyleValueInputGUI.php");
659  $num_input = new ilTRBLNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
660  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "trbl_numeric_no_perc")
661  {
662  $num_input->setAllowPercentage(false);
663  }
664  $this->form_gui->addItem($num_input);
665  break;
666 
667  case "border_width":
668  include_once("./Services/Style/classes/class.ilTRBLBorderWidthInputGUI.php");
669  $bw_input = new ilTRBLBorderWidthInputGUI($lng->txt("sty_".$var), $basepar);
670  $this->form_gui->addItem($bw_input);
671  break;
672 
673  case "border_style":
674  include_once("./Services/Style/classes/class.ilTRBLBorderStyleInputGUI.php");
675  $bw_input = new ilTRBLBorderStyleInputGUI($lng->txt("sty_".$var), $basepar);
676  $this->form_gui->addItem($bw_input);
677  break;
678 
679  case "trbl_color":
680  include_once("./Services/Style/classes/class.ilTRBLColorPickerInputGUI.php");
681  $col_input = new ilTRBLColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
682  $col_input->setAcceptNamedColors(true);
683  $this->form_gui->addItem($col_input);
684  break;
685 
686  case "background_image":
687  include_once("./Services/Style/classes/class.ilBackgroundImageInputGUI.php");
688  $im_input = new ilBackgroundImageInputGUI($lng->txt("sty_".$var), $basepar);
689  $imgs = array();
690  foreach ($this->object->getImages() as $entry)
691  {
692  $imgs[] = $entry["entry"];
693  }
694  $im_input->setImages($imgs);
695  $this->form_gui->addItem($im_input);
696  break;
697 
698  case "background_position":
699  include_once("./Services/Style/classes/class.ilBackgroundPositionInputGUI.php");
700  $im_input = new ilBackgroundPositionInputGUI($lng->txt("sty_".$var), $basepar);
701  $this->form_gui->addItem($im_input);
702  break;
703  }
704  }
705  }
706 
707  // save and cancel commands
708  $this->form_gui->addCommandButton("updateTagStyle", $lng->txt("save_return"));
709  $this->form_gui->addCommandButton("refreshTagStyle", $lng->txt("save_refresh"));
710 
711 // $this->form_gui->setTitle($lng->txt("edit"));
712  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
713  }
714 
719  public function getValues()
720  {
721  $style = $this->object->getStyle();
722  $cur = explode(".",$_GET["tag"]);
723  $cur_tag = $cur[0];
724  $cur_class = $cur[1];
725  $cur_parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style, $_GET["style_type"]);
726 
727  $parameters = ilObjStyleSheet::_getStyleParameters();
728  foreach($parameters as $p => $v)
729  {
730  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
731  if (is_array($filtered_groups[$v["group"]]) && !in_array($cur_tag, $filtered_groups[$v["group"]]))
732  {
733  continue;
734  }
735  $p = explode(".", $p);
736  $p = $p[0];
737  $input = $this->form_gui->getItemByPostVar($p);
738  switch ($v["input"])
739  {
740  case "":
741  break;
742 
743  case "trbl_numeric":
744  case "border_width":
745  case "border_style":
746  case "trbl_color":
747  $input->setAllValue($cur_parameters[$v["subpar"][0]]);
748  $input->setTopValue($cur_parameters[$v["subpar"][1]]);
749  $input->setRightValue($cur_parameters[$v["subpar"][2]]);
750  $input->setBottomValue($cur_parameters[$v["subpar"][3]]);
751  $input->setLeftValue($cur_parameters[$v["subpar"][4]]);
752  break;
753 
754  default:
755  $input->setValue($cur_parameters[$p]);
756  break;
757  }
758  }
759  }
760 
764  function exportStyleObject()
765  {
766  $file = $this->object->export();
767 
768  ilUtil::deliverFile($file, "sty_".$this->object->getId().".zip");
769  }
770 
771  function extractParametersOfTag($a_tag, $a_class, $a_style, $a_type)
772  {
773  $parameters = array();
774  foreach($a_style as $tag)
775  {
776  foreach($tag as $par)
777  {
778  if ($par["tag"] == $a_tag && $par["class"] == $a_class
779  && $par["type"] == $a_type)
780  {
781  $parameters[$par["parameter"]] = $par["value"];
782  }
783  }
784  }
785  return $parameters;
786  }
787 
792  {
793  $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
794  $this->editObject();
795  }
796 
800  function refreshObject()
801  {
802  $this->object->setTitle($_POST["style_title"]);
803  $this->object->setDescription($_POST["style_description"]);
804 
805  foreach($_POST["styval"] as $id => $value)
806  {
807  $this->object->updateStyleParameter($id, $value);
808  }
809  $this->object->update();
810  $this->editObject();
811  }
812 
818  function deleteObject($a_error = false)
819  {
820  //$this->setTabs();
821 
822  // display confirmation message
823  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
824  $cgui = new ilConfirmationGUI();
825  $cgui->setFormAction($this->ctrl->getFormAction($this));
826  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
827  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
828  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
829 
830  $caption = ilUtil::getImageTagByType("styf", $this->tpl->tplPath).
831  " ".ilObject::_lookupTitle($this->object->getId());
832 
833  $cgui->addItem("id[]", "", $caption);
834 
835  $this->tpl->setContent($cgui->getHTML());
836  }
837 
838 
843  {
844  $this->ctrl->returnToParent($this);
845  }
846 
851  {
852  global $ilias;
853 
854  $this->object->delete();
855 
856  $this->ctrl->returnToParent($this);
857  }
858 
863  {
864  if (is_array($_POST["sty_select"]))
865  {
866  foreach($_POST["sty_select"] as $id => $dummy)
867  {
868  $this->object->deleteParameter($id);
869  }
870  }
871  $this->object->read();
872  $this->object->writeCSSFile();
873  $this->editObject();
874  }
875 
879  function saveObject()
880  {
881  if(!trim($_POST["style_title"]))
882  {
883  $this->ctrl->redirect($this, "create");
884  }
885 
886 //echo "HH"; exit;
887  $class_name = "ilObjStyleSheet";
888  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
889  $newObj = new ilObjStyleSheet();
890  $newObj->setTitle("-");
891  $newObj->create();
892  $newObj->setTitle(ilUtil::stripSlashes($_POST["style_title"]));
893  $newObj->setDescription(ilUtil::stripSlashes($_POST["style_description"]));
894  $newObj->update();
895 
896  // assign style to style sheet folder,
897  // if parent is style sheet folder
898  if ($_GET["ref_id"] > 0)
899  {
900 
901  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
902  if ($fold->getType() == "stys")
903  {
904  $fold->addStyle($newObj->getId());
905  $fold->update();
906  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
907  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
908  }
909  }
910 
911  return $newObj->getId();
912  }
913 
917  function copyStyleObject()
918  {
919  global $ilias;
920 
921  if ($_POST["source_style"] > 0)
922  $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
923  $new_id = $style_obj->ilClone();
924 
925  // assign style to style sheet folder,
926  // if parent is style sheet folder
927  if ($_GET["ref_id"] > 0)
928  {
929 
930  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
931  if ($fold->getType() == "stys")
932  {
933  $fold->addStyle($new_id);
934  $fold->update();
935  ilObjStyleSheet::_writeStandard($new_id, "1");
936  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
937  }
938  }
939 
940  return $new_id;
941  }
942 
946  function importStyleObject()
947  {
948  // check file
949  $source = $_FILES["stylefile"]["tmp_name"];
950  if (($source == 'none') || (!$source))
951  {
952  $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
953  }
954 
955  // check correct file type
956  $info = pathinfo($_FILES["stylefile"]["name"]);
957  if (strtolower($info["extension"]) != "zip" && strtolower($info["extension"]) != "xml")
958  {
959  $this->ilias->raiseError("File must be a zip or xml file!",$this->ilias->error_obj->MESSAGE);
960  }
961 
962  $class_name = "ilObjStyleSheet";
963  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
964  $newObj = new ilObjStyleSheet();
965  //$newObj->setTitle();
966  //$newObj->setDescription($_POST["style_description"]);
967  $newObj->import($_FILES["stylefile"]);
968  //$newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
969 
970  // assign style to style sheet folder,
971  // if parent is style sheet folder
972  if ($_GET["ref_id"] > 0)
973  {
974 
975  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
976  if ($fold->getType() == "stys")
977  {
978  $fold->addStyle($newObj->getId());
979  $fold->update();
980  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
981  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
982  }
983  }
984 
985  return $newObj->getId();
986  }
987 
991  function cancelObject()
992  {
993  global $lng;
994 
995  ilUtil::sendInfo($lng->txt("msg_cancel"), true);
996  $this->ctrl->returnToParent($this);
997  }
998 
1002  function getAdminTabs(&$tabs_gui)
1003  {
1004  $this->getTabs($tabs_gui);
1005  }
1006 
1010  function setTabs()
1011  {
1012  global $lng;
1013 
1014  $this->getTabs($this->tabs_gui);
1015 
1016  if (strtolower(get_class($this->object)) == "ilobjstylesheet")
1017  {
1018  $this->tpl->setVariable("HEADER", $this->object->getTitle());
1019  }
1020  else
1021  {
1022  $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
1023  }
1024  }
1025 
1031  function getTabs(&$tabs_gui)
1032  {
1033  global $lng, $ilCtrl, $ilTabs, $ilHelp;
1034 
1035  $ilHelp->setScreenIdComponent("sty");
1036 
1037  if ($ilCtrl->getCmd() == "editTagStyle")
1038  {
1039  // back to upper context
1040  $tabs_gui->setBackTarget($lng->txt("back"),
1041  $ilCtrl->getLinkTarget($this, "edit"));
1042 
1043  $t = explode(".", $_GET["tag"]);
1044  $t2 = explode(":", $t[1]);
1045  $pc = $this->object->_getPseudoClasses($t[0]);
1046  if (is_array($pc) && count($pc) > 0)
1047  {
1048  // style classes
1049  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0]);
1050  $tabs_gui->addTarget("sty_tag_normal",
1051  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1052  get_class($this));
1053  if ($t2[1] == "")
1054  {
1055  $ilTabs->setTabActive("sty_tag_normal");
1056  }
1057 
1058  foreach ($pc as $p)
1059  {
1060  // style classes
1061  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0].":".$p);
1062  $tabs_gui->addTarget("sty_tag_".$p,
1063  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1064  get_class($this));
1065  if ($t2[1] == $p)
1066  {
1067  $ilTabs->setTabActive("sty_tag_".$p);
1068  }
1069  }
1070  $ilCtrl->setParameter($this, "tag", $_GET["tag"]);
1071  }
1072  }
1073  else
1074  {
1075  // back to upper context
1076  $tabs_gui->setBackTarget($lng->txt("back"),
1077  $this->ctrl->getLinkTarget($this, "returnToUpperContext"));
1078 
1079  // style classes
1080  $tabs_gui->addTarget("sty_style_chars",
1081  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1082  get_class($this));
1083 
1084  // colors
1085  $tabs_gui->addTarget("sty_colors",
1086  $this->ctrl->getLinkTarget($this, "listColors"), "listColors",
1087  get_class($this));
1088 
1089  // images
1090  $tabs_gui->addTarget("sty_images",
1091  $this->ctrl->getLinkTarget($this, "listImages"), "listImages",
1092  get_class($this));
1093 
1094  // table templates
1095  $tabs_gui->addTarget("sty_templates",
1096  $this->ctrl->getLinkTarget($this, "listTemplates"), "listTemplates",
1097  get_class($this));
1098 
1099  // settings
1100  $tabs_gui->addTarget("settings",
1101  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1102  get_class($this));
1103 
1104  // accordiontest
1105 /*
1106  $tabs_gui->addTarget("accordiontest",
1107  $this->ctrl->getLinkTarget($this, "accordiontest"), "accordiontest",
1108  get_class($this));*/
1109  }
1110 
1111  }
1112 
1118  function setSubTabs()
1119  {
1120  global $lng, $ilTabs, $ilCtrl;
1121 
1123 
1124  foreach ($types as $super_type => $types)
1125  {
1126  // text block characteristics
1127  $ilCtrl->setParameter($this, "style_type", $super_type);
1128  $ilTabs->addSubTabTarget("sty_".$super_type."_char",
1129  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1130  get_class($this));
1131  }
1132 
1133  $ilCtrl->setParameter($this, "style_type", $_GET["style_type"]);
1134  }
1135 
1142  {
1143  global $lng, $ilTabs, $ilCtrl;
1144 
1146 
1147  foreach ($types as $t => $c)
1148  {
1149  $ilCtrl->setParameter($this, "temp_type", $t);
1150  $ilTabs->addSubTabTarget("sty_".$t."_templates",
1151  $this->ctrl->getLinkTarget($this, "listTemplates"), array("listTemplates", ""),
1152  get_class($this));
1153  }
1154 
1155  $ilCtrl->setParameter($this, "temp_type", $_GET["temp_type"]);
1156  }
1157 
1163  {
1164  global $ilLocator;
1165 
1166  if ($_GET["admin_mode"] == "settings") // system settings
1167  {
1169 
1170  $ilLocator->addItem(ilObject::_lookupTitle(
1171  ilObject::_lookupObjId($_GET["ref_id"])),
1172  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
1173 
1174  if ($_GET["obj_id"] > 0)
1175  {
1176  $ilLocator->addItem($this->object->getTitle(),
1177  $this->ctrl->getLinkTarget($this, "edit"));
1178  }
1179  }
1180  else // repository administration
1181  {
1182  //?
1183  }
1184 
1185  }
1186 
1187  function showUpperIcon()
1188  {
1189  global $tree, $tpl, $objDefinition;
1190 
1191  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1192  {
1193  $tpl->setUpperIcon(
1194  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
1195  "editContentStyles"));
1196  }
1197  else
1198  {
1199  // ?
1200  }
1201  }
1202 
1206  function listImagesObject()
1207  {
1208  global $tpl, $ilToolbar, $ilCtrl, $lng, $rbacsystem;
1209 
1210  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1211  {
1212  $ilToolbar->addButton($lng->txt("sty_add_image"),
1213  $ilCtrl->getLinkTarget($this, "addImage"));
1214  }
1215 
1216  include_once("./Services/Style/classes/class.ilStyleImageTableGUI.php");
1217  $table_gui = new ilStyleImageTableGUI($this, "listImages",
1218  $this->object);
1219  $tpl->setContent($table_gui->getHTML());
1220 
1221  }
1222 
1226  function addImageObject()
1227  {
1228  global $tpl;
1229 
1230  $this->initImageForm();
1231  $tpl->setContent($this->form_gui->getHTML());
1232  }
1233 
1238  {
1239  global $ilCtrl;
1240 
1241  $ilCtrl->redirect($this, "listImages");
1242  }
1243 
1248  {
1249  global $tpl, $ilCtrl;
1250 
1251  $this->initImageForm();
1252 
1253  if ($this->form_gui->checkInput())
1254  {
1255  $this->object->uploadImage($_FILES["image_file"]);
1256  $ilCtrl->redirect($this, "listImages");
1257  }
1258  else
1259  {
1260  //$this->form_gui->setImageFormValuesByPost();
1261  $tpl->setContent($this->form_gui->getHTML());
1262  }
1263 
1264  }
1265 
1269  function initImageForm()
1270  {
1271  global $lng, $ilCtrl;
1272 
1273  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1274  $this->form_gui = new ilPropertyFormGUI();
1275 
1276  $this->form_gui->setTitle($lng->txt("sty_add_image"));
1277 
1278  $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
1279  $file_input->setRequired(true);
1280  $this->form_gui->addItem($file_input);
1281 
1282  $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
1283  $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
1284  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1285  }
1286 
1291  {
1292  global $ilCtrl;
1293 
1294  $images = $this->object->getImages();
1295 
1296  foreach ($images as $image)
1297  {
1298  if (is_array($_POST["file"]) && in_array($image["entry"], $_POST["file"]))
1299  {
1300  $this->object->deleteImage($image["entry"]);
1301  }
1302  }
1303  $ilCtrl->redirect($this, "listImages");
1304  }
1305 
1310  {
1311  global $ilCtrl, $tpl, $lng;
1312 
1313 //var_dump($_POST);
1314 
1315  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1316  {
1317  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1318  $ilCtrl->redirect($this, "edit");
1319  }
1320  else
1321  {
1322  // check whether there are any core style classes included
1323  $core_styles = ilObjStyleSheet::_getCoreStyles();
1324  foreach ($_POST["char"] as $char)
1325  {
1326  if (!empty($core_styles[$char]))
1327  {
1328  $this->deleteCoreCharMessage();
1329  return;
1330  }
1331  }
1332 
1333  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1334  $cgui = new ilConfirmationGUI();
1335  $cgui->setFormAction($ilCtrl->getFormAction($this));
1336  $cgui->setHeaderText($lng->txt("sty_confirm_char_deletion"));
1337  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1338  $cgui->setConfirm($lng->txt("delete"), "deleteCharacteristic");
1339 
1340  foreach ($_POST["char"] as $char)
1341  {
1342  $char_comp = explode(".", $char);
1343  $cgui->addItem("char[]", $char, $char_comp[2]);
1344  }
1345 
1346  $tpl->setContent($cgui->getHTML());
1347  }
1348  }
1349 
1357  {
1358  global $ilCtrl, $tpl, $lng;
1359 
1360  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1361  $cgui = new ilConfirmationGUI();
1362  $cgui->setFormAction($ilCtrl->getFormAction($this));
1363 
1364 
1365  $core_styles = ilObjStyleSheet::_getCoreStyles();
1366  $cnt = 0;
1367  foreach ($_POST["char"] as $char)
1368  {
1369  if (!empty($core_styles[$char]))
1370  {
1371  $cnt++;
1372  $char_comp = explode(".", $char);
1373  $cgui->addItem("", "", $char_comp[2]);
1374  }
1375  else
1376  {
1377  $cgui->addHiddenItem("char[]", $char);
1378  }
1379  }
1380  $all_core_styles = ($cnt == count($_POST["char"]))
1381  ? true
1382  : false;
1383 
1384  if ($all_core_styles)
1385  {
1386  $cgui->setHeaderText($lng->txt("sty_all_styles_obligatory"));
1387  $cgui->setCancel($lng->txt("back"), "cancelCharacteristicDeletion");
1388  }
1389  else
1390  {
1391  $cgui->setHeaderText($lng->txt("sty_some_styles_obligatory_delete_rest"));
1392  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1393  $cgui->setConfirm($lng->txt("sty_delete_other_selected"), "deleteCharacteristicConfirmation");
1394  }
1395 
1396  $tpl->setContent($cgui->getHTML());
1397  }
1398 
1403  {
1404  global $ilCtrl, $lng;
1405 
1406  ilUtil::sendInfo($lng->txt("action_aborted"), true);
1407  $ilCtrl->redirect($this, "edit");
1408  }
1409 
1414  {
1415  global $ilCtrl;
1416 
1417  if (is_array($_POST["char"]))
1418  {
1419  foreach($_POST["char"] as $char)
1420  {
1421  $char_comp = explode(".", $char);
1422  $type = $char_comp[0];
1423  $tag = $char_comp[1];
1424  $class = $char_comp[2];
1425 
1426  $this->object->deleteCharacteristic($type, $tag, $class);
1427  }
1428  }
1429 
1430  $ilCtrl->redirect($this, "edit");
1431  }
1432 
1437  {
1438  global $tpl;
1439 
1440  $this->initCharacteristicForm("create");
1441  $tpl->setContent($this->form_gui->getHTML());
1442  }
1443 
1448  {
1449  global $ilCtrl, $tpl, $lng;
1450 
1451  $this->initCharacteristicForm("create");
1452 
1453  if ($this->form_gui->checkInput())
1454  {
1455  if ($this->object->characteristicExists($_POST["new_characteristic"], $_GET["style_type"]))
1456  {
1457  $char_input = $this->form_gui->getItemByPostVar("new_characteristic");
1458  $char_input->setAlert($lng->txt("sty_characteristic_already_exists"));
1459  }
1460  else
1461  {
1462  $this->object->addCharacteristic($_POST["type"], $_POST["new_characteristic"]);
1463  ilUtil::sendInfo($lng->txt("sty_added_characteristic"), true);
1464  $ilCtrl->setParameter($this, "tag",
1465  ilObjStyleSheet::_determineTag($_POST["type"]).".".$_POST["new_characteristic"]);
1466  $ilCtrl->setParameter($this, "style_type", $_POST["type"]);
1467  $ilCtrl->redirect($this, "editTagStyle");
1468  }
1469  }
1470  $this->form_gui->setValuesByPost();
1471  $tpl->setContent($this->form_gui->getHTML());
1472  }
1473 
1479  public function initCharacteristicForm($a_mode)
1480  {
1481  global $lng, $ilCtrl;
1482 
1483  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1484  $this->form_gui = new ilPropertyFormGUI();
1485 
1486  // title
1487  $txt_input = new ilRegExpInputGUI($lng->txt("title"), "new_characteristic");
1488  $txt_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1489  $txt_input->setNoMatchMessage($lng->txt("sty_msg_characteristic_must_only_include")." A-Z, a-z, 1-9");
1490  $txt_input->setRequired(true);
1491  $this->form_gui->addItem($txt_input);
1492 
1493  // type
1494  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
1495  $types = $all_super_types[$this->super_type];
1496  $exp_types = array();
1497  foreach($types as $t)
1498  {
1500  {
1501  $exp_types[$t] = $lng->txt("sty_type_".$t);
1502  }
1503  }
1504  if (count($exp_types) > 1)
1505  {
1506  $type_input = new ilSelectInputGUI($lng->txt("sty_type"), "type");
1507  $type_input->setOptions($exp_types);
1508  $type_input->setValue(key($exp_types));
1509  $this->form_gui->addItem($type_input);
1510  }
1511  else if (count($exp_types) == 1)
1512  {
1513  $hid_input = new ilHiddenInputGUI("type");
1514  $hid_input->setValue(key($exp_types));
1515  $this->form_gui->addItem($hid_input);
1516  }
1517 
1518  $this->form_gui->setTitle($lng->txt("sty_add_characteristic"));
1519  $this->form_gui->addCommandButton("saveCharacteristic", $lng->txt("save"));
1520  $this->form_gui->addCommandButton("edit", $lng->txt("cancel"));
1521  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1522  }
1523 
1527  static function getStyleExampleHTML($a_type, $a_class)
1528  {
1529  global $lng;
1530 
1531  $c = explode(":", $a_class);
1532  $a_class = $c[0];
1533 
1534  $ex_tpl = new ilTemplate("tpl.style_example.html", true, true, "Services/Style");
1535 
1536  $ex_tpl->setCurrentBlock("Example_".$a_type);
1537  $ex_tpl->setVariable("EX_CLASS", "ilc_".$a_type."_".$a_class);
1538  $ex_tpl->setVariable("EX_TEXT", "ABC abc 123");
1539  if (in_array($a_type, array("media_cont", "qimg")))
1540  {
1541  $ex_tpl->setVariable("IMG_MEDIA_DISABLED", ilUtil::getImagePath("media_disabled.png"));
1542  }
1543  if (in_array($a_type, array("table", "table_caption")))
1544  {
1545  $ex_tpl->setVariable("TXT_CAPTION", $lng->txt("sty_caption"));
1546  }
1547  if (in_array($a_class, array("OrderListItemHorizontal", "OrderListHorizontal")))
1548  {
1549  $ex_tpl->setVariable("HOR", "Horizontal");
1550  }
1551  $ex_tpl->parseCurrentBlock();
1552 
1553  return $ex_tpl->get();
1554  }
1555 
1560  {
1561  global $ilCtrl, $lng;
1562 
1563  //var_dump($_POST);
1564 
1565  foreach ($_POST["all_chars"] as $char)
1566  {
1567  $ca = explode(".", $char);
1568  $this->object->saveHideStatus($ca[0], $ca[2],
1569  (is_array($_POST["hide"]) && in_array($char, $_POST["hide"])));
1570  }
1571 
1572  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
1573  $ilCtrl->redirect($this, "edit");
1574  }
1575 
1583  {
1584  global $ilCtrl, $lng;
1585 
1586  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1587  {
1588  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1589  }
1590  else
1591  {
1592  $style_cp = implode("::", $_POST["char"]);
1593  $style_cp = $this->object->getId().":::".$_GET["style_type"].":::".$style_cp;
1594  $_SESSION["sty_copy"] = $style_cp;
1595  ilUtil::sendSuccess($lng->txt("sty_copied_please_select_target"), true);
1596  }
1597  $ilCtrl->redirect($this, "edit");
1598  }
1599 
1607  {
1608  global $tpl, $ilTabs;
1609 
1610  $ilTabs->clearTargets();
1611 
1612  include_once("./Services/Style/classes/class.ilPasteStyleCharacteristicTableGUI.php");
1613  $table = new ilPasteStyleCharacteristicTableGUI($this, "pasteCharacteristicsOverview");
1614 
1615  $tpl->setContent($table->getHTML());
1616  }
1617 
1625  {
1626  global $ilCtrl, $lng;
1627 
1628  if (is_array($_POST["title"]))
1629  {
1630  foreach ($_POST["title"] as $from_char => $to_title)
1631  {
1632  $fc = explode(".", $from_char);
1633 
1634  if ($_POST["conflict_action"][$from_char] == "overwrite" ||
1635  !$this->object->characteristicExists($to_title, $fc[0]))
1636  {
1637  $this->object->copyCharacteristic($_POST["from_style_id"],
1638  $fc[0], $fc[2], $to_title);
1639  }
1640  }
1641  ilObjStyleSheet::_writeUpToDate($this->object->getId(), false);
1642  unset($_SESSION["sty_copy"]);
1643  ilUtil::sendSuccess($lng->txt("sty_style_classes_copied"), true);
1644  }
1645 
1646  $ilCtrl->redirect($this, "edit");
1647  }
1648 
1649  //
1650  // Color management
1651  //
1652 
1656  function listColorsObject()
1657  {
1658  global $tpl, $rbacsystem, $ilToolbar, $ilCtrl;
1659 
1660  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1661  {
1662  $ilToolbar->addButton($this->lng->txt("sty_add_color"),
1663  $ilCtrl->getLinkTarget($this, "addColor"));
1664  }
1665 
1666  include_once("./Services/Style/classes/class.ilStyleColorTableGUI.php");
1667  $table_gui = new ilStyleColorTableGUI($this, "listColors",
1668  $this->object);
1669  $tpl->setContent($table_gui->getHTML());
1670 
1671  }
1672 
1676  function addColorObject()
1677  {
1678  global $tpl;
1679 
1680  $this->initColorForm();
1681  $tpl->setContent($this->form_gui->getHTML());
1682  }
1683 
1687  function editColorObject()
1688  {
1689  global $tpl, $ilCtrl;
1690 
1691  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1692  $this->initColorForm("edit");
1693  $this->getColorFormValues();
1694  $tpl->setContent($this->form_gui->getHTML());
1695  }
1696 
1697 
1701  function initColorForm($a_mode = "create")
1702  {
1703  global $lng, $ilCtrl;
1704 
1705  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1706  $this->form_gui = new ilPropertyFormGUI();
1707 
1708  $this->form_gui->setTitle($lng->txt("sty_add_color"));
1709 
1710  // name
1711  $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
1712  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1713  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1714  $name_input->setRequired(true);
1715  $name_input->setSize(15);
1716  $name_input->setMaxLength(15);
1717  $this->form_gui->addItem($name_input);
1718 
1719  // code
1720  $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
1721  $color_input->setRequired(true);
1722  $color_input->setDefaultColor("");
1723  $this->form_gui->addItem($color_input);
1724 
1725  if ($a_mode == "create")
1726  {
1727  $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
1728  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1729  }
1730  else
1731  {
1732  $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
1733  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1734  }
1735  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1736  }
1737 
1742  {
1743  if ($_GET["c_name"] != "")
1744  {
1745  $values["color_name"] = $_GET["c_name"];
1746  $values["color_code"] = $this->object->getColorCodeForName($_GET["c_name"]);
1747  $this->form_gui->setValuesByArray($values);
1748  }
1749  }
1750 
1755  {
1756  global $ilCtrl;
1757 
1758  $ilCtrl->redirect($this, "listColors");
1759  }
1760 
1764  function saveColorObject()
1765  {
1766  global $tpl, $ilCtrl, $lng;
1767 
1768  $this->initColorForm();
1769 
1770  if ($this->form_gui->checkInput())
1771  {
1772  if ($this->object->colorExists($_POST["color_name"]))
1773  {
1774  $col_input = $this->form_gui->getItemByPostVar("color_name");
1775  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1776  }
1777  else
1778  {
1779  $this->object->addColor($_POST["color_name"],
1780  $_POST["color_code"]);
1781  $ilCtrl->redirect($this, "listColors");
1782  }
1783  }
1784  $this->form_gui->setValuesByPost();
1785  $tpl->setContent($this->form_gui->getHTML());
1786  }
1787 
1792  {
1793  global $tpl, $ilCtrl, $lng;
1794 
1795  $this->initColorForm("edit");
1796 
1797  if ($this->form_gui->checkInput())
1798  {
1799  if ($this->object->colorExists($_POST["color_name"]) &&
1800  $_POST["color_name"] != $_GET["c_name"])
1801  {
1802  $col_input = $this->form_gui->getItemByPostVar("color_name");
1803  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1804  }
1805  else
1806  {
1807  $this->object->updateColor($_GET["c_name"], $_POST["color_name"],
1808  $_POST["color_code"]);
1809  $ilCtrl->redirect($this, "listColors");
1810  }
1811  }
1812  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1813  $this->form_gui->setValuesByPost();
1814  $tpl->setContent($this->form_gui->getHTML());
1815  }
1816 
1821  {
1822  global $ilCtrl, $tpl, $lng;
1823 
1824  if (!is_array($_POST["color"]) || count($_POST["color"]) == 0)
1825  {
1826  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1827  $ilCtrl->redirect($this, "listColors");
1828  }
1829  else
1830  {
1831  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1832  $cgui = new ilConfirmationGUI();
1833  $cgui->setFormAction($ilCtrl->getFormAction($this));
1834  $cgui->setHeaderText($lng->txt("sty_confirm_color_deletion"));
1835  $cgui->setCancel($lng->txt("cancel"), "cancelColorDeletion");
1836  $cgui->setConfirm($lng->txt("delete"), "deleteColor");
1837 
1838  foreach ($_POST["color"] as $c)
1839  {
1840  $cgui->addItem("color[]", ilUtil::prepareFormOutput($c), $c);
1841  }
1842 
1843  $tpl->setContent($cgui->getHTML());
1844  }
1845  }
1846 
1851  {
1852  global $ilCtrl;
1853 
1854  $ilCtrl->redirect($this, "listColors");
1855  }
1856 
1861  {
1862  global $ilCtrl;
1863 
1864  if (is_array($_POST["color"]))
1865  {
1866  foreach ($_POST["color"] as $c)
1867  {
1868  $this->object->removeColor($c);
1869  }
1870  }
1871 
1872  $ilCtrl->redirect($this, "listColors");
1873  }
1874 
1875  //
1876  // Templates management
1877  //
1878 
1883  {
1884  global $tpl, $ilTabs, $ilCtrl;
1885 
1886  $ctype = $_GET["temp_type"];
1887  if ($ctype == "")
1888  {
1889  $ctype = "table";
1890  $ilCtrl->setParameter($this, "temp_type", $ctype);
1891  $_GET["temp_type"] = $ctype;
1892  }
1893 
1894  $this->setTemplatesSubTabs();
1895  $ilTabs->setSubTabActive("sty_".$ctype."_templates");
1896 
1897  $this->includeCSS();
1898  include_once("./Services/Style/classes/class.ilTableTemplatesTableGUI.php");
1899  $table_gui = new ilTableTemplatesTableGUI($ctype, $this, "listTemplates",
1900  $this->object);
1901  $tpl->setContent($table_gui->getHTML());
1902 
1903  }
1904 
1909  {
1910  global $tpl;
1911 
1912  $this->initTemplateForm();
1913  $tpl->setContent($this->form_gui->getHTML());
1914  }
1915 
1920  {
1921  global $tpl, $ilCtrl;
1922 
1923  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
1924  $this->initTemplateForm("edit");
1925  $this->getTemplateFormValues();
1926 
1927  $this->displayTemplateEditForm();
1928  }
1929 
1933  function getTemplatePreview($a_type, $a_t_id, $a_small_mode = false)
1934  {
1935  return $this->_getTemplatePreview(
1936  $this->object, $a_type, $a_t_id, $a_small_mode);
1937  }
1938 
1942  function _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode = false)
1943  {
1944  global $lng, $tpl;
1945 
1946  $kr = $kc = 7;
1947  if ($a_small_mode)
1948  {
1949  $kr = 6;
1950  $kc = 5;
1951  }
1952 
1953  $ts = $a_style->getTemplate($a_t_id);
1954  $t = $ts["classes"];
1955 
1956  // preview
1957  if ($a_type == "table")
1958  {
1959  $p_content = '<PageContent><Table DataTable="y"';
1960  if ($t["row_head"] != "")
1961  {
1962  $p_content.= ' HeaderRows="1"';
1963  }
1964  if ($t["row_foot"] != "")
1965  {
1966  $p_content.= ' FooterRows="1"';
1967  }
1968  if ($t["col_head"] != "")
1969  {
1970  $p_content.= ' HeaderCols="1"';
1971  }
1972  if ($t["col_foot"] != "")
1973  {
1974  $p_content.= ' FooterCols="1"';
1975  }
1976  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1977  if (!$a_small_mode)
1978  {
1979  $p_content.= '<Caption>'.$lng->txt("sty_caption").'</Caption>';
1980  }
1981  for($i = 1; $i<=$kr; $i++)
1982  {
1983  $p_content.= '<TableRow>';
1984  for($j = 1; $j<=$kc; $j++)
1985  {
1986  if ($a_small_mode)
1987  {
1988  $cell = '&lt;div style="height:2px;"&gt;&lt;/div&gt;';
1989  }
1990  else
1991  {
1992  $cell = 'xxx';
1993  }
1994  $p_content.= '<TableData><PageContent><Paragraph Characteristic="TableContent">'.$cell.'</Paragraph></PageContent></TableData>';
1995  }
1996  $p_content.= '</TableRow>';
1997  }
1998  $p_content.= '</Table></PageContent>';
1999  }
2000 
2001  if ($a_type == "vaccordion" || $a_type == "haccordion")
2002  {
2003  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2005 
2006  if ($a_small_mode)
2007  {
2008  $c = '&amp;nbsp;';
2009  $h = '&amp;nbsp;';
2010  }
2011  else
2012  {
2013  $c = 'xxx';
2014  $h = 'head';
2015  }
2016  if ($a_type == "vaccordion")
2017  {
2018  $p_content = '<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
2019  if ($a_small_mode)
2020  {
2021  $p_content.= ' ContentWidth="70"';
2022  }
2023  }
2024  else
2025  {
2026  $p_content = '<PageContent><Tabs Type="HorizontalAccordion"';
2027  if ($a_small_mode)
2028  {
2029  $p_content.= ' ContentHeight="40"';
2030  $p_content.= ' ContentWidth="70"';
2031  $c = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';
2032  }
2033  else
2034  {
2035  $p_content.= ' ContentHeight="40"';
2036  }
2037  }
2038  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
2039  $p_content.= '<Tab><PageContent><Paragraph>'.$c.'</Paragraph></PageContent>';
2040  $p_content.= '<TabCaption>'.$h.'</TabCaption>';
2041  $p_content.= '</Tab>';
2042  $p_content.= '</Tabs></PageContent>';
2043  }
2044 //echo htmlentities($p_content);
2045  $txml = $a_style->getTemplateXML();
2046 //echo htmlentities($txml);
2047  $p_content.= $txml;
2048  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
2049  $r_content = ilPCTableGUI::_renderTable($p_content, "");
2050 
2051  return $r_content;
2052  }
2053 
2057  function initTemplateForm($a_mode = "create")
2058  {
2059  global $lng, $ilCtrl;
2060 
2061  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2062  $this->form_gui = new ilPropertyFormGUI();
2063 
2064  if ($a_mode == "create")
2065  {
2066  $this->form_gui->setTitle($lng->txt("sty_add_template"));
2067  }
2068  else
2069  {
2070  $this->form_gui->setTitle($lng->txt("sty_edit_template"));
2071  }
2072 
2073  // name
2074  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2075  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2076  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2077  $name_input->setRequired(true);
2078  $name_input->setSize(30);
2079  $name_input->setMaxLength(30);
2080  $this->form_gui->addItem($name_input);
2081 
2082  // template style classes
2083  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2084  foreach ($scs as $sc => $st)
2085  {
2086  $sc_input = new ilSelectInputGUI($lng->txt("sty_".$sc."_class"), $sc."_class");
2087  $chars = $this->object->getCharacteristics($st);
2088  $options = array("" => "");
2089  foreach($chars as $char)
2090  {
2091  $options[$char] = $char;
2092  }
2093  $sc_input->setOptions($options);
2094  $this->form_gui->addItem($sc_input);
2095  }
2096 
2097  if ($a_mode == "create")
2098  {
2099  $this->form_gui->addCommandButton("saveTemplate", $lng->txt("save"));
2100  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2101  }
2102  else
2103  {
2104  $this->form_gui->addCommandButton("refreshTemplate", $lng->txt("save_refresh"));
2105  $this->form_gui->addCommandButton("updateTemplate", $lng->txt("save_return"));
2106  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2107  }
2108  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2109  }
2110 
2115  {
2116  global $ilCtrl;
2117 
2118  $ilCtrl->redirect($this, "listTemplates");
2119  }
2120 
2121 
2126  {
2127  global $tpl, $ilCtrl, $lng;
2128 
2129  $this->initTemplateForm();
2130 
2131  if ($this->form_gui->checkInput())
2132  {
2133  if ($this->object->templateExists($_POST["name"]))
2134  {
2135  $name_input = $this->form_gui->getItemByPostVar("name");
2136  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2137  }
2138  else
2139  {
2140  $classes = array();
2141  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2142  {
2143  $classes[$tct] = $_POST[$tct."_class"];
2144  }
2145  $t_id = $this->object->addTemplate($_GET["temp_type"], $_POST["name"], $classes);
2146  $this->object->writeTemplatePreview($t_id,
2147  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2148  $ilCtrl->redirect($this, "listTemplates");
2149  }
2150  }
2151  $this->form_gui->setValuesByPost();
2152  $tpl->setContent($this->form_gui->getHTML());
2153  }
2154 
2158  function updateTemplateObject($a_refresh = false)
2159  {
2160  global $tpl, $ilCtrl, $lng;
2161 
2162  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
2163  $this->initTemplateForm("edit");
2164 
2165  if ($this->form_gui->checkInput())
2166  {
2167  if ($this->object->templateExists($_POST["name"]) &&
2168  $_POST["name"] != ilObjStyleSheet::lookupTemplateName($_GET["t_id"]))
2169  {
2170  $name_input = $this->form_gui->getItemByPostVar("name");
2171  $name_input->setAlert($lng->txt("sty_template_already_exists"));
2172  }
2173  else
2174  {
2175  $classes = array();
2176  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2177  {
2178  $classes[$tct] = $_POST[$tct."_class"];
2179  }
2180 
2181  $this->object->updateTemplate($_GET["t_id"],
2182  $_POST["name"], $classes);
2183  $this->object->writeTemplatePreview($_GET["t_id"],
2184  $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"], true));
2185  if(!$a_refresh)
2186  {
2187  $ilCtrl->redirect($this, "listTemplates");
2188  }
2189  }
2190  }
2191 
2192  $this->form_gui->setValuesByPost();
2193  $this->displayTemplateEditForm();
2194  }
2195 
2200  {
2201  global $tpl;
2202 
2203  $a_tpl = new ilTemplate("tpl.template_edit.html", true, true,
2204  "Services/Style");
2205  $this->includeCSS();
2206  $a_tpl->setVariable("FORM", $this->form_gui->getHTML());
2207  $a_tpl->setVariable("PREVIEW", $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"]));
2208  $tpl->setContent($a_tpl->get());
2209  }
2210 
2215  {
2216  $this->updateTemplateObject(true);
2217  }
2218 
2223  {
2224  if ($_GET["t_id"] > 0)
2225  {
2226  $t = $this->object->getTemplate($_GET["t_id"]);
2227 
2228  $values["name"] = $t["name"];
2229  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2230  foreach ($scs as $k => $type)
2231  {
2232  $values[$k."_class"] = $t["classes"][$k];
2233  }
2234  $this->form_gui->setValuesByArray($values);
2235  }
2236  }
2237 
2242  {
2243  global $ilCtrl, $tpl, $lng;
2244 
2245  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
2246  {
2247  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2248  $ilCtrl->redirect($this, "listTemplates");
2249  }
2250  else
2251  {
2252  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2253  $cgui = new ilConfirmationGUI();
2254  $cgui->setFormAction($ilCtrl->getFormAction($this));
2255  $cgui->setHeaderText($lng->txt("sty_confirm_template_deletion"));
2256  $cgui->setCancel($lng->txt("cancel"), "cancelTemplateDeletion");
2257  $cgui->setConfirm($lng->txt("sty_del_template"), "deleteTemplate");
2258 
2259  foreach ($_POST["tid"] as $tid)
2260  {
2261  $classes = $this->object->getTemplateClasses($tid);
2262  $cl_str = "";
2263  $listed = array();
2264  foreach ($classes as $cl)
2265  {
2266  if ($cl != "" && !$listed[$cl])
2267  {
2268  $cl_str.= '<div>- '.
2269  $cl."</div>";
2270  $listed[$cl] = true;
2271  }
2272  }
2273  if ($cl_str != "")
2274  {
2275  $cl_str = '<div style="padding-left:30px;" class="small">'.
2276  "<div><i>".$lng->txt("sty_style_class")."</i></div>".$cl_str."</div>";
2277  }
2278  $cgui->addItem("tid[]", $tid, $this->object->lookupTemplateName($tid).$cl_str);
2279  }
2280 
2281  $cgui->addButton($lng->txt("sty_del_template_keep_classes"), "deleteTemplateKeepClasses");
2282 
2283  $tpl->setContent($cgui->getHTML());
2284  }
2285  }
2286 
2291  {
2292  global $ilCtrl;
2293 
2294  $ilCtrl->redirect($this, "listTemplates");
2295  }
2296 
2301  {
2302  global $ilCtrl;
2303 
2304  if (is_array($_POST["tid"]))
2305  {
2306  foreach ($_POST["tid"] as $tid)
2307  {
2308  $this->object->removeTemplate($tid);
2309  }
2310  }
2311 
2312  $ilCtrl->redirect($this, "listTemplates");
2313  }
2314 
2319  {
2320  global $ilCtrl;
2321 
2322  if (is_array($_POST["tid"]))
2323  {
2324  foreach ($_POST["tid"] as $tid)
2325  {
2326  $cls = $this->object->getTemplateClasses($tid);
2327  foreach ($cls as $k => $cls)
2328  {
2329  $ty = $this->object->determineTemplateStyleClassType($_GET["temp_type"], $k);
2330  $ta = ilObjStyleSheet::_determineTag($ty);
2331  $this->object->deleteCharacteristic($ty, $ta, $cls);
2332  }
2333  $this->object->removeTemplate($tid);
2334  }
2335  }
2336 
2337  $ilCtrl->redirect($this, "listTemplates");
2338  }
2339 
2344  {
2345  global $tpl;
2346 
2347  $this->initTemplateGenerationForm();
2348  $tpl->setContent($this->form_gui->getHTML());
2349  }
2350 
2355  {
2356  global $lng, $ilCtrl;
2357 
2358  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2359  $this->form_gui = new ilPropertyFormGUI();
2360 
2361  $this->form_gui->setTitle($lng->txt("sty_generate_template"));
2362 
2363  // name
2364  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2365  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2366  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2367  $name_input->setRequired(true);
2368  $name_input->setSize(30);
2369  $name_input->setMaxLength(30);
2370  $this->form_gui->addItem($name_input);
2371 
2372  // basic layout
2373  $bl_input = new ilSelectInputGUI($lng->txt("sty_template_layout"), "layout");
2374  $options = array(
2375  "coloredZebra" => $lng->txt("sty_table_template_colored_zebra"),
2376  "bwZebra" => $lng->txt("sty_table_template_bw_zebra"),
2377  "noZebra" => $lng->txt("sty_table_template_no_zebra")
2378  );
2379  $bl_input->setOptions($options);
2380  $this->form_gui->addItem($bl_input);
2381 
2382  // top bottom padding
2383  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
2384  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_top_bottom_padding"), "tb_padding");
2385  $num_input->setAllowPercentage(false);
2386  $num_input->setValue("3px");
2387  $this->form_gui->addItem($num_input);
2388 
2389  // left right padding
2390  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_left_right_padding"), "lr_padding");
2391  $num_input->setAllowPercentage(false);
2392  $num_input->setValue("10px");
2393  $this->form_gui->addItem($num_input);
2394 
2395  // base color
2396  $bc_input = new ilSelectInputGUI($lng->txt("sty_base_color"), "base_color");
2397  $cs = $this->object->getColors();
2398  $options = array();
2399  foreach ($cs as $c)
2400  {
2401  $options[$c["name"]] = $c["name"];
2402  }
2403  $bc_input->setOptions($options);
2404  $this->form_gui->addItem($bc_input);
2405 
2406  // Lightness Settings
2407  $lss = array("border" => 90, "header_text" => 70, "header_bg" => 0,
2408  "cell1_text" => -60, "cell1_bg" => 90, "cell2_text" => -60, "cell2_bg" => 75);
2409  foreach ($lss as $ls => $v)
2410  {
2411  $l_input = new ilNumberInputGUI($lng->txt("sty_lightness_".$ls), "lightness_".$ls);
2412  $l_input->setMaxValue(100);
2413  $l_input->setMinValue(-100);
2414  $l_input->setValue($v);
2415  $l_input->setSize(4);
2416  $l_input->setMaxLength(4);
2417  $this->form_gui->addItem($l_input);
2418  }
2419 
2420  $this->form_gui->addCommandButton("templateGeneration", $lng->txt("generate"));
2421  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2422  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2423  }
2424 
2429  {
2430  global $tpl, $ilCtrl, $lng;
2431 
2432  $this->initTemplateGenerationForm();
2433 
2434  if ($this->form_gui->checkInput())
2435  {
2436  if ($this->object->templateExists($_POST["name"]))
2437  {
2438  $name_input = $this->form_gui->getItemByPostVar("name");
2439  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2440  }
2441  else
2442  {
2443  // -> move to application class!
2444 
2445  // cell classes
2446  $cells = array("H" => "header", "C1" => "cell1", "C2" => "cell2");
2447  $tb_p = $this->form_gui->getItemByPostVar("tb_padding");
2448  $tb_padding = $tb_p->getValue();
2449  $lr_p = $this->form_gui->getItemByPostVar("lr_padding");
2450  $lr_padding = $lr_p->getValue();
2451  $cell_color = $_POST["base_color"];
2452 
2453  // use mid gray as cell color for bw zebra
2454  if ($_POST["layout"] == "bwZebra")
2455  {
2456  $cell_color = "MidGray";
2457  if (!$this->object->colorExists($cell_color))
2458  {
2459  $this->object->addColor($cell_color, "7F7F7F");
2460  }
2461  $this->object->updateColor($cell_color, $cell_color, "7F7F7F");
2462  }
2463 
2464  foreach ($cells as $k => $cell)
2465  {
2466  $cell_class[$k] = $_POST["name"].$k;
2467  if (!$this->object->characteristicExists($cell_class[$k], "table_cell"))
2468  {
2469  $this->object->addCharacteristic("table_cell", $cell_class[$k], true);
2470  }
2471  if ($_POST["layout"] == "bwZebra" && $k == "H")
2472  {
2473  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2474  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2475  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2476  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2477  }
2478  else
2479  {
2480  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2481  "!".$cell_color."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2482  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2483  "!".$cell_color."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2484  }
2485  $this->object->replaceStylePar("td", $cell_class[$k], "padding-top",
2486  $tb_padding, "table_cell");
2487  $this->object->replaceStylePar("td", $cell_class[$k], "padding-bottom",
2488  $tb_padding, "table_cell");
2489  $this->object->replaceStylePar("td", $cell_class[$k], "padding-left",
2490  $lr_padding, "table_cell");
2491  $this->object->replaceStylePar("td", $cell_class[$k], "padding-right",
2492  $lr_padding, "table_cell");
2493  $this->object->replaceStylePar("td", $cell_class[$k], "border-width",
2494  "1px", "table_cell");
2495  $this->object->replaceStylePar("td", $cell_class[$k], "border-style",
2496  "solid", "table_cell");
2497  $this->object->replaceStylePar("td", $cell_class[$k], "border-color",
2498  "!".$cell_color."(".$_POST["lightness_border"].")", "table_cell");
2499  $this->object->replaceStylePar("td", $cell_class[$k], "font-weight",
2500  "normal", "table_cell");
2501  }
2502 
2503  // table class
2504  $classes["table"] = $_POST["name"]."T";
2505  if (!$this->object->characteristicExists($classes["table"], "table"))
2506  {
2507  $this->object->addCharacteristic("table", $classes["table"], true);
2508  }
2509  $this->object->replaceStylePar("table", $classes["table"], "caption-side",
2510  "bottom", "table");
2511  $this->object->replaceStylePar("table", $classes["table"], "border-collapse",
2512  "collapse", "table");
2513  $this->object->replaceStylePar("table", $classes["table"], "margin-top",
2514  "5px", "table");
2515  $this->object->replaceStylePar("table", $classes["table"], "margin-bottom",
2516  "5px", "table");
2517  if ($_POST["layout"] == "bwZebra")
2518  {
2519  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-color",
2520  "!".$_POST["base_color"], "table");
2521  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-style",
2522  "solid", "table");
2523  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-width",
2524  "3px", "table");
2525  $sb = array("left", "right", "top");
2526  foreach ($sb as $b)
2527  {
2528  $this->object->replaceStylePar("table", $classes["table"], "border-".$b."-width",
2529  "0px", "table");
2530  }
2531  }
2532 
2533  switch ($_POST["layout"])
2534  {
2535  case "coloredZebra":
2536  $classes["row_head"] = $cell_class["H"];
2537  $classes["odd_row"] = $cell_class["C1"];
2538  $classes["even_row"] = $cell_class["C2"];
2539  break;
2540 
2541  case "bwZebra":
2542  $classes["row_head"] = $cell_class["H"];
2543  $classes["odd_row"] = $cell_class["C1"];
2544  $classes["even_row"] = $cell_class["C2"];
2545  break;
2546 
2547  case "noZebra":
2548  $classes["row_head"] = $cell_class["H"];
2549  $classes["odd_row"] = $cell_class["C1"];
2550  $classes["even_row"] = $cell_class["C1"];
2551  $classes["col_head"] = $cell_class["C2"];
2552  break;
2553  }
2554 
2555 
2556  $t_id = $this->object->addTemplate($_GET["temp_type"],
2557  $_POST["name"], $classes);
2558  $this->object->writeTemplatePreview($t_id,
2559  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2560  $ilCtrl->redirect($this, "listTemplates");
2561  }
2562  }
2563  $this->form_gui->setValuesByPost();
2564  $tpl->setContent($this->form_gui->getHTML());
2565  }
2566 
2568  {
2569  global $tpl;
2570 
2571  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2572 
2573  $acc = new ilAccordionGUI();
2574  $acc->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2575  $acc->addItem("Header 2", str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx x xx x xx", 30));
2576  $acc->setOrientation(ilAccordionGUI::HORIZONTAL);
2577 
2578  $ac2 = new ilAccordionGUI();
2579  $ac2->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2580  $ac2->addItem("Header 2", $acc->getHTML());
2581  $ac2->setOrientation(ilAccordionGUI::VERTICAL);
2582 
2583  $tpl->setContent($ac2->getHTML());
2584  }
2585 
2590  {
2591  global $ilCtrl;
2592 
2593  if ($_GET["baseClass"] == "ilAdministrationGUI")
2594  {
2595  $ilCtrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
2596  }
2597  $ilCtrl->returnToParent($this);
2598  }
2599 
2600 
2601 }
2602 ?>