ILIAS  Release_4_3_x_branch Revision 61807
 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  {
1168  $ilLocator->addItem($this->lng->txt("administration"),
1169  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
1170  ilFrameTargetInfo::_getFrame("MainContent"));
1171 
1172  $ilLocator->addItem(ilObject::_lookupTitle(
1173  ilObject::_lookupObjId($_GET["ref_id"])),
1174  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
1175 
1176  if ($_GET["obj_id"] > 0)
1177  {
1178  $ilLocator->addItem($this->object->getTitle(),
1179  $this->ctrl->getLinkTarget($this, "edit"));
1180  }
1181  }
1182  else // repository administration
1183  {
1184  //?
1185  }
1186 
1187  }
1188 
1189  function showUpperIcon()
1190  {
1191  global $tree, $tpl, $objDefinition;
1192 
1193  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1194  {
1195  $tpl->setUpperIcon(
1196  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
1197  "editContentStyles"));
1198  }
1199  else
1200  {
1201  // ?
1202  }
1203  }
1204 
1208  function listImagesObject()
1209  {
1210  global $tpl, $ilToolbar, $ilCtrl, $lng, $rbacsystem;
1211 
1212  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1213  {
1214  $ilToolbar->addButton($lng->txt("sty_add_image"),
1215  $ilCtrl->getLinkTarget($this, "addImage"));
1216  }
1217 
1218  include_once("./Services/Style/classes/class.ilStyleImageTableGUI.php");
1219  $table_gui = new ilStyleImageTableGUI($this, "listImages",
1220  $this->object);
1221  $tpl->setContent($table_gui->getHTML());
1222 
1223  }
1224 
1228  function addImageObject()
1229  {
1230  global $tpl;
1231 
1232  $this->initImageForm();
1233  $tpl->setContent($this->form_gui->getHTML());
1234  }
1235 
1240  {
1241  global $ilCtrl;
1242 
1243  $ilCtrl->redirect($this, "listImages");
1244  }
1245 
1250  {
1251  global $tpl, $ilCtrl;
1252 
1253  $this->initImageForm();
1254 
1255  if ($this->form_gui->checkInput())
1256  {
1257  $this->object->uploadImage($_FILES["image_file"]);
1258  $ilCtrl->redirect($this, "listImages");
1259  }
1260  else
1261  {
1262  //$this->form_gui->setImageFormValuesByPost();
1263  $tpl->setContent($this->form_gui->getHTML());
1264  }
1265 
1266  }
1267 
1271  function initImageForm()
1272  {
1273  global $lng, $ilCtrl;
1274 
1275  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1276  $this->form_gui = new ilPropertyFormGUI();
1277 
1278  $this->form_gui->setTitle($lng->txt("sty_add_image"));
1279 
1280  $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
1281  $file_input->setRequired(true);
1282  $this->form_gui->addItem($file_input);
1283 
1284  $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
1285  $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
1286  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1287  }
1288 
1293  {
1294  global $ilCtrl;
1295 
1296  $images = $this->object->getImages();
1297 
1298  foreach ($images as $image)
1299  {
1300  if (is_array($_POST["file"]) && in_array($image["entry"], $_POST["file"]))
1301  {
1302  $this->object->deleteImage($image["entry"]);
1303  }
1304  }
1305  $ilCtrl->redirect($this, "listImages");
1306  }
1307 
1312  {
1313  global $ilCtrl, $tpl, $lng;
1314 
1315 //var_dump($_POST);
1316 
1317  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1318  {
1319  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1320  $ilCtrl->redirect($this, "edit");
1321  }
1322  else
1323  {
1324  // check whether there are any core style classes included
1325  $core_styles = ilObjStyleSheet::_getCoreStyles();
1326  foreach ($_POST["char"] as $char)
1327  {
1328  if (!empty($core_styles[$char]))
1329  {
1330  $this->deleteCoreCharMessage();
1331  return;
1332  }
1333  }
1334 
1335  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1336  $cgui = new ilConfirmationGUI();
1337  $cgui->setFormAction($ilCtrl->getFormAction($this));
1338  $cgui->setHeaderText($lng->txt("sty_confirm_char_deletion"));
1339  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1340  $cgui->setConfirm($lng->txt("delete"), "deleteCharacteristic");
1341 
1342  foreach ($_POST["char"] as $char)
1343  {
1344  $char_comp = explode(".", $char);
1345  $cgui->addItem("char[]", $char, $char_comp[2]);
1346  }
1347 
1348  $tpl->setContent($cgui->getHTML());
1349  }
1350  }
1351 
1359  {
1360  global $ilCtrl, $tpl, $lng;
1361 
1362  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1363  $cgui = new ilConfirmationGUI();
1364  $cgui->setFormAction($ilCtrl->getFormAction($this));
1365 
1366 
1367  $core_styles = ilObjStyleSheet::_getCoreStyles();
1368  $cnt = 0;
1369  foreach ($_POST["char"] as $char)
1370  {
1371  if (!empty($core_styles[$char]))
1372  {
1373  $cnt++;
1374  $char_comp = explode(".", $char);
1375  $cgui->addItem("", "", $char_comp[2]);
1376  }
1377  else
1378  {
1379  $cgui->addHiddenItem("char[]", $char);
1380  }
1381  }
1382  $all_core_styles = ($cnt == count($_POST["char"]))
1383  ? true
1384  : false;
1385 
1386  if ($all_core_styles)
1387  {
1388  $cgui->setHeaderText($lng->txt("sty_all_styles_obligatory"));
1389  $cgui->setCancel($lng->txt("back"), "cancelCharacteristicDeletion");
1390  }
1391  else
1392  {
1393  $cgui->setHeaderText($lng->txt("sty_some_styles_obligatory_delete_rest"));
1394  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1395  $cgui->setConfirm($lng->txt("sty_delete_other_selected"), "deleteCharacteristicConfirmation");
1396  }
1397 
1398  $tpl->setContent($cgui->getHTML());
1399  }
1400 
1405  {
1406  global $ilCtrl, $lng;
1407 
1408  ilUtil::sendInfo($lng->txt("action_aborted"), true);
1409  $ilCtrl->redirect($this, "edit");
1410  }
1411 
1416  {
1417  global $ilCtrl;
1418 
1419  if (is_array($_POST["char"]))
1420  {
1421  foreach($_POST["char"] as $char)
1422  {
1423  $char_comp = explode(".", $char);
1424  $type = $char_comp[0];
1425  $tag = $char_comp[1];
1426  $class = $char_comp[2];
1427 
1428  $this->object->deleteCharacteristic($type, $tag, $class);
1429  }
1430  }
1431 
1432  $ilCtrl->redirect($this, "edit");
1433  }
1434 
1439  {
1440  global $tpl;
1441 
1442  $this->initCharacteristicForm("create");
1443  $tpl->setContent($this->form_gui->getHTML());
1444  }
1445 
1450  {
1451  global $ilCtrl, $tpl, $lng;
1452 
1453  $this->initCharacteristicForm("create");
1454 
1455  if ($this->form_gui->checkInput())
1456  {
1457  if ($this->object->characteristicExists($_POST["new_characteristic"], $_GET["style_type"]))
1458  {
1459  $char_input = $this->form_gui->getItemByPostVar("new_characteristic");
1460  $char_input->setAlert($lng->txt("sty_characteristic_already_exists"));
1461  }
1462  else
1463  {
1464  $this->object->addCharacteristic($_POST["type"], $_POST["new_characteristic"]);
1465  ilUtil::sendInfo($lng->txt("sty_added_characteristic"), true);
1466  $ilCtrl->setParameter($this, "tag",
1467  ilObjStyleSheet::_determineTag($_POST["type"]).".".$_POST["new_characteristic"]);
1468  $ilCtrl->setParameter($this, "style_type", $_POST["type"]);
1469  $ilCtrl->redirect($this, "editTagStyle");
1470  }
1471  }
1472  $this->form_gui->setValuesByPost();
1473  $tpl->setContent($this->form_gui->getHTML());
1474  }
1475 
1481  public function initCharacteristicForm($a_mode)
1482  {
1483  global $lng, $ilCtrl;
1484 
1485  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1486  $this->form_gui = new ilPropertyFormGUI();
1487 
1488  // title
1489  $txt_input = new ilRegExpInputGUI($lng->txt("title"), "new_characteristic");
1490  $txt_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1491  $txt_input->setNoMatchMessage($lng->txt("sty_msg_characteristic_must_only_include")." A-Z, a-z, 1-9");
1492  $txt_input->setRequired(true);
1493  $this->form_gui->addItem($txt_input);
1494 
1495  // type
1496  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
1497  $types = $all_super_types[$this->super_type];
1498  $exp_types = array();
1499  foreach($types as $t)
1500  {
1502  {
1503  $exp_types[$t] = $lng->txt("sty_type_".$t);
1504  }
1505  }
1506  if (count($exp_types) > 1)
1507  {
1508  $type_input = new ilSelectInputGUI($lng->txt("sty_type"), "type");
1509  $type_input->setOptions($exp_types);
1510  $type_input->setValue(key($exp_types));
1511  $this->form_gui->addItem($type_input);
1512  }
1513  else if (count($exp_types) == 1)
1514  {
1515  $hid_input = new ilHiddenInputGUI("type");
1516  $hid_input->setValue(key($exp_types));
1517  $this->form_gui->addItem($hid_input);
1518  }
1519 
1520  $this->form_gui->setTitle($lng->txt("sty_add_characteristic"));
1521  $this->form_gui->addCommandButton("saveCharacteristic", $lng->txt("save"));
1522  $this->form_gui->addCommandButton("edit", $lng->txt("cancel"));
1523  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1524  }
1525 
1529  static function getStyleExampleHTML($a_type, $a_class)
1530  {
1531  global $lng;
1532 
1533  $c = explode(":", $a_class);
1534  $a_class = $c[0];
1535 
1536  $ex_tpl = new ilTemplate("tpl.style_example.html", true, true, "Services/Style");
1537 
1538  $ex_tpl->setCurrentBlock("Example_".$a_type);
1539  $ex_tpl->setVariable("EX_CLASS", "ilc_".$a_type."_".$a_class);
1540  $ex_tpl->setVariable("EX_TEXT", "ABC abc 123");
1541  if (in_array($a_type, array("media_cont", "qimg")))
1542  {
1543  $ex_tpl->setVariable("IMG_MEDIA_DISABLED", ilUtil::getImagePath("media_disabled.png"));
1544  }
1545  if (in_array($a_type, array("table", "table_caption")))
1546  {
1547  $ex_tpl->setVariable("TXT_CAPTION", $lng->txt("sty_caption"));
1548  }
1549  if (in_array($a_class, array("OrderListItemHorizontal", "OrderListHorizontal")))
1550  {
1551  $ex_tpl->setVariable("HOR", "Horizontal");
1552  }
1553  $ex_tpl->parseCurrentBlock();
1554 
1555  return $ex_tpl->get();
1556  }
1557 
1562  {
1563  global $ilCtrl, $lng;
1564 
1565  //var_dump($_POST);
1566 
1567  foreach ($_POST["all_chars"] as $char)
1568  {
1569  $ca = explode(".", $char);
1570  $this->object->saveHideStatus($ca[0], $ca[2],
1571  (is_array($_POST["hide"]) && in_array($char, $_POST["hide"])));
1572  }
1573 
1574  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
1575  $ilCtrl->redirect($this, "edit");
1576  }
1577 
1585  {
1586  global $ilCtrl, $lng;
1587 
1588  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1589  {
1590  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1591  }
1592  else
1593  {
1594  $style_cp = implode("::", $_POST["char"]);
1595  $style_cp = $this->object->getId().":::".$_GET["style_type"].":::".$style_cp;
1596  $_SESSION["sty_copy"] = $style_cp;
1597  ilUtil::sendSuccess($lng->txt("sty_copied_please_select_target"), true);
1598  }
1599  $ilCtrl->redirect($this, "edit");
1600  }
1601 
1609  {
1610  global $tpl, $ilTabs;
1611 
1612  $ilTabs->clearTargets();
1613 
1614  include_once("./Services/Style/classes/class.ilPasteStyleCharacteristicTableGUI.php");
1615  $table = new ilPasteStyleCharacteristicTableGUI($this, "pasteCharacteristicsOverview");
1616 
1617  $tpl->setContent($table->getHTML());
1618  }
1619 
1627  {
1628  global $ilCtrl, $lng;
1629 
1630  if (is_array($_POST["title"]))
1631  {
1632  foreach ($_POST["title"] as $from_char => $to_title)
1633  {
1634  $fc = explode(".", $from_char);
1635 
1636  if ($_POST["conflict_action"][$from_char] == "overwrite" ||
1637  !$this->object->characteristicExists($to_title, $fc[0]))
1638  {
1639  $this->object->copyCharacteristic($_POST["from_style_id"],
1640  $fc[0], $fc[2], $to_title);
1641  }
1642  }
1643  ilObjStyleSheet::_writeUpToDate($this->object->getId(), false);
1644  unset($_SESSION["sty_copy"]);
1645  ilUtil::sendSuccess($lng->txt("sty_style_classes_copied"), true);
1646  }
1647 
1648  $ilCtrl->redirect($this, "edit");
1649  }
1650 
1651  //
1652  // Color management
1653  //
1654 
1658  function listColorsObject()
1659  {
1660  global $tpl, $rbacsystem, $ilToolbar, $ilCtrl;
1661 
1662  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1663  {
1664  $ilToolbar->addButton($this->lng->txt("sty_add_color"),
1665  $ilCtrl->getLinkTarget($this, "addColor"));
1666  }
1667 
1668  include_once("./Services/Style/classes/class.ilStyleColorTableGUI.php");
1669  $table_gui = new ilStyleColorTableGUI($this, "listColors",
1670  $this->object);
1671  $tpl->setContent($table_gui->getHTML());
1672 
1673  }
1674 
1678  function addColorObject()
1679  {
1680  global $tpl;
1681 
1682  $this->initColorForm();
1683  $tpl->setContent($this->form_gui->getHTML());
1684  }
1685 
1689  function editColorObject()
1690  {
1691  global $tpl, $ilCtrl;
1692 
1693  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1694  $this->initColorForm("edit");
1695  $this->getColorFormValues();
1696  $tpl->setContent($this->form_gui->getHTML());
1697  }
1698 
1699 
1703  function initColorForm($a_mode = "create")
1704  {
1705  global $lng, $ilCtrl;
1706 
1707  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1708  $this->form_gui = new ilPropertyFormGUI();
1709 
1710  $this->form_gui->setTitle($lng->txt("sty_add_color"));
1711 
1712  // name
1713  $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
1714  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1715  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1716  $name_input->setRequired(true);
1717  $name_input->setSize(15);
1718  $name_input->setMaxLength(15);
1719  $this->form_gui->addItem($name_input);
1720 
1721  // code
1722  $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
1723  $color_input->setRequired(true);
1724  $color_input->setDefaultColor("");
1725  $this->form_gui->addItem($color_input);
1726 
1727  if ($a_mode == "create")
1728  {
1729  $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
1730  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1731  }
1732  else
1733  {
1734  $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
1735  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1736  }
1737  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1738  }
1739 
1744  {
1745  if ($_GET["c_name"] != "")
1746  {
1747  $values["color_name"] = $_GET["c_name"];
1748  $values["color_code"] = $this->object->getColorCodeForName($_GET["c_name"]);
1749  $this->form_gui->setValuesByArray($values);
1750  }
1751  }
1752 
1757  {
1758  global $ilCtrl;
1759 
1760  $ilCtrl->redirect($this, "listColors");
1761  }
1762 
1766  function saveColorObject()
1767  {
1768  global $tpl, $ilCtrl, $lng;
1769 
1770  $this->initColorForm();
1771 
1772  if ($this->form_gui->checkInput())
1773  {
1774  if ($this->object->colorExists($_POST["color_name"]))
1775  {
1776  $col_input = $this->form_gui->getItemByPostVar("color_name");
1777  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1778  }
1779  else
1780  {
1781  $this->object->addColor($_POST["color_name"],
1782  $_POST["color_code"]);
1783  $ilCtrl->redirect($this, "listColors");
1784  }
1785  }
1786  $this->form_gui->setValuesByPost();
1787  $tpl->setContent($this->form_gui->getHTML());
1788  }
1789 
1794  {
1795  global $tpl, $ilCtrl, $lng;
1796 
1797  $this->initColorForm("edit");
1798 
1799  if ($this->form_gui->checkInput())
1800  {
1801  if ($this->object->colorExists($_POST["color_name"]) &&
1802  $_POST["color_name"] != $_GET["c_name"])
1803  {
1804  $col_input = $this->form_gui->getItemByPostVar("color_name");
1805  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1806  }
1807  else
1808  {
1809  $this->object->updateColor($_GET["c_name"], $_POST["color_name"],
1810  $_POST["color_code"]);
1811  $ilCtrl->redirect($this, "listColors");
1812  }
1813  }
1814  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1815  $this->form_gui->setValuesByPost();
1816  $tpl->setContent($this->form_gui->getHTML());
1817  }
1818 
1823  {
1824  global $ilCtrl, $tpl, $lng;
1825 
1826  if (!is_array($_POST["color"]) || count($_POST["color"]) == 0)
1827  {
1828  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1829  $ilCtrl->redirect($this, "listColors");
1830  }
1831  else
1832  {
1833  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1834  $cgui = new ilConfirmationGUI();
1835  $cgui->setFormAction($ilCtrl->getFormAction($this));
1836  $cgui->setHeaderText($lng->txt("sty_confirm_color_deletion"));
1837  $cgui->setCancel($lng->txt("cancel"), "cancelColorDeletion");
1838  $cgui->setConfirm($lng->txt("delete"), "deleteColor");
1839 
1840  foreach ($_POST["color"] as $c)
1841  {
1842  $cgui->addItem("color[]", ilUtil::prepareFormOutput($c), $c);
1843  }
1844 
1845  $tpl->setContent($cgui->getHTML());
1846  }
1847  }
1848 
1853  {
1854  global $ilCtrl;
1855 
1856  $ilCtrl->redirect($this, "listColors");
1857  }
1858 
1863  {
1864  global $ilCtrl;
1865 
1866  if (is_array($_POST["color"]))
1867  {
1868  foreach ($_POST["color"] as $c)
1869  {
1870  $this->object->removeColor($c);
1871  }
1872  }
1873 
1874  $ilCtrl->redirect($this, "listColors");
1875  }
1876 
1877  //
1878  // Templates management
1879  //
1880 
1885  {
1886  global $tpl, $ilTabs, $ilCtrl;
1887 
1888  $ctype = $_GET["temp_type"];
1889  if ($ctype == "")
1890  {
1891  $ctype = "table";
1892  $ilCtrl->setParameter($this, "temp_type", $ctype);
1893  $_GET["temp_type"] = $ctype;
1894  }
1895 
1896  $this->setTemplatesSubTabs();
1897  $ilTabs->setSubTabActive("sty_".$ctype."_templates");
1898 
1899  $this->includeCSS();
1900  include_once("./Services/Style/classes/class.ilTableTemplatesTableGUI.php");
1901  $table_gui = new ilTableTemplatesTableGUI($ctype, $this, "listTemplates",
1902  $this->object);
1903  $tpl->setContent($table_gui->getHTML());
1904 
1905  }
1906 
1911  {
1912  global $tpl;
1913 
1914  $this->initTemplateForm();
1915  $tpl->setContent($this->form_gui->getHTML());
1916  }
1917 
1922  {
1923  global $tpl, $ilCtrl;
1924 
1925  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
1926  $this->initTemplateForm("edit");
1927  $this->getTemplateFormValues();
1928 
1929  $this->displayTemplateEditForm();
1930  }
1931 
1935  function getTemplatePreview($a_type, $a_t_id, $a_small_mode = false)
1936  {
1937  return $this->_getTemplatePreview(
1938  $this->object, $a_type, $a_t_id, $a_small_mode);
1939  }
1940 
1944  function _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode = false)
1945  {
1946  global $lng, $tpl;
1947 
1948  $kr = $kc = 7;
1949  if ($a_small_mode)
1950  {
1951  $kr = 6;
1952  $kc = 5;
1953  }
1954 
1955  $ts = $a_style->getTemplate($a_t_id);
1956  $t = $ts["classes"];
1957 
1958  // preview
1959  if ($a_type == "table")
1960  {
1961  $p_content = '<PageContent><Table DataTable="y"';
1962  if ($t["row_head"] != "")
1963  {
1964  $p_content.= ' HeaderRows="1"';
1965  }
1966  if ($t["row_foot"] != "")
1967  {
1968  $p_content.= ' FooterRows="1"';
1969  }
1970  if ($t["col_head"] != "")
1971  {
1972  $p_content.= ' HeaderCols="1"';
1973  }
1974  if ($t["col_foot"] != "")
1975  {
1976  $p_content.= ' FooterCols="1"';
1977  }
1978  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1979  if (!$a_small_mode)
1980  {
1981  $p_content.= '<Caption>'.$lng->txt("sty_caption").'</Caption>';
1982  }
1983  for($i = 1; $i<=$kr; $i++)
1984  {
1985  $p_content.= '<TableRow>';
1986  for($j = 1; $j<=$kc; $j++)
1987  {
1988  if ($a_small_mode)
1989  {
1990  $cell = '&lt;div style="height:2px;"&gt;&lt;/div&gt;';
1991  }
1992  else
1993  {
1994  $cell = 'xxx';
1995  }
1996  $p_content.= '<TableData><PageContent><Paragraph Characteristic="TableContent">'.$cell.'</Paragraph></PageContent></TableData>';
1997  }
1998  $p_content.= '</TableRow>';
1999  }
2000  $p_content.= '</Table></PageContent>';
2001  }
2002 
2003  if ($a_type == "vaccordion" || $a_type == "haccordion")
2004  {
2005  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2007 
2008  if ($a_small_mode)
2009  {
2010  $c = '&amp;nbsp;';
2011  $h = '&amp;nbsp;';
2012  }
2013  else
2014  {
2015  $c = 'xxx';
2016  $h = 'head';
2017  }
2018  if ($a_type == "vaccordion")
2019  {
2020  $p_content = '<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
2021  if ($a_small_mode)
2022  {
2023  $p_content.= ' ContentWidth="70"';
2024  }
2025  }
2026  else
2027  {
2028  $p_content = '<PageContent><Tabs Type="HorizontalAccordion"';
2029  if ($a_small_mode)
2030  {
2031  $p_content.= ' ContentHeight="40"';
2032  $p_content.= ' ContentWidth="70"';
2033  $c = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';
2034  }
2035  else
2036  {
2037  $p_content.= ' ContentHeight="40"';
2038  }
2039  }
2040  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
2041  $p_content.= '<Tab><PageContent><Paragraph>'.$c.'</Paragraph></PageContent>';
2042  $p_content.= '<TabCaption>'.$h.'</TabCaption>';
2043  $p_content.= '</Tab>';
2044  $p_content.= '</Tabs></PageContent>';
2045  }
2046 //echo htmlentities($p_content);
2047  $txml = $a_style->getTemplateXML();
2048 //echo htmlentities($txml);
2049  $p_content.= $txml;
2050  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
2051  $r_content = ilPCTableGUI::_renderTable($p_content, "");
2052 
2053  return $r_content;
2054  }
2055 
2059  function initTemplateForm($a_mode = "create")
2060  {
2061  global $lng, $ilCtrl;
2062 
2063  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2064  $this->form_gui = new ilPropertyFormGUI();
2065 
2066  if ($a_mode == "create")
2067  {
2068  $this->form_gui->setTitle($lng->txt("sty_add_template"));
2069  }
2070  else
2071  {
2072  $this->form_gui->setTitle($lng->txt("sty_edit_template"));
2073  }
2074 
2075  // name
2076  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2077  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2078  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2079  $name_input->setRequired(true);
2080  $name_input->setSize(30);
2081  $name_input->setMaxLength(30);
2082  $this->form_gui->addItem($name_input);
2083 
2084  // template style classes
2085  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2086  foreach ($scs as $sc => $st)
2087  {
2088  $sc_input = new ilSelectInputGUI($lng->txt("sty_".$sc."_class"), $sc."_class");
2089  $chars = $this->object->getCharacteristics($st);
2090  $options = array("" => "");
2091  foreach($chars as $char)
2092  {
2093  $options[$char] = $char;
2094  }
2095  $sc_input->setOptions($options);
2096  $this->form_gui->addItem($sc_input);
2097  }
2098 
2099  if ($a_mode == "create")
2100  {
2101  $this->form_gui->addCommandButton("saveTemplate", $lng->txt("save"));
2102  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2103  }
2104  else
2105  {
2106  $this->form_gui->addCommandButton("refreshTemplate", $lng->txt("save_refresh"));
2107  $this->form_gui->addCommandButton("updateTemplate", $lng->txt("save_return"));
2108  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2109  }
2110  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2111  }
2112 
2117  {
2118  global $ilCtrl;
2119 
2120  $ilCtrl->redirect($this, "listTemplates");
2121  }
2122 
2123 
2128  {
2129  global $tpl, $ilCtrl, $lng;
2130 
2131  $this->initTemplateForm();
2132 
2133  if ($this->form_gui->checkInput())
2134  {
2135  if ($this->object->templateExists($_POST["name"]))
2136  {
2137  $name_input = $this->form_gui->getItemByPostVar("name");
2138  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2139  }
2140  else
2141  {
2142  $classes = array();
2143  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2144  {
2145  $classes[$tct] = $_POST[$tct."_class"];
2146  }
2147  $t_id = $this->object->addTemplate($_GET["temp_type"], $_POST["name"], $classes);
2148  $this->object->writeTemplatePreview($t_id,
2149  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2150  $ilCtrl->redirect($this, "listTemplates");
2151  }
2152  }
2153  $this->form_gui->setValuesByPost();
2154  $tpl->setContent($this->form_gui->getHTML());
2155  }
2156 
2160  function updateTemplateObject($a_refresh = false)
2161  {
2162  global $tpl, $ilCtrl, $lng;
2163 
2164  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
2165  $this->initTemplateForm("edit");
2166 
2167  if ($this->form_gui->checkInput())
2168  {
2169  if ($this->object->templateExists($_POST["name"]) &&
2170  $_POST["name"] != ilObjStyleSheet::lookupTemplateName($_GET["t_id"]))
2171  {
2172  $name_input = $this->form_gui->getItemByPostVar("name");
2173  $name_input->setAlert($lng->txt("sty_template_already_exists"));
2174  }
2175  else
2176  {
2177  $classes = array();
2178  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2179  {
2180  $classes[$tct] = $_POST[$tct."_class"];
2181  }
2182 
2183  $this->object->updateTemplate($_GET["t_id"],
2184  $_POST["name"], $classes);
2185  $this->object->writeTemplatePreview($_GET["t_id"],
2186  $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"], true));
2187  if(!$a_refresh)
2188  {
2189  $ilCtrl->redirect($this, "listTemplates");
2190  }
2191  }
2192  }
2193 
2194  $this->form_gui->setValuesByPost();
2195  $this->displayTemplateEditForm();
2196  }
2197 
2202  {
2203  global $tpl;
2204 
2205  $a_tpl = new ilTemplate("tpl.template_edit.html", true, true,
2206  "Services/Style");
2207  $this->includeCSS();
2208  $a_tpl->setVariable("FORM", $this->form_gui->getHTML());
2209  $a_tpl->setVariable("PREVIEW", $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"]));
2210  $tpl->setContent($a_tpl->get());
2211  }
2212 
2217  {
2218  $this->updateTemplateObject(true);
2219  }
2220 
2225  {
2226  if ($_GET["t_id"] > 0)
2227  {
2228  $t = $this->object->getTemplate($_GET["t_id"]);
2229 
2230  $values["name"] = $t["name"];
2231  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2232  foreach ($scs as $k => $type)
2233  {
2234  $values[$k."_class"] = $t["classes"][$k];
2235  }
2236  $this->form_gui->setValuesByArray($values);
2237  }
2238  }
2239 
2244  {
2245  global $ilCtrl, $tpl, $lng;
2246 
2247  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
2248  {
2249  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2250  $ilCtrl->redirect($this, "listTemplates");
2251  }
2252  else
2253  {
2254  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2255  $cgui = new ilConfirmationGUI();
2256  $cgui->setFormAction($ilCtrl->getFormAction($this));
2257  $cgui->setHeaderText($lng->txt("sty_confirm_template_deletion"));
2258  $cgui->setCancel($lng->txt("cancel"), "cancelTemplateDeletion");
2259  $cgui->setConfirm($lng->txt("sty_del_template"), "deleteTemplate");
2260 
2261  foreach ($_POST["tid"] as $tid)
2262  {
2263  $classes = $this->object->getTemplateClasses($tid);
2264  $cl_str = "";
2265  $listed = array();
2266  foreach ($classes as $cl)
2267  {
2268  if ($cl != "" && !$listed[$cl])
2269  {
2270  $cl_str.= '<div>- '.
2271  $cl."</div>";
2272  $listed[$cl] = true;
2273  }
2274  }
2275  if ($cl_str != "")
2276  {
2277  $cl_str = '<div style="padding-left:30px;" class="small">'.
2278  "<div><i>".$lng->txt("sty_style_class")."</i></div>".$cl_str."</div>";
2279  }
2280  $cgui->addItem("tid[]", $tid, $this->object->lookupTemplateName($tid).$cl_str);
2281  }
2282 
2283  $cgui->addButton($lng->txt("sty_del_template_keep_classes"), "deleteTemplateKeepClasses");
2284 
2285  $tpl->setContent($cgui->getHTML());
2286  }
2287  }
2288 
2293  {
2294  global $ilCtrl;
2295 
2296  $ilCtrl->redirect($this, "listTemplates");
2297  }
2298 
2303  {
2304  global $ilCtrl;
2305 
2306  if (is_array($_POST["tid"]))
2307  {
2308  foreach ($_POST["tid"] as $tid)
2309  {
2310  $this->object->removeTemplate($tid);
2311  }
2312  }
2313 
2314  $ilCtrl->redirect($this, "listTemplates");
2315  }
2316 
2321  {
2322  global $ilCtrl;
2323 
2324  if (is_array($_POST["tid"]))
2325  {
2326  foreach ($_POST["tid"] as $tid)
2327  {
2328  $cls = $this->object->getTemplateClasses($tid);
2329  foreach ($cls as $k => $cls)
2330  {
2331  $ty = $this->object->determineTemplateStyleClassType($_GET["temp_type"], $k);
2332  $ta = ilObjStyleSheet::_determineTag($ty);
2333  $this->object->deleteCharacteristic($ty, $ta, $cls);
2334  }
2335  $this->object->removeTemplate($tid);
2336  }
2337  }
2338 
2339  $ilCtrl->redirect($this, "listTemplates");
2340  }
2341 
2346  {
2347  global $tpl;
2348 
2349  $this->initTemplateGenerationForm();
2350  $tpl->setContent($this->form_gui->getHTML());
2351  }
2352 
2357  {
2358  global $lng, $ilCtrl;
2359 
2360  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2361  $this->form_gui = new ilPropertyFormGUI();
2362 
2363  $this->form_gui->setTitle($lng->txt("sty_generate_template"));
2364 
2365  // name
2366  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2367  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2368  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2369  $name_input->setRequired(true);
2370  $name_input->setSize(30);
2371  $name_input->setMaxLength(30);
2372  $this->form_gui->addItem($name_input);
2373 
2374  // basic layout
2375  $bl_input = new ilSelectInputGUI($lng->txt("sty_template_layout"), "layout");
2376  $options = array(
2377  "coloredZebra" => $lng->txt("sty_table_template_colored_zebra"),
2378  "bwZebra" => $lng->txt("sty_table_template_bw_zebra"),
2379  "noZebra" => $lng->txt("sty_table_template_no_zebra")
2380  );
2381  $bl_input->setOptions($options);
2382  $this->form_gui->addItem($bl_input);
2383 
2384  // top bottom padding
2385  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
2386  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_top_bottom_padding"), "tb_padding");
2387  $num_input->setAllowPercentage(false);
2388  $num_input->setValue("3px");
2389  $this->form_gui->addItem($num_input);
2390 
2391  // left right padding
2392  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_left_right_padding"), "lr_padding");
2393  $num_input->setAllowPercentage(false);
2394  $num_input->setValue("10px");
2395  $this->form_gui->addItem($num_input);
2396 
2397  // base color
2398  $bc_input = new ilSelectInputGUI($lng->txt("sty_base_color"), "base_color");
2399  $cs = $this->object->getColors();
2400  $options = array();
2401  foreach ($cs as $c)
2402  {
2403  $options[$c["name"]] = $c["name"];
2404  }
2405  $bc_input->setOptions($options);
2406  $this->form_gui->addItem($bc_input);
2407 
2408  // Lightness Settings
2409  $lss = array("border" => 90, "header_text" => 70, "header_bg" => 0,
2410  "cell1_text" => -60, "cell1_bg" => 90, "cell2_text" => -60, "cell2_bg" => 75);
2411  foreach ($lss as $ls => $v)
2412  {
2413  $l_input = new ilNumberInputGUI($lng->txt("sty_lightness_".$ls), "lightness_".$ls);
2414  $l_input->setMaxValue(100);
2415  $l_input->setMinValue(-100);
2416  $l_input->setValue($v);
2417  $l_input->setSize(4);
2418  $l_input->setMaxLength(4);
2419  $this->form_gui->addItem($l_input);
2420  }
2421 
2422  $this->form_gui->addCommandButton("templateGeneration", $lng->txt("generate"));
2423  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2424  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2425  }
2426 
2431  {
2432  global $tpl, $ilCtrl, $lng;
2433 
2434  $this->initTemplateGenerationForm();
2435 
2436  if ($this->form_gui->checkInput())
2437  {
2438  if ($this->object->templateExists($_POST["name"]))
2439  {
2440  $name_input = $this->form_gui->getItemByPostVar("name");
2441  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2442  }
2443  else
2444  {
2445  // -> move to application class!
2446 
2447  // cell classes
2448  $cells = array("H" => "header", "C1" => "cell1", "C2" => "cell2");
2449  $tb_p = $this->form_gui->getItemByPostVar("tb_padding");
2450  $tb_padding = $tb_p->getValue();
2451  $lr_p = $this->form_gui->getItemByPostVar("lr_padding");
2452  $lr_padding = $lr_p->getValue();
2453  $cell_color = $_POST["base_color"];
2454 
2455  // use mid gray as cell color for bw zebra
2456  if ($_POST["layout"] == "bwZebra")
2457  {
2458  $cell_color = "MidGray";
2459  if (!$this->object->colorExists($cell_color))
2460  {
2461  $this->object->addColor($cell_color, "7F7F7F");
2462  }
2463  $this->object->updateColor($cell_color, $cell_color, "7F7F7F");
2464  }
2465 
2466  foreach ($cells as $k => $cell)
2467  {
2468  $cell_class[$k] = $_POST["name"].$k;
2469  if (!$this->object->characteristicExists($cell_class[$k], "table_cell"))
2470  {
2471  $this->object->addCharacteristic("table_cell", $cell_class[$k], true);
2472  }
2473  if ($_POST["layout"] == "bwZebra" && $k == "H")
2474  {
2475  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2476  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2477  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2478  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2479  }
2480  else
2481  {
2482  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2483  "!".$cell_color."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2484  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2485  "!".$cell_color."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2486  }
2487  $this->object->replaceStylePar("td", $cell_class[$k], "padding-top",
2488  $tb_padding, "table_cell");
2489  $this->object->replaceStylePar("td", $cell_class[$k], "padding-bottom",
2490  $tb_padding, "table_cell");
2491  $this->object->replaceStylePar("td", $cell_class[$k], "padding-left",
2492  $lr_padding, "table_cell");
2493  $this->object->replaceStylePar("td", $cell_class[$k], "padding-right",
2494  $lr_padding, "table_cell");
2495  $this->object->replaceStylePar("td", $cell_class[$k], "border-width",
2496  "1px", "table_cell");
2497  $this->object->replaceStylePar("td", $cell_class[$k], "border-style",
2498  "solid", "table_cell");
2499  $this->object->replaceStylePar("td", $cell_class[$k], "border-color",
2500  "!".$cell_color."(".$_POST["lightness_border"].")", "table_cell");
2501  $this->object->replaceStylePar("td", $cell_class[$k], "font-weight",
2502  "normal", "table_cell");
2503  }
2504 
2505  // table class
2506  $classes["table"] = $_POST["name"]."T";
2507  if (!$this->object->characteristicExists($classes["table"], "table"))
2508  {
2509  $this->object->addCharacteristic("table", $classes["table"], true);
2510  }
2511  $this->object->replaceStylePar("table", $classes["table"], "caption-side",
2512  "bottom", "table");
2513  $this->object->replaceStylePar("table", $classes["table"], "border-collapse",
2514  "collapse", "table");
2515  $this->object->replaceStylePar("table", $classes["table"], "margin-top",
2516  "5px", "table");
2517  $this->object->replaceStylePar("table", $classes["table"], "margin-bottom",
2518  "5px", "table");
2519  if ($_POST["layout"] == "bwZebra")
2520  {
2521  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-color",
2522  "!".$_POST["base_color"], "table");
2523  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-style",
2524  "solid", "table");
2525  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-width",
2526  "3px", "table");
2527  $sb = array("left", "right", "top");
2528  foreach ($sb as $b)
2529  {
2530  $this->object->replaceStylePar("table", $classes["table"], "border-".$b."-width",
2531  "0px", "table");
2532  }
2533  }
2534 
2535  switch ($_POST["layout"])
2536  {
2537  case "coloredZebra":
2538  $classes["row_head"] = $cell_class["H"];
2539  $classes["odd_row"] = $cell_class["C1"];
2540  $classes["even_row"] = $cell_class["C2"];
2541  break;
2542 
2543  case "bwZebra":
2544  $classes["row_head"] = $cell_class["H"];
2545  $classes["odd_row"] = $cell_class["C1"];
2546  $classes["even_row"] = $cell_class["C2"];
2547  break;
2548 
2549  case "noZebra":
2550  $classes["row_head"] = $cell_class["H"];
2551  $classes["odd_row"] = $cell_class["C1"];
2552  $classes["even_row"] = $cell_class["C1"];
2553  $classes["col_head"] = $cell_class["C2"];
2554  break;
2555  }
2556 
2557 
2558  $t_id = $this->object->addTemplate($_GET["temp_type"],
2559  $_POST["name"], $classes);
2560  $this->object->writeTemplatePreview($t_id,
2561  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2562  $ilCtrl->redirect($this, "listTemplates");
2563  }
2564  }
2565  $this->form_gui->setValuesByPost();
2566  $tpl->setContent($this->form_gui->getHTML());
2567  }
2568 
2570  {
2571  global $tpl;
2572 
2573  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2574 
2575  $acc = new ilAccordionGUI();
2576  $acc->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2577  $acc->addItem("Header 2", str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx x xx x xx", 30));
2578  $acc->setOrientation(ilAccordionGUI::HORIZONTAL);
2579 
2580  $ac2 = new ilAccordionGUI();
2581  $ac2->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2582  $ac2->addItem("Header 2", $acc->getHTML());
2583  $ac2->setOrientation(ilAccordionGUI::VERTICAL);
2584 
2585  $tpl->setContent($ac2->getHTML());
2586  }
2587 
2592  {
2593  global $ilCtrl;
2594 
2595  if ($_GET["baseClass"] == "ilAdministrationGUI")
2596  {
2597  $ilCtrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
2598  }
2599  $ilCtrl->returnToParent($this);
2600  }
2601 
2602 
2603 }
2604 ?>