ILIAS  Release_4_1_x_branch Revision 61804
 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, $ilToolbar;
126 
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  $ilTabs->setSubTabActive("sty_".$style_type."_char");
141 
142  // add new style?
143  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
144  $subtypes = $all_super_types[$style_type];
145  $expandable = false;
146  foreach ($subtypes as $t)
147  {
149  {
150  $expandable = true;
151  }
152  }
153  if ($expandable)
154  {
155  $ilToolbar->addButton($lng->txt("sty_add_characteristic"),
156  $ilCtrl->getLinkTarget($this, "addCharacteristicForm"));
157  }
158 
159  if ($_SESSION["sty_copy"] != "")
160  {
161  $style_cp = explode(":::", $_SESSION["sty_copy"]);
162  if ($style_cp[1] == $_GET["style_type"])
163  {
164  if ($expandable)
165  {
166  $ilToolbar->addSeparator();
167  }
168  $ilToolbar->addButton($lng->txt("sty_paste_style_classes"),
169  $ilCtrl->getLinkTarget($this, "pasteCharacteristicsOverview"));
170  }
171  }
172 
173  include_once("./Services/Style/classes/class.ilStyleTableGUI.php");
174  $table_gui = new ilStyleTableGUI($this, "edit", $chars, $style_type,
175  $this->object);
176 
177  $ctpl->setCurrentBlock("style_table");
178  $ctpl->setVariable("STYLE_TABLE", $table_gui->getHTML());
179  $ctpl->parseCurrentBlock();
180 
181  $this->tpl->setContent($ctpl->get());
182  }
183 
187  function propertiesObject()
188  {
189  global $rbacsystem, $lng;
190 
191  // set style sheet
192  $this->tpl->setCurrentBlock("ContentStyle");
193  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
194  $this->object->getContentStylePath($this->object->getId()));
195  $this->tpl->parseCurrentBlock();
196 
197  // add button button
198  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
199 
200  // export button
201  $this->tpl->setCurrentBlock("btn_cell");
202  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportStyle"));
203  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("export"));
204  $this->tpl->parseCurrentBlock();
205 
206  $this->initPropertiesForm();
207  $this->getPropertiesValues();
208  $this->tpl->setContent($this->form->getHTML());
209 
210 /*
211  $this->getTemplateFile("edit", "sty");
212  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
213 
214  // title and description
215  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
216  $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
217  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
218  $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
219  $this->tpl->parseCurrentBlock();
220 
221  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
222  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
223  $this->tpl->setVariable("BTN_SAVE", "update");
224  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
225 */
226  }
227 
232  public function getPropertiesValues()
233  {
234  $values = array();
235 
236  $values["style_title"] = $this->object->getTitle();
237  $values["style_description"] = $this->object->getDescription();
238  $values["disable_auto_margins"] = (int) $this->object->lookupStyleSetting("disable_auto_margins");
239 
240  $this->form->setValuesByArray($values);
241  }
242 
248  public function initPropertiesForm($a_mode = "edit")
249  {
250  global $lng;
251  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
252  $this->form = new ilPropertyFormGUI();
253 
254  // title
255  $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
256  $ti->setMaxLength(128);
257  $ti->setSize(40);
258  $ti->setRequired(true);
259  $this->form->addItem($ti);
260 
261  // description
262  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
263  //$ta->setCols();
264  //$ta->setRows();
265  $this->form->addItem($ta);
266 
267  // disable automatic margins for left/right alignment
268  $cb = new ilCheckboxInputGUI($this->lng->txt("sty_disable_auto_margins"), "disable_auto_margins");
269  $cb->setInfo($this->lng->txt("sty_disable_auto_margins_info"));
270  $this->form->addItem($cb);
271 
272 
273  // save and cancel commands
274  if ($a_mode == "create")
275  {
276  $this->form->addCommandButton("save", $lng->txt("save"));
277  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
278  }
279  else
280  {
281  $this->form->addCommandButton("update", $lng->txt("save"));
282  }
283 
284  $this->form->setTitle($lng->txt("edit_stylesheet"));
285  $this->form->setFormAction($this->ctrl->getFormAction($this));
286 
287  }
288 
292  function updateObject()
293  {
294  global $lng, $ilCtrl, $tpl;
295 
296  $this->initPropertiesForm("edit");
297  if ($this->form->checkInput())
298  {
299  $this->object->setTitle($this->form->getInput("style_title"));
300  $this->object->setDescription($this->form->getInput("style_description"));
301  $this->object->writeStyleSetting("disable_auto_margins",
302  $this->form->getInput("disable_auto_margins"));
303  $this->object->update();
304  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
305  $ilCtrl->redirect($this, "properties");
306  }
307  else
308  {
309  $this->form->setValuesByPost();
310  $tpl->setContent($this->form->getHtml());
311  }
312  }
313 
318  {
319  global $ilCtrl;
320 
321  $cur = explode(".",$_GET["tag"]);
322  $cur_tag = $cur[0];
323  $cur_class = $cur[1];
324 
325  $this->initTagStyleForm("edit", $cur_tag);
326 
327  if ($this->form_gui->checkInput())
328  {
329  $this->saveTagStyle();
330  $ilCtrl->redirect($this, "editTagStyle");
331  }
332  else
333  {
334  $this->form_gui->setValuesByPost();
335  $this->outputTagStyleEditScreen();
336  }
337  }
338 
343  {
344  global $ilCtrl;
345 
346  $cur = explode(".",$_GET["tag"]);
347  $cur_tag = $cur[0];
348  $cur_class = $cur[1];
349 
350  $this->initTagStyleForm("edit", $cur_tag);
351  if ($this->form_gui->checkInput())
352  {
353  $this->saveTagStyle();
354  $ilCtrl->redirect($this, "edit");
355  }
356  else
357  {
358  $this->form_gui->setValuesByPost();
359  $this->outputTagStyleEditScreen();
360  }
361  }
362 
366  function saveTagStyle()
367  {
368  $cur = explode(".", $_GET["tag"]);
369  $cur_tag = $cur[0];
370  $cur_class = $cur[1];
371  $avail_pars = ilObjStyleSheet::_getStyleParameters($cur_tag);
372  foreach ($avail_pars as $par => $v)
373  {
374  $var = str_replace("-", "_", $par);
375  $basepar_arr = explode(".", $par);
376  $basepar = $basepar_arr[0];
377 //var_dump($basepar_arr);
378  if ($basepar_arr[1] != "" && $basepar_arr[1] != $cur_tag)
379  {
380  continue;
381  }
382 
383  switch ($v["input"])
384  {
385  case "fontsize":
386  case "numeric_no_perc":
387  case "numeric":
388  case "background_image":
389  $in = $this->form_gui->getItemByPostVar($basepar);
390 //echo "<br>-".$cur_tag."-".$cur_class."-".$basepar."-".$_GET["style_type"]."-";
391  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
392  break;
393 
394  case "color":
395  $color = trim($_POST[$basepar]);
396  if ($color != "" && trim(substr($color,0,1) != "!"))
397  {
398  $color = "#".$color;
399  }
400  $this->writeStylePar($cur_tag, $cur_class, $basepar, $color, $_GET["style_type"]);
401  break;
402 
403  case "trbl_numeric":
404  case "border_width":
405  case "border_style":
406  $in = $this->form_gui->getItemByPostVar($basepar);
407  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0], $in->getAllValue(), $_GET["style_type"]);
408  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1], $in->getTopValue(), $_GET["style_type"]);
409  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2], $in->getRightValue(), $_GET["style_type"]);
410  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3], $in->getBottomValue(), $_GET["style_type"]);
411  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4], $in->getLeftValue(), $_GET["style_type"]);
412  break;
413 
414  case "trbl_color":
415  $in = $this->form_gui->getItemByPostVar($basepar);
416  $tblr_p = array (0 => "getAllValue", 1 => "getTopValue", 2 => "getRightValue",
417  3 => "getBottomValue", 4 => "getLeftValue");
418  foreach ($tblr_p as $k => $func)
419  {
420  $val = trim($in->$func());
421  $val = (($in->getAcceptNamedColors() && substr($val, 0, 1) == "!")
422  || $val == "")
423  ? $val
424  : "#".$val;
425  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][$k], $val, $_GET["style_type"]);
426  }
427  /*$this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0],
428  trim($in->getAllValue() != "") ? "#".$in->getAllValue() : "", $_GET["style_type"]);
429  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1],
430  trim($in->getTopValue() != "") ? "#".$in->getTopValue() : "", $_GET["style_type"]);
431  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2],
432  trim($in->getRightValue() != "") ? "#".$in->getRightValue() : "", $_GET["style_type"]);
433  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3],
434  trim($in->getBottomValue() != "") ? "#".$in->getBottomValue() : "", $_GET["style_type"]);
435  $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4],
436  trim($in->getLeftValue() != "") ? "#".$in->getLeftValue() : "", $_GET["style_type"]);
437  */
438  break;
439 
440  case "background_position":
441  $in = $this->form_gui->getItemByPostVar($basepar);
442  $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"]);
443  break;
444 
445  default:
446  $this->writeStylePar($cur_tag, $cur_class, $basepar, $_POST[$basepar], $_GET["style_type"]);
447  break;
448  }
449  }
450 
451  $this->object->update();
452  }
453 
454  function writeStylePar($cur_tag, $cur_class, $par, $value, $a_type)
455  {
456  if ($a_type == "")
457  {
458  return;
459  }
460 
461  if ($value != "")
462  {
463  $this->object->replaceStylePar($cur_tag, $cur_class, $par, $value, $a_type);
464  }
465  else
466  {
467  $this->object->deleteStylePar($cur_tag, $cur_class, $par, $a_type);
468  }
469  }
470 
476  {
477  global $tpl;
478 
479  $cur = explode(".",$_GET["tag"]);
480  $cur_tag = $cur[0];
481  $cur_class = $cur[1];
482 
483  $this->initTagStyleForm("edit", $cur_tag);
484  $this->getValues();
485  $this->outputTagStyleEditScreen();
486  }
487 
492  {
493  global $tpl, $ilCtrl, $lng;
494 
495  // set style sheet
496  $tpl->setCurrentBlock("ContentStyle");
497  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
498  $this->object->getContentStylePath($this->object->getId()));
499 
500  $ts_tpl = new ilTemplate("tpl.style_tag_edit.html", true, true, "Services/Style");
501 
502  $cur = explode(".",$_GET["tag"]);
503  $cur_tag = $cur[0];
504  $cur_class = $cur[1];
505 
506  $ts_tpl->setVariable("EXAMPLE",
507  ilObjStyleSheetGUI::getStyleExampleHTML($_GET["style_type"], $cur_class));
508 
509  $ts_tpl->setVariable("FORM",
510  $this->form_gui->getHtml());
511 
512  $tpl->setTitle($cur_class." (".$lng->txt("sty_type_".$_GET["style_type"]).")");
513 
514  $tpl->setContent($ts_tpl->get());
515  }
516 
517 
523  public function initTagStyleForm($a_mode, $a_cur_tag)
524  {
525  global $lng;
526 
527  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
528  $this->form_gui = new ilPropertyFormGUI();
529 
530  $avail_pars = $this->object->getAvailableParameters();
531  $groups = $this->object->getStyleParameterGroups();
532 
533  // output select lists
534  foreach ($groups as $k => $group)
535  {
536  // filter groups of properties that should only be
537  // displayed with matching tag
538  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
539  if (is_array($filtered_groups[$k]) && !in_array($a_cur_tag, $filtered_groups[$k]))
540  {
541  continue;
542  }
543 
544  $sh = new ilFormSectionHeaderGUI();
545  $sh->setTitle($lng->txt("sty_".$k));
546  $this->form_gui->addItem($sh);
547 
548  foreach ($group as $par)
549  {
550  $basepar = explode(".", $par);
551  $basepar = $basepar[0];
552 
553  $var = str_replace("-", "_", $basepar);
554  $up_par = strtoupper($var);
555 
557  {
558  case "select":
559  $sel_input = new ilSelectInputGUI($lng->txt("sty_".$var), $basepar);
560  $options = array("" => "");
561  foreach ($avail_pars[$par] as $p)
562  {
563  $options[$p] = $p;
564  }
565  $sel_input->setOptions($options);
566  $this->form_gui->addItem($sel_input);
567  break;
568 
569  case "text":
570  $text_input = new ilTextInputGUI($lng->txt("sty_".$var), $basepar);
571  $text_input->setMaxLength(200);
572  $text_input->setSize(20);
573  $this->form_gui->addItem($text_input);
574  break;
575 
576  case "fontsize":
577  include_once("./Services/Style/classes/class.ilFontSizeInputGUI.php");
578  $fs_input = new ilFontSizeInputGUI($lng->txt("sty_".$var), $basepar);
579  $this->form_gui->addItem($fs_input);
580  break;
581 
582  case "numeric_no_perc":
583  case "numeric":
584  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
585  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
586  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "numeric_no_perc")
587  {
588  $num_input->setAllowPercentage(false);
589  }
590  $this->form_gui->addItem($num_input);
591  break;
592 
593  case "percentage":
594  $per_input = new ilNumberInputGUI($lng->txt("sty_".$var), $basepar);
595  $per_input->setMinValue(0);
596  $per_input->setMaxValue(100);
597  $per_input->setMaxLength(3);
598  $per_input->setSize(3);
599  $this->form_gui->addItem($per_input);
600  break;
601 
602  case "color":
603  //include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
604  $col_input = new ilColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
605  $col_input->setDefaultColor("");
606  $col_input->setAcceptNamedColors(true);
607  $this->form_gui->addItem($col_input);
608  break;
609 
610  case "trbl_numeric":
611  include_once("./Services/Style/classes/class.ilTRBLNumericStyleValueInputGUI.php");
612  $num_input = new ilTRBLNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
613  if (ilObjStyleSheet::_getStyleParameterInputType($par) == "trbl_numeric_no_perc")
614  {
615  $num_input->setAllowPercentage(false);
616  }
617  $this->form_gui->addItem($num_input);
618  break;
619 
620  case "border_width":
621  include_once("./Services/Style/classes/class.ilTRBLBorderWidthInputGUI.php");
622  $bw_input = new ilTRBLBorderWidthInputGUI($lng->txt("sty_".$var), $basepar);
623  $this->form_gui->addItem($bw_input);
624  break;
625 
626  case "border_style":
627  include_once("./Services/Style/classes/class.ilTRBLBorderStyleInputGUI.php");
628  $bw_input = new ilTRBLBorderStyleInputGUI($lng->txt("sty_".$var), $basepar);
629  $this->form_gui->addItem($bw_input);
630  break;
631 
632  case "trbl_color":
633  include_once("./Services/Style/classes/class.ilTRBLColorPickerInputGUI.php");
634  $col_input = new ilTRBLColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
635  $col_input->setAcceptNamedColors(true);
636  $this->form_gui->addItem($col_input);
637  break;
638 
639  case "background_image":
640  include_once("./Services/Style/classes/class.ilBackgroundImageInputGUI.php");
641  $im_input = new ilBackgroundImageInputGUI($lng->txt("sty_".$var), $basepar);
642  $imgs = array();
643  foreach ($this->object->getImages() as $entry)
644  {
645  $imgs[] = $entry["entry"];
646  }
647  $im_input->setImages($imgs);
648  $this->form_gui->addItem($im_input);
649  break;
650 
651  case "background_position":
652  include_once("./Services/Style/classes/class.ilBackgroundPositionInputGUI.php");
653  $im_input = new ilBackgroundPositionInputGUI($lng->txt("sty_".$var), $basepar);
654  $this->form_gui->addItem($im_input);
655  break;
656  }
657  }
658  }
659 
660  // save and cancel commands
661  $this->form_gui->addCommandButton("updateTagStyle", $lng->txt("save_return"));
662  $this->form_gui->addCommandButton("refreshTagStyle", $lng->txt("save_refresh"));
663 
664 // $this->form_gui->setTitle($lng->txt("edit"));
665  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
666  }
667 
672  public function getValues()
673  {
674  $style = $this->object->getStyle();
675  $cur = explode(".",$_GET["tag"]);
676  $cur_tag = $cur[0];
677  $cur_class = $cur[1];
678  $cur_parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style, $_GET["style_type"]);
679 
680  $parameters = ilObjStyleSheet::_getStyleParameters();
681  foreach($parameters as $p => $v)
682  {
683  $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
684  if (is_array($filtered_groups[$v["group"]]) && !in_array($cur_tag, $filtered_groups[$v["group"]]))
685  {
686  continue;
687  }
688  $p = explode(".", $p);
689  $p = $p[0];
690  $input = $this->form_gui->getItemByPostVar($p);
691  switch ($v["input"])
692  {
693  case "":
694  break;
695 
696  case "trbl_numeric":
697  case "border_width":
698  case "border_style":
699  case "trbl_color":
700  $input->setAllValue($cur_parameters[$v["subpar"][0]]);
701  $input->setTopValue($cur_parameters[$v["subpar"][1]]);
702  $input->setRightValue($cur_parameters[$v["subpar"][2]]);
703  $input->setBottomValue($cur_parameters[$v["subpar"][3]]);
704  $input->setLeftValue($cur_parameters[$v["subpar"][4]]);
705  break;
706 
707  default:
708  $input->setValue($cur_parameters[$p]);
709  break;
710  }
711  }
712  }
713 
717  function exportStyleObject()
718  {
719  $file = $this->object->export();
720 
721  ilUtil::deliverFile($file, "sty_".$this->object->getId().".zip");
722  }
723 
724  function extractParametersOfTag($a_tag, $a_class, $a_style, $a_type)
725  {
726  $parameters = array();
727  foreach($a_style as $tag)
728  {
729  foreach($tag as $par)
730  {
731  if ($par["tag"] == $a_tag && $par["class"] == $a_class
732  && $par["type"] == $a_type)
733  {
734  $parameters[$par["parameter"]] = $par["value"];
735  }
736  }
737  }
738  return $parameters;
739  }
740 
745  {
746  $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
747  $this->editObject();
748  }
749 
753  function refreshObject()
754  {
755  //$class_name = "ilObjStyleSheet";
756  //require_once("classes/class.ilObjStyleSheet.php");
757  $this->object->setTitle($_POST["style_title"]);
758  $this->object->setDescription($_POST["style_description"]);
759 
760  foreach($_POST["styval"] as $id => $value)
761  {
762  $this->object->updateStyleParameter($id, $value);
763  }
764  $this->object->update();
765  $this->editObject();
766  }
767 
773  function deleteObject($a_error = false)
774  {
775  //$this->setTabs();
776 
777  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
778 
779  if(!$a_error)
780  {
781  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
782  }
783 
784  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
785 
786  // BEGIN TABLE HEADER
787  $this->tpl->setCurrentBlock("table_header");
788  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
789  $this->tpl->parseCurrentBlock();
790 
791  // END TABLE HEADER
792 
793  // BEGIN TABLE DATA
794  $counter = 0;
795 
796  $this->tpl->setCurrentBlock("table_row");
797  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
798  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
799  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
800  $this->tpl->parseCurrentBlock();
801 
802  // END TABLE DATA
803 
804  // BEGIN OPERATION_BTN
805  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
806  "cancelDelete" => $this->lng->txt("cancel"));
807  foreach ($buttons as $name => $value)
808  {
809  $this->tpl->setCurrentBlock("operation_btn");
810  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
811  $this->tpl->setVariable("BTN_NAME",$name);
812  $this->tpl->setVariable("BTN_VALUE",$value);
813  $this->tpl->parseCurrentBlock();
814  }
815  }
816 
817 
822  {
823  $this->ctrl->returnToParent($this);
824  }
825 
830  {
831  global $ilias;
832 
833  $this->object->delete();
834 
835  $this->ctrl->returnToParent($this);
836  }
837 
842  {
843  if (is_array($_POST["sty_select"]))
844  {
845  foreach($_POST["sty_select"] as $id => $dummy)
846  {
847  $this->object->deleteParameter($id);
848  }
849  }
850  $this->object->read();
851  $this->object->writeCSSFile();
852  $this->editObject();
853  }
854 
858  function saveObject()
859  {
860 //echo "HH"; exit;
861  $class_name = "ilObjStyleSheet";
862  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
863  $newObj = new ilObjStyleSheet();
864  $newObj->setTitle("-");
865  $newObj->create();
866  $newObj->setTitle(ilUtil::stripSlashes($_POST["style_title"]));
867  $newObj->setDescription(ilUtil::stripSlashes($_POST["style_description"]));
868  $newObj->update();
869 
870  // assign style to style sheet folder,
871  // if parent is style sheet folder
872  if ($_GET["ref_id"] > 0)
873  {
874 
875  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
876  if ($fold->getType() == "stys")
877  {
878  $fold->addStyle($newObj->getId());
879  $fold->update();
880  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
881  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
882  }
883  }
884 
885  return $newObj->getId();
886  }
887 
891  function copyStyleObject()
892  {
893  global $ilias;
894 
895  if ($_POST["source_style"] > 0)
896  $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
897  $new_id = $style_obj->ilClone();
898 
899  // assign style to style sheet folder,
900  // if parent is style sheet folder
901  if ($_GET["ref_id"] > 0)
902  {
903 
904  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
905  if ($fold->getType() == "stys")
906  {
907  $fold->addStyle($new_id);
908  $fold->update();
909  ilObjStyleSheet::_writeStandard($new_id, "1");
910  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
911  }
912  }
913 
914  return $new_id;
915  }
916 
920  function importStyleObject()
921  {
922  // check file
923  $source = $_FILES["stylefile"]["tmp_name"];
924  if (($source == 'none') || (!$source))
925  {
926  $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
927  }
928 
929  // check correct file type
930  $info = pathinfo($_FILES["stylefile"]["name"]);
931  if (strtolower($info["extension"]) != "zip" && strtolower($info["extension"]) != "xml")
932  {
933  $this->ilias->raiseError("File must be a zip or xml file!",$this->ilias->error_obj->MESSAGE);
934  }
935 
936  $class_name = "ilObjStyleSheet";
937  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
938  $newObj = new ilObjStyleSheet();
939  //$newObj->setTitle();
940  //$newObj->setDescription($_POST["style_description"]);
941  $newObj->import($_FILES["stylefile"]);
942  //$newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
943 
944  // assign style to style sheet folder,
945  // if parent is style sheet folder
946  if ($_GET["ref_id"] > 0)
947  {
948 
949  $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
950  if ($fold->getType() == "stys")
951  {
952  $fold->addStyle($newObj->getId());
953  $fold->update();
954  ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
955  $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
956  }
957  }
958 
959  return $newObj->getId();
960  }
961 
965  function cancelObject()
966  {
967  global $lng;
968 
969  ilUtil::sendInfo($lng->txt("msg_cancel"), true);
970  $this->ctrl->returnToParent($this);
971  }
972 
976  function getAdminTabs(&$tabs_gui)
977  {
978  $this->getTabs($tabs_gui);
979  }
980 
984  function setTabs()
985  {
986  global $lng;
987 
988  $this->getTabs($this->tabs_gui);
989 
990  if (strtolower(get_class($this->object)) == "ilobjstylesheet")
991  {
992  $this->tpl->setVariable("HEADER", $this->object->getTitle());
993  }
994  else
995  {
996  $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
997  }
998  }
999 
1005  function getTabs(&$tabs_gui)
1006  {
1007  global $lng, $ilCtrl, $ilTabs;
1008 
1009  if ($ilCtrl->getCmd() == "editTagStyle")
1010  {
1011  // back to upper context
1012  $tabs_gui->setBackTarget($lng->txt("back"),
1013  $ilCtrl->getLinkTarget($this, "edit"));
1014 
1015  $t = explode(".", $_GET["tag"]);
1016  $t2 = explode(":", $t[1]);
1017  $pc = $this->object->_getPseudoClasses($t[0]);
1018  if (is_array($pc) && count($pc) > 0)
1019  {
1020  // style classes
1021  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0]);
1022  $tabs_gui->addTarget("sty_tag_normal",
1023  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1024  get_class($this));
1025  if ($t2[1] == "")
1026  {
1027  $ilTabs->setTabActive("sty_tag_normal");
1028  }
1029 
1030  foreach ($pc as $p)
1031  {
1032  // style classes
1033  $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0].":".$p);
1034  $tabs_gui->addTarget("sty_tag_".$p,
1035  $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1036  get_class($this));
1037  if ($t2[1] == $p)
1038  {
1039  $ilTabs->setTabActive("sty_tag_".$p);
1040  }
1041  }
1042  $ilCtrl->setParameter($this, "tag", $_GET["tag"]);
1043  }
1044  }
1045  else
1046  {
1047  // back to upper context
1048  $tabs_gui->setBackTarget($lng->txt("back"),
1049  $this->ctrl->getLinkTarget($this, "returnToUpperContext"));
1050 
1051  // style classes
1052  $tabs_gui->addTarget("sty_style_chars",
1053  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1054  get_class($this));
1055 
1056  // colors
1057  $tabs_gui->addTarget("sty_colors",
1058  $this->ctrl->getLinkTarget($this, "listColors"), "listColors",
1059  get_class($this));
1060 
1061  // images
1062  $tabs_gui->addTarget("sty_images",
1063  $this->ctrl->getLinkTarget($this, "listImages"), "listImages",
1064  get_class($this));
1065 
1066  // table templates
1067  $tabs_gui->addTarget("sty_templates",
1068  $this->ctrl->getLinkTarget($this, "listTemplates"), "listTemplates",
1069  get_class($this));
1070 
1071  // settings
1072  $tabs_gui->addTarget("settings",
1073  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1074  get_class($this));
1075 
1076  // accordiontest
1077 /*
1078  $tabs_gui->addTarget("accordiontest",
1079  $this->ctrl->getLinkTarget($this, "accordiontest"), "accordiontest",
1080  get_class($this));*/
1081  }
1082 
1083  }
1084 
1090  function setSubTabs()
1091  {
1092  global $lng, $ilTabs, $ilCtrl;
1093 
1095 
1096  foreach ($types as $super_type => $types)
1097  {
1098  // text block characteristics
1099  $ilCtrl->setParameter($this, "style_type", $super_type);
1100  $ilTabs->addSubTabTarget("sty_".$super_type."_char",
1101  $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1102  get_class($this));
1103  }
1104 
1105  $ilCtrl->setParameter($this, "style_type", $_GET["style_type"]);
1106  }
1107 
1114  {
1115  global $lng, $ilTabs, $ilCtrl;
1116 
1118 
1119  foreach ($types as $t => $c)
1120  {
1121  $ilCtrl->setParameter($this, "temp_type", $t);
1122  $ilTabs->addSubTabTarget("sty_".$t."_templates",
1123  $this->ctrl->getLinkTarget($this, "listTemplates"), array("listTemplates", ""),
1124  get_class($this));
1125  }
1126 
1127  $ilCtrl->setParameter($this, "temp_type", $_GET["temp_type"]);
1128  }
1129 
1135  {
1136  global $ilLocator;
1137 
1138  if ($_GET["admin_mode"] == "settings") // system settings
1139  {
1140  $ilLocator->addItem($this->lng->txt("administration"),
1141  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
1142  ilFrameTargetInfo::_getFrame("MainContent"));
1143 
1144  $ilLocator->addItem(ilObject::_lookupTitle(
1145  ilObject::_lookupObjId($_GET["ref_id"])),
1146  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
1147 
1148  if ($_GET["obj_id"] > 0)
1149  {
1150  $ilLocator->addItem($this->object->getTitle(),
1151  $this->ctrl->getLinkTarget($this, "edit"));
1152  }
1153  }
1154  else // repository administration
1155  {
1156  //?
1157  }
1158 
1159  }
1160 
1161  function showUpperIcon()
1162  {
1163  global $tree, $tpl, $objDefinition;
1164 
1165  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1166  {
1167  $tpl->setUpperIcon(
1168  $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
1169  "editContentStyles"));
1170  }
1171  else
1172  {
1173  // ?
1174  }
1175  }
1176 
1180  function listImagesObject()
1181  {
1182  global $tpl;
1183 
1184  include_once("./Services/Style/classes/class.ilStyleImageTableGUI.php");
1185  $table_gui = new ilStyleImageTableGUI($this, "listImages",
1186  $this->object);
1187  $tpl->setContent($table_gui->getHTML());
1188 
1189  }
1190 
1194  function addImageObject()
1195  {
1196  global $tpl;
1197 
1198  $this->initImageForm();
1199  $tpl->setContent($this->form_gui->getHTML());
1200  }
1201 
1206  {
1207  global $ilCtrl;
1208 
1209  $ilCtrl->redirect($this, "listImages");
1210  }
1211 
1216  {
1217  global $tpl, $ilCtrl;
1218 
1219  $this->initImageForm();
1220 
1221  if ($this->form_gui->checkInput())
1222  {
1223  $this->object->uploadImage($_FILES["image_file"]);
1224  $ilCtrl->redirect($this, "listImages");
1225  }
1226  else
1227  {
1228  //$this->form_gui->setImageFormValuesByPost();
1229  $tpl->setContent($this->form_gui->getHTML());
1230  }
1231 
1232  }
1233 
1237  function initImageForm()
1238  {
1239  global $lng, $ilCtrl;
1240 
1241  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1242  $this->form_gui = new ilPropertyFormGUI();
1243 
1244  $this->form_gui->setTitle($lng->txt("sty_add_image"));
1245 
1246  $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
1247  $file_input->setRequired(true);
1248  $this->form_gui->addItem($file_input);
1249 
1250  $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
1251  $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
1252  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1253  }
1254 
1259  {
1260  global $ilCtrl;
1261 
1262  $images = $this->object->getImages();
1263 
1264  foreach ($images as $image)
1265  {
1266  if (is_array($_POST["file"]) && in_array($image["entry"], $_POST["file"]))
1267  {
1268  $this->object->deleteImage($image["entry"]);
1269  }
1270  }
1271  $ilCtrl->redirect($this, "listImages");
1272  }
1273 
1278  {
1279  global $ilCtrl, $tpl, $lng;
1280 
1281 //var_dump($_POST);
1282 
1283  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1284  {
1285  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1286  $ilCtrl->redirect($this, "edit");
1287  }
1288  else
1289  {
1290  // check whether there are any core style classes included
1291  $core_styles = ilObjStyleSheet::_getCoreStyles();
1292  foreach ($_POST["char"] as $char)
1293  {
1294  if (!empty($core_styles[$char]))
1295  {
1296  $this->deleteCoreCharMessage();
1297  return;
1298  }
1299  }
1300 
1301  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1302  $cgui = new ilConfirmationGUI();
1303  $cgui->setFormAction($ilCtrl->getFormAction($this));
1304  $cgui->setHeaderText($lng->txt("sty_confirm_char_deletion"));
1305  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1306  $cgui->setConfirm($lng->txt("delete"), "deleteCharacteristic");
1307 
1308  foreach ($_POST["char"] as $char)
1309  {
1310  $char_comp = explode(".", $char);
1311  $cgui->addItem("char[]", $char, $char_comp[2]);
1312  }
1313 
1314  $tpl->setContent($cgui->getHTML());
1315  }
1316  }
1317 
1325  {
1326  global $ilCtrl, $tpl, $lng;
1327 
1328  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1329  $cgui = new ilConfirmationGUI();
1330  $cgui->setFormAction($ilCtrl->getFormAction($this));
1331 
1332 
1333  $core_styles = ilObjStyleSheet::_getCoreStyles();
1334  $cnt = 0;
1335  foreach ($_POST["char"] as $char)
1336  {
1337  if (!empty($core_styles[$char]))
1338  {
1339  $cnt++;
1340  $char_comp = explode(".", $char);
1341  $cgui->addItem("", "", $char_comp[2]);
1342  }
1343  else
1344  {
1345  $cgui->addHiddenItem("char[]", $char);
1346  }
1347  }
1348  $all_core_styles = ($cnt == count($_POST["char"]))
1349  ? true
1350  : false;
1351 
1352  if ($all_core_styles)
1353  {
1354  $cgui->setHeaderText($lng->txt("sty_all_styles_obligatory"));
1355  $cgui->setCancel($lng->txt("back"), "cancelCharacteristicDeletion");
1356  }
1357  else
1358  {
1359  $cgui->setHeaderText($lng->txt("sty_some_styles_obligatory_delete_rest"));
1360  $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1361  $cgui->setConfirm($lng->txt("sty_delete_other_selected"), "deleteCharacteristicConfirmation");
1362  }
1363 
1364  $tpl->setContent($cgui->getHTML());
1365  }
1366 
1371  {
1372  global $ilCtrl, $lng;
1373 
1374  ilUtil::sendInfo($lng->txt("action_aborted"), true);
1375  $ilCtrl->redirect($this, "edit");
1376  }
1377 
1382  {
1383  global $ilCtrl;
1384 
1385  if (is_array($_POST["char"]))
1386  {
1387  foreach($_POST["char"] as $char)
1388  {
1389  $char_comp = explode(".", $char);
1390  $type = $char_comp[0];
1391  $tag = $char_comp[1];
1392  $class = $char_comp[2];
1393 
1394  $this->object->deleteCharacteristic($type, $tag, $class);
1395  }
1396  }
1397 
1398  $ilCtrl->redirect($this, "edit");
1399  }
1400 
1405  {
1406  global $tpl;
1407 
1408  $this->initCharacteristicForm("create");
1409  $tpl->setContent($this->form_gui->getHTML());
1410  }
1411 
1416  {
1417  global $ilCtrl, $tpl, $lng;
1418 
1419  $this->initCharacteristicForm("create");
1420 
1421  if ($this->form_gui->checkInput())
1422  {
1423  if ($this->object->characteristicExists($_POST["new_characteristic"], $_GET["style_type"]))
1424  {
1425  $char_input = $this->form_gui->getItemByPostVar("new_characteristic");
1426  $char_input->setAlert($lng->txt("sty_characteristic_already_exists"));
1427  }
1428  else
1429  {
1430  $this->object->addCharacteristic($_POST["type"], $_POST["new_characteristic"]);
1431  ilUtil::sendInfo($lng->txt("sty_added_characteristic"), true);
1432  $ilCtrl->setParameter($this, "tag",
1433  ilObjStyleSheet::_determineTag($_POST["type"]).".".$_POST["new_characteristic"]);
1434  $ilCtrl->setParameter($this, "style_type", $_POST["type"]);
1435  $ilCtrl->redirect($this, "editTagStyle");
1436  }
1437  }
1438  $this->form_gui->setValuesByPost();
1439  $tpl->setContent($this->form_gui->getHTML());
1440  }
1441 
1447  public function initCharacteristicForm($a_mode)
1448  {
1449  global $lng, $ilCtrl;
1450 
1451  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1452  $this->form_gui = new ilPropertyFormGUI();
1453 
1454  // title
1455  $txt_input = new ilRegExpInputGUI($lng->txt("title"), "new_characteristic");
1456  $txt_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1457  $txt_input->setNoMatchMessage($lng->txt("sty_msg_characteristic_must_only_include")." A-Z, a-z, 1-9");
1458  $txt_input->setRequired(true);
1459  $this->form_gui->addItem($txt_input);
1460 
1461  // type
1462  $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
1463  $types = $all_super_types[$this->super_type];
1464  $exp_types = array();
1465  foreach($types as $t)
1466  {
1468  {
1469  $exp_types[$t] = $lng->txt("sty_type_".$t);
1470  }
1471  }
1472  if (count($exp_types) > 1)
1473  {
1474  $type_input = new ilSelectInputGUI($lng->txt("sty_type"), "type");
1475  $type_input->setOptions($exp_types);
1476  $type_input->setValue(key($exp_types));
1477  $this->form_gui->addItem($type_input);
1478  }
1479  else if (count($exp_types) == 1)
1480  {
1481  $hid_input = new ilHiddenInputGUI("type");
1482  $hid_input->setValue(key($exp_types));
1483  $this->form_gui->addItem($hid_input);
1484  }
1485 
1486  $this->form_gui->setTitle($lng->txt("sty_add_characteristic"));
1487  $this->form_gui->addCommandButton("saveCharacteristic", $lng->txt("save"));
1488  $this->form_gui->addCommandButton("edit", $lng->txt("cancel"));
1489  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1490  }
1491 
1495  static function getStyleExampleHTML($a_type, $a_class)
1496  {
1497  global $lng;
1498 
1499  $c = explode(":", $a_class);
1500  $a_class = $c[0];
1501 
1502  $ex_tpl = new ilTemplate("tpl.style_example.html", true, true, "Services/Style");
1503 
1504  $ex_tpl->setCurrentBlock("Example_".$a_type);
1505  $ex_tpl->setVariable("EX_CLASS", "ilc_".$a_type."_".$a_class);
1506  $ex_tpl->setVariable("EX_TEXT", "ABC abc 123");
1507  if ($a_type == "media_cont")
1508  {
1509  $ex_tpl->setVariable("IMG_MEDIA_DISABLED", ilUtil::getImagePath("media_disabled.gif"));
1510  }
1511  if (in_array($a_type, array("table", "table_caption")))
1512  {
1513  $ex_tpl->setVariable("TXT_CAPTION", $lng->txt("sty_caption"));
1514  }
1515  $ex_tpl->parseCurrentBlock();
1516 
1517  return $ex_tpl->get();
1518  }
1519 
1524  {
1525  global $ilCtrl, $lng;
1526 
1527  //var_dump($_POST);
1528 
1529  foreach ($_POST["all_chars"] as $char)
1530  {
1531  $ca = explode(".", $char);
1532  $this->object->saveHideStatus($ca[0], $ca[2],
1533  (is_array($_POST["hide"]) && in_array($char, $_POST["hide"])));
1534  }
1535 
1536  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
1537  $ilCtrl->redirect($this, "edit");
1538  }
1539 
1547  {
1548  global $ilCtrl, $lng;
1549 
1550  if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1551  {
1552  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1553  }
1554  else
1555  {
1556  $style_cp = implode("::", $_POST["char"]);
1557  $style_cp = $this->object->getId().":::".$_GET["style_type"].":::".$style_cp;
1558  $_SESSION["sty_copy"] = $style_cp;
1559  ilUtil::sendSuccess($lng->txt("sty_copied_please_select_target"), true);
1560  }
1561  $ilCtrl->redirect($this, "edit");
1562  }
1563 
1571  {
1572  global $tpl, $ilTabs;
1573 
1574  $ilTabs->clearTargets();
1575 
1576  include_once("./Services/Style/classes/class.ilPasteStyleCharacteristicTableGUI.php");
1577  $table = new ilPasteStyleCharacteristicTableGUI($this, "pasteCharacteristicsOverview");
1578 
1579  $tpl->setContent($table->getHTML());
1580  }
1581 
1589  {
1590  global $ilCtrl, $lng;
1591 
1592  if (is_array($_POST["title"]))
1593  {
1594  foreach ($_POST["title"] as $from_char => $to_title)
1595  {
1596  $fc = explode(".", $from_char);
1597 
1598  if ($_POST["conflict_action"][$from_char] == "overwrite" ||
1599  !$this->object->characteristicExists($to_title, $fc[0]))
1600  {
1601  $this->object->copyCharacteristic($_POST["from_style_id"],
1602  $fc[0], $fc[2], $to_title);
1603  }
1604  }
1605  ilObjStyleSheet::_writeUpToDate($this->object->getId(), false);
1606  unset($_SESSION["sty_copy"]);
1607  ilUtil::sendSuccess($lng->txt("sty_style_classes_copied"), true);
1608  }
1609 
1610  $ilCtrl->redirect($this, "edit");
1611  }
1612 
1613  //
1614  // Color management
1615  //
1616 
1620  function listColorsObject()
1621  {
1622  global $tpl;
1623 
1624  include_once("./Services/Style/classes/class.ilStyleColorTableGUI.php");
1625  $table_gui = new ilStyleColorTableGUI($this, "listColors",
1626  $this->object);
1627  $tpl->setContent($table_gui->getHTML());
1628 
1629  }
1630 
1634  function addColorObject()
1635  {
1636  global $tpl;
1637 
1638  $this->initColorForm();
1639  $tpl->setContent($this->form_gui->getHTML());
1640  }
1641 
1645  function editColorObject()
1646  {
1647  global $tpl, $ilCtrl;
1648 
1649  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1650  $this->initColorForm("edit");
1651  $this->getColorFormValues();
1652  $tpl->setContent($this->form_gui->getHTML());
1653  }
1654 
1655 
1659  function initColorForm($a_mode = "create")
1660  {
1661  global $lng, $ilCtrl;
1662 
1663  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1664  $this->form_gui = new ilPropertyFormGUI();
1665 
1666  $this->form_gui->setTitle($lng->txt("sty_add_color"));
1667 
1668  // name
1669  $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
1670  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1671  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1672  $name_input->setRequired(true);
1673  $name_input->setSize(15);
1674  $name_input->setMaxLength(15);
1675  $this->form_gui->addItem($name_input);
1676 
1677  // code
1678  $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
1679  $color_input->setRequired(true);
1680  $color_input->setDefaultColor("");
1681  $this->form_gui->addItem($color_input);
1682 
1683  if ($a_mode == "create")
1684  {
1685  $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
1686  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1687  }
1688  else
1689  {
1690  $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
1691  $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1692  }
1693  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1694  }
1695 
1700  {
1701  if ($_GET["c_name"] != "")
1702  {
1703  $values["color_name"] = $_GET["c_name"];
1704  $values["color_code"] = $this->object->getColorCodeForName($_GET["c_name"]);
1705  $this->form_gui->setValuesByArray($values);
1706  }
1707  }
1708 
1713  {
1714  global $ilCtrl;
1715 
1716  $ilCtrl->redirect($this, "listColors");
1717  }
1718 
1722  function saveColorObject()
1723  {
1724  global $tpl, $ilCtrl, $lng;
1725 
1726  $this->initColorForm();
1727 
1728  if ($this->form_gui->checkInput())
1729  {
1730  if ($this->object->colorExists($_POST["color_name"]))
1731  {
1732  $col_input = $this->form_gui->getItemByPostVar("color_name");
1733  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1734  }
1735  else
1736  {
1737  $this->object->addColor($_POST["color_name"],
1738  $_POST["color_code"]);
1739  $ilCtrl->redirect($this, "listColors");
1740  }
1741  }
1742  $this->form_gui->setValuesByPost();
1743  $tpl->setContent($this->form_gui->getHTML());
1744  }
1745 
1750  {
1751  global $tpl, $ilCtrl, $lng;
1752 
1753  $this->initColorForm("edit");
1754 
1755  if ($this->form_gui->checkInput())
1756  {
1757  if ($this->object->colorExists($_POST["color_name"]) &&
1758  $_POST["color_name"] != $_GET["c_name"])
1759  {
1760  $col_input = $this->form_gui->getItemByPostVar("color_name");
1761  $col_input->setAlert($lng->txt("sty_color_already_exists"));
1762  }
1763  else
1764  {
1765  $this->object->updateColor($_GET["c_name"], $_POST["color_name"],
1766  $_POST["color_code"]);
1767  $ilCtrl->redirect($this, "listColors");
1768  }
1769  }
1770  $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1771  $this->form_gui->setValuesByPost();
1772  $tpl->setContent($this->form_gui->getHTML());
1773  }
1774 
1779  {
1780  global $ilCtrl, $tpl, $lng;
1781 
1782  if (!is_array($_POST["color"]) || count($_POST["color"]) == 0)
1783  {
1784  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1785  $ilCtrl->redirect($this, "listColors");
1786  }
1787  else
1788  {
1789  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1790  $cgui = new ilConfirmationGUI();
1791  $cgui->setFormAction($ilCtrl->getFormAction($this));
1792  $cgui->setHeaderText($lng->txt("sty_confirm_color_deletion"));
1793  $cgui->setCancel($lng->txt("cancel"), "cancelColorDeletion");
1794  $cgui->setConfirm($lng->txt("delete"), "deleteColor");
1795 
1796  foreach ($_POST["color"] as $c)
1797  {
1798  $cgui->addItem("color[]", ilUtil::prepareFormOutput($c), $c);
1799  }
1800 
1801  $tpl->setContent($cgui->getHTML());
1802  }
1803  }
1804 
1809  {
1810  global $ilCtrl;
1811 
1812  $ilCtrl->redirect($this, "listColors");
1813  }
1814 
1819  {
1820  global $ilCtrl;
1821 
1822  if (is_array($_POST["color"]))
1823  {
1824  foreach ($_POST["color"] as $c)
1825  {
1826  $this->object->removeColor($c);
1827  }
1828  }
1829 
1830  $ilCtrl->redirect($this, "listColors");
1831  }
1832 
1833  //
1834  // Templates management
1835  //
1836 
1841  {
1842  global $tpl, $ilTabs, $ilCtrl;
1843 
1844  $ctype = $_GET["temp_type"];
1845  if ($ctype == "")
1846  {
1847  $ctype = "table";
1848  $ilCtrl->setParameter($this, "temp_type", $ctype);
1849  $_GET["temp_type"] = $ctype;
1850  }
1851 
1852  $this->setTemplatesSubTabs();
1853  $ilTabs->setSubTabActive("sty_".$ctype."_templates");
1854 
1855  $this->includeCSS();
1856  include_once("./Services/Style/classes/class.ilTableTemplatesTableGUI.php");
1857  $table_gui = new ilTableTemplatesTableGUI($ctype, $this, "listTemplates",
1858  $this->object);
1859  $tpl->setContent($table_gui->getHTML());
1860 
1861  }
1862 
1867  {
1868  global $tpl;
1869 
1870  $this->initTemplateForm();
1871  $tpl->setContent($this->form_gui->getHTML());
1872  }
1873 
1878  {
1879  global $tpl, $ilCtrl;
1880 
1881  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
1882  $this->initTemplateForm("edit");
1883  $this->getTemplateFormValues();
1884 
1885  $this->displayTemplateEditForm();
1886  }
1887 
1891  function getTemplatePreview($a_type, $a_t_id, $a_small_mode = false)
1892  {
1893  return $this->_getTemplatePreview(
1894  $this->object, $a_type, $a_t_id, $a_small_mode);
1895  }
1896 
1900  function _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode = false)
1901  {
1902  global $lng, $tpl;
1903 
1904  $kr = $kc = 7;
1905  if ($a_small_mode)
1906  {
1907  $kr = 6;
1908  $kc = 5;
1909  }
1910 
1911  $ts = $a_style->getTemplate($a_t_id);
1912  $t = $ts["classes"];
1913 
1914  // preview
1915  if ($a_type == "table")
1916  {
1917  $p_content = '<PageContent><Table DataTable="y"';
1918  if ($t["row_head"] != "")
1919  {
1920  $p_content.= ' HeaderRows="1"';
1921  }
1922  if ($t["row_foot"] != "")
1923  {
1924  $p_content.= ' FooterRows="1"';
1925  }
1926  if ($t["col_head"] != "")
1927  {
1928  $p_content.= ' HeaderCols="1"';
1929  }
1930  if ($t["col_foot"] != "")
1931  {
1932  $p_content.= ' FooterCols="1"';
1933  }
1934  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1935  if (!$a_small_mode)
1936  {
1937  $p_content.= '<Caption>'.$lng->txt("sty_caption").'</Caption>';
1938  }
1939  for($i = 1; $i<=$kr; $i++)
1940  {
1941  $p_content.= '<TableRow>';
1942  for($j = 1; $j<=$kc; $j++)
1943  {
1944  if ($a_small_mode)
1945  {
1946  $cell = '&lt;div style="height:2px;"&gt;&lt;/div&gt;';
1947  }
1948  else
1949  {
1950  $cell = 'xxx';
1951  }
1952  $p_content.= '<TableData><PageContent><Paragraph Characteristic="TableContent">'.$cell.'</Paragraph></PageContent></TableData>';
1953  }
1954  $p_content.= '</TableRow>';
1955  }
1956  $p_content.= '</Table></PageContent>';
1957  }
1958 
1959  if ($a_type == "vaccordion" || $a_type == "haccordion")
1960  {
1961  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1963 
1964  if ($a_small_mode)
1965  {
1966  $c = '&amp;nbsp;';
1967  $h = '&amp;nbsp;';
1968  }
1969  else
1970  {
1971  $c = 'xxx';
1972  $h = 'head';
1973  }
1974  if ($a_type == "vaccordion")
1975  {
1976  $p_content = '<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
1977  if ($a_small_mode)
1978  {
1979  $p_content.= ' ContentWidth="70"';
1980  }
1981  }
1982  else
1983  {
1984  $p_content = '<PageContent><Tabs Type="HorizontalAccordion"';
1985  if ($a_small_mode)
1986  {
1987  $p_content.= ' ContentHeight="40"';
1988  $p_content.= ' ContentWidth="70"';
1989  $c = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';
1990  }
1991  else
1992  {
1993  $p_content.= ' ContentHeight="40"';
1994  }
1995  }
1996  $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
1997  $p_content.= '<Tab><PageContent><Paragraph>'.$c.'</Paragraph></PageContent>';
1998  $p_content.= '<TabCaption>'.$h.'</TabCaption>';
1999  $p_content.= '</Tab>';
2000  $p_content.= '</Tabs></PageContent>';
2001  }
2002 //echo htmlentities($p_content);
2003  $txml = $a_style->getTemplateXML();
2004 //echo htmlentities($txml);
2005  $p_content.= $txml;
2006  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
2007  $r_content = ilPCTableGUI::_renderTable($p_content, "");
2008 
2009  return $r_content;
2010  }
2011 
2015  function initTemplateForm($a_mode = "create")
2016  {
2017  global $lng, $ilCtrl;
2018 
2019  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2020  $this->form_gui = new ilPropertyFormGUI();
2021 
2022  if ($a_mode == "create")
2023  {
2024  $this->form_gui->setTitle($lng->txt("sty_add_template"));
2025  }
2026  else
2027  {
2028  $this->form_gui->setTitle($lng->txt("sty_edit_template"));
2029  }
2030 
2031  // name
2032  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2033  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2034  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2035  $name_input->setRequired(true);
2036  $name_input->setSize(30);
2037  $name_input->setMaxLength(30);
2038  $this->form_gui->addItem($name_input);
2039 
2040  // template style classes
2041  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2042  foreach ($scs as $sc => $st)
2043  {
2044  $sc_input = new ilSelectInputGUI($lng->txt("sty_".$sc."_class"), $sc."_class");
2045  $chars = $this->object->getCharacteristics($st);
2046  $options = array("" => "");
2047  foreach($chars as $char)
2048  {
2049  $options[$char] = $char;
2050  }
2051  $sc_input->setOptions($options);
2052  $this->form_gui->addItem($sc_input);
2053  }
2054 
2055  if ($a_mode == "create")
2056  {
2057  $this->form_gui->addCommandButton("saveTemplate", $lng->txt("save"));
2058  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2059  }
2060  else
2061  {
2062  $this->form_gui->addCommandButton("refreshTemplate", $lng->txt("save_refresh"));
2063  $this->form_gui->addCommandButton("updateTemplate", $lng->txt("save_return"));
2064  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2065  }
2066  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2067  }
2068 
2073  {
2074  global $ilCtrl;
2075 
2076  $ilCtrl->redirect($this, "listTemplates");
2077  }
2078 
2079 
2084  {
2085  global $tpl, $ilCtrl, $lng;
2086 
2087  $this->initTemplateForm();
2088 
2089  if ($this->form_gui->checkInput())
2090  {
2091  if ($this->object->templateExists($_POST["name"]))
2092  {
2093  $name_input = $this->form_gui->getItemByPostVar("name");
2094  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2095  }
2096  else
2097  {
2098  $classes = array();
2099  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2100  {
2101  $classes[$tct] = $_POST[$tct."_class"];
2102  }
2103  $t_id = $this->object->addTemplate($_GET["temp_type"], $_POST["name"], $classes);
2104  $this->object->writeTemplatePreview($t_id,
2105  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2106  $ilCtrl->redirect($this, "listTemplates");
2107  }
2108  }
2109  $this->form_gui->setValuesByPost();
2110  $tpl->setContent($this->form_gui->getHTML());
2111  }
2112 
2116  function updateTemplateObject($a_refresh = false)
2117  {
2118  global $tpl, $ilCtrl, $lng;
2119 
2120  $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
2121  $this->initTemplateForm("edit");
2122 
2123  if ($this->form_gui->checkInput())
2124  {
2125  if ($this->object->templateExists($_POST["name"]) &&
2126  $_POST["name"] != ilObjStyleSheet::lookupTemplateName($_GET["t_id"]))
2127  {
2128  $name_input = $this->form_gui->getItemByPostVar("name");
2129  $name_input->setAlert($lng->txt("sty_template_already_exists"));
2130  }
2131  else
2132  {
2133  $classes = array();
2134  foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2135  {
2136  $classes[$tct] = $_POST[$tct."_class"];
2137  }
2138 
2139  $this->object->updateTemplate($_GET["t_id"],
2140  $_POST["name"], $classes);
2141  $this->object->writeTemplatePreview($_GET["t_id"],
2142  $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"], true));
2143  if(!$a_refresh)
2144  {
2145  $ilCtrl->redirect($this, "listTemplates");
2146  }
2147  }
2148  }
2149 
2150  $this->form_gui->setValuesByPost();
2151  $this->displayTemplateEditForm();
2152  }
2153 
2158  {
2159  global $tpl;
2160 
2161  $a_tpl = new ilTemplate("tpl.template_edit.html", true, true,
2162  "Services/Style");
2163  $this->includeCSS();
2164  $a_tpl->setVariable("FORM", $this->form_gui->getHTML());
2165  $a_tpl->setVariable("PREVIEW", $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"]));
2166  $tpl->setContent($a_tpl->get());
2167  }
2168 
2173  {
2174  $this->updateTemplateObject(true);
2175  }
2176 
2181  {
2182  if ($_GET["t_id"] > 0)
2183  {
2184  $t = $this->object->getTemplate($_GET["t_id"]);
2185 
2186  $values["name"] = $t["name"];
2187  $scs = ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]);
2188  foreach ($scs as $k => $type)
2189  {
2190  $values[$k."_class"] = $t["classes"][$k];
2191  }
2192  $this->form_gui->setValuesByArray($values);
2193  }
2194  }
2195 
2200  {
2201  global $ilCtrl, $tpl, $lng;
2202 
2203  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
2204  {
2205  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2206  $ilCtrl->redirect($this, "listTemplates");
2207  }
2208  else
2209  {
2210  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2211  $cgui = new ilConfirmationGUI();
2212  $cgui->setFormAction($ilCtrl->getFormAction($this));
2213  $cgui->setHeaderText($lng->txt("sty_confirm_template_deletion"));
2214  $cgui->setCancel($lng->txt("cancel"), "cancelTemplateDeletion");
2215  $cgui->setConfirm($lng->txt("sty_del_template"), "deleteTemplate");
2216 
2217  foreach ($_POST["tid"] as $tid)
2218  {
2219  $classes = $this->object->getTemplateClasses($tid);
2220  $cl_str = "";
2221  $listed = array();
2222  foreach ($classes as $cl)
2223  {
2224  if ($cl != "" && !$listed[$cl])
2225  {
2226  $cl_str.= '<div>- '.
2227  $cl."</div>";
2228  $listed[$cl] = true;
2229  }
2230  }
2231  if ($cl_str != "")
2232  {
2233  $cl_str = '<div style="padding-left:30px;" class="small">'.
2234  "<div><i>".$lng->txt("sty_style_class")."</i></div>".$cl_str."</div>";
2235  }
2236  $cgui->addItem("tid[]", $tid, $this->object->lookupTemplateName($tid).$cl_str);
2237  }
2238 
2239  $cgui->addButton($lng->txt("sty_del_template_keep_classes"), "deleteTemplateKeepClasses");
2240 
2241  $tpl->setContent($cgui->getHTML());
2242  }
2243  }
2244 
2249  {
2250  global $ilCtrl;
2251 
2252  $ilCtrl->redirect($this, "listTemplates");
2253  }
2254 
2259  {
2260  global $ilCtrl;
2261 
2262  if (is_array($_POST["tid"]))
2263  {
2264  foreach ($_POST["tid"] as $tid)
2265  {
2266  $this->object->removeTemplate($tid);
2267  }
2268  }
2269 
2270  $ilCtrl->redirect($this, "listTemplates");
2271  }
2272 
2277  {
2278  global $ilCtrl;
2279 
2280  if (is_array($_POST["tid"]))
2281  {
2282  foreach ($_POST["tid"] as $tid)
2283  {
2284  $cls = $this->object->getTemplateClasses($tid);
2285  foreach ($cls as $k => $cls)
2286  {
2287  $ty = $this->object->determineTemplateStyleClassType($_GET["temp_type"], $k);
2288  $ta = ilObjStyleSheet::_determineTag($ty);
2289  $this->object->deleteCharacteristic($ty, $ta, $cls);
2290  }
2291  $this->object->removeTemplate($tid);
2292  }
2293  }
2294 
2295  $ilCtrl->redirect($this, "listTemplates");
2296  }
2297 
2302  {
2303  global $tpl;
2304 
2305  $this->initTemplateGenerationForm();
2306  $tpl->setContent($this->form_gui->getHTML());
2307  }
2308 
2313  {
2314  global $lng, $ilCtrl;
2315 
2316  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2317  $this->form_gui = new ilPropertyFormGUI();
2318 
2319  $this->form_gui->setTitle($lng->txt("sty_generate_template"));
2320 
2321  // name
2322  $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2323  $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2324  $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2325  $name_input->setRequired(true);
2326  $name_input->setSize(30);
2327  $name_input->setMaxLength(30);
2328  $this->form_gui->addItem($name_input);
2329 
2330  // basic layout
2331  $bl_input = new ilSelectInputGUI($lng->txt("sty_template_layout"), "layout");
2332  $options = array(
2333  "coloredZebra" => $lng->txt("sty_table_template_colored_zebra"),
2334  "bwZebra" => $lng->txt("sty_table_template_bw_zebra"),
2335  "noZebra" => $lng->txt("sty_table_template_no_zebra")
2336  );
2337  $bl_input->setOptions($options);
2338  $this->form_gui->addItem($bl_input);
2339 
2340  // top bottom padding
2341  include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
2342  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_top_bottom_padding"), "tb_padding");
2343  $num_input->setAllowPercentage(false);
2344  $num_input->setValue("3px");
2345  $this->form_gui->addItem($num_input);
2346 
2347  // left right padding
2348  $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_left_right_padding"), "lr_padding");
2349  $num_input->setAllowPercentage(false);
2350  $num_input->setValue("10px");
2351  $this->form_gui->addItem($num_input);
2352 
2353  // base color
2354  $bc_input = new ilSelectInputGUI($lng->txt("sty_base_color"), "base_color");
2355  $cs = $this->object->getColors();
2356  $options = array();
2357  foreach ($cs as $c)
2358  {
2359  $options[$c["name"]] = $c["name"];
2360  }
2361  $bc_input->setOptions($options);
2362  $this->form_gui->addItem($bc_input);
2363 
2364  // Lightness Settings
2365  $lss = array("border" => 90, "header_text" => 70, "header_bg" => 0,
2366  "cell1_text" => -60, "cell1_bg" => 90, "cell2_text" => -60, "cell2_bg" => 75);
2367  foreach ($lss as $ls => $v)
2368  {
2369  $l_input = new ilNumberInputGUI($lng->txt("sty_lightness_".$ls), "lightness_".$ls);
2370  $l_input->setMaxValue(100);
2371  $l_input->setMinValue(-100);
2372  $l_input->setValue($v);
2373  $l_input->setSize(4);
2374  $l_input->setMaxLength(4);
2375  $this->form_gui->addItem($l_input);
2376  }
2377 
2378  $this->form_gui->addCommandButton("templateGeneration", $lng->txt("generate"));
2379  $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2380  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2381  }
2382 
2387  {
2388  global $tpl, $ilCtrl, $lng;
2389 
2390  $this->initTemplateGenerationForm();
2391 
2392  if ($this->form_gui->checkInput())
2393  {
2394  if ($this->object->templateExists($_POST["name"]))
2395  {
2396  $name_input = $this->form_gui->getItemByPostVar("name");
2397  $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2398  }
2399  else
2400  {
2401  // -> move to application class!
2402 
2403  // cell classes
2404  $cells = array("H" => "header", "C1" => "cell1", "C2" => "cell2");
2405  $tb_p = $this->form_gui->getItemByPostVar("tb_padding");
2406  $tb_padding = $tb_p->getValue();
2407  $lr_p = $this->form_gui->getItemByPostVar("lr_padding");
2408  $lr_padding = $lr_p->getValue();
2409  $cell_color = $_POST["base_color"];
2410 
2411  // use mid gray as cell color for bw zebra
2412  if ($_POST["layout"] == "bwZebra")
2413  {
2414  $cell_color = "MidGray";
2415  if (!$this->object->colorExists($cell_color))
2416  {
2417  $this->object->addColor($cell_color, "7F7F7F");
2418  }
2419  $this->object->updateColor($cell_color, $cell_color, "7F7F7F");
2420  }
2421 
2422  foreach ($cells as $k => $cell)
2423  {
2424  $cell_class[$k] = $_POST["name"].$k;
2425  if (!$this->object->characteristicExists($cell_class[$k], "table_cell"))
2426  {
2427  $this->object->addCharacteristic("table_cell", $cell_class[$k], true);
2428  }
2429  if ($_POST["layout"] == "bwZebra" && $k == "H")
2430  {
2431  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2432  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2433  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2434  "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2435  }
2436  else
2437  {
2438  $this->object->replaceStylePar("td", $cell_class[$k], "color",
2439  "!".$cell_color."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2440  $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2441  "!".$cell_color."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2442  }
2443  $this->object->replaceStylePar("td", $cell_class[$k], "padding-top",
2444  $tb_padding, "table_cell");
2445  $this->object->replaceStylePar("td", $cell_class[$k], "padding-bottom",
2446  $tb_padding, "table_cell");
2447  $this->object->replaceStylePar("td", $cell_class[$k], "padding-left",
2448  $lr_padding, "table_cell");
2449  $this->object->replaceStylePar("td", $cell_class[$k], "padding-right",
2450  $lr_padding, "table_cell");
2451  $this->object->replaceStylePar("td", $cell_class[$k], "border-width",
2452  "1px", "table_cell");
2453  $this->object->replaceStylePar("td", $cell_class[$k], "border-style",
2454  "solid", "table_cell");
2455  $this->object->replaceStylePar("td", $cell_class[$k], "border-color",
2456  "!".$cell_color."(".$_POST["lightness_border"].")", "table_cell");
2457  $this->object->replaceStylePar("td", $cell_class[$k], "font-weight",
2458  "normal", "table_cell");
2459  }
2460 
2461  // table class
2462  $classes["table"] = $_POST["name"]."T";
2463  if (!$this->object->characteristicExists($classes["table"], "table"))
2464  {
2465  $this->object->addCharacteristic("table", $classes["table"], true);
2466  }
2467  $this->object->replaceStylePar("table", $classes["table"], "caption-side",
2468  "bottom", "table");
2469  $this->object->replaceStylePar("table", $classes["table"], "border-collapse",
2470  "collapse", "table");
2471  $this->object->replaceStylePar("table", $classes["table"], "margin-top",
2472  "5px", "table");
2473  $this->object->replaceStylePar("table", $classes["table"], "margin-bottom",
2474  "5px", "table");
2475  if ($_POST["layout"] == "bwZebra")
2476  {
2477  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-color",
2478  "!".$_POST["base_color"], "table");
2479  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-style",
2480  "solid", "table");
2481  $this->object->replaceStylePar("table", $classes["table"], "border-bottom-width",
2482  "3px", "table");
2483  $sb = array("left", "right", "top");
2484  foreach ($sb as $b)
2485  {
2486  $this->object->replaceStylePar("table", $classes["table"], "border-".$b."-width",
2487  "0px", "table");
2488  }
2489  }
2490 
2491  switch ($_POST["layout"])
2492  {
2493  case "coloredZebra":
2494  $classes["row_head"] = $cell_class["H"];
2495  $classes["odd_row"] = $cell_class["C1"];
2496  $classes["even_row"] = $cell_class["C2"];
2497  break;
2498 
2499  case "bwZebra":
2500  $classes["row_head"] = $cell_class["H"];
2501  $classes["odd_row"] = $cell_class["C1"];
2502  $classes["even_row"] = $cell_class["C2"];
2503  break;
2504 
2505  case "noZebra":
2506  $classes["row_head"] = $cell_class["H"];
2507  $classes["odd_row"] = $cell_class["C1"];
2508  $classes["even_row"] = $cell_class["C1"];
2509  $classes["col_head"] = $cell_class["C2"];
2510  break;
2511  }
2512 
2513 
2514  $t_id = $this->object->addTemplate($_GET["temp_type"],
2515  $_POST["name"], $classes);
2516  $this->object->writeTemplatePreview($t_id,
2517  $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2518  $ilCtrl->redirect($this, "listTemplates");
2519  }
2520  }
2521  $this->form_gui->setValuesByPost();
2522  $tpl->setContent($this->form_gui->getHTML());
2523  }
2524 
2526  {
2527  global $tpl;
2528 
2529  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2530 
2531  $acc = new ilAccordionGUI();
2532  $acc->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2533  $acc->addItem("Header 2", str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx x xx x xx", 30));
2534  $acc->setOrientation(ilAccordionGUI::HORIZONTAL);
2535 
2536  $ac2 = new ilAccordionGUI();
2537  $ac2->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2538  $ac2->addItem("Header 2", $acc->getHTML());
2539  $ac2->setOrientation(ilAccordionGUI::VERTICAL);
2540 
2541  $tpl->setContent($ac2->getHTML());
2542  }
2543 
2548  {
2549  global $ilCtrl;
2550 
2551  if ($_GET["baseClass"] == "ilAdministrationGUI")
2552  {
2553  $ilCtrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
2554  }
2555  $ilCtrl->returnToParent($this);
2556  }
2557 
2558 
2559 }
2560 ?>