ILIAS  Release_4_0_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 "./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  $this->prepareOutput();
56  switch($next_class)
57  {
58  default:
59  $cmd.= "Object";
60  $ret =& $this->$cmd();
61  break;
62  }
63 
64  return $ret;
65  }
66 
67  function viewObject()
68  {
69  $this->editObject();
70  }
71 
75  function createObject()
76  {
77  global $rbacsystem, $lng, $tpl;
78 
79  //$this->setTabs();
80 
81  $this->lng =& $lng;
82  //$this->ctrl->setParameter($this,'new_type',$this->type);
83  $this->getTemplateFile("create", "sty");
84 
85  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("sty_create_new_stylesheet"));
86 
87  $this->tpl->setVariable("TXT_STYLE_BY_IMPORT", $this->lng->txt("sty_import_stylesheet"));
88  $this->tpl->setVariable("TXT_STYLE_BY_COPY", $this->lng->txt("sty_copy_other_stylesheet"));
89  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("import_file"));
90  $this->tpl->setVariable("TXT_SOURCE", $this->lng->txt("sty_source"));
91  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
92  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
93 
94  $this->ctrl->setParameter($this, "new_type", "sty");
95  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
96  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
97  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
98  $this->tpl->setVariable("TXT_COPY", $this->lng->txt("copy"));
99  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
100  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
101 
102  // get all learning module styles
103  $clonable_styles = ilObjStyleSheet::_getClonableContentStyles();
104  $select = ilUtil::formSelect("", "source_style", $clonable_styles, false, true);
105  $this->tpl->setVariable("SOURCE_SELECT", $select);
106  }
107 
111  function includeCSS()
112  {
113  // set style sheet
114  $this->tpl->setCurrentBlock("ContentStyle");
115  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
116  $this->object->getContentStylePath($this->object->getId()));
117  $this->tpl->parseCurrentBlock();
118  }
119 
123  function editObject()
124  {
125  global $rbacsystem, $lng, $ilTabs, $ilCtrl;
126 //ilObjStyleSheet::_addMissingStyleClassesToAllStyles();
127  $this->setSubTabs();
128 
129  $this->includeCSS();
130 
131  $ctpl = new ilTemplate("tpl.sty_classes.html", true, true, "Services/Style");
132 
133  // output characteristics
134  $chars = $this->object->getCharacteristics();
135 
136  $style_type = ($this->super_type != "")
137  ? $this->super_type
138  : "text_block";
139  $ilCtrl->setParameter($this, "style_type", $style_type);
140 
141  $ilTabs->setSubTabActive("sty_".$style_type."_char");
142 
143  include_once("./Services/Style/classes/class.ilStyleTableGUI.php");
144  $table_gui = new ilStyleTableGUI($this, "edit", $chars, $style_type,
145  $this->object);
146 
147  $ctpl->setCurrentBlock("style_table");
148  $ctpl->setVariable("STYLE_TABLE", $table_gui->getHTML());
149  $ctpl->parseCurrentBlock();
150 
151  $this->tpl->setContent($ctpl->get());
152  }
153 
157  function propertiesObject()
158  {
159  global $rbacsystem, $lng;
160 
161  // set style sheet
162  $this->tpl->setCurrentBlock("ContentStyle");
163  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
164  $this->object->getContentStylePath($this->object->getId()));
165  $this->tpl->parseCurrentBlock();
166 
167  // add button button
168  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
169 
170  // export button
171  $this->tpl->setCurrentBlock("btn_cell");
172  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportStyle"));
173  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("export"));
174  $this->tpl->parseCurrentBlock();
175 
176  $this->initPropertiesForm();
177  $this->getPropertiesValues();
178  $this->tpl->setContent($this->form->getHTML());
179 
180 /*
181  $this->getTemplateFile("edit", "sty");
182  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
183 
184  // title and description
185  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
186  $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
187  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
188  $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
189  $this->tpl->parseCurrentBlock();
190 
191  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
192  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
193  $this->tpl->setVariable("BTN_SAVE", "update");
194  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
195 */
196  }
197 
202  public function getPropertiesValues()
203  {
204  $values = array();
205 
206  $values["style_title"] = $this->object->getTitle();
207  $values["style_description"] = $this->object->getDescription();
208  $values["disable_auto_margins"] = (int) $this->object->lookupStyleSetting("disable_auto_margins");
209 
210  $this->form->setValuesByArray($values);
211  }
212 
218  public function initPropertiesForm($a_mode = "edit")
219  {
220  global $lng;
221  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
222  $this->form = new ilPropertyFormGUI();
223 
224  // title
225  $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
226  $ti->setMaxLength(128);
227  $ti->setSize(40);
228  $ti->setRequired(true);
229  $this->form->addItem($ti);
230 
231  // description
232  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
233  //$ta->setCols();
234  //$ta->setRows();
235  $this->form->addItem($ta);
236 
237  // disable automatic margins for left/right alignment
238  $cb = new ilCheckboxInputGUI($this->lng->txt("sty_disable_auto_margins"), "disable_auto_margins");
239  $cb->setInfo($this->lng->txt("sty_disable_auto_margins_info"));
240  $this->form->addItem($cb);
241 
242 
243  // save and cancel commands
244  if ($a_mode == "create")
245  {
246  $this->form->addCommandButton("save", $lng->txt("save"));
247  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
248  }
249  else
250  {
251  $this->form->addCommandButton("update", $lng->txt("save"));
252  }
253 
254  $this->form->setTitle($lng->txt("edit_stylesheet"));
255  $this->form->setFormAction($this->ctrl->getFormAction($this));
256 
257  }
258 
262  function updateObject()
263  {
264  global $lng, $ilCtrl, $tpl;
265 
266  $this->initPropertiesForm("edit");
267  if ($this->form->checkInput())
268  {
269  $this->object->setTitle($this->form->getInput("style_title"));
270  $this->object->setDescription($this->form->getInput("style_description"));
271  $this->object->writeStyleSetting("disable_auto_margins",
272  $this->form->getInput("disable_auto_margins"));
273  $this->object->update();
274  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
275  $ilCtrl->redirect($this, "properties");
276  }
277  else
278  {
279  $this->form->setValuesByPost();
280  $tpl->setContent($this->form->getHtml());
281  }
282  }
283 
288  {
289  global $ilCtrl;
290 
291  $cur = explode(".",$_GET["tag"]);
292  $cur_tag = $cur[0];
293  $cur_class = $cur[1];
294 
295  $this->initTagStyleForm("edit", $cur_tag);
296 
297  if ($this->form_gui->checkInput())
298  {
299  $this->saveTagStyle();
300  $ilCtrl->redirect($this, "editTagStyle");
301  }
302  else
303  {
304  $this->form_gui->setValuesByPost();
305  $this->outputTagStyleEditScreen();
306  }
307  }
308 
313  {
314  global $ilCtrl;
315 
316  $cur = explode(".",$_GET["tag"]);
317  $cur_tag = $cur[0];
318  $cur_class = $cur[1];
319 
320  $this->initTagStyleForm("edit", $cur_tag);
321  if ($this->form_gui->checkInput())
322  {
323  $this->saveTagStyle();
324  $ilCtrl->redirect($this, "edit");
325  }
326  else
327  {
328  $this->form_gui->setValuesByPost();
329  $this->outputTagStyleEditScreen();
330  }
331  }
332 
336  function saveTagStyle()
337  {
338  $cur = explode(".", $_GET["tag"]);
339  $cur_tag = $cur[0];
340  $cur_class = $cur[1];
341  $avail_pars = ilObjStyleSheet::_getStyleParameters($cur_tag);
342  foreach ($avail_pars as $par => $v)
343  {
344  $var = str_replace("-", "_", $par);
345  $basepar_arr = explode(".", $par);
346  $basepar = $basepar_arr[0];
347 //var_dump($basepar_arr);
348  if ($basepar_arr[1] != "" && $basepar_arr[1] != $cur_tag)
349  {
350  continue;
351  }
352 
353  switch ($v["input"])
354  {
355  case "fontsize":
356  case "numeric_no_perc":
357  case "numeric":
358  case "background_image":
359  $in = $this->form_gui->getItemByPostVar($basepar);
360 //echo "<br>-".$cur_tag."-".$cur_class."-".$basepar."-".$_GET["style_type"]."-";
361  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
362  break;
363 
364  case "color":
365  $color = trim($_POST[$basepar]);
366  if ($color != "" && trim(substr($color,0,1) != "!"))
367  {
368  $color = "#".$color;
369  }
370  $this->writeStylePar($cur_tag, $cur_class, $basepar, $color, $_GET["style_type"]);
371  break;
372 
373  case "trbl_numeric":
374  case "border_width":
375  case "border_style":
376  $in = $this->form_gui->getItemByPostVar($basepar);
377  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0], $in->getAllValue(), $_GET["style_type"]);
378  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1], $in->getTopValue(), $_GET["style_type"]);
379  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2], $in->getRightValue(), $_GET["style_type"]);
380  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3], $in->getBottomValue(), $_GET["style_type"]);
381  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4], $in->getLeftValue(), $_GET["style_type"]);
382  break;
383 
384  case "trbl_color":
385  $in = $this->form_gui->getItemByPostVar($basepar);
386  $tblr_p = array (0 => "getAllValue", 1 => "getTopValue", 2 => "getRightValue",
387  3 => "getBottomValue", 4 => "getLeftValue");
388  foreach ($tblr_p as $k => $func)
389  {
390  $val = trim($in->$func());
391  $val = (($in->getAcceptNamedColors() && substr($val, 0, 1) == "!")
392  || $val == "")
393  ? $val
394  : "#".$val;
395  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][$k], $val, $_GET["style_type"]);
396  }
397  /*$this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0],
398  trim($in->getAllValue() != "") ? "#".$in->getAllValue() : "", $_GET["style_type"]);
399  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1],
400  trim($in->getTopValue() != "") ? "#".$in->getTopValue() : "", $_GET["style_type"]);
401  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2],
402  trim($in->getRightValue() != "") ? "#".$in->getRightValue() : "", $_GET["style_type"]);
403  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3],
404  trim($in->getBottomValue() != "") ? "#".$in->getBottomValue() : "", $_GET["style_type"]);
405  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4],
406  trim($in->getLeftValue() != "") ? "#".$in->getLeftValue() : "", $_GET["style_type"]);
407  */
408  break;
409 
410  case "background_position":
411  $in = $this->form_gui->getItemByPostVar($basepar);
412  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
413  break;
414 
415  default:
416  $this->writeStylePar($cur_tag, $cur_class, $basepar, $_POST[$basepar], $_GET["style_type"]);
417  break;
418  }
419  }
420 
421  $this->object->update();
422  }
423 
424  function writeStylePar($cur_tag, $cur_class, $par, $value, $a_type)
425  {
426  if ($a_type == "")
427  {
428  return;
429  }
430 
431  if ($value != "")
432  {
433  $this->object->replaceStylePar($cur_tag, $cur_class, $par, $value, $a_type);
434  }
435  else
436  {
437  $this->object->deleteStylePar($cur_tag, $cur_class, $par, $a_type);
438  }
439  }
440 
446  {
447  global $tpl;
448 
449  $cur = explode(".",$_GET["tag"]);
450  $cur_tag = $cur[0];
451  $cur_class = $cur[1];
452 
453  $this->initTagStyleForm("edit", $cur_tag);
454  $this->getValues();
455  $this->outputTagStyleEditScreen();
456  }
457 
462  {
463  global $tpl, $ilCtrl, $lng;
464 
465  // set style sheet
466  $tpl->setCurrentBlock("ContentStyle");
467  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
468  $this->object->getContentStylePath($this->object->getId()));
469 
470  $ts_tpl = new ilTemplate("tpl.style_tag_edit.html", true, true, "Services/Style");
471 
472  $cur = explode(".",$_GET["tag"]);
473  $cur_tag = $cur[0];
474  $cur_class = $cur[1];
475 
476  $ts_tpl->setVariable("EXAMPLE",
477  ilObjStyleSheetGUI::getStyleExampleHTML($_GET["style_type"], $cur_class));
478 
479  $ts_tpl->setVariable("FORM",
480  $this->form_gui->getHtml());
481 
482  $tpl->setTitle($cur_class." (".$lng->txt("sty_type_".$_GET["style_type"]).")");
483 
484  $tpl->setContent($ts_tpl->get());
485  }
486 
487 
493  public function initTagStyleForm($a_mode, $a_cur_tag)
494  {
495  global $lng;
496 
497  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
498  $this->form_gui = new ilPropertyFormGUI();
499 
500  $avail_pars = $this->object->getAvailableParameters();
501  $groups = $this->object->getStyleParameterGroups();
502 
503  // output select lists
504  foreach ($groups as $k => $group)
505  {
506  // filter groups of properties that should only be
507  // displayed with matching tag
508  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
509  if (is_array($filtered_groups[$k]) && !in_array($a_cur_tag, $filtered_groups[$k]))
510  {
511  continue;
512  }
513 
514  $sh = new ilFormSectionHeaderGUI();
515  $sh->setTitle($lng->txt("sty_".$k));
516  $this->form_gui->addItem($sh);
517 
518  foreach ($group as $par)
519  {
520  $basepar = explode(".", $par);
521  $basepar = $basepar[0];
522 
523  $var = str_replace("-", "_", $basepar);
524  $up_par = strtoupper($var);
525 
527  {
528  case "select":
529  $sel_input = new ilSelectInputGUI($lng->txt("sty_".$var), $basepar);
530  $options = array("" => "");
531  foreach ($avail_pars[$par] as $p)
532  {
533  $options[$p] = $p;
534  }
535  $sel_input->setOptions($options);
536  $this->form_gui->addItem($sel_input);
537  break;
538 
539  case "text":
540  $text_input = new ilTextInputGUI($lng->txt("sty_".$var), $basepar);
541  $text_input->setMaxLength(200);
542  $text_input->setSize(20);
543  $this->form_gui->addItem($text_input);
544  break;
545 
546  case "fontsize":
547  include_once("./Services/Style/classes/class.ilFontSizeInputGUI.php");
548  $fs_input = new ilFontSizeInputGUI($lng->txt("sty_".$var), $basepar);
549  $this->form_gui->addItem($fs_input);
550  break;
551 
552  case "numeric_no_perc":
553  case "numeric":
554  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
555  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
556  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "numeric_no_perc")
557  {
558  $num_input->setAllowPercentage(false);
559  }
560  $this->form_gui->addItem($num_input);
561  break;
562 
563  case "percentage":
564  $per_input = new ilNumberInputGUI($lng->txt("sty_".$var), $basepar);
565  $per_input->setMinValue(0);
566  $per_input->setMaxValue(100);
567  $per_input->setMaxLength(3);
568  $per_input->setSize(3);
569  $this->form_gui->addItem($per_input);
570  break;
571 
572  case "color":
573  //include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
574  $col_input = new ilColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
575  $col_input->setDefaultColor("");
576  $col_input->setAcceptNamedColors(true);
577  $this->form_gui->addItem($col_input);
578  break;
579 
580  case "trbl_numeric":
581  include_once("./Services/Style/classes/class.ilTRBLNumericStyleValueInputGUI.php");
582  $num_input = new ilTRBLNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
583  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "trbl_numeric_no_perc")
584  {
585  $num_input->setAllowPercentage(false);
586  }
587  $this->form_gui->addItem($num_input);
588  break;
589 
590  case "border_width":
591  include_once("./Services/Style/classes/class.ilTRBLBorderWidthInputGUI.php");
592  $bw_input = new ilTRBLBorderWidthInputGUI($lng->txt("sty_".$var), $basepar);
593  $this->form_gui->addItem($bw_input);
594  break;
595 
596  case "border_style":
597  include_once("./Services/Style/classes/class.ilTRBLBorderStyleInputGUI.php");
598  $bw_input = new ilTRBLBorderStyleInputGUI($lng->txt("sty_".$var), $basepar);
599  $this->form_gui->addItem($bw_input);
600  break;
601 
602  case "trbl_color":
603  include_once("./Services/Style/classes/class.ilTRBLColorPickerInputGUI.php");
604  $col_input = new ilTRBLColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
605  $col_input->setAcceptNamedColors(true);
606  $this->form_gui->addItem($col_input);
607  break;
608 
609  case "background_image":
610  include_once("./Services/Style/classes/class.ilBackgroundImageInputGUI.php");
611  $im_input = new ilBackgroundImageInputGUI($lng->txt("sty_".$var), $basepar);
612  $imgs = array();
613  foreach ($this->object->getImages() as $entry)
614  {
615  $imgs[] = $entry["entry"];
616  }
617  $im_input->setImages($imgs);
618  $this->form_gui->addItem($im_input);
619  break;
620 
621  case "background_position":
622  include_once("./Services/Style/classes/class.ilBackgroundPositionInputGUI.php");
623  $im_input = new ilBackgroundPositionInputGUI($lng->txt("sty_".$var), $basepar);
624  $this->form_gui->addItem($im_input);
625  break;
626  }
627  }
628  }
629 
630  // save and cancel commands
631  $this->form_gui->addCommandButton("updateTagStyle", $lng->txt("save_return"));
632  $this->form_gui->addCommandButton("refreshTagStyle", $lng->txt("save_refresh"));
633 
634 // $this->form_gui->setTitle($lng->txt("edit"));
635  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
636  }
637 
642  public function getValues()
643  {
644  $style = $this->object->getStyle();
645  $cur = explode(".",$_GET["tag"]);
646  $cur_tag = $cur[0];
647  $cur_class = $cur[1];
648  $cur_parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style, $_GET["style_type"]);
649 
650  $parameters = ilObjStyleSheet::_getStyleParameters();
651  foreach($parameters as $p => $v)
652  {
653  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
654  if (is_array($filtered_groups[$v["group"]]) && !in_array($cur_tag, $filtered_groups[$v["group"]]))
655  {
656  continue;
657  }
658  $p = explode(".", $p);
659  $p = $p[0];
660  $input = $this->form_gui->getItemByPostVar($p);
661  switch ($v["input"])
662  {
663  case "":
664  break;
665 
666  case "trbl_numeric":
667  case "border_width":
668  case "border_style":
669  case "trbl_color":
670  $input->setAllValue($cur_parameters[$v["subpar"][0]]);
671  $input->setTopValue($cur_parameters[$v["subpar"][1]]);
672  $input->setRightValue($cur_parameters[$v["subpar"][2]]);
673  $input->setBottomValue($cur_parameters[$v["subpar"][3]]);
674  $input->setLeftValue($cur_parameters[$v["subpar"][4]]);
675  break;
676 
677  default:
678  $input->setValue($cur_parameters[$p]);
679  break;
680  }
681  }
682  }
683 
687  function exportStyleObject()
688  {
689  $file = $this->object->export();
690 
691  ilUtil::deliverFile($file, "sty_".$this->object->getId().".zip");
692  }
693 
694  function extractParametersOfTag($a_tag, $a_class, $a_style, $a_type)
695  {
696  $parameters = array();
697  foreach($a_style as $tag)
698  {
699  foreach($tag as $par)
700  {
701  if ($par["tag"] == $a_tag && $par["class"] == $a_class
702  && $par["type"] == $a_type)
703  {
704  $parameters[$par["parameter"]] = $par["value"];
705  }
706  }
707  }
708  return $parameters;
709  }
710 
715  {
716  $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
717  $this->editObject();
718  }
719 
723  function refreshObject()
724  {
725  //$class_name = "ilObjStyleSheet";
726  //require_once("classes/class.ilObjStyleSheet.php");
727  $this->object->setTitle($_POST["style_title"]);
728  $this->object->setDescription($_POST["style_description"]);
729 
730  foreach($_POST["styval"] as $id => $value)
731  {
732  $this->object->updateStyleParameter($id, $value);
733  }
734  $this->object->update();
735  $this->editObject();
736  }
737 
743  function deleteObject($a_error = false)
744  {
745  //$this->setTabs();
746 
747  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
748 
749  if(!$a_error)
750  {
751  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
752  }
753 
754  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
755 
756  // BEGIN TABLE HEADER
757  $this->tpl->setCurrentBlock("table_header");
758  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
759  $this->tpl->parseCurrentBlock();
760 
761  // END TABLE HEADER
762 
763  // BEGIN TABLE DATA
764  $counter = 0;
765 
766  $this->tpl->setCurrentBlock("table_row");
767  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
768  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
769  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
770  $this->tpl->parseCurrentBlock();
771 
772  // END TABLE DATA
773 
774  // BEGIN OPERATION_BTN
775  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
776  "cancelDelete" => $this->lng->txt("cancel"));
777  foreach ($buttons as $name => $value)
778  {
779  $this->tpl->setCurrentBlock("operation_btn");
780  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
781  $this->tpl->setVariable("BTN_NAME",$name);
782  $this->tpl->setVariable("BTN_VALUE",$value);
783  $this->tpl->parseCurrentBlock();
784  }
785  }
786 
787 
792  {
793  $this->ctrl->returnToParent($this);
794  }
795 
800  {
801  global $ilias;
802 
803  $this->object->delete();
804 
805  $this->ctrl->returnToParent($this);
806  }
807 
812  {
813  if (is_array($_POST["sty_select"]))
814  {
815  foreach($_POST["sty_select"] as $id => $dummy)
816  {
817  $this->object->deleteParameter($id);
818  }
819  }
820  $this->object->read();
821  $this->object->writeCSSFile();
822  $this->editObject();
823  }
824 
828  function saveObject()
829  {
830 //echo "HH"; exit;
831  $class_name = "ilObjStyleSheet";
832  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
833  $newObj = new ilObjStyleSheet();
834  $newObj->setTitle("-");
835  $newObj->create();
836  $newObj->setTitle(ilUtil::stripSlashes($_POST["style_title"]));
837  $newObj->setDescription(ilUtil::stripSlashes($_POST["style_description"]));
838  $newObj->update();
839 
840  // assign style to style sheet folder,
841  // if parent is style sheet folder
842  if ($_GET["ref_id"] > 0)
843  {
844 
845  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
846  if ($fold->getType() == "stys")
847  {
848  $fold->addStyle($newObj->getId());
849  $fold->update();
850  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
851  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
852  }
853  }
854 
855  return $newObj->getId();
856  }
857 
861  function copyStyleObject()
862  {
863  global $ilias;
864 
865  if ($_POST["source_style"] > 0)
866  $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
867  $new_id = $style_obj->ilClone();
868 
869  // assign style to style sheet folder,
870  // if parent is style sheet folder
871  if ($_GET["ref_id"] > 0)
872  {
873 
874  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
875  if ($fold->getType() == "stys")
876  {
877  $fold->addStyle($new_id);
878  $fold->update();
879  ilObjStyleSheet::_writeStandard($new_id, "1");
880  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
881  }
882  }
883 
884  return $new_id;
885  }
886 
890  function importStyleObject()
891  {
892  // check file
893  $source = $_FILES["stylefile"]["tmp_name"];
894  if (($source == 'none') || (!$source))
895  {
896  $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
897  }
898 
899  // check correct file type
900  $info = pathinfo($_FILES["stylefile"]["name"]);
901  if (strtolower($info["extension"]) != "zip" && strtolower($info["extension"]) != "xml")
902  {
903  $this->ilias->raiseError("File must be a zip or xml file!",$this->ilias->error_obj->MESSAGE);
904  }
905 
906  $class_name = "ilObjStyleSheet";
907  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
908  $newObj = new ilObjStyleSheet();
909  //$newObj->setTitle();
910  //$newObj->setDescription($_POST["style_description"]);
911  $newObj->import($_FILES["stylefile"]);
912  //$newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
913 
914  // assign style to style sheet folder,
915  // if parent is style sheet folder
916  if ($_GET["ref_id"] > 0)
917  {
918 
919  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
920  if ($fold->getType() == "stys")
921  {
922  $fold->addStyle($newObj->getId());
923  $fold->update();
924  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
925  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
926  }
927  }
928 
929  return $newObj->getId();
930  }
931 
935  function cancelObject()
936  {
937  global $lng;
938 
939  ilUtil::sendInfo($lng->txt("msg_cancel"), true);
940  $this->ctrl->returnToParent($this);
941  }
942 
946  function getAdminTabs(&$tabs_gui)
947  {
948  $this->getTabs($tabs_gui);
949  }
950 
954  function setTabs()
955  {
956  global $lng;
957 
958  $this->getTabs($this->tabs_gui);
959 
960  if (strtolower(get_class($this->object)) == "ilobjstylesheet")
961  {
962  $this->tpl->setVariable("HEADER", $this->object->getTitle());
963  }
964  else
965  {
966  $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
967  }
968  }
969 
975  function getTabs(&$tabs_gui)
976  {
977  global $lng, $ilCtrl, $ilTabs;
978 
979  if ($ilCtrl->getCmd() == "editTagStyle")
980  {
981  // back to upper context
982  $tabs_gui->setBackTarget($lng->txt("back"),
983  $ilCtrl->getLinkTarget($this, "edit"));
984 
985  $t = explode(".", $_GET["tag"]);
986  $t2 = explode(":", $t[1]);
987  $pc = $this->object->_getPseudoClasses($t[0]);
988  if (is_array($pc) && count($pc) > 0)
989  {
990  // style classes
991  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0]);
992  $tabs_gui->addTarget("sty_tag_normal",
993  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
994  get_class($this));
995  if ($t2[1] == "")
996  {
997  $ilTabs->setTabActive("sty_tag_normal");
998  }
999 
1000  foreach ($pc as $p)
1001  {
1002  // style classes
1003  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0].":".$p);
1004  $tabs_gui->addTarget("sty_tag_".$p,
1005  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1006  get_class($this));
1007  if ($t2[1] == $p)
1008  {
1009  $ilTabs->setTabActive("sty_tag_".$p);
1010  }
1011  }
1012  $ilCtrl->setParameter($this, "tag", $_GET["tag"]);
1013  }
1014  }
1015  else
1016  {
1017  // back to upper context
1018  $tabs_gui->setBackTarget($lng->txt("back"),
1019  $this->ctrl->getLinkTarget($this, "returnToUpperContext"));
1020 
1021  // style classes
1022  $tabs_gui->addTarget("sty_style_chars",
1023  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1024  get_class($this));
1025 
1026  // colors
1027  $tabs_gui->addTarget("sty_colors",
1028  $this->ctrl->getLinkTarget($this, "listColors"), "listColors",
1029  get_class($this));
1030 
1031  // images
1032  $tabs_gui->addTarget("sty_images",
1033  $this->ctrl->getLinkTarget($this, "listImages"), "listImages",
1034  get_class($this));
1035 
1036  // table templates
1037  $tabs_gui->addTarget("sty_templates",
1038  $this->ctrl->getLinkTarget($this, "listTemplates"), "listTemplates",
1039  get_class($this));
1040 
1041  // settings
1042  $tabs_gui->addTarget("settings",
1043  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1044  get_class($this));
1045 
1046  // accordiontest
1047 /*
1048  $tabs_gui->addTarget("accordiontest",
1049  $this->ctrl->getLinkTarget($this, "accordiontest"), "accordiontest",
1050  get_class($this));*/
1051  }
1052 
1053  }
1054 
1060  function setSubTabs()
1061  {
1062  global $lng, $ilTabs, $ilCtrl;
1063 
1065 
1066  foreach ($types as $super_type => $types)
1067  {
1068  // text block characteristics
1069  $ilCtrl->setParameter($this, "style_type", $super_type);
1070  $ilTabs->addSubTabTarget("sty_".$super_type."_char",
1071  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1072  get_class($this));
1073  }
1074 
1075  $ilCtrl->setParameter($this, "style_type", $_GET["style_type"]);
1076  }
1077 
1084  {
1085  global $lng, $ilTabs, $ilCtrl;
1086 
1088 
1089  foreach ($types as $t => $c)
1090  {
1091  $ilCtrl->setParameter($this, "temp_type", $t);
1092  $ilTabs->addSubTabTarget("sty_".$t."_templates",
1093  $this->ctrl->getLinkTarget($this, "listTemplates"), array("listTemplates", ""),
1094  get_class($this));
1095  }
1096 
1097  $ilCtrl->setParameter($this, "temp_type", $_GET["temp_type"]);
1098  }
1099 
1105  {
1106  global $ilLocator;
1107 
1108  if ($_GET["admin_mode"] == "settings") // system settings
1109  {
1110  $ilLocator->addItem($this->lng->txt("administration"),
1111  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
1112  ilFrameTargetInfo::_getFrame("MainContent"));
1113 
1114  $ilLocator->addItem(ilObject::_lookupTitle(
1115  ilObject::_lookupObjId($_GET["ref_id"])),
1116  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
1117 
1118  if ($_GET["obj_id"] > 0)
1119  {
1120  $ilLocator->addItem($this->object->getTitle(),
1121  $this->ctrl->getLinkTarget($this, "edit"));
1122  }
1123  }
1124  else // repository administration
1125  {
1126  //?
1127  }
1128 
1129  }
1130 
1131  function showUpperIcon()
1132  {
1133  global $tree, $tpl, $objDefinition;
1134 
1135  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1136  {
1137  $tpl->setUpperIcon(
1138  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
1139  "editContentStyles"));
1140  }
1141  else
1142  {
1143  // ?
1144  }
1145  }
1146 
1150  function listImagesObject()
1151  {
1152  global $tpl;
1153 
1154  include_once("./Services/Style/classes/class.ilStyleImageTableGUI.php");
1155  $table_gui = new ilStyleImageTableGUI($this, "listImages",
1156  $this->object);
1157  $tpl->setContent($table_gui->getHTML());
1158 
1159  }
1160 
1164  function addImageObject()
1165  {
1166  global $tpl;
1167 
1168  $this->initImageForm();
1169  $tpl->setContent($this->form_gui->getHTML());
1170  }
1171 
1176  {
1177  global $ilCtrl;
1178 
1179  $ilCtrl->redirect($this, "listImages");
1180  }
1181 
1186  {
1187  global $tpl, $ilCtrl;
1188 
1189  $this->initImageForm();
1190 
1191  if ($this->form_gui->checkInput())
1192  {
1193  $this->object->uploadImage($_FILES["image_file"]);
1194  $ilCtrl->redirect($this, "listImages");
1195  }
1196  else
1197  {
1198  //$this->form_gui->setImageFormValuesByPost();
1199  $tpl->setContent($this->form_gui->getHTML());
1200  }
1201 
1202  }
1203 
1207  function initImageForm()
1208  {
1209  global $lng, $ilCtrl;
1210 
1211  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1212  $this->form_gui = new ilPropertyFormGUI();
1213 
1214  $this->form_gui->setTitle($lng->txt("sty_add_image"));
1215 
1216  $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
1217  $file_input->setRequired(true);
1218  $this->form_gui->addItem($file_input);
1219 
1220  $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
1221  $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
1222  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1223  }
1224 
1229  {
1230  global $ilCtrl;
1231 
1232  $images = $this->object->getImages();
1233 
1234  foreach ($images as $image)
1235  {
1236  if (is_array($_POST["file"]) && in_array($image["entry"], $_POST["file"]))
1237  {
1238  $this->object->deleteImage($image["entry"]);
1239  }
1240  }
1241  $ilCtrl->redirect($this, "listImages");
1242  }
1243 
1248  {
1249  global $ilCtrl, $tpl, $lng;
1250 
1251 //var_dump($_POST);
1252 
1253  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1254  {
1255  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1256  $ilCtrl->redirect($this, "edit");
1257  }
1258  else
1259  {
1260  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1261  $cgui = new ilConfirmationGUI();
1262  $cgui->setFormAction($ilCtrl->getFormAction($this));
1263  $cgui->setHeaderText($lng->txt("sty_confirm_char_deletion"));
1264  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1265  $cgui->setConfirm($lng->txt("delete"), "deleteCharacteristic");
1266 
1267  foreach ($_POST["char"] as $char)
1268  {
1269  $char_comp = explode(".", $char);
1270  $cgui->addItem("char[]", $char, $char_comp[2]);
1271  }
1272 
1273  $tpl->setContent($cgui->getHTML());
1274  }
1275  }
1276 
1281  {
1282  global $ilCtrl, $lng;
1283 
1284  ilUtil::sendInfo($lng->txt("action_aborted"), true);
1285  $ilCtrl->redirect($this, "edit");
1286  }
1287 
1292  {
1293  global $ilCtrl;
1294 
1295  if (is_array($_POST["char"]))
1296  {
1297  foreach($_POST["char"] as $char)
1298  {
1299  $char_comp = explode(".", $char);
1300  $type = $char_comp[0];
1301  $tag = $char_comp[1];
1302  $class = $char_comp[2];
1303 
1304  $this->object->deleteCharacteristic($type, $tag, $class);
1305  }
1306  }
1307 
1308  $ilCtrl->redirect($this, "edit");
1309  }
1310 
1315  {
1316  global $tpl;
1317 
1318  $this->initCharacteristicForm("create");
1319  $tpl->setContent($this->form_gui->getHTML());
1320  }
1321 
1326  {
1327  global $ilCtrl, $tpl, $lng;
1328 
1329  $this->initCharacteristicForm("create");
1330 
1331  if ($this->form_gui->checkInput())
1332  {
1333  if ($this->object->characteristicExists($_POST["new_characteristic"], $_GET["style_type"]))
1334  {
1335  $char_input = $this->form_gui->getItemByPostVar("new_characteristic");
1336  $char_input->setAlert($lng->txt("sty_characteristic_already_exists"));
1337  }
1338  else
1339  {
1340  $this->object->addCharacteristic($_POST["type"], $_POST["new_characteristic"]);
1341  ilUtil::sendInfo($lng->txt("sty_added_characteristic"), true);
1342  $ilCtrl->redirect($this, "edit");
1343  }
1344  }
1345  $this->form_gui->setValuesByPost();
1346  $tpl->setContent($this->form_gui->getHTML());
1347  }
1348 
1354  public function initCharacteristicForm($a_mode)
1355  {
1356  global $lng, $ilCtrl;
1357 
1358  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1359  $this->form_gui = new ilPropertyFormGUI();
1360 
1361  // title
1362  $txt_input = new ilRegExpInputGUI($lng->txt("title"), "new_characteristic");
1363  $txt_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1364  $txt_input->setNoMatchMessage($lng->txt("sty_msg_characteristic_must_only_include")." A-Z, a-z, 1-9");
1365  $txt_input->setRequired(true);
1366  $this->form_gui->addItem($txt_input);
1367 
1368  // type
1369  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
1370  $types = $all_super_types[$this->super_type];
1371  $exp_types = array();
1372  foreach($types as $t)
1373  {
1375  {
1376  $exp_types[$t] = $lng->txt("sty_type_".$t);
1377  }
1378  }
1379  if (count($exp_types) > 1)
1380  {
1381  $type_input = new ilSelectInputGUI($lng->txt("sty_type"), "type");
1382  $type_input->setOptions($exp_types);
1383  $type_input->setValue(key($exp_types));
1384  $this->form_gui->addItem($type_input);
1385  }
1386  else if (count($exp_types) == 1)
1387  {
1388  $hid_input = new ilHiddenInputGUI("type");
1389  $hid_input->setValue(key($exp_types));
1390  $this->form_gui->addItem($hid_input);
1391  }
1392 
1393  $this->form_gui->setTitle($lng->txt("sty_add_characteristic"));
1394  $this->form_gui->addCommandButton("saveCharacteristic", $lng->txt("save"));
1395  $this->form_gui->addCommandButton("edit", $lng->txt("cancel"));
1396  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1397  }
1398 
1402  static function getStyleExampleHTML($a_type, $a_class)
1403  {
1404  global $lng;
1405 
1406  $c = explode(":", $a_class);
1407  $a_class = $c[0];
1408 
1409  $ex_tpl = new ilTemplate("tpl.style_example.html", true, true, "Services/Style");
1410 
1411  $ex_tpl->setCurrentBlock("Example_".$a_type);
1412  $ex_tpl->setVariable("EX_CLASS", "ilc_".$a_type."_".$a_class);
1413  $ex_tpl->setVariable("EX_TEXT", "ABC abc 123");
1414  if ($a_type == "media_cont")
1415  {
1416  $ex_tpl->setVariable("IMG_MEDIA_DISABLED", ilUtil::getImagePath("media_disabled.gif"));
1417  }
1418  if (in_array($a_type, array("table", "table_caption")))
1419  {
1420  $ex_tpl->setVariable("TXT_CAPTION", $lng->txt("sty_caption"));
1421  }
1422  $ex_tpl->parseCurrentBlock();
1423 
1424  return $ex_tpl->get();
1425  }
1426 
1431  {
1432  global $ilCtrl, $lng;
1433 
1434  //var_dump($_POST);
1435 
1436  foreach ($_POST["all_chars"] as $char)
1437  {
1438  $ca = explode(".", $char);
1439  $this->object->saveHideStatus($ca[0], $ca[2],
1440  (is_array($_POST["hide"]) && in_array($char, $_POST["hide"])));
1441  }
1442 
1443  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
1444  $ilCtrl->redirect($this, "edit");
1445  }
1446 
1447 
1448  //
1449  // Color management
1450  //
1451 
1455  function listColorsObject()
1456  {
1457  global $tpl;
1458 
1459  include_once("./Services/Style/classes/class.ilStyleColorTableGUI.php");
1460  $table_gui = new ilStyleColorTableGUI($this, "listColors",
1461  $this->object);
1462  $tpl->setContent($table_gui->getHTML());
1463 
1464  }
1465 
1469  function addColorObject()
1470  {
1471  global $tpl;
1472 
1473  $this->initColorForm();
1474  $tpl->setContent($this->form_gui->getHTML());
1475  }
1476 
1480  function editColorObject()
1481  {
1482  global $tpl, $ilCtrl;
1483 
1484  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1485  $this->initColorForm("edit");
1486  $this->getColorFormValues();
1487  $tpl->setContent($this->form_gui->getHTML());
1488  }
1489 
1490 
1494  function initColorForm($a_mode = "create")
1495  {
1496  global $lng, $ilCtrl;
1497 
1498  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1499  $this->form_gui = new ilPropertyFormGUI();
1500 
1501  $this->form_gui->setTitle($lng->txt("sty_add_color"));
1502 
1503  // name
1504  $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
1505  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1506  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1507  $name_input->setRequired(true);
1508  $name_input->setSize(15);
1509  $name_input->setMaxLength(15);
1510  $this->form_gui->addItem($name_input);
1511 
1512  // code
1513  $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
1514  $color_input->setRequired(true);
1515  $color_input->setDefaultColor("");
1516  $this->form_gui->addItem($color_input);
1517 
1518  if ($a_mode == "create")
1519  {
1520  $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
1521  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1522  }
1523  else
1524  {
1525  $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
1526  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1527  }
1528  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1529  }
1530 
1535  {
1536  if ($_GET["c_name"] != "")
1537  {
1538  $values["color_name"] = $_GET["c_name"];
1539  $values["color_code"] = $this->object->getColorCodeForName($_GET["c_name"]);
1540  $this->form_gui->setValuesByArray($values);
1541  }
1542  }
1543 
1548  {
1549  global $ilCtrl;
1550 
1551  $ilCtrl->redirect($this, "listColors");
1552  }
1553 
1557  function saveColorObject()
1558  {
1559  global $tpl, $ilCtrl, $lng;
1560 
1561  $this->initColorForm();
1562 
1563  if ($this->form_gui->checkInput())
1564  {
1565  if ($this->object->colorExists($_POST["color_name"]))
1566  {
1567  $col_input = $this->form_gui->getItemByPostVar("color_name");
1568  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1569  }
1570  else
1571  {
1572  $this->object->addColor($_POST["color_name"],
1573  $_POST["color_code"]);
1574  $ilCtrl->redirect($this, "listColors");
1575  }
1576  }
1577  $this->form_gui->setValuesByPost();
1578  $tpl->setContent($this->form_gui->getHTML());
1579  }
1580 
1585  {
1586  global $tpl, $ilCtrl, $lng;
1587 
1588  $this->initColorForm("edit");
1589 
1590  if ($this->form_gui->checkInput())
1591  {
1592  if ($this->object->colorExists($_POST["color_name"]) &&
1593  $_POST["color_name"] != $_GET["c_name"])
1594  {
1595  $col_input = $this->form_gui->getItemByPostVar("color_name");
1596  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1597  }
1598  else
1599  {
1600  $this->object->updateColor($_GET["c_name"], $_POST["color_name"],
1601  $_POST["color_code"]);
1602  $ilCtrl->redirect($this, "listColors");
1603  }
1604  }
1605  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1606  $this->form_gui->setValuesByPost();
1607  $tpl->setContent($this->form_gui->getHTML());
1608  }
1609 
1614  {
1615  global $ilCtrl, $tpl, $lng;
1616 
1617  if (!is_array($_POST["color"]) || count($_POST["color"]) == 0)
1618  {
1619  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1620  $ilCtrl->redirect($this, "listColors");
1621  }
1622  else
1623  {
1624  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1625  $cgui = new ilConfirmationGUI();
1626  $cgui->setFormAction($ilCtrl->getFormAction($this));
1627  $cgui->setHeaderText($lng->txt("sty_confirm_color_deletion"));
1628  $cgui->setCancel($lng->txt("cancel"), "cancelColorDeletion");
1629  $cgui->setConfirm($lng->txt("delete"), "deleteColor");
1630 
1631  foreach ($_POST["color"] as $c)
1632  {
1633  $cgui->addItem("color[]", ilUtil::prepareFormOutput($c), $c);
1634  }
1635 
1636  $tpl->setContent($cgui->getHTML());
1637  }
1638  }
1639 
1644  {
1645  global $ilCtrl;
1646 
1647  $ilCtrl->redirect($this, "listColors");
1648  }
1649 
1654  {
1655  global $ilCtrl;
1656 
1657  if (is_array($_POST["color"]))
1658  {
1659  foreach ($_POST["color"] as $c)
1660  {
1661  $this->object->removeColor($c);
1662  }
1663  }
1664 
1665  $ilCtrl->redirect($this, "listColors");
1666  }
1667 
1668  //
1669  // Templates management
1670  //
1671 
1676  {
1677  global $tpl, $ilTabs, $ilCtrl;
1678 
1679  $ctype = $_GET["temp_type"];
1680  if ($ctype == "")
1681  {
1682  $ctype = "table";
1683  $ilCtrl->setParameter($this, "temp_type", $ctype);
1684  $_GET["temp_type"] = $ctype;
1685  }
1686 
1687  $this->setTemplatesSubTabs();
1688  $ilTabs->setSubTabActive("sty_".$ctype."_templates");
1689 
1690  $this->includeCSS();
1691  include_once("./Services/Style/classes/class.ilTableTemplatesTableGUI.php");
1692  $table_gui = new ilTableTemplatesTableGUI($ctype, $this, "listTemplates",
1693  $this->object);
1694  $tpl->setContent($table_gui->getHTML());
1695 
1696  }
1697 
1702  {
1703  global $tpl;
1704 
1705  $this->initTemplateForm();
1706  $tpl->setContent($this->form_gui->getHTML());
1707  }
1708 
1713  {
1714  global $tpl, $ilCtrl;
1715 
1716  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
1717  $this->initTemplateForm("edit");
1718  $this->getTemplateFormValues();
1719 
1720  $this->displayTemplateEditForm();
1721  }
1722 
1726  function getTemplatePreview($a_type, $a_t_id, $a_small_mode = false)
1727  {
1728  return $this->_getTemplatePreview(
1729  $this->object, $a_type, $a_t_id, $a_small_mode);
1730  }
1731 
1735  function _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode = false)
1736  {
1737  global $lng, $tpl;
1738 
1739  $kr = $kc = 7;
1740  if ($a_small_mode)
1741  {
1742  $kr = 6;
1743  $kc = 5;
1744  }
1745 
1746  $ts = $a_style->getTemplate($a_t_id);
1747  $t = $ts["classes"];
1748 
1749  // preview
1750  if ($a_type == "table")
1751  {
1752  $p_content = '<PageContent><Table DataTable="y"';
1753  if ($t["row_head"] != "")
1754  {
1755  $p_content.= ' HeaderRows="1"';
1756  }
1757  if ($t["row_foot"] != "")
1758  {
1759  $p_content.= ' FooterRows="1"';
1760  }
1761  if ($t["col_head"] != "")
1762  {
1763  $p_content.= ' HeaderCols="1"';
1764  }
1765  if ($t["col_foot"] != "")
1766  {
1767  $p_content.= ' FooterCols="1"';
1768  }
1769  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1770  if (!$a_small_mode)
1771  {
1772  $p_content.= '<Caption>'.$lng->txt("sty_caption").'</Caption>';
1773  }
1774  for($i = 1; $i<=$kr; $i++)
1775  {
1776  $p_content.= '<TableRow>';
1777  for($j = 1; $j<=$kc; $j++)
1778  {
1779  if ($a_small_mode)
1780  {
1781  $cell = '&lt;div style="height:2px;"&gt;&lt;/div&gt;';
1782  }
1783  else
1784  {
1785  $cell = 'xxx';
1786  }
1787  $p_content.= '<TableData><PageContent><Paragraph Characteristic="TableContent">'.$cell.'</Paragraph></PageContent></TableData>';
1788  }
1789  $p_content.= '</TableRow>';
1790  }
1791  $p_content.= '</Table></PageContent>';
1792  }
1793 
1794  if ($a_type == "vaccordion" || $a_type == "haccordion")
1795  {
1796  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1798 
1799  if ($a_small_mode)
1800  {
1801  $c = '&amp;nbsp;';
1802  $h = '&amp;nbsp;';
1803  }
1804  else
1805  {
1806  $c = 'xxx';
1807  $h = 'head';
1808  }
1809  if ($a_type == "vaccordion")
1810  {
1811  $p_content = '<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
1812  if ($a_small_mode)
1813  {
1814  $p_content.= ' ContentWidth="70"';
1815  }
1816  }
1817  else
1818  {
1819  $p_content = '<PageContent><Tabs Type="HorizontalAccordion"';
1820  if ($a_small_mode)
1821  {
1822  $p_content.= ' ContentHeight="40"';
1823  $p_content.= ' ContentWidth="70"';
1824  $c = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';
1825  }
1826  else
1827  {
1828  $p_content.= ' ContentHeight="40"';
1829  }
1830  }
1831  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1832  $p_content.= '<Tab><PageContent><Paragraph>'.$c.'</Paragraph></PageContent>';
1833  $p_content.= '<TabCaption>'.$h.'</TabCaption>';
1834  $p_content.= '</Tab>';
1835  $p_content.= '</Tabs></PageContent>';
1836  }
1837 //echo htmlentities($p_content);
1838  $txml = $a_style->getTemplateXML();
1839 //echo htmlentities($txml);
1840  $p_content.= $txml;
1841  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
1842  $r_content = ilPCTableGUI::_renderTable($p_content, "");
1843 
1844  return $r_content;
1845  }
1846 
1850  function initTemplateForm($a_mode = "create")
1851  {
1852  global $lng, $ilCtrl;
1853 
1854  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1855  $this->form_gui = new ilPropertyFormGUI();
1856 
1857  if ($a_mode == "create")
1858  {
1859  $this->form_gui->setTitle($lng->txt("sty_add_template"));
1860  }
1861  else
1862  {
1863  $this->form_gui->setTitle($lng->txt("sty_edit_template"));
1864  }
1865 
1866  // name
1867  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
1868  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1869  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1870  $name_input->setRequired(true);
1871  $name_input->setSize(30);
1872  $name_input->setMaxLength(30);
1873  $this->form_gui->addItem($name_input);
1874 
1875  // template style classes
1876  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
1877  foreach ($scs as $sc => $st)
1878  {
1879  $sc_input = new ilSelectInputGUI($lng->txt("sty_".$sc."_class"), $sc."_class");
1880  $chars = $this->object->getCharacteristics($st);
1881  $options = array("" => "");
1882  foreach($chars as $char)
1883  {
1884  $options[$char] = $char;
1885  }
1886  $sc_input->setOptions($options);
1887  $this->form_gui->addItem($sc_input);
1888  }
1889 
1890  if ($a_mode == "create")
1891  {
1892  $this->form_gui->addCommandButton("saveTemplate", $lng->txt("save"));
1893  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
1894  }
1895  else
1896  {
1897  $this->form_gui->addCommandButton("refreshTemplate", $lng->txt("save_refresh"));
1898  $this->form_gui->addCommandButton("updateTemplate", $lng->txt("save_return"));
1899  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
1900  }
1901  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1902  }
1903 
1908  {
1909  global $ilCtrl;
1910 
1911  $ilCtrl->redirect($this, "listTemplates");
1912  }
1913 
1918  {
1919  global $tpl, $ilCtrl, $lng;
1920 
1921  $this->initTemplateForm();
1922 
1923  if ($this->form_gui->checkInput())
1924  {
1925  if ($this->object->templateExists($_POST["name"]))
1926  {
1927  $name_input = $this->form_gui->getItemByPostVar("name");
1928  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
1929  }
1930  else
1931  {
1932  $classes = array();
1933  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
1934  {
1935  $classes[$tct] = $_POST[$tct."_class"];
1936  }
1937  $t_id = $this->object->addTemplate($_GET["temp_type"], $_POST["name"], $classes);
1938  $this->object->writeTemplatePreview($t_id,
1939  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
1940  $ilCtrl->redirect($this, "listTemplates");
1941  }
1942  }
1943  $this->form_gui->setValuesByPost();
1944  $tpl->setContent($this->form_gui->getHTML());
1945  }
1946 
1950  function updateTemplateObject($a_refresh = false)
1951  {
1952  global $tpl, $ilCtrl, $lng;
1953 
1954  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
1955  $this->initTemplateForm("edit");
1956 
1957  if ($this->form_gui->checkInput())
1958  {
1959  if ($this->object->templateExists($_POST["name"]) &&
1960  $_POST["name"] != ilObjStyleSheet::lookupTemplateName($_GET["t_id"]))
1961  {
1962  $name_input = $this->form_gui->getItemByPostVar("name");
1963  $name_input->setAlert($lng->txt("sty_template_already_exists"));
1964  }
1965  else
1966  {
1967  $classes = array();
1968  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
1969  {
1970  $classes[$tct] = $_POST[$tct."_class"];
1971  }
1972 
1973  $this->object->updateTemplate($_GET["t_id"],
1974  $_POST["name"], $classes);
1975  $this->object->writeTemplatePreview($_GET["t_id"],
1976  $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"], true));
1977  if(!$a_refresh)
1978  {
1979  $ilCtrl->redirect($this, "listTemplates");
1980  }
1981  }
1982  }
1983 
1984  $this->form_gui->setValuesByPost();
1985  $this->displayTemplateEditForm();
1986  }
1987 
1992  {
1993  global $tpl;
1994 
1995  $a_tpl = new ilTemplate("tpl.template_edit.html", true, true,
1996  "Services/Style");
1997  $this->includeCSS();
1998  $a_tpl->setVariable("FORM", $this->form_gui->getHTML());
1999  $a_tpl->setVariable("PREVIEW", $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"]));
2000  $tpl->setContent($a_tpl->get());
2001  }
2002 
2007  {
2008  $this->updateTemplateObject(true);
2009  }
2010 
2015  {
2016  if ($_GET["t_id"] > 0)
2017  {
2018  $t = $this->object->getTemplate($_GET["t_id"]);
2019 
2020  $values["name"] = $t["name"];
2021  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2022  foreach ($scs as $k => $type)
2023  {
2024  $values[$k."_class"] = $t["classes"][$k];
2025  }
2026  $this->form_gui->setValuesByArray($values);
2027  }
2028  }
2029 
2034  {
2035  global $ilCtrl, $tpl, $lng;
2036 
2037  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
2038  {
2039  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2040  $ilCtrl->redirect($this, "listTemplates");
2041  }
2042  else
2043  {
2044  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2045  $cgui = new ilConfirmationGUI();
2046  $cgui->setFormAction($ilCtrl->getFormAction($this));
2047  $cgui->setHeaderText($lng->txt("sty_confirm_template_deletion"));
2048  $cgui->setCancel($lng->txt("cancel"), "cancelTemplateDeletion");
2049  $cgui->setConfirm($lng->txt("sty_del_template"), "deleteTemplate");
2050 
2051  foreach ($_POST["tid"] as $tid)
2052  {
2053  $classes = $this->object->getTemplateClasses($tid);
2054  $cl_str = "";
2055  $listed = array();
2056  foreach ($classes as $cl)
2057  {
2058  if ($cl != "" && !$listed[$cl])
2059  {
2060  $cl_str.= '<div>- '.
2061  $cl."</div>";
2062  $listed[$cl] = true;
2063  }
2064  }
2065  if ($cl_str != "")
2066  {
2067  $cl_str = '<div style="padding-left:30px;" class="small">'.
2068  "<div><i>".$lng->txt("sty_style_class")."</i></div>".$cl_str."</div>";
2069  }
2070  $cgui->addItem("tid[]", $tid, $this->object->lookupTemplateName($tid).$cl_str);
2071  }
2072 
2073  $cgui->addButton($lng->txt("sty_del_template_keep_classes"), "deleteTemplateKeepClasses");
2074 
2075  $tpl->setContent($cgui->getHTML());
2076  }
2077  }
2078 
2083  {
2084  global $ilCtrl;
2085 
2086  $ilCtrl->redirect($this, "listTemplates");
2087  }
2088 
2093  {
2094  global $ilCtrl;
2095 
2096  if (is_array($_POST["tid"]))
2097  {
2098  foreach ($_POST["tid"] as $tid)
2099  {
2100  $this->object->removeTemplate($tid);
2101  }
2102  }
2103 
2104  $ilCtrl->redirect($this, "listTemplates");
2105  }
2106 
2111  {
2112  global $ilCtrl;
2113 
2114  if (is_array($_POST["tid"]))
2115  {
2116  foreach ($_POST["tid"] as $tid)
2117  {
2118  $cls = $this->object->getTemplateClasses($tid);
2119  foreach ($cls as $k => $cls)
2120  {
2121  $ty = $this->object->determineTemplateStyleClassType($_GET["temp_type"], $k);
2122  $ta = ilObjStyleSheet::_determineTag($ty);
2123  $this->object->deleteCharacteristic($ty, $ta, $cls);
2124  }
2125  $this->object->removeTemplate($tid);
2126  }
2127  }
2128 
2129  $ilCtrl->redirect($this, "listTemplates");
2130  }
2131 
2136  {
2137  global $tpl;
2138 
2139  $this->initTemplateGenerationForm();
2140  $tpl->setContent($this->form_gui->getHTML());
2141  }
2142 
2147  {
2148  global $lng, $ilCtrl;
2149 
2150  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2151  $this->form_gui = new ilPropertyFormGUI();
2152 
2153  $this->form_gui->setTitle($lng->txt("sty_generate_template"));
2154 
2155  // name
2156  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2157  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2158  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2159  $name_input->setRequired(true);
2160  $name_input->setSize(30);
2161  $name_input->setMaxLength(30);
2162  $this->form_gui->addItem($name_input);
2163 
2164  // basic layout
2165  $bl_input = new ilSelectInputGUI($lng->txt("sty_template_layout"), "layout");
2166  $options = array(
2167  "coloredZebra" => $lng->txt("sty_table_template_colored_zebra"),
2168  "bwZebra" => $lng->txt("sty_table_template_bw_zebra"),
2169  "noZebra" => $lng->txt("sty_table_template_no_zebra")
2170  );
2171  $bl_input->setOptions($options);
2172  $this->form_gui->addItem($bl_input);
2173 
2174  // top bottom padding
2175  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
2176  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_top_bottom_padding"), "tb_padding");
2177  $num_input->setAllowPercentage(false);
2178  $num_input->setValue("3px");
2179  $this->form_gui->addItem($num_input);
2180 
2181  // left right padding
2182  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_left_right_padding"), "lr_padding");
2183  $num_input->setAllowPercentage(false);
2184  $num_input->setValue("10px");
2185  $this->form_gui->addItem($num_input);
2186 
2187  // base color
2188  $bc_input = new ilSelectInputGUI($lng->txt("sty_base_color"), "base_color");
2189  $cs = $this->object->getColors();
2190  $options = array();
2191  foreach ($cs as $c)
2192  {
2193  $options[$c["name"]] = $c["name"];
2194  }
2195  $bc_input->setOptions($options);
2196  $this->form_gui->addItem($bc_input);
2197 
2198  // Lightness Settings
2199  $lss = array("border" => 90, "header_text" => 70, "header_bg" => 0,
2200  "cell1_text" => -60, "cell1_bg" => 90, "cell2_text" => -60, "cell2_bg" => 75);
2201  foreach ($lss as $ls => $v)
2202  {
2203  $l_input = new ilNumberInputGUI($lng->txt("sty_lightness_".$ls), "lightness_".$ls);
2204  $l_input->setMaxValue(100);
2205  $l_input->setMinValue(-100);
2206  $l_input->setValue($v);
2207  $l_input->setSize(4);
2208  $l_input->setMaxLength(4);
2209  $this->form_gui->addItem($l_input);
2210  }
2211 
2212  $this->form_gui->addCommandButton("templateGeneration", $lng->txt("generate"));
2213  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2214  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2215  }
2216 
2221  {
2222  global $tpl, $ilCtrl, $lng;
2223 
2224  $this->initTemplateGenerationForm();
2225 
2226  if ($this->form_gui->checkInput())
2227  {
2228  if ($this->object->templateExists($_POST["name"]))
2229  {
2230  $name_input = $this->form_gui->getItemByPostVar("name");
2231  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2232  }
2233  else
2234  {
2235  // -> move to application class!
2236 
2237  // cell classes
2238  $cells = array("H" => "header", "C1" => "cell1", "C2" => "cell2");
2239  $tb_p = $this->form_gui->getItemByPostVar("tb_padding");
2240  $tb_padding = $tb_p->getValue();
2241  $lr_p = $this->form_gui->getItemByPostVar("lr_padding");
2242  $lr_padding = $lr_p->getValue();
2243  $cell_color = $_POST["base_color"];
2244 
2245  // use mid gray as cell color for bw zebra
2246  if ($_POST["layout"] == "bwZebra")
2247  {
2248  $cell_color = "MidGray";
2249  if (!$this->object->colorExists($cell_color))
2250  {
2251  $this->object->addColor($cell_color, "7F7F7F");
2252  }
2253  $this->object->updateColor($cell_color, $cell_color, "7F7F7F");
2254  }
2255 
2256  foreach ($cells as $k => $cell)
2257  {
2258  $cell_class[$k] = $_POST["name"].$k;
2259  if (!$this->object->characteristicExists($cell_class[$k], "table_cell"))
2260  {
2261  $this->object->addCharacteristic("table_cell", $cell_class[$k], true);
2262  }
2263  if ($_POST["layout"] == "bwZebra" && $k == "H")
2264  {
2265  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2266  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2267  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2268  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2269  }
2270  else
2271  {
2272  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2273  "!".$cell_color."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2274  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2275  "!".$cell_color."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2276  }
2277  $this->object->replaceStylePar("td", $cell_class[$k], "padding-top",
2278  $tb_padding, "table_cell");
2279  $this->object->replaceStylePar("td", $cell_class[$k], "padding-bottom",
2280  $tb_padding, "table_cell");
2281  $this->object->replaceStylePar("td", $cell_class[$k], "padding-left",
2282  $lr_padding, "table_cell");
2283  $this->object->replaceStylePar("td", $cell_class[$k], "padding-right",
2284  $lr_padding, "table_cell");
2285  $this->object->replaceStylePar("td", $cell_class[$k], "border-width",
2286  "1px", "table_cell");
2287  $this->object->replaceStylePar("td", $cell_class[$k], "border-style",
2288  "solid", "table_cell");
2289  $this->object->replaceStylePar("td", $cell_class[$k], "border-color",
2290  "!".$cell_color."(".$_POST["lightness_border"].")", "table_cell");
2291  $this->object->replaceStylePar("td", $cell_class[$k], "font-weight",
2292  "normal", "table_cell");
2293  }
2294 
2295  // table class
2296  $classes["table"] = $_POST["name"]."T";
2297  if (!$this->object->characteristicExists($classes["table"], "table"))
2298  {
2299  $this->object->addCharacteristic("table", $classes["table"], true);
2300  }
2301  $this->object->replaceStylePar("table", $classes["table"], "caption-side",
2302  "bottom", "table");
2303  $this->object->replaceStylePar("table", $classes["table"], "border-collapse",
2304  "collapse", "table");
2305  $this->object->replaceStylePar("table", $classes["table"], "margin-top",
2306  "5px", "table");
2307  $this->object->replaceStylePar("table", $classes["table"], "margin-bottom",
2308  "5px", "table");
2309  if ($_POST["layout"] == "bwZebra")
2310  {
2311  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-color",
2312  "!".$_POST["base_color"], "table");
2313  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-style",
2314  "solid", "table");
2315  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-width",
2316  "3px", "table");
2317  $sb = array("left", "right", "top");
2318  foreach ($sb as $b)
2319  {
2320  $this->object->replaceStylePar("table", $classes["table"], "border-".$b."-width",
2321  "0px", "table");
2322  }
2323  }
2324 
2325  switch ($_POST["layout"])
2326  {
2327  case "coloredZebra":
2328  $classes["row_head"] = $cell_class["H"];
2329  $classes["odd_row"] = $cell_class["C1"];
2330  $classes["even_row"] = $cell_class["C2"];
2331  break;
2332 
2333  case "bwZebra":
2334  $classes["row_head"] = $cell_class["H"];
2335  $classes["odd_row"] = $cell_class["C1"];
2336  $classes["even_row"] = $cell_class["C2"];
2337  break;
2338 
2339  case "noZebra":
2340  $classes["row_head"] = $cell_class["H"];
2341  $classes["odd_row"] = $cell_class["C1"];
2342  $classes["even_row"] = $cell_class["C1"];
2343  $classes["col_head"] = $cell_class["C2"];
2344  break;
2345  }
2346 
2347 
2348  $t_id = $this->object->addTemplate($_GET["temp_type"],
2349  $_POST["name"], $classes);
2350  $this->object->writeTemplatePreview($t_id,
2351  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2352  $ilCtrl->redirect($this, "listTemplates");
2353  }
2354  }
2355  $this->form_gui->setValuesByPost();
2356  $tpl->setContent($this->form_gui->getHTML());
2357  }
2358 
2360  {
2361  global $tpl;
2362 
2363  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2364 
2365  $acc = new ilAccordionGUI();
2366  $acc->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2367  $acc->addItem("Header 2", str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx x xx x xx", 30));
2368  $acc->setOrientation(ilAccordionGUI::HORIZONTAL);
2369 
2370  $ac2 = new ilAccordionGUI();
2371  $ac2->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2372  $ac2->addItem("Header 2", $acc->getHTML());
2373  $ac2->setOrientation(ilAccordionGUI::VERTICAL);
2374 
2375  $tpl->setContent($ac2->getHTML());
2376  }
2377 
2382  {
2383  global $ilCtrl;
2384 
2385  if ($_GET["baseClass"] == "ilAdministrationGUI")
2386  {
2387  $ilCtrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
2388  }
2389  $ilCtrl->returnToParent($this);
2390  }
2391 
2392 }
2393 ?>