ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
16require_once "./Services/Object/classes/class.ilObjectGUI.php";
17require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
18
20{
25
30 function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
31 {
32 global $ilCtrl, $lng, $tpl;
33
34 $this->ctrl =& $ilCtrl;
35 $this->lng =& $lng;
36 $this->lng->loadLanguageModule("style");
37 $ilCtrl->saveParameter($this, array("tag", "style_type", "temp_type"));
38 if ($_GET["style_type"] != "")
39 {
40 $this->super_type = ilObjStyleSheet::_getStyleSuperTypeForType($_GET["style_type"]);
41 }
42
43 $this->type = "sty";
44 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
45 }
46
50 function &executeCommand()
51 {
52 $next_class = $this->ctrl->getNextClass($this);
53 $cmd = $this->ctrl->getCmd("edit");
54
55 // #9440/#9489: prepareOutput will fail if not set properly
56 if(!$this->object)
57 {
58 $this->setCreationMode(true);
59 }
60
61 $this->prepareOutput();
62 switch($next_class)
63 {
64 default:
65 $cmd.= "Object";
66 $ret =& $this->$cmd();
67 break;
68 }
69
70 return $ret;
71 }
72
73 function viewObject()
74 {
75 $this->editObject();
76 }
77
81 function createObject()
82 {
83 global $rbacsystem, $lng, $tpl, $ilHelp;
84
85 $forms = array();
86
87
88 $ilHelp->setScreenIdComponent("sty");
89 $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "create");
90
91 // --- create
92
93 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
94 $form = new ilPropertyFormGUI();
95 $form->setFormAction($this->ctrl->getFormAction($this));
96 $form->setTitle($this->lng->txt("sty_create_new_stylesheet"));
97
98 // title
99 $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
100 $ti->setMaxLength(128);
101 $ti->setSize(40);
102 $ti->setRequired(true);
103 $form->addItem($ti);
104
105 // description
106 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
107 $ta->setCols(40);
108 $ta->setRows(2);
109 $form->addItem($ta);
110
111 $form->addCommandButton("save", $this->lng->txt("save"));
112 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
113
114 $forms[] = $form;
115
116
117 // --- import
118
119 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
120 $form = new ilPropertyFormGUI();
121 $form->setFormAction($this->ctrl->getFormAction($this));
122 $form->setTitle($this->lng->txt("sty_import_stylesheet"));
123
124 // title
125 $ti = new ilFileInputGUI($this->lng->txt("import_file"), "stylefile");
126 $ti->setRequired(true);
127 $form->addItem($ti);
128
129 $form->addCommandButton("importStyle", $this->lng->txt("import"));
130 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
131
132 $forms[] = $form;
133
134
135 // --- clone
136
137 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
138 $form = new ilPropertyFormGUI();
139 $form->setFormAction($this->ctrl->getFormAction($this));
140 $form->setTitle($this->lng->txt("sty_copy_other_stylesheet"));
141
142 // source
143 $ti = new ilSelectInputGUI($this->lng->txt("sty_source"), "source_style");
144 $ti->setRequired(true);
146 $form->addItem($ti);
147
148 $form->addCommandButton("copyStyle", $this->lng->txt("copy"));
149 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
150
151 $forms[] = $form;
152
153
154 $this->tpl->setContent($this->getCreationFormsHTML($forms));
155 }
156
160 function includeCSS()
161 {
162 // set style sheet
163 $this->tpl->setCurrentBlock("ContentStyle");
164 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
165 $this->object->getContentStylePath($this->object->getId()));
166 $this->tpl->parseCurrentBlock();
167 }
168
172 function editObject()
173 {
174 global $rbacsystem, $lng, $ilTabs, $ilCtrl, $ilToolbar, $tpl;
175
176 $this->setSubTabs();
177
178 $this->includeCSS();
179
180 $ctpl = new ilTemplate("tpl.sty_classes.html", true, true, "Services/Style");
181
182 // output characteristics
183 $chars = $this->object->getCharacteristics();
184
185 $style_type = ($this->super_type != "")
186 ? $this->super_type
187 : "text_block";
188 $ilCtrl->setParameter($this, "style_type", $style_type);
189 $ilTabs->setSubTabActive("sty_".$style_type."_char");
190
191 // workaround to include default rte styles
192 if ($this->super_type == "rte")
193 {
194 $tpl->addCss("Modules/Scorm2004/templates/default/player.css");
195 include_once("./Modules/Scorm2004/classes/ilSCORM13Player.php");
196 $tpl->addInlineCss(ilSCORM13Player::getInlineCss());
197 }
198
199 // add new style?
200 $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
201 $subtypes = $all_super_types[$style_type];
202 $expandable = false;
203 foreach ($subtypes as $t)
204 {
206 {
207 $expandable = true;
208 }
209 }
210 if ($expandable && $rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
211 {
212 $ilToolbar->addButton($lng->txt("sty_add_characteristic"),
213 $ilCtrl->getLinkTarget($this, "addCharacteristicForm"));
214 }
215
216 if ($_SESSION["sty_copy"] != "")
217 {
218
219 $style_cp = explode(":::", $_SESSION["sty_copy"]);
220 if ($style_cp[1] == $style_type)
221 {
222
223 if ($expandable)
224 {
225 $ilToolbar->addSeparator();
226 }
227 $ilToolbar->addButton($lng->txt("sty_paste_style_classes"),
228 $ilCtrl->getLinkTarget($this, "pasteCharacteristicsOverview"));
229 }
230 }
231
232 include_once("./Services/Style/classes/class.ilStyleTableGUI.php");
233 $table_gui = new ilStyleTableGUI($this, "edit", $chars, $style_type,
234 $this->object);
235
236 $ctpl->setCurrentBlock("style_table");
237 $ctpl->setVariable("STYLE_TABLE", $table_gui->getHTML());
238 $ctpl->parseCurrentBlock();
239
240 $this->tpl->setContent($ctpl->get());
241 }
242
247 {
248 global $rbacsystem, $lng, $ilToolbar;
249
250 // set style sheet
251 $this->tpl->setCurrentBlock("ContentStyle");
252 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
253 $this->object->getContentStylePath($this->object->getId()));
254 $this->tpl->parseCurrentBlock();
255
256 // export button
257 $ilToolbar->addButton($this->lng->txt("export"),
258 $this->ctrl->getLinkTarget($this, "exportStyle"));
259
260 $this->initPropertiesForm();
261 $this->getPropertiesValues();
262 $this->tpl->setContent($this->form->getHTML());
263 }
264
269 public function getPropertiesValues()
270 {
271 $values = array();
272
273 $values["style_title"] = $this->object->getTitle();
274 $values["style_description"] = $this->object->getDescription();
275 $values["disable_auto_margins"] = (int) $this->object->lookupStyleSetting("disable_auto_margins");
276
277 $this->form->setValuesByArray($values);
278 }
279
285 public function initPropertiesForm($a_mode = "edit")
286 {
287 global $lng, $rbacsystem;
288
289 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
290 $this->form = new ilPropertyFormGUI();
291
292 // title
293 $ti = new ilTextInputGUI($this->lng->txt("title"), "style_title");
294 $ti->setMaxLength(128);
295 $ti->setSize(40);
296 $ti->setRequired(true);
297 $this->form->addItem($ti);
298
299 // description
300 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "style_description");
301 //$ta->setCols();
302 //$ta->setRows();
303 $this->form->addItem($ta);
304
305 // disable automatic margins for left/right alignment
306 $cb = new ilCheckboxInputGUI($this->lng->txt("sty_disable_auto_margins"), "disable_auto_margins");
307 $cb->setInfo($this->lng->txt("sty_disable_auto_margins_info"));
308 $this->form->addItem($cb);
309
310 // save and cancel commands
311
312 if ($a_mode == "create")
313 {
314 $this->form->addCommandButton("save", $lng->txt("save"));
315 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
316 }
317 else
318 {
319 if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
320 {
321 $this->form->addCommandButton("update", $lng->txt("save"));
322 }
323 }
324
325 $this->form->setTitle($lng->txt("edit_stylesheet"));
326 $this->form->setFormAction($this->ctrl->getFormAction($this));
327
328 }
329
333 function updateObject()
334 {
335 global $lng, $ilCtrl, $tpl;
336
337 $this->initPropertiesForm("edit");
338 if ($this->form->checkInput())
339 {
340 $this->object->setTitle($this->form->getInput("style_title"));
341 $this->object->setDescription($this->form->getInput("style_description"));
342 $this->object->writeStyleSetting("disable_auto_margins",
343 $this->form->getInput("disable_auto_margins"));
344 $this->object->update();
345 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
346 $ilCtrl->redirect($this, "properties");
347 }
348 else
349 {
350 $this->form->setValuesByPost();
351 $tpl->setContent($this->form->getHtml());
352 }
353 }
354
359 {
360 global $ilCtrl;
361
362 $cur = explode(".",$_GET["tag"]);
363 $cur_tag = $cur[0];
364 $cur_class = $cur[1];
365
366 $this->initTagStyleForm("edit", $cur_tag);
367
368 if ($this->form_gui->checkInput())
369 {
370 $this->saveTagStyle();
371 $ilCtrl->redirect($this, "editTagStyle");
372 }
373 else
374 {
375 $this->form_gui->setValuesByPost();
377 }
378 }
379
384 {
385 global $ilCtrl;
386
387 $cur = explode(".",$_GET["tag"]);
388 $cur_tag = $cur[0];
389 $cur_class = $cur[1];
390
391 $this->initTagStyleForm("edit", $cur_tag);
392 if ($this->form_gui->checkInput())
393 {
394 $this->saveTagStyle();
395 $ilCtrl->redirect($this, "edit");
396 }
397 else
398 {
399 $this->form_gui->setValuesByPost();
401 }
402 }
403
407 function saveTagStyle()
408 {
409 $cur = explode(".", $_GET["tag"]);
410 $cur_tag = $cur[0];
411 $cur_class = $cur[1];
412 $avail_pars = ilObjStyleSheet::_getStyleParameters($cur_tag);
413 foreach ($avail_pars as $par => $v)
414 {
415 $var = str_replace("-", "_", $par);
416 $basepar_arr = explode(".", $par);
417 $basepar = $basepar_arr[0];
418 if ($basepar_arr[1] != "" && $basepar_arr[1] != $cur_tag)
419 {
420 continue;
421 }
422
423 switch ($v["input"])
424 {
425 case "fontsize":
426 case "numeric_no_perc":
427 case "numeric":
428 case "background_image":
429 $in = $this->form_gui->getItemByPostVar($basepar);
430//echo "<br>-".$cur_tag."-".$cur_class."-".$basepar."-".$_GET["style_type"]."-";
431 $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
432 break;
433
434 case "color":
435 $color = trim($_POST[$basepar]);
436 if ($color != "" && trim(substr($color,0,1) != "!"))
437 {
438 $color = "#".$color;
439 }
440 $this->writeStylePar($cur_tag, $cur_class, $basepar, $color, $_GET["style_type"], (int) $_GET["mq_id"]);
441 break;
442
443 case "trbl_numeric":
444 case "border_width":
445 case "border_style":
446 $in = $this->form_gui->getItemByPostVar($basepar);
447 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][0], $in->getAllValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
448 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][1], $in->getTopValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
449 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][2], $in->getRightValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
450 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][3], $in->getBottomValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
451 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][4], $in->getLeftValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
452 break;
453
454 case "trbl_color":
455 $in = $this->form_gui->getItemByPostVar($basepar);
456 $tblr_p = array (0 => "getAllValue", 1 => "getTopValue", 2 => "getRightValue",
457 3 => "getBottomValue", 4 => "getLeftValue");
458 foreach ($tblr_p as $k => $func)
459 {
460 $val = trim($in->$func());
461 $val = (($in->getAcceptNamedColors() && substr($val, 0, 1) == "!")
462 || $val == "")
463 ? $val
464 : "#".$val;
465 $this->writeStylePar($cur_tag, $cur_class, $v["subpar"][$k], $val, $_GET["style_type"], (int) $_GET["mq_id"]);
466 }
467 break;
468
469 case "background_position":
470 $in = $this->form_gui->getItemByPostVar($basepar);
471 $this->writeStylePar($cur_tag, $cur_class, $basepar, $in->getValue(), $_GET["style_type"], (int) $_GET["mq_id"]);
472 break;
473
474 default:
475 $this->writeStylePar($cur_tag, $cur_class, $basepar, $_POST[$basepar], $_GET["style_type"], (int) $_GET["mq_id"]);
476 break;
477 }
478 }
479
480 // write custom parameter
481 $this->object->deleteCustomStylePars($cur_tag, $cur_class, $_GET["style_type"], (int) $_GET["mq_id"]);
482 if (is_array($_POST["custom_par"]))
483 {
484 foreach ($_POST["custom_par"] as $cpar)
485 {
486 $par_arr = explode(":", $cpar);
487 if (count($par_arr) == 2)
488 {
489 $par = trim($par_arr[0]);
490 $val = trim(str_replace(";", "", $par_arr[1]));
491 $this->writeStylePar($cur_tag, $cur_class, $par, $val, $_GET["style_type"], (int) $_GET["mq_id"], true);
492 }
493 }
494 }
495
496 $this->object->update();
497 }
498
499 function writeStylePar($cur_tag, $cur_class, $par, $value, $a_type, $a_mq_id, $a_custom = false)
500 {
501// echo $_GET["mq_id"]."-";
502// echo $a_mq_id."-"; exit;
503 if ($a_type == "")
504 {
505 return;
506 }
507
508 if ($value != "")
509 {
510 $this->object->replaceStylePar($cur_tag, $cur_class, $par, $value, $a_type, $a_mq_id, $a_custom);
511 }
512 else
513 {
514 $this->object->deleteStylePar($cur_tag, $cur_class, $par, $a_type, $a_mq_id, $a_custom);
515 }
516 }
517
523 {
524 global $tpl, $ilToolbar, $lng, $ilCtrl;
525
526 // media query selector
527 $mqs = $this->object->getMediaQueries();
528 if (count($mqs) > 0)
529 {
530 //
531 $options = array(
532 "" => $lng->txt("sty_default"),
533 );
534 foreach ($mqs as $mq)
535 {
536 $options[$mq["id"]] = $mq["mquery"];
537 }
538 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
539 $si = new ilSelectInputGUI("@media", "mq_id");
540 $si->setOptions($options);
541 $si->setValue((int) $_GET["mq_id"]);
542 $ilToolbar->addInputItem($si, true);
543 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
544 $ilToolbar->addFormButton($lng->txt("sty_switch"), "switchMQuery");
545 }
546
547 // workaround to include default rte styles
548 //if (in_array($_GET["style_type"], array("rte_menu")))
549 if ($this->super_type == "rte")
550 {
551 $tpl->addCss("Modules/Scorm2004/templates/default/player.css");
552 include_once("./Modules/Scorm2004/classes/ilSCORM13Player.php");
553 $tpl->addInlineCss(ilSCORM13Player::getInlineCss());
554 }
555
556 $cur = explode(".",$_GET["tag"]);
557 $cur_tag = $cur[0];
558 $cur_class = $cur[1];
559
560 $this->initTagStyleForm("edit", $cur_tag);
561 $this->getValues();
563 }
564
572 {
573 global $ilCtrl;
574
575 $ilCtrl->setParameter($this, "mq_id", (int) $_POST["mq_id"]);
576 $ilCtrl->redirect($this, "editTagStyle");
577 }
578
579
584 {
585 global $tpl, $ilCtrl, $lng;
586
587 // set style sheet
588 $tpl->setCurrentBlock("ContentStyle");
589 $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
590 $this->object->getContentStylePath($this->object->getId()));
591
592 $ts_tpl = new ilTemplate("tpl.style_tag_edit.html", true, true, "Services/Style");
593
594 $cur = explode(".",$_GET["tag"]);
595 $cur_tag = $cur[0];
596 $cur_class = $cur[1];
597
598 $ts_tpl->setVariable("EXAMPLE",
599 ilObjStyleSheetGUI::getStyleExampleHTML($_GET["style_type"], $cur_class));
600
601 $ts_tpl->setVariable("FORM",
602 $this->form_gui->getHtml());
603
604 $tpl->setTitle($cur_class." (".$lng->txt("sty_type_".$_GET["style_type"]).")");
605
606 $tpl->setContent($ts_tpl->get());
607 }
608
609
615 public function initTagStyleForm($a_mode, $a_cur_tag)
616 {
617 global $lng, $ilCtrl;
618
619 $ilCtrl->saveParameter($this, array("mq_id"));
620
621 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
622 $this->form_gui = new ilPropertyFormGUI();
623
624 $avail_pars = $this->object->getAvailableParameters();
625 $groups = $this->object->getStyleParameterGroups();
626
627 // output select lists
628 foreach ($groups as $k => $group)
629 {
630 // filter groups of properties that should only be
631 // displayed with matching tag
632 $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
633 if (is_array($filtered_groups[$k]) && !in_array($a_cur_tag, $filtered_groups[$k]))
634 {
635 continue;
636 }
637
638 $sh = new ilFormSectionHeaderGUI();
639 $sh->setTitle($lng->txt("sty_".$k));
640 $this->form_gui->addItem($sh);
641
642 foreach ($group as $par)
643 {
644 $basepar = explode(".", $par);
645 $basepar = $basepar[0];
646
647 $var = str_replace("-", "_", $basepar);
648 $up_par = strtoupper($var);
649
651 {
652 case "select":
653 $sel_input = new ilSelectInputGUI($lng->txt("sty_".$var), $basepar);
654 $options = array("" => "");
655 foreach ($avail_pars[$par] as $p)
656 {
657 $options[$p] = $p;
658 }
659 $sel_input->setOptions($options);
660 $this->form_gui->addItem($sel_input);
661 break;
662
663 case "text":
664 $text_input = new ilTextInputGUI($lng->txt("sty_".$var), $basepar);
665 $text_input->setMaxLength(200);
666 $text_input->setSize(20);
667 $this->form_gui->addItem($text_input);
668 break;
669
670 case "fontsize":
671 include_once("./Services/Style/classes/class.ilFontSizeInputGUI.php");
672 $fs_input = new ilFontSizeInputGUI($lng->txt("sty_".$var), $basepar);
673 $this->form_gui->addItem($fs_input);
674 break;
675
676 case "numeric_no_perc":
677 case "numeric":
678 include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
679 $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
680 if (ilObjStyleSheet::_getStyleParameterInputType($par) == "numeric_no_perc")
681 {
682 $num_input->setAllowPercentage(false);
683 }
684 $this->form_gui->addItem($num_input);
685 break;
686
687 case "percentage":
688 $per_input = new ilNumberInputGUI($lng->txt("sty_".$var), $basepar);
689 $per_input->setMinValue(0);
690 $per_input->setMaxValue(100);
691 $per_input->setMaxLength(3);
692 $per_input->setSize(3);
693 $this->form_gui->addItem($per_input);
694 break;
695
696 case "color":
697 //include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
698 $col_input = new ilColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
699 $col_input->setDefaultColor("");
700 $col_input->setAcceptNamedColors(true);
701 $this->form_gui->addItem($col_input);
702 break;
703
704 case "trbl_numeric":
705 include_once("./Services/Style/classes/class.ilTRBLNumericStyleValueInputGUI.php");
706 $num_input = new ilTRBLNumericStyleValueInputGUI($lng->txt("sty_".$var), $basepar);
707 if (ilObjStyleSheet::_getStyleParameterInputType($par) == "trbl_numeric_no_perc")
708 {
709 $num_input->setAllowPercentage(false);
710 }
711 $this->form_gui->addItem($num_input);
712 break;
713
714 case "border_width":
715 include_once("./Services/Style/classes/class.ilTRBLBorderWidthInputGUI.php");
716 $bw_input = new ilTRBLBorderWidthInputGUI($lng->txt("sty_".$var), $basepar);
717 $this->form_gui->addItem($bw_input);
718 break;
719
720 case "border_style":
721 include_once("./Services/Style/classes/class.ilTRBLBorderStyleInputGUI.php");
722 $bw_input = new ilTRBLBorderStyleInputGUI($lng->txt("sty_".$var), $basepar);
723 $this->form_gui->addItem($bw_input);
724 break;
725
726 case "trbl_color":
727 include_once("./Services/Style/classes/class.ilTRBLColorPickerInputGUI.php");
728 $col_input = new ilTRBLColorPickerInputGUI($lng->txt("sty_".$var), $basepar);
729 $col_input->setAcceptNamedColors(true);
730 $this->form_gui->addItem($col_input);
731 break;
732
733 case "background_image":
734 include_once("./Services/Style/classes/class.ilBackgroundImageInputGUI.php");
735 $im_input = new ilBackgroundImageInputGUI($lng->txt("sty_".$var), $basepar);
736 $imgs = array();
737 foreach ($this->object->getImages() as $entry)
738 {
739 $imgs[] = $entry["entry"];
740 }
741 $im_input->setImages($imgs);
742 $this->form_gui->addItem($im_input);
743 break;
744
745 case "background_position":
746 include_once("./Services/Style/classes/class.ilBackgroundPositionInputGUI.php");
747 $im_input = new ilBackgroundPositionInputGUI($lng->txt("sty_".$var), $basepar);
748 $this->form_gui->addItem($im_input);
749 break;
750 }
751 }
752 }
753
754 // custom parameters
755 $sh = new ilFormSectionHeaderGUI();
756 $sh->setTitle($lng->txt("sty_custom"));
757 $this->form_gui->addItem($sh);
758
759 // custom parameters
760 $ti = new ilTextInputGUI($this->lng->txt("sty_custom_par"), "custom_par");
761 $ti->setMaxLength(300);
762 $ti->setSize(80);
763 $ti->setMulti(true);
764 $ti->setInfo($this->lng->txt("sty_custom_par_info"));
765 $this->form_gui->addItem($ti);
766
767
768 // save and cancel commands
769 $this->form_gui->addCommandButton("updateTagStyle", $lng->txt("save_return"));
770 $this->form_gui->addCommandButton("refreshTagStyle", $lng->txt("save_refresh"));
771
772// $this->form_gui->setTitle($lng->txt("edit"));
773 $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
774 }
775
780 public function getValues()
781 {
782 $style = $this->object->getStyle();
783 $cur = explode(".",$_GET["tag"]);
784 $cur_tag = $cur[0];
785 $cur_class = $cur[1];
786 $cur_parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style, $_GET["style_type"],
787 (int) $_GET["mq_id"], false);
789 foreach($parameters as $p => $v)
790 {
791 $filtered_groups = ilObjStyleSheet::_getFilteredGroups();
792 if (is_array($filtered_groups[$v["group"]]) && !in_array($cur_tag, $filtered_groups[$v["group"]]))
793 {
794 continue;
795 }
796 $p = explode(".", $p);
797 $p = $p[0];
798 $input = $this->form_gui->getItemByPostVar($p);
799 switch ($v["input"])
800 {
801 case "":
802 break;
803
804 case "trbl_numeric":
805 case "border_width":
806 case "border_style":
807 case "trbl_color":
808 $input->setAllValue($cur_parameters[$v["subpar"][0]]);
809 $input->setTopValue($cur_parameters[$v["subpar"][1]]);
810 $input->setRightValue($cur_parameters[$v["subpar"][2]]);
811 $input->setBottomValue($cur_parameters[$v["subpar"][3]]);
812 $input->setLeftValue($cur_parameters[$v["subpar"][4]]);
813 break;
814
815 default:
816 $input->setValue($cur_parameters[$p]);
817 break;
818 }
819 }
820
821 $cust_parameters = $this->extractParametersOfTag($cur_tag, $cur_class, $style, $_GET["style_type"],
822 (int) $_GET["mq_id"], true);
823 $vals = array();
824 foreach ($cust_parameters as $k => $c)
825 {
826 $vals[] = $k.": ".$c;
827 }
828 $input = $this->form_gui->getItemByPostVar("custom_par");
829 $input->setValue($vals);
830 }
831
836 {
837 $file = $this->object->export();
838
839 ilUtil::deliverFile($file, "sty_".$this->object->getId().".zip");
840 }
841
842 function extractParametersOfTag($a_tag, $a_class, $a_style, $a_type, $a_mq_id = 0, $a_custom = false)
843 {
844 $parameters = array();
845 foreach($a_style as $tag)
846 {
847 foreach($tag as $par)
848 {
849 if ($par["tag"] == $a_tag && $par["class"] == $a_class
850 && $par["type"] == $a_type && (int) $a_mq_id == (int) $par["mq_id"]
851 && (int) $a_custom == (int) $par["custom"])
852 {
853 $parameters[$par["parameter"]] = $par["value"];
854 }
855 }
856 }
857 return $parameters;
858 }
859
864 {
865 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
866 $this->editObject();
867 }
868
872 function refreshObject()
873 {
874 $this->object->setTitle($_POST["style_title"]);
875 $this->object->setDescription($_POST["style_description"]);
876
877 foreach($_POST["styval"] as $id => $value)
878 {
879 $this->object->updateStyleParameter($id, $value);
880 }
881 $this->object->update();
882 $this->editObject();
883 }
884
890 function deleteObject($a_error = false)
891 {
892 //$this->setTabs();
893
894 // display confirmation message
895 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
896 $cgui = new ilConfirmationGUI();
897 $cgui->setFormAction($this->ctrl->getFormAction($this));
898 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
899 $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
900 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
901
902 $caption = ilUtil::getImageTagByType("sty", $this->tpl->tplPath).
903 " ".ilObject::_lookupTitle($this->object->getId());
904
905 $cgui->addItem("id[]", "", $caption);
906
907 $this->tpl->setContent($cgui->getHTML());
908 }
909
910
915 {
916 $this->ctrl->returnToParent($this);
917 }
918
923 {
924 global $ilias;
925
926 $this->object->delete();
927
928 $this->ctrl->returnToParent($this);
929 }
930
935 {
936 if (is_array($_POST["sty_select"]))
937 {
938 foreach($_POST["sty_select"] as $id => $dummy)
939 {
940 $this->object->deleteParameter($id);
941 }
942 }
943 $this->object->read();
944 $this->object->writeCSSFile();
945 $this->editObject();
946 }
947
951 function saveObject()
952 {
953 if(!trim($_POST["style_title"]))
954 {
955 $this->ctrl->redirect($this, "create");
956 }
957
958//echo "HH"; exit;
959 $class_name = "ilObjStyleSheet";
960 require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
961 $newObj = new ilObjStyleSheet();
962 $newObj->setTitle("-");
963 $newObj->create();
964 $newObj->setTitle(ilUtil::stripSlashes($_POST["style_title"]));
965 $newObj->setDescription(ilUtil::stripSlashes($_POST["style_description"]));
966 $newObj->update();
967
968 // assign style to style sheet folder,
969 // if parent is style sheet folder
970 if ($_GET["ref_id"] > 0)
971 {
972
973 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
974 if ($fold->getType() == "stys")
975 {
976 $fold->addStyle($newObj->getId());
977 $fold->update();
978 ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
979 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
980 }
981 }
982
983 return $newObj->getId();
984 }
985
990 {
991 global $ilias;
992
993 if ($_POST["source_style"] > 0)
994 $style_obj =& $ilias->obj_factory->getInstanceByObjId($_POST["source_style"]);
995 $new_id = $style_obj->ilClone();
996
997 // assign style to style sheet folder,
998 // if parent is style sheet folder
999 if ($_GET["ref_id"] > 0)
1000 {
1001
1002 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
1003 if ($fold->getType() == "stys")
1004 {
1005 $fold->addStyle($new_id);
1006 $fold->update();
1007 ilObjStyleSheet::_writeStandard($new_id, "1");
1008 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
1009 }
1010 }
1011
1012 return $new_id;
1013 }
1014
1019 {
1020 // check file
1021 $source = $_FILES["stylefile"]["tmp_name"];
1022 if (($source == 'none') || (!$source))
1023 {
1024 $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
1025 }
1026
1027 // check correct file type
1028 $info = pathinfo($_FILES["stylefile"]["name"]);
1029 if (strtolower($info["extension"]) != "zip" && strtolower($info["extension"]) != "xml")
1030 {
1031 $this->ilias->raiseError("File must be a zip or xml file!",$this->ilias->error_obj->MESSAGE);
1032 }
1033
1034 $class_name = "ilObjStyleSheet";
1035 require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1036 $newObj = new ilObjStyleSheet();
1037 //$newObj->setTitle();
1038 //$newObj->setDescription($_POST["style_description"]);
1039 $newObj->import($_FILES["stylefile"]);
1040 //$newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
1041
1042 // assign style to style sheet folder,
1043 // if parent is style sheet folder
1044 if ($_GET["ref_id"] > 0)
1045 {
1046
1047 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
1048 if ($fold->getType() == "stys")
1049 {
1050 $fold->addStyle($newObj->getId());
1051 $fold->update();
1052 ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
1053 $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
1054 }
1055 }
1056
1057 return $newObj->getId();
1058 }
1059
1063 function cancelObject()
1064 {
1065 global $lng;
1066
1067 ilUtil::sendInfo($lng->txt("msg_cancel"), true);
1068 $this->ctrl->returnToParent($this);
1069 }
1070
1074 function getAdminTabs(&$tabs_gui)
1075 {
1076 $this->getTabs($tabs_gui);
1077 }
1078
1082 function setTabs()
1083 {
1084 global $lng;
1085
1086 $this->getTabs($this->tabs_gui);
1087
1088 if (strtolower(get_class($this->object)) == "ilobjstylesheet")
1089 {
1090 $this->tpl->setVariable("HEADER", $this->object->getTitle());
1091 }
1092 else
1093 {
1094 $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
1095 }
1096 }
1097
1103 function getTabs(&$tabs_gui)
1104 {
1105 global $lng, $ilCtrl, $ilTabs, $ilHelp;
1106
1107 $ilHelp->setScreenIdComponent("sty");
1108
1109 if ($ilCtrl->getCmd() == "editTagStyle")
1110 {
1111 // back to upper context
1112 $tabs_gui->setBackTarget($lng->txt("back"),
1113 $ilCtrl->getLinkTarget($this, "edit"));
1114
1115 $t = explode(".", $_GET["tag"]);
1116 $t2 = explode(":", $t[1]);
1117 $pc = $this->object->_getPseudoClasses($t[0]);
1118 if (is_array($pc) && count($pc) > 0)
1119 {
1120 // style classes
1121 $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0]);
1122 $tabs_gui->addTarget("sty_tag_normal",
1123 $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1124 get_class($this));
1125 if ($t2[1] == "")
1126 {
1127 $ilTabs->setTabActive("sty_tag_normal");
1128 }
1129
1130 foreach ($pc as $p)
1131 {
1132 // style classes
1133 $ilCtrl->setParameter($this, "tag", $t[0].".".$t2[0].":".$p);
1134 $tabs_gui->addTarget("sty_tag_".$p,
1135 $this->ctrl->getLinkTarget($this, "editTagStyle"), array("editTagStyle", ""),
1136 get_class($this));
1137 if ($t2[1] == $p)
1138 {
1139 $ilTabs->setTabActive("sty_tag_".$p);
1140 }
1141 }
1142 $ilCtrl->setParameter($this, "tag", $_GET["tag"]);
1143 }
1144 }
1145 else
1146 {
1147 // back to upper context
1148 $tabs_gui->setBackTarget($lng->txt("back"),
1149 $this->ctrl->getLinkTarget($this, "returnToUpperContext"));
1150
1151 // style classes
1152 $tabs_gui->addTarget("sty_style_chars",
1153 $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1154 get_class($this));
1155
1156 // colors
1157 $tabs_gui->addTarget("sty_colors",
1158 $this->ctrl->getLinkTarget($this, "listColors"), "listColors",
1159 get_class($this));
1160
1161 // media queries
1162 $tabs_gui->addTarget("sty_media_queries",
1163 $this->ctrl->getLinkTarget($this, "listMediaQueries"), "listMediaQueries",
1164 get_class($this));
1165
1166 // images
1167 $tabs_gui->addTarget("sty_images",
1168 $this->ctrl->getLinkTarget($this, "listImages"), "listImages",
1169 get_class($this));
1170
1171 // table templates
1172 $tabs_gui->addTarget("sty_templates",
1173 $this->ctrl->getLinkTarget($this, "listTemplates"), "listTemplates",
1174 get_class($this));
1175
1176 // settings
1177 $tabs_gui->addTarget("settings",
1178 $this->ctrl->getLinkTarget($this, "properties"), "properties",
1179 get_class($this));
1180
1181 // accordiontest
1182/*
1183 $tabs_gui->addTarget("accordiontest",
1184 $this->ctrl->getLinkTarget($this, "accordiontest"), "accordiontest",
1185 get_class($this));*/
1186 }
1187
1188 }
1189
1195 function setSubTabs()
1196 {
1197 global $lng, $ilTabs, $ilCtrl;
1198
1200
1201 foreach ($types as $super_type => $types)
1202 {
1203 // text block characteristics
1204 $ilCtrl->setParameter($this, "style_type", $super_type);
1205 $ilTabs->addSubTabTarget("sty_".$super_type."_char",
1206 $this->ctrl->getLinkTarget($this, "edit"), array("edit", ""),
1207 get_class($this));
1208 }
1209
1210 $ilCtrl->setParameter($this, "style_type", $_GET["style_type"]);
1211 }
1212
1219 {
1220 global $lng, $ilTabs, $ilCtrl;
1221
1223
1224 foreach ($types as $t => $c)
1225 {
1226 $ilCtrl->setParameter($this, "temp_type", $t);
1227 $ilTabs->addSubTabTarget("sty_".$t."_templates",
1228 $this->ctrl->getLinkTarget($this, "listTemplates"), array("listTemplates", ""),
1229 get_class($this));
1230 }
1231
1232 $ilCtrl->setParameter($this, "temp_type", $_GET["temp_type"]);
1233 }
1234
1240 {
1241 global $ilLocator;
1242
1243 if ($_GET["admin_mode"] == "settings") // system settings
1244 {
1245 parent::addAdminLocatorItems(true);
1246
1247 $ilLocator->addItem(ilObject::_lookupTitle(
1248 ilObject::_lookupObjId($_GET["ref_id"])),
1249 $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui", "view"));
1250
1251 if ($_GET["obj_id"] > 0)
1252 {
1253 $ilLocator->addItem($this->object->getTitle(),
1254 $this->ctrl->getLinkTarget($this, "edit"));
1255 }
1256 }
1257 else // repository administration
1258 {
1259 //?
1260 }
1261
1262 }
1263
1264 function showUpperIcon()
1265 {
1266 global $tree, $tpl, $objDefinition;
1267
1268 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1269 {
1270 $tpl->setUpperIcon(
1271 $this->ctrl->getLinkTargetByClass("ilobjstylesettingsgui",
1272 "editContentStyles"));
1273 }
1274 else
1275 {
1276 // ?
1277 }
1278 }
1279
1284 {
1285 global $tpl, $ilToolbar, $ilCtrl, $lng, $rbacsystem;
1286
1287 if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1288 {
1289 $ilToolbar->addButton($lng->txt("sty_add_image"),
1290 $ilCtrl->getLinkTarget($this, "addImage"));
1291 }
1292
1293 include_once("./Services/Style/classes/class.ilStyleImageTableGUI.php");
1294 $table_gui = new ilStyleImageTableGUI($this, "listImages",
1295 $this->object);
1296 $tpl->setContent($table_gui->getHTML());
1297
1298 }
1299
1304 {
1305 global $tpl;
1306
1307 $this->initImageForm();
1308 $tpl->setContent($this->form_gui->getHTML());
1309 }
1310
1315 {
1316 global $ilCtrl;
1317
1318 $ilCtrl->redirect($this, "listImages");
1319 }
1320
1325 {
1326 global $tpl, $ilCtrl;
1327
1328 $this->initImageForm();
1329
1330 if ($this->form_gui->checkInput())
1331 {
1332 $this->object->uploadImage($_FILES["image_file"]);
1333 $ilCtrl->redirect($this, "listImages");
1334 }
1335 else
1336 {
1337 //$this->form_gui->setImageFormValuesByPost();
1338 $tpl->setContent($this->form_gui->getHTML());
1339 }
1340
1341 }
1342
1346 function initImageForm()
1347 {
1348 global $lng, $ilCtrl;
1349
1350 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1351 $this->form_gui = new ilPropertyFormGUI();
1352
1353 $this->form_gui->setTitle($lng->txt("sty_add_image"));
1354
1355 $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
1356 $file_input->setRequired(true);
1357 $this->form_gui->addItem($file_input);
1358
1359 $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
1360 $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
1361 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1362 }
1363
1368 {
1369 global $ilCtrl;
1370
1371 $images = $this->object->getImages();
1372
1373 foreach ($images as $image)
1374 {
1375 if (is_array($_POST["file"]) && in_array($image["entry"], $_POST["file"]))
1376 {
1377 $this->object->deleteImage($image["entry"]);
1378 }
1379 }
1380 $ilCtrl->redirect($this, "listImages");
1381 }
1382
1387 {
1388 global $ilCtrl, $tpl, $lng;
1389
1390//var_dump($_POST);
1391
1392 if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1393 {
1394 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1395 $ilCtrl->redirect($this, "edit");
1396 }
1397 else
1398 {
1399 // check whether there are any core style classes included
1400 $core_styles = ilObjStyleSheet::_getCoreStyles();
1401 foreach ($_POST["char"] as $char)
1402 {
1403 if (!empty($core_styles[$char]))
1404 {
1405 $this->deleteCoreCharMessage();
1406 return;
1407 }
1408 }
1409
1410 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1411 $cgui = new ilConfirmationGUI();
1412 $cgui->setFormAction($ilCtrl->getFormAction($this));
1413 $cgui->setHeaderText($lng->txt("sty_confirm_char_deletion"));
1414 $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1415 $cgui->setConfirm($lng->txt("delete"), "deleteCharacteristic");
1416
1417 foreach ($_POST["char"] as $char)
1418 {
1419 $char_comp = explode(".", $char);
1420 $cgui->addItem("char[]", $char, $char_comp[2]);
1421 }
1422
1423 $tpl->setContent($cgui->getHTML());
1424 }
1425 }
1426
1434 {
1435 global $ilCtrl, $tpl, $lng;
1436
1437 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1438 $cgui = new ilConfirmationGUI();
1439 $cgui->setFormAction($ilCtrl->getFormAction($this));
1440
1441
1442 $core_styles = ilObjStyleSheet::_getCoreStyles();
1443 $cnt = 0;
1444 foreach ($_POST["char"] as $char)
1445 {
1446 if (!empty($core_styles[$char]))
1447 {
1448 $cnt++;
1449 $char_comp = explode(".", $char);
1450 $cgui->addItem("", "", $char_comp[2]);
1451 }
1452 else
1453 {
1454 $cgui->addHiddenItem("char[]", $char);
1455 }
1456 }
1457 $all_core_styles = ($cnt == count($_POST["char"]))
1458 ? true
1459 : false;
1460
1461 if ($all_core_styles)
1462 {
1463 $cgui->setHeaderText($lng->txt("sty_all_styles_obligatory"));
1464 $cgui->setCancel($lng->txt("back"), "cancelCharacteristicDeletion");
1465 }
1466 else
1467 {
1468 $cgui->setHeaderText($lng->txt("sty_some_styles_obligatory_delete_rest"));
1469 $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
1470 $cgui->setConfirm($lng->txt("sty_delete_other_selected"), "deleteCharacteristicConfirmation");
1471 }
1472
1473 $tpl->setContent($cgui->getHTML());
1474 }
1475
1480 {
1481 global $ilCtrl, $lng;
1482
1483 ilUtil::sendInfo($lng->txt("action_aborted"), true);
1484 $ilCtrl->redirect($this, "edit");
1485 }
1486
1491 {
1492 global $ilCtrl;
1493
1494 if (is_array($_POST["char"]))
1495 {
1496 foreach($_POST["char"] as $char)
1497 {
1498 $char_comp = explode(".", $char);
1499 $type = $char_comp[0];
1500 $tag = $char_comp[1];
1501 $class = $char_comp[2];
1502
1503 $this->object->deleteCharacteristic($type, $tag, $class);
1504 }
1505 }
1506
1507 $ilCtrl->redirect($this, "edit");
1508 }
1509
1514 {
1515 global $tpl;
1516
1517 $this->initCharacteristicForm("create");
1518 $tpl->setContent($this->form_gui->getHTML());
1519 }
1520
1525 {
1526 global $ilCtrl, $tpl, $lng;
1527
1528 $this->initCharacteristicForm("create");
1529
1530 if ($this->form_gui->checkInput())
1531 {
1532 if ($this->object->characteristicExists($_POST["new_characteristic"], $_GET["style_type"]))
1533 {
1534 $char_input = $this->form_gui->getItemByPostVar("new_characteristic");
1535 $char_input->setAlert($lng->txt("sty_characteristic_already_exists"));
1536 }
1537 else
1538 {
1539 $this->object->addCharacteristic($_POST["type"], $_POST["new_characteristic"]);
1540 ilUtil::sendInfo($lng->txt("sty_added_characteristic"), true);
1541 $ilCtrl->setParameter($this, "tag",
1542 ilObjStyleSheet::_determineTag($_POST["type"]).".".$_POST["new_characteristic"]);
1543 $ilCtrl->setParameter($this, "style_type", $_POST["type"]);
1544 $ilCtrl->redirect($this, "editTagStyle");
1545 }
1546 }
1547 $this->form_gui->setValuesByPost();
1548 $tpl->setContent($this->form_gui->getHTML());
1549 }
1550
1556 public function initCharacteristicForm($a_mode)
1557 {
1558 global $lng, $ilCtrl;
1559
1560 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1561 $this->form_gui = new ilPropertyFormGUI();
1562
1563 // title
1564 $txt_input = new ilRegExpInputGUI($lng->txt("title"), "new_characteristic");
1565 $txt_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1566 $txt_input->setNoMatchMessage($lng->txt("sty_msg_characteristic_must_only_include")." A-Z, a-z, 1-9");
1567 $txt_input->setRequired(true);
1568 $this->form_gui->addItem($txt_input);
1569
1570 // type
1571 $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
1572 $types = $all_super_types[$this->super_type];
1573 $exp_types = array();
1574 foreach($types as $t)
1575 {
1577 {
1578 $exp_types[$t] = $lng->txt("sty_type_".$t);
1579 }
1580 }
1581 if (count($exp_types) > 1)
1582 {
1583 $type_input = new ilSelectInputGUI($lng->txt("sty_type"), "type");
1584 $type_input->setOptions($exp_types);
1585 $type_input->setValue(key($exp_types));
1586 $this->form_gui->addItem($type_input);
1587 }
1588 else if (count($exp_types) == 1)
1589 {
1590 $hid_input = new ilHiddenInputGUI("type");
1591 $hid_input->setValue(key($exp_types));
1592 $this->form_gui->addItem($hid_input);
1593 }
1594
1595 $this->form_gui->setTitle($lng->txt("sty_add_characteristic"));
1596 $this->form_gui->addCommandButton("saveCharacteristic", $lng->txt("save"));
1597 $this->form_gui->addCommandButton("edit", $lng->txt("cancel"));
1598 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1599 }
1600
1604 static function getStyleExampleHTML($a_type, $a_class)
1605 {
1606 global $lng;
1607
1608 $c = explode(":", $a_class);
1609 $a_class = $c[0];
1610
1611 $ex_tpl = new ilTemplate("tpl.style_example.html", true, true, "Services/Style");
1612
1613 $ex_tpl->setCurrentBlock("Example_".$a_type);
1614 $ex_tpl->setVariable("EX_CLASS", "ilc_".$a_type."_".$a_class);
1615 $ex_tpl->setVariable("EX_TEXT", "ABC abc 123");
1616 if (in_array($a_type, array("media_cont", "qimg")))
1617 {
1618 //
1619 }
1620 if (in_array($a_type, array("table", "table_caption")))
1621 {
1622 $ex_tpl->setVariable("TXT_CAPTION", $lng->txt("sty_caption"));
1623 }
1624 if (in_array($a_class, array("OrderListItemHorizontal", "OrderListHorizontal")))
1625 {
1626 $ex_tpl->setVariable("HOR", "Horizontal");
1627 }
1628 $ex_tpl->parseCurrentBlock();
1629
1630 return $ex_tpl->get();
1631 }
1632
1637 {
1638 global $ilCtrl, $lng;
1639
1640 //var_dump($_POST);
1641
1642 foreach ($_POST["all_chars"] as $char)
1643 {
1644 $ca = explode(".", $char);
1645 $this->object->saveHideStatus($ca[0], $ca[2],
1646 (is_array($_POST["hide"]) && in_array($char, $_POST["hide"])));
1647 }
1648
1649 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
1650 $ilCtrl->redirect($this, "edit");
1651 }
1652
1660 {
1661 global $ilCtrl, $lng;
1662
1663 if (!is_array($_POST["char"]) || count($_POST["char"]) == 0)
1664 {
1665 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1666 }
1667 else
1668 {
1669 $style_cp = implode("::", $_POST["char"]);
1670 $style_cp = $this->object->getId().":::".$_GET["style_type"].":::".$style_cp;
1671 $_SESSION["sty_copy"] = $style_cp;
1672 ilUtil::sendSuccess($lng->txt("sty_copied_please_select_target"), true);
1673 }
1674 $ilCtrl->redirect($this, "edit");
1675 }
1676
1684 {
1685 global $tpl, $ilTabs;
1686
1687 $ilTabs->clearTargets();
1688
1689 include_once("./Services/Style/classes/class.ilPasteStyleCharacteristicTableGUI.php");
1690 $table = new ilPasteStyleCharacteristicTableGUI($this, "pasteCharacteristicsOverview");
1691
1692 $tpl->setContent($table->getHTML());
1693 }
1694
1702 {
1703 global $ilCtrl, $lng;
1704
1705 if (is_array($_POST["title"]))
1706 {
1707 foreach ($_POST["title"] as $from_char => $to_title)
1708 {
1709 $fc = explode(".", $from_char);
1710
1711 if ($_POST["conflict_action"][$from_char] == "overwrite" ||
1712 !$this->object->characteristicExists($to_title, $fc[0]))
1713 {
1714 $this->object->copyCharacteristic($_POST["from_style_id"],
1715 $fc[0], $fc[2], $to_title);
1716 }
1717 }
1718 ilObjStyleSheet::_writeUpToDate($this->object->getId(), false);
1719 unset($_SESSION["sty_copy"]);
1720 ilUtil::sendSuccess($lng->txt("sty_style_classes_copied"), true);
1721 }
1722
1723 $ilCtrl->redirect($this, "edit");
1724 }
1725
1726 //
1727 // Color management
1728 //
1729
1734 {
1735 global $tpl, $rbacsystem, $ilToolbar, $ilCtrl;
1736
1737 if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1738 {
1739 $ilToolbar->addButton($this->lng->txt("sty_add_color"),
1740 $ilCtrl->getLinkTarget($this, "addColor"));
1741 }
1742
1743 include_once("./Services/Style/classes/class.ilStyleColorTableGUI.php");
1744 $table_gui = new ilStyleColorTableGUI($this, "listColors",
1745 $this->object);
1746 $tpl->setContent($table_gui->getHTML());
1747
1748 }
1749
1754 {
1755 global $tpl;
1756
1757 $this->initColorForm();
1758 $tpl->setContent($this->form_gui->getHTML());
1759 }
1760
1765 {
1766 global $tpl, $ilCtrl;
1767
1768 $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1769 $this->initColorForm("edit");
1770 $this->getColorFormValues();
1771 $tpl->setContent($this->form_gui->getHTML());
1772 }
1773
1774
1778 function initColorForm($a_mode = "create")
1779 {
1780 global $lng, $ilCtrl;
1781
1782 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1783 $this->form_gui = new ilPropertyFormGUI();
1784
1785 $this->form_gui->setTitle($lng->txt("sty_add_color"));
1786
1787 // name
1788 $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
1789 $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1790 $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
1791 $name_input->setRequired(true);
1792 $name_input->setSize(15);
1793 $name_input->setMaxLength(15);
1794 $this->form_gui->addItem($name_input);
1795
1796 // code
1797 $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
1798 $color_input->setRequired(true);
1799 $color_input->setDefaultColor("");
1800 $this->form_gui->addItem($color_input);
1801
1802 if ($a_mode == "create")
1803 {
1804 $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
1805 $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1806 }
1807 else
1808 {
1809 $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
1810 $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
1811 }
1812 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1813 }
1814
1819 {
1820 if ($_GET["c_name"] != "")
1821 {
1822 $values["color_name"] = $_GET["c_name"];
1823 $values["color_code"] = $this->object->getColorCodeForName($_GET["c_name"]);
1824 $this->form_gui->setValuesByArray($values);
1825 }
1826 }
1827
1832 {
1833 global $ilCtrl;
1834
1835 $ilCtrl->redirect($this, "listColors");
1836 }
1837
1842 {
1843 global $tpl, $ilCtrl, $lng;
1844
1845 $this->initColorForm();
1846
1847 if ($this->form_gui->checkInput())
1848 {
1849 if ($this->object->colorExists($_POST["color_name"]))
1850 {
1851 $col_input = $this->form_gui->getItemByPostVar("color_name");
1852 $col_input->setAlert($lng->txt("sty_color_already_exists"));
1853 }
1854 else
1855 {
1856 $this->object->addColor($_POST["color_name"],
1857 $_POST["color_code"]);
1858 $ilCtrl->redirect($this, "listColors");
1859 }
1860 }
1861 $this->form_gui->setValuesByPost();
1862 $tpl->setContent($this->form_gui->getHTML());
1863 }
1864
1869 {
1870 global $tpl, $ilCtrl, $lng;
1871
1872 $this->initColorForm("edit");
1873
1874 if ($this->form_gui->checkInput())
1875 {
1876 if ($this->object->colorExists($_POST["color_name"]) &&
1877 $_POST["color_name"] != $_GET["c_name"])
1878 {
1879 $col_input = $this->form_gui->getItemByPostVar("color_name");
1880 $col_input->setAlert($lng->txt("sty_color_already_exists"));
1881 }
1882 else
1883 {
1884 $this->object->updateColor($_GET["c_name"], $_POST["color_name"],
1885 $_POST["color_code"]);
1886 $ilCtrl->redirect($this, "listColors");
1887 }
1888 }
1889 $ilCtrl->setParameter($this, "c_name", $_GET["c_name"]);
1890 $this->form_gui->setValuesByPost();
1891 $tpl->setContent($this->form_gui->getHTML());
1892 }
1893
1898 {
1899 global $ilCtrl, $tpl, $lng;
1900
1901 if (!is_array($_POST["color"]) || count($_POST["color"]) == 0)
1902 {
1903 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1904 $ilCtrl->redirect($this, "listColors");
1905 }
1906 else
1907 {
1908 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1909 $cgui = new ilConfirmationGUI();
1910 $cgui->setFormAction($ilCtrl->getFormAction($this));
1911 $cgui->setHeaderText($lng->txt("sty_confirm_color_deletion"));
1912 $cgui->setCancel($lng->txt("cancel"), "cancelColorDeletion");
1913 $cgui->setConfirm($lng->txt("delete"), "deleteColor");
1914
1915 foreach ($_POST["color"] as $c)
1916 {
1917 $cgui->addItem("color[]", ilUtil::prepareFormOutput($c), $c);
1918 }
1919
1920 $tpl->setContent($cgui->getHTML());
1921 }
1922 }
1923
1928 {
1929 global $ilCtrl;
1930
1931 $ilCtrl->redirect($this, "listColors");
1932 }
1933
1938 {
1939 global $ilCtrl;
1940
1941 if (is_array($_POST["color"]))
1942 {
1943 foreach ($_POST["color"] as $c)
1944 {
1945 $this->object->removeColor($c);
1946 }
1947 }
1948
1949 $ilCtrl->redirect($this, "listColors");
1950 }
1951
1952 //
1953 // Media query management
1954 //
1955
1960 {
1961 global $tpl, $rbacsystem, $ilToolbar, $ilCtrl;
1962
1963 if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
1964 {
1965 $ilToolbar->addButton($this->lng->txt("sty_add_media_query"),
1966 $ilCtrl->getLinkTarget($this, "addMediaQuery"));
1967 }
1968
1969 include_once("./Services/Style/classes/class.ilStyleMediaQueryTableGUI.php");
1970 $table_gui = new ilStyleMediaQueryTableGUI($this, "listMediaQueries",
1971 $this->object);
1972 $tpl->setContent($table_gui->getHTML());
1973 }
1974
1979 {
1980 global $tpl;
1981
1982 $this->initMediaQueryForm();
1983 $tpl->setContent($this->form_gui->getHTML());
1984 }
1985
1990 {
1991 global $tpl, $ilCtrl;
1992
1993 $ilCtrl->setParameter($this, "mq_id", $_GET["mq_id"]);
1994 $this->initMediaQueryForm("edit");
1995 $this->getMediaQueryFormValues();
1996 $tpl->setContent($this->form_gui->getHTML());
1997 }
1998
1999
2003 function initMediaQueryForm($a_mode = "create")
2004 {
2005 global $lng, $ilCtrl;
2006
2007 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2008 $this->form_gui = new ilPropertyFormGUI();
2009
2010 $this->form_gui->setTitle($lng->txt("sty_add_media_query"));
2011
2012 // media query
2013 $ti = new ilTextInputGUI("@media", "mquery");
2014 $ti->setMaxLength(2000);
2015 $this->form_gui->addItem($ti);
2016
2017
2018 if ($a_mode == "create")
2019 {
2020 $this->form_gui->addCommandButton("saveMediaQuery", $lng->txt("save"));
2021 $this->form_gui->addCommandButton("listMediaQueries", $lng->txt("cancel"));
2022 }
2023 else
2024 {
2025 $this->form_gui->addCommandButton("updateMediaQuery", $lng->txt("save"));
2026 $this->form_gui->addCommandButton("listMediaQueries", $lng->txt("cancel"));
2027 }
2028 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2029 }
2030
2035 {
2036 if ($_GET["mq_id"] != "")
2037 {
2038 foreach ($this->object->getMediaQueries() as $mq)
2039 {
2040 if ($mq["id"] == (int) $_GET["mq_id"])
2041 {
2042 $values["mquery"] = $mq["mquery"];
2043 }
2044 }
2045 $this->form_gui->setValuesByArray($values);
2046 }
2047 }
2048
2053 {
2054 global $tpl, $ilCtrl, $lng;
2055
2056 $this->initMediaQueryForm();
2057
2058 if ($this->form_gui->checkInput())
2059 {
2060 $this->object->addMediaQuery($_POST["mquery"]);
2061 $ilCtrl->redirect($this, "listMediaQueries");
2062 }
2063 $this->form_gui->setValuesByPost();
2064 $tpl->setContent($this->form_gui->getHTML());
2065 }
2066
2071 {
2072 global $tpl, $ilCtrl, $lng;
2073
2074 $this->initMediaQueryForm("edit");
2075
2076 if ($this->form_gui->checkInput())
2077 {
2078 $this->object->updateMediaQuery((int) $_GET["mq_id"], $_POST["mquery"]);
2079 $ilCtrl->redirect($this, "listMediaQueries");
2080 }
2081 $ilCtrl->setParameter($this, "mq_id", $_GET["mq_id"]);
2082 $this->form_gui->setValuesByPost();
2083 $tpl->setContent($this->form_gui->getHTML());
2084 }
2085
2090 {
2091 global $ilCtrl, $tpl, $lng;
2092
2093 if (!is_array($_POST["mq_id"]) || count($_POST["mq_id"]) == 0)
2094 {
2095 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2096 $ilCtrl->redirect($this, "listMediaQueries");
2097 }
2098 else
2099 {
2100 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2101 $cgui = new ilConfirmationGUI();
2102 $cgui->setFormAction($ilCtrl->getFormAction($this));
2103 $cgui->setHeaderText($lng->txt("sty_sure_del_mqueries"));
2104 $cgui->setCancel($lng->txt("cancel"), "listMediaQueries");
2105 $cgui->setConfirm($lng->txt("delete"), "deleteMediaQueries");
2106
2107 foreach ($_POST["mq_id"] as $i)
2108 {
2109 $mq = $this->object->getMediaQueryForId($i);
2110 $cgui->addItem("mq_id[]", $i, $mq["mquery"]);
2111 }
2112
2113 $tpl->setContent($cgui->getHTML());
2114 }
2115 }
2116
2124 {
2125 global $ilCtrl, $rbacsystem;
2126
2127 if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]) && is_array($_POST["mq_id"]))
2128 {
2129 foreach ($_POST["mq_id"] as $id)
2130 {
2131 $this->object->deleteMediaQuery($id);
2132 }
2133 }
2134 $ilCtrl->redirect($this, "listMediaQueries");
2135 }
2136
2144 {
2145 global $ilCtrl;
2146
2147 if (is_array($_POST["order"]))
2148 {
2149 $this->object->saveMediaQueryOrder($_POST["order"]);
2150 }
2151 $ilCtrl->redirect($this, "listMediaQueries");
2152 }
2153
2154
2155 //
2156 // Templates management
2157 //
2158
2163 {
2164 global $tpl, $ilTabs, $ilCtrl;
2165
2166 $ctype = $_GET["temp_type"];
2167 if ($ctype == "")
2168 {
2169 $ctype = "table";
2170 $ilCtrl->setParameter($this, "temp_type", $ctype);
2171 $_GET["temp_type"] = $ctype;
2172 }
2173
2174 $this->setTemplatesSubTabs();
2175 $ilTabs->setSubTabActive("sty_".$ctype."_templates");
2176
2177 $this->includeCSS();
2178 include_once("./Services/Style/classes/class.ilTableTemplatesTableGUI.php");
2179 $table_gui = new ilTableTemplatesTableGUI($ctype, $this, "listTemplates",
2180 $this->object);
2181 $tpl->setContent($table_gui->getHTML());
2182
2183 }
2184
2189 {
2190 global $tpl;
2191
2192 $this->initTemplateForm();
2193 $tpl->setContent($this->form_gui->getHTML());
2194 }
2195
2200 {
2201 global $tpl, $ilCtrl;
2202
2203 $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
2204 $this->initTemplateForm("edit");
2205 $this->getTemplateFormValues();
2206
2207 $this->displayTemplateEditForm();
2208 }
2209
2213 function getTemplatePreview($a_type, $a_t_id, $a_small_mode = false)
2214 {
2215 return $this->_getTemplatePreview(
2216 $this->object, $a_type, $a_t_id, $a_small_mode);
2217 }
2218
2222 function _getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode = false)
2223 {
2224 global $lng, $tpl;
2225
2226 $kr = $kc = 7;
2227 if ($a_small_mode)
2228 {
2229 $kr = 6;
2230 $kc = 5;
2231 }
2232
2233 $ts = $a_style->getTemplate($a_t_id);
2234 $t = $ts["classes"];
2235
2236 // preview
2237 if ($a_type == "table")
2238 {
2239 $p_content = '<PageContent><Table DataTable="y"';
2240 if ($t["row_head"] != "")
2241 {
2242 $p_content.= ' HeaderRows="1"';
2243 }
2244 if ($t["row_foot"] != "")
2245 {
2246 $p_content.= ' FooterRows="1"';
2247 }
2248 if ($t["col_head"] != "")
2249 {
2250 $p_content.= ' HeaderCols="1"';
2251 }
2252 if ($t["col_foot"] != "")
2253 {
2254 $p_content.= ' FooterCols="1"';
2255 }
2256 $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
2257 if (!$a_small_mode)
2258 {
2259 $p_content.= '<Caption>'.$lng->txt("sty_caption").'</Caption>';
2260 }
2261 for($i = 1; $i<=$kr; $i++)
2262 {
2263 $p_content.= '<TableRow>';
2264 for($j = 1; $j<=$kc; $j++)
2265 {
2266 if ($a_small_mode)
2267 {
2268 $cell = '&lt;div style="height:2px;"&gt;&lt;/div&gt;';
2269 }
2270 else
2271 {
2272 $cell = 'xxx';
2273 }
2274 $p_content.= '<TableData><PageContent><Paragraph Characteristic="TableContent">'.$cell.'</Paragraph></PageContent></TableData>';
2275 }
2276 $p_content.= '</TableRow>';
2277 }
2278 $p_content.= '</Table></PageContent>';
2279 }
2280
2281 if ($a_type == "vaccordion" || $a_type == "haccordion")
2282 {
2283 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2285
2286 if ($a_small_mode)
2287 {
2288 $c = '&amp;nbsp;';
2289 $h = '&amp;nbsp;';
2290 }
2291 else
2292 {
2293 $c = 'xxx';
2294 $h = 'head';
2295 }
2296 if ($a_type == "vaccordion")
2297 {
2298 $p_content = '<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
2299 if ($a_small_mode)
2300 {
2301 $p_content.= ' ContentWidth="70"';
2302 }
2303 }
2304 else
2305 {
2306 $p_content = '<PageContent><Tabs Type="HorizontalAccordion"';
2307 if ($a_small_mode)
2308 {
2309 $p_content.= ' ContentHeight="40"';
2310 $p_content.= ' ContentWidth="70"';
2311 $c = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';
2312 }
2313 else
2314 {
2315 $p_content.= ' ContentHeight="40"';
2316 }
2317 }
2318 $p_content.= ' Template="'.$a_style->lookupTemplateName($a_t_id).'">';
2319 $p_content.= '<Tab><PageContent><Paragraph>'.$c.'</Paragraph></PageContent>';
2320 $p_content.= '<TabCaption>'.$h.'</TabCaption>';
2321 $p_content.= '</Tab>';
2322 $p_content.= '</Tabs></PageContent>';
2323 }
2324//echo htmlentities($p_content);
2325 $txml = $a_style->getTemplateXML();
2326//echo htmlentities($txml);
2327 $p_content.= $txml;
2328 include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
2329 $r_content = ilPCTableGUI::_renderTable($p_content, "");
2330
2331 return $r_content;
2332 }
2333
2337 function initTemplateForm($a_mode = "create")
2338 {
2339 global $lng, $ilCtrl;
2340
2341 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2342 $this->form_gui = new ilPropertyFormGUI();
2343
2344 if ($a_mode == "create")
2345 {
2346 $this->form_gui->setTitle($lng->txt("sty_add_template"));
2347 }
2348 else
2349 {
2350 $this->form_gui->setTitle($lng->txt("sty_edit_template"));
2351 }
2352
2353 // name
2354 $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2355 $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2356 $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2357 $name_input->setRequired(true);
2358 $name_input->setSize(30);
2359 $name_input->setMaxLength(30);
2360 $this->form_gui->addItem($name_input);
2361
2362 // template style classes
2364 foreach ($scs as $sc => $st)
2365 {
2366 $sc_input = new ilSelectInputGUI($lng->txt("sty_".$sc."_class"), $sc."_class");
2367 $chars = $this->object->getCharacteristics($st);
2368 $options = array("" => "");
2369 foreach($chars as $char)
2370 {
2371 $options[$char] = $char;
2372 }
2373 $sc_input->setOptions($options);
2374 $this->form_gui->addItem($sc_input);
2375 }
2376
2377 if ($a_mode == "create")
2378 {
2379 $this->form_gui->addCommandButton("saveTemplate", $lng->txt("save"));
2380 $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2381 }
2382 else
2383 {
2384 $this->form_gui->addCommandButton("refreshTemplate", $lng->txt("save_refresh"));
2385 $this->form_gui->addCommandButton("updateTemplate", $lng->txt("save_return"));
2386 $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2387 }
2388 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2389 }
2390
2395 {
2396 global $ilCtrl;
2397
2398 $ilCtrl->redirect($this, "listTemplates");
2399 }
2400
2401
2406 {
2407 global $tpl, $ilCtrl, $lng;
2408
2409 $this->initTemplateForm();
2410
2411 if ($this->form_gui->checkInput())
2412 {
2413 if ($this->object->templateExists($_POST["name"]))
2414 {
2415 $name_input = $this->form_gui->getItemByPostVar("name");
2416 $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2417 }
2418 else
2419 {
2420 $classes = array();
2421 foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2422 {
2423 $classes[$tct] = $_POST[$tct."_class"];
2424 }
2425 $t_id = $this->object->addTemplate($_GET["temp_type"], $_POST["name"], $classes);
2426 $this->object->writeTemplatePreview($t_id,
2427 $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2428 $ilCtrl->redirect($this, "listTemplates");
2429 }
2430 }
2431 $this->form_gui->setValuesByPost();
2432 $tpl->setContent($this->form_gui->getHTML());
2433 }
2434
2438 function updateTemplateObject($a_refresh = false)
2439 {
2440 global $tpl, $ilCtrl, $lng;
2441
2442 $ilCtrl->setParameter($this, "t_id", $_GET["t_id"]);
2443 $this->initTemplateForm("edit");
2444
2445 if ($this->form_gui->checkInput())
2446 {
2447 if ($this->object->templateExists($_POST["name"]) &&
2449 {
2450 $name_input = $this->form_gui->getItemByPostVar("name");
2451 $name_input->setAlert($lng->txt("sty_template_already_exists"));
2452 }
2453 else
2454 {
2455 $classes = array();
2456 foreach (ilObjStyleSheet::_getTemplateClassTypes($_GET["temp_type"]) as $tct => $ct)
2457 {
2458 $classes[$tct] = $_POST[$tct."_class"];
2459 }
2460
2461 $this->object->updateTemplate($_GET["t_id"],
2462 $_POST["name"], $classes);
2463 $this->object->writeTemplatePreview($_GET["t_id"],
2464 $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"], true));
2465 if(!$a_refresh)
2466 {
2467 $ilCtrl->redirect($this, "listTemplates");
2468 }
2469 }
2470 }
2471
2472 $this->form_gui->setValuesByPost();
2473 $this->displayTemplateEditForm();
2474 }
2475
2480 {
2481 global $tpl;
2482
2483 $a_tpl = new ilTemplate("tpl.template_edit.html", true, true,
2484 "Services/Style");
2485 $this->includeCSS();
2486 $a_tpl->setVariable("FORM", $this->form_gui->getHTML());
2487 $a_tpl->setVariable("PREVIEW", $this->getTemplatePreview($_GET["temp_type"], $_GET["t_id"]));
2488 $tpl->setContent($a_tpl->get());
2489 }
2490
2495 {
2496 $this->updateTemplateObject(true);
2497 }
2498
2503 {
2504 if ($_GET["t_id"] > 0)
2505 {
2506 $t = $this->object->getTemplate($_GET["t_id"]);
2507
2508 $values["name"] = $t["name"];
2510 foreach ($scs as $k => $type)
2511 {
2512 $values[$k."_class"] = $t["classes"][$k];
2513 }
2514 $this->form_gui->setValuesByArray($values);
2515 }
2516 }
2517
2522 {
2523 global $ilCtrl, $tpl, $lng;
2524
2525 if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
2526 {
2527 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2528 $ilCtrl->redirect($this, "listTemplates");
2529 }
2530 else
2531 {
2532 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2533 $cgui = new ilConfirmationGUI();
2534 $cgui->setFormAction($ilCtrl->getFormAction($this));
2535 $cgui->setHeaderText($lng->txt("sty_confirm_template_deletion"));
2536 $cgui->setCancel($lng->txt("cancel"), "cancelTemplateDeletion");
2537 $cgui->setConfirm($lng->txt("sty_del_template"), "deleteTemplate");
2538
2539 foreach ($_POST["tid"] as $tid)
2540 {
2541 $classes = $this->object->getTemplateClasses($tid);
2542 $cl_str = "";
2543 $listed = array();
2544 foreach ($classes as $cl)
2545 {
2546 if ($cl != "" && !$listed[$cl])
2547 {
2548 $cl_str.= '<div>- '.
2549 $cl."</div>";
2550 $listed[$cl] = true;
2551 }
2552 }
2553 if ($cl_str != "")
2554 {
2555 $cl_str = '<div style="padding-left:30px;" class="small">'.
2556 "<div><i>".$lng->txt("sty_style_class")."</i></div>".$cl_str."</div>";
2557 }
2558 $cgui->addItem("tid[]", $tid, $this->object->lookupTemplateName($tid).$cl_str);
2559 }
2560
2561 $cgui->addButton($lng->txt("sty_del_template_keep_classes"), "deleteTemplateKeepClasses");
2562
2563 $tpl->setContent($cgui->getHTML());
2564 }
2565 }
2566
2571 {
2572 global $ilCtrl;
2573
2574 $ilCtrl->redirect($this, "listTemplates");
2575 }
2576
2581 {
2582 global $ilCtrl;
2583
2584 if (is_array($_POST["tid"]))
2585 {
2586 foreach ($_POST["tid"] as $tid)
2587 {
2588 $this->object->removeTemplate($tid);
2589 }
2590 }
2591
2592 $ilCtrl->redirect($this, "listTemplates");
2593 }
2594
2599 {
2600 global $ilCtrl;
2601
2602 if (is_array($_POST["tid"]))
2603 {
2604 foreach ($_POST["tid"] as $tid)
2605 {
2606 $cls = $this->object->getTemplateClasses($tid);
2607 foreach ($cls as $k => $cls)
2608 {
2609 $ty = $this->object->determineTemplateStyleClassType($_GET["temp_type"], $k);
2611 $this->object->deleteCharacteristic($ty, $ta, $cls);
2612 }
2613 $this->object->removeTemplate($tid);
2614 }
2615 }
2616
2617 $ilCtrl->redirect($this, "listTemplates");
2618 }
2619
2624 {
2625 global $tpl;
2626
2628 $tpl->setContent($this->form_gui->getHTML());
2629 }
2630
2635 {
2636 global $lng, $ilCtrl;
2637
2638 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2639 $this->form_gui = new ilPropertyFormGUI();
2640
2641 $this->form_gui->setTitle($lng->txt("sty_generate_template"));
2642
2643 // name
2644 $name_input = new ilRegExpInputGUI($lng->txt("sty_template_name"), "name");
2645 $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*$/");
2646 $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include")." A-Z, a-z, 1-9");
2647 $name_input->setRequired(true);
2648 $name_input->setSize(30);
2649 $name_input->setMaxLength(30);
2650 $this->form_gui->addItem($name_input);
2651
2652 // basic layout
2653 $bl_input = new ilSelectInputGUI($lng->txt("sty_template_layout"), "layout");
2654 $options = array(
2655 "coloredZebra" => $lng->txt("sty_table_template_colored_zebra"),
2656 "bwZebra" => $lng->txt("sty_table_template_bw_zebra"),
2657 "noZebra" => $lng->txt("sty_table_template_no_zebra")
2658 );
2659 $bl_input->setOptions($options);
2660 $this->form_gui->addItem($bl_input);
2661
2662 // top bottom padding
2663 include_once("./Services/Style/classes/class.ilNumericStyleValueInputGUI.php");
2664 $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_top_bottom_padding"), "tb_padding");
2665 $num_input->setAllowPercentage(false);
2666 $num_input->setValue("3px");
2667 $this->form_gui->addItem($num_input);
2668
2669 // left right padding
2670 $num_input = new ilNumericStyleValueInputGUI($lng->txt("sty_left_right_padding"), "lr_padding");
2671 $num_input->setAllowPercentage(false);
2672 $num_input->setValue("10px");
2673 $this->form_gui->addItem($num_input);
2674
2675 // base color
2676 $bc_input = new ilSelectInputGUI($lng->txt("sty_base_color"), "base_color");
2677 $cs = $this->object->getColors();
2678 $options = array();
2679 foreach ($cs as $c)
2680 {
2681 $options[$c["name"]] = $c["name"];
2682 }
2683 $bc_input->setOptions($options);
2684 $this->form_gui->addItem($bc_input);
2685
2686 // Lightness Settings
2687 $lss = array("border" => 90, "header_text" => 70, "header_bg" => 0,
2688 "cell1_text" => -60, "cell1_bg" => 90, "cell2_text" => -60, "cell2_bg" => 75);
2689 foreach ($lss as $ls => $v)
2690 {
2691 $l_input = new ilNumberInputGUI($lng->txt("sty_lightness_".$ls), "lightness_".$ls);
2692 $l_input->setMaxValue(100);
2693 $l_input->setMinValue(-100);
2694 $l_input->setValue($v);
2695 $l_input->setSize(4);
2696 $l_input->setMaxLength(4);
2697 $this->form_gui->addItem($l_input);
2698 }
2699
2700 $this->form_gui->addCommandButton("templateGeneration", $lng->txt("generate"));
2701 $this->form_gui->addCommandButton("cancelTemplateSaving", $lng->txt("cancel"));
2702 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
2703 }
2704
2709 {
2710 global $tpl, $ilCtrl, $lng;
2711
2713
2714 if ($this->form_gui->checkInput())
2715 {
2716 if ($this->object->templateExists($_POST["name"]))
2717 {
2718 $name_input = $this->form_gui->getItemByPostVar("name");
2719 $name_input->setAlert($lng->txt("sty_table_template_already_exists"));
2720 }
2721 else
2722 {
2723 // -> move to application class!
2724
2725 // cell classes
2726 $cells = array("H" => "header", "C1" => "cell1", "C2" => "cell2");
2727 $tb_p = $this->form_gui->getItemByPostVar("tb_padding");
2728 $tb_padding = $tb_p->getValue();
2729 $lr_p = $this->form_gui->getItemByPostVar("lr_padding");
2730 $lr_padding = $lr_p->getValue();
2731 $cell_color = $_POST["base_color"];
2732
2733 // use mid gray as cell color for bw zebra
2734 if ($_POST["layout"] == "bwZebra")
2735 {
2736 $cell_color = "MidGray";
2737 if (!$this->object->colorExists($cell_color))
2738 {
2739 $this->object->addColor($cell_color, "7F7F7F");
2740 }
2741 $this->object->updateColor($cell_color, $cell_color, "7F7F7F");
2742 }
2743
2744 foreach ($cells as $k => $cell)
2745 {
2746 $cell_class[$k] = $_POST["name"].$k;
2747 if (!$this->object->characteristicExists($cell_class[$k], "table_cell"))
2748 {
2749 $this->object->addCharacteristic("table_cell", $cell_class[$k], true);
2750 }
2751 if ($_POST["layout"] == "bwZebra" && $k == "H")
2752 {
2753 $this->object->replaceStylePar("td", $cell_class[$k], "color",
2754 "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2755 $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2756 "!".$_POST["base_color"]."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2757 }
2758 else
2759 {
2760 $this->object->replaceStylePar("td", $cell_class[$k], "color",
2761 "!".$cell_color."(".$_POST["lightness_".$cell."_text"].")", "table_cell");
2762 $this->object->replaceStylePar("td", $cell_class[$k], "background-color",
2763 "!".$cell_color."(".$_POST["lightness_".$cell."_bg"].")", "table_cell");
2764 }
2765 $this->object->replaceStylePar("td", $cell_class[$k], "padding-top",
2766 $tb_padding, "table_cell");
2767 $this->object->replaceStylePar("td", $cell_class[$k], "padding-bottom",
2768 $tb_padding, "table_cell");
2769 $this->object->replaceStylePar("td", $cell_class[$k], "padding-left",
2770 $lr_padding, "table_cell");
2771 $this->object->replaceStylePar("td", $cell_class[$k], "padding-right",
2772 $lr_padding, "table_cell");
2773 $this->object->replaceStylePar("td", $cell_class[$k], "border-width",
2774 "1px", "table_cell");
2775 $this->object->replaceStylePar("td", $cell_class[$k], "border-style",
2776 "solid", "table_cell");
2777 $this->object->replaceStylePar("td", $cell_class[$k], "border-color",
2778 "!".$cell_color."(".$_POST["lightness_border"].")", "table_cell");
2779 $this->object->replaceStylePar("td", $cell_class[$k], "font-weight",
2780 "normal", "table_cell");
2781 }
2782
2783 // table class
2784 $classes["table"] = $_POST["name"]."T";
2785 if (!$this->object->characteristicExists($classes["table"], "table"))
2786 {
2787 $this->object->addCharacteristic("table", $classes["table"], true);
2788 }
2789 $this->object->replaceStylePar("table", $classes["table"], "caption-side",
2790 "bottom", "table");
2791 $this->object->replaceStylePar("table", $classes["table"], "border-collapse",
2792 "collapse", "table");
2793 $this->object->replaceStylePar("table", $classes["table"], "margin-top",
2794 "5px", "table");
2795 $this->object->replaceStylePar("table", $classes["table"], "margin-bottom",
2796 "5px", "table");
2797 if ($_POST["layout"] == "bwZebra")
2798 {
2799 $this->object->replaceStylePar("table", $classes["table"], "border-bottom-color",
2800 "!".$_POST["base_color"], "table");
2801 $this->object->replaceStylePar("table", $classes["table"], "border-bottom-style",
2802 "solid", "table");
2803 $this->object->replaceStylePar("table", $classes["table"], "border-bottom-width",
2804 "3px", "table");
2805 $sb = array("left", "right", "top");
2806 foreach ($sb as $b)
2807 {
2808 $this->object->replaceStylePar("table", $classes["table"], "border-".$b."-width",
2809 "0px", "table");
2810 }
2811 }
2812
2813 switch ($_POST["layout"])
2814 {
2815 case "coloredZebra":
2816 $classes["row_head"] = $cell_class["H"];
2817 $classes["odd_row"] = $cell_class["C1"];
2818 $classes["even_row"] = $cell_class["C2"];
2819 break;
2820
2821 case "bwZebra":
2822 $classes["row_head"] = $cell_class["H"];
2823 $classes["odd_row"] = $cell_class["C1"];
2824 $classes["even_row"] = $cell_class["C2"];
2825 break;
2826
2827 case "noZebra":
2828 $classes["row_head"] = $cell_class["H"];
2829 $classes["odd_row"] = $cell_class["C1"];
2830 $classes["even_row"] = $cell_class["C1"];
2831 $classes["col_head"] = $cell_class["C2"];
2832 break;
2833 }
2834
2835
2836 $t_id = $this->object->addTemplate($_GET["temp_type"],
2837 $_POST["name"], $classes);
2838 $this->object->writeTemplatePreview($t_id,
2839 $this->getTemplatePreview($_GET["temp_type"], $t_id, true));
2840 $ilCtrl->redirect($this, "listTemplates");
2841 }
2842 }
2843 $this->form_gui->setValuesByPost();
2844 $tpl->setContent($this->form_gui->getHTML());
2845 }
2846
2848 {
2849 global $tpl;
2850
2851 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2852
2853 $acc = new ilAccordionGUI();
2854 $acc->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2855 $acc->addItem("Header 2", str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx x xx x xx", 30));
2856 $acc->setOrientation(ilAccordionGUI::HORIZONTAL);
2857
2858 $ac2 = new ilAccordionGUI();
2859 $ac2->addItem("Header 1", str_repeat("bla bla bla bla bla bla", 30));
2860 $ac2->addItem("Header 2", $acc->getHTML());
2861 $ac2->setOrientation(ilAccordionGUI::VERTICAL);
2862
2863 $tpl->setContent($ac2->getHTML());
2864 }
2865
2870 {
2871 global $ilCtrl;
2872
2873 if ($_GET["baseClass"] == "ilAdministrationGUI")
2874 {
2875 $ilCtrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
2876 }
2877 $ilCtrl->returnToParent($this);
2878 }
2879
2880
2881}
2882?>
print $file
$_GET["client_id"]
Accordion user interface class.
static addCss()
Add required css.
This class represents a background image property in a property form.
This class represents a background position in a property form.
This class represents a checkbox property in a property form.
Color picker form for selecting color hexcodes using yui library.
Confirmation screen class.
This class represents a file property in a property form.
This class represents a fint size property in a property form.
This class represents a section header in a property form.
const ID_PART_SCREEN
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
This class represents a number property in a property form.
This class represents a numeric style property in a property form.
Class ilObjStyleSheetGUI.
editTemplateObject()
Edit table template.
listImagesObject()
List images of style.
updateMediaQueryObject()
Update media query.
saveMediaQueryOrderObject()
Save media query order.
cancelCharacteristicDeletionObject()
Cancel characteristic deletion.
generateTemplateObject()
Generate table template.
initTagStyleForm($a_mode, $a_cur_tag)
Init tag style editing form.
templateGenerationObject()
Table template generation.
getValues()
FORM: Get current values from persistent object.
refreshObject()
refresh style sheet
cancelObject()
update style sheet
deleteMediaQueryConfirmationObject()
Confirm media query deletion.
listMediaQueriesObject()
List media queries of style.
deleteCharacteristicConfirmationObject()
Characteristic deletion confirmation screen.
cancelTemplateDeletionObject()
Cancel table template deletion.
getAdminTabs(&$tabs_gui)
admin and normal tabs are equal for roles
getPropertiesValues()
Get current values for properties from.
getTemplatePreview($a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
newStyleParameterObject()
add style parameter
addCharacteristicFormObject()
Add characteristic.
pasteCharacteristicsObject()
Paste characteristics.
deleteObject($a_error=false)
display deletion confirmation screen
refreshTemplateObject()
Refresh table template.
deleteTemplateObject()
Delete table template.
deleteColorConfirmationObject()
Delete color confirmation.
cancelColorDeletionObject()
Cancel color deletion.
deleteTemplateKeepClassesObject()
Delete table template.
getColorFormValues()
Set values for color editing.
getTabs(&$tabs_gui)
adds tabs to tab gui object
addAdminLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
getTemplateFormValues()
Set values for table template editing.
updateTagStyleObject()
save and refresh tag editing
initTemplateGenerationForm()
Init table template generation form.
deleteTemplateConfirmationObject()
Delete table template confirmation.
pasteCharacteristicsOverviewObject()
Paste characteristics overview.
saveHideStatusObject()
Save hide status for characteristics.
writeStylePar($cur_tag, $cur_class, $par, $value, $a_type, $a_mq_id, $a_custom=false)
initColorForm($a_mode="create")
Init color form.
cancelColorSavingObject()
Cancel color saving.
copyStyleObject()
save style sheet
outputTagStyleEditScreen()
Output tag style edit screen.
switchMQueryObject()
Switch media query.
addMediaQueryObject()
Add a media query.
updateObject()
Update properties.
initTemplateForm($a_mode="create")
Init table template form.
deleteStyleParameterObject()
delete style parameters
displayTemplateEditForm()
Display table tempalte edit form.
updateTemplateObject($a_refresh=false)
Update table template.
importStyleObject()
import style sheet
deleteMediaQueriesObject()
Delete Media Queries.
initMediaQueryForm($a_mode="create")
Init media query form.
saveCharacteristicObject()
Save Characteristic.
copyCharacteristicsObject()
Copy style classes.
cancelDeleteObject()
cancel oobject deletion
refreshTagStyleObject()
save and refresh tag editing
editMediaQueryObject()
Edit media query.
editTagStyleObject()
Edit tag style.
confirmedDeleteObject()
delete selected style objects
initPropertiesForm($a_mode="edit")
FORM: Init properties form.
listColorsObject()
List colors of style.
setTemplatesSubTabs()
adds tabs to tab gui object
saveTemplateObject()
Save table template.
getMediaQueryFormValues()
Set values for media query editing.
ilObjStyleSheetGUI($a_data, $a_id, $a_call_by_reference, $a_prep=true)
Constructor @access public.
static getStyleExampleHTML($a_type, $a_class)
Get style example HTML.
viewObject()
list childs of current object
deleteCoreCharMessage()
Message that appears, when user tries to delete core characteristics.
includeCSS()
Include CSS in output.
returnToUpperContextObject()
return to upper context
_getTemplatePreview($a_style, $a_type, $a_t_id, $a_small_mode=false)
Get table template preview.
initCharacteristicForm($a_mode)
Init tag style editing form.
extractParametersOfTag($a_tag, $a_class, $a_style, $a_type, $a_mq_id=0, $a_custom=false)
& executeCommand()
execute command
setSubTabs()
adds tabs to tab gui object
saveMediaQueryObject()
Save media query.
listTemplatesObject()
List templates.
cancelTemplateSavingObject()
Cancel color saving.
deleteCharacteristicObject()
Delete one or multiple style characteristic.
Class ilObjStyleSheet.
static _getStyleParameterInputType($par)
static _getTemplateClassTypes($a_template_type="")
Get template class types.
static _getStyleParameters($a_tag="")
lookupTemplateName($a_t_id)
Lookup table template name for template ID.
static _isExpandable($a_type)
_writeStandard($a_id, $a_std)
Write standard flag.
static _determineTag($a_type)
static _getStyleSuperTypeForType($a_type)
_getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
_writeUpToDate($a_id, $a_up_to_date)
Write up to date.
static _getCoreStyles()
Get core styles.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
prepareOutput()
prepare output
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
setCreationMode($a_mode=true)
if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class!...
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _renderTable($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null)
Static render table function.
This class represents a property form user interface.
This class represents a regular expression input property in a property form.
This class represents a selection list property in a property form.
TableGUI class for style editor (image list)
TableGUI class for style editor (image list)
TableGUI class for style editor (image list)
TableGUI class for style editor.
This class represents a border style with all/top/right/bottom/left in a property form.
This class represents a border width with all/top/right/bottom/left in a property form.
Color picker form for selecting color hexcodes using yui library (all/top/right/bottom/left)
This class represents a numeric style property with all/top/right/bottom/left in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$_POST['username']
Definition: cron.php:12
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options