19declare(strict_types=1);
60 $this->main_tpl =
$DIC->ui()->mainTemplate();
64 $this->
object = $style_sheet;
70 $cur = explode(
".", $this->request->getTag());
71 $this->current_tag = (string) $cur[0];
72 $this->current_class = (string) ($cur[1] ??
"");
74 $t = explode(
":", $cur[1] ??
"");
75 $this->current_base_class = (string) $t[0];
76 $this->current_pseudo_class = (string) ($t[1] ??
"");
78 $this->style_type = $this->request->getStyleType();
79 $this->requested_char = $this->request->getCharacteristic();
80 $this->mq_id = $this->request->getMediaQueryId();
83 $ctrl->saveParameter($this,
"tag");
87 bool $a_custom =
false
89 $style = $this->
object->getStyle();
90 $parameters = array();
91 foreach ($style as $tag) {
92 foreach ($tag as $par) {
93 if ($par[
"tag"] == $this->current_tag && $par[
"class"] == $this->current_class
94 && $par[
"type"] == $this->style_type && $this->mq_id == (
int) $par[
"mq_id"]
95 && (
int) $a_custom == (
int) $par[
"custom"]) {
96 $parameters[$par[
"parameter"]] = $par[
"value"];
108 $ctrl = $this->gui_service->ctrl();
110 $next_class = $ctrl->getNextClass($this);
111 $cmd = $ctrl->getCmd();
112 $this->showMigrationState();
113 switch ($next_class) {
116 "listCharacteristics",
"addCharacteristic",
"saveCharacteristic",
117 "deleteCharacteristicConfirmation",
"cancelCharacteristicDeletion",
"deleteCharacteristic",
118 "copyCharacteristics",
"pasteCharacteristicsOverview",
"pasteCharacteristics",
119 "pasteCharacteristicsWithinStyle",
"pasteCharacteristicsFromOtherStyle",
120 "saveStatus",
"setOutdated",
"removeOutdated",
121 "editTagStyle",
"refreshTagStyle",
"updateTagStyle",
122 "editTagTitles",
"saveTagTitles",
"switchMQuery",
"migrateImages"])) {
130 $mt = $this->gui_service->mainTemplate();
131 $lng = $this->domain_service->lng();
132 $style_id = $this->
object->getId();
133 $f = $this->gui_service->ui()->factory();
134 $toolbar = $this->gui_service->toolbar();
135 $ctrl = $this->gui_service->ctrl();
136 if (!$this->domain_service->style($style_id)->isMigrated()) {
137 $mt->setOnScreenMessage(
'info',
$lng->txt(
'sty_style_not_migrated'));
139 if ($this->domain_service->image(
141 $this->access_manager
142 )->hasLegacyDirAndNoImages()) {
143 $mt->setOnScreenMessage(
'info',
$lng->txt(
'sty_legacy_image_directory_found'));
144 $toolbar->addComponent(
145 $f->button()->standard(
146 $lng->txt(
'sty_migrate_images'),
147 $ctrl->getLinkTarget($this,
"migrateImages")
156 $lng = $this->domain_service->lng();
157 $ilTabs = $this->gui_service->tabs();
158 $ilCtrl = $this->gui_service->ctrl();
159 $ilToolbar = $this->gui_service->toolbar();
160 $tpl = $this->gui_service->mainTemplate();
162 $this->setListSubTabs();
165 $chars = $this->
object->getCharacteristics();
167 $style_type = ($this->super_type !=
"")
170 $ilCtrl->setParameter($this,
"style_type", $style_type);
171 $ilTabs->activateSubTab(
"sty_" . $style_type .
"_char");
175 $subtypes = $all_super_types[$style_type];
177 foreach ($subtypes as $t) {
182 if ($expandable && $this->access_manager->checkWrite()) {
183 $ilToolbar->addButton(
184 $lng->txt(
"sty_add_characteristic"),
185 $ilCtrl->getLinkTarget($this,
"addCharacteristic")
189 if ($this->manager->hasCopiedCharacteristics($style_type)) {
191 $ilToolbar->addSeparator();
193 $ilToolbar->addButton(
194 $lng->txt(
"sty_paste_style_classes"),
195 $ilCtrl->getLinkTarget($this,
"pasteCharacteristicsOverview")
199 $table_gui = $this->gui_service->characteristic()->CharacteristicTableGUI(
205 $this->access_manager
208 $tpl->setContent($table_gui->getHTML());
213 $lng = $this->domain_service->lng();
214 $tabs = $this->gui_service->tabs();
215 $ctrl = $this->gui_service->ctrl();
219 foreach ($types as $super_type => $t) {
221 $ctrl->setParameter($this,
"style_type", $super_type);
223 "sty_" . $super_type .
"_char",
224 $lng->txt(
"sty_" . $super_type .
"_char"),
225 $ctrl->getLinkTarget($this,
"listCharacteristics")
229 $ctrl->setParameter($this,
"style_type", $this->style_type);
234 $tpl = $this->gui_service->mainTemplate();
236 $form = $this->initCharacteristicForm();
237 $tpl->setContent($form->getHTML());
242 $ilCtrl = $this->gui_service->ctrl();
243 $tpl = $this->gui_service->mainTemplate();
244 $lng = $this->domain_service->lng();
246 $form = $this->initCharacteristicForm();
248 if ($form->checkInput()) {
249 $new_characteristic = $form->getInput(
"new_characteristic");
250 $type = $form->getInput(
"type");
251 if ($this->
object->characteristicExists($new_characteristic, $this->style_type)) {
252 $char_input = $form->getItemByPostVar(
"new_characteristic");
253 $char_input->setAlert(
$lng->txt(
"sty_characteristic_already_exists"));
255 $this->
object->addCharacteristic($type, $new_characteristic);
256 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"sty_added_characteristic"),
true);
257 $ilCtrl->setParameter(
262 $ilCtrl->setParameter($this,
"style_type", $type);
263 $ilCtrl->redirectByClass(
"ilstylecharacteristicgui",
"editTagStyle");
266 $form->setValuesByPost();
267 $tpl->setContent($form->getHTML());
272 $ilCtrl = $this->gui_service->ctrl();
273 $tpl = $this->gui_service->mainTemplate();
274 $lng = $this->domain_service->lng();
278 $chars = $this->request->getCharacteristics();
279 if (count($chars) == 0) {
280 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"no_checkbox"),
true);
281 $ilCtrl->redirect($this,
"edit");
285 foreach ($chars as $char) {
286 if (!empty($core_styles[$char])) {
287 $this->deleteCoreCharMessage();
293 $cgui->setFormAction($ilCtrl->getFormAction($this));
294 $cgui->setHeaderText(
$lng->txt(
"sty_confirm_char_deletion"));
295 $cgui->setCancel(
$lng->txt(
"cancel"),
"cancelCharacteristicDeletion");
296 $cgui->setConfirm(
$lng->txt(
"delete"),
"deleteCharacteristic");
298 foreach ($chars as $char) {
299 $char_comp = explode(
".", $char);
300 $cgui->addItem(
"char[]", $char, $char_comp[2]);
303 $tpl->setContent($cgui->getHTML());
310 $ilCtrl = $this->gui_service->ctrl();
311 $tpl = $this->gui_service->mainTemplate();
312 $lng = $this->domain_service->lng();
315 $cgui->setFormAction($ilCtrl->getFormAction($this));
321 $chars = $this->request->getCharacteristics();
322 foreach ($chars as $char) {
323 if (!empty($core_styles[$char])) {
325 $char_comp = explode(
".", $char);
326 $cgui->addItem(
"",
"", $char_comp[2]);
328 $cgui->addHiddenItem(
"char[]", $char);
331 $all_core_styles = ($cnt == count($chars));
333 if ($all_core_styles) {
334 $cgui->setHeaderText(
$lng->txt(
"sty_all_styles_obligatory"));
335 $cgui->setCancel(
$lng->txt(
"back"),
"cancelCharacteristicDeletion");
336 $cgui->setConfirm(
$lng->txt(
"ok"),
"cancelCharacteristicDeletion");
338 $cgui->setHeaderText(
$lng->txt(
"sty_some_styles_obligatory_delete_rest"));
339 $cgui->setCancel(
$lng->txt(
"cancel"),
"cancelCharacteristicDeletion");
340 $cgui->setConfirm(
$lng->txt(
"sty_delete_other_selected"),
"deleteCharacteristicConfirmation");
343 $tpl->setContent($cgui->getHTML());
348 $ilCtrl = $this->gui_service->ctrl();
349 $lng = $this->domain_service->lng();
351 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"action_aborted"),
true);
352 $ilCtrl->redirect($this,
"listCharacteristics");
361 $ilCtrl = $this->gui_service->ctrl();
363 $chars = $this->request->getCharacteristics();
364 foreach ($chars as $char) {
365 $char_comp = explode(
".", $char);
366 $type = $char_comp[0];
367 $tag = $char_comp[1];
368 $class = $char_comp[2];
370 $this->manager->deleteCharacteristic(
376 $ilCtrl->redirect($this,
"listCharacteristics");
384 $lng = $this->domain_service->lng();
385 $ilCtrl = $this->gui_service->ctrl();
391 $txt_input->setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
392 $txt_input->setNoMatchMessage(
$lng->txt(
"sty_msg_characteristic_must_only_include") .
" A-Z, a-z, 0-9");
393 $txt_input->setRequired(
true);
394 $form->addItem($txt_input);
398 $types = $all_super_types[$this->super_type];
399 $exp_types = array();
400 foreach ($types as $t) {
402 $exp_types[$t] =
$lng->txt(
"sty_type_" . $t);
405 if (count($exp_types) > 1) {
407 $type_input->setOptions($exp_types);
408 $type_input->setValue(key($exp_types));
409 $form->addItem($type_input);
410 } elseif (count($exp_types) == 1) {
412 $hid_input->setValue(key($exp_types));
413 $form->addItem($hid_input);
416 $form->setTitle(
$lng->txt(
"sty_add_characteristic"));
417 $form->addCommandButton(
"saveCharacteristic",
$lng->txt(
"save"));
418 $form->addCommandButton(
"listCharacteristics",
$lng->txt(
"cancel"));
419 $form->setFormAction($ilCtrl->getFormAction($this));
426 $tabs = $this->gui_service->tabs();
427 $ctrl = $this->gui_service->ctrl();
428 $lng = $this->domain_service->lng();
430 $tabs->clearTargets();
433 $tabs->setBackTarget(
435 $ctrl->getLinkTargetByClass(
"ilobjstylesheetgui",
"edit")
439 $ctrl->setParameter($this,
"tag", $this->current_tag .
"." . $this->current_base_class);
442 $lng->txt(
"sty_parameters"),
443 $ctrl->getLinkTarget($this,
"editTagStyle")
449 $lng->txt(
"sty_titles"),
450 $ctrl->getLinkTarget($this,
"editTagTitles")
452 $ctrl->setParameter($this,
"tag", $this->request->getTag());
457 $tabs = $this->gui_service->tabs();
458 $ctrl = $this->gui_service->ctrl();
459 $lng = $this->domain_service->lng();
461 $pc = $this->
object->_getPseudoClasses($this->current_tag);
462 if (count($pc) > 0) {
464 $ctrl->setParameter($this,
"tag", $this->current_tag .
"." . $this->current_base_class);
467 $lng->txt(
"sty_tag_normal"),
468 $ctrl->getLinkTarget($this,
"editTagStyle")
470 if ($this->current_pseudo_class ==
"") {
471 $tabs->activateSubTab(
"sty_tag_normal");
474 foreach ($pc as $p) {
479 $this->current_tag .
"." . $this->current_base_class .
":" . $p
484 $ctrl->getLinkTarget($this,
"editTagStyle")
486 if ($this->current_pseudo_class == $p) {
487 $tabs->activateSubTab(
"sty_tag_" . $p);
490 $ctrl->setParameter($this,
"tag", $this->current_tag .
"." . $this->current_base_class);
492 $ctrl->setParameter($this,
"tag", $this->request->getTag());
497 $ilToolbar = $this->gui_service->toolbar();
498 $lng = $this->domain_service->lng();
499 $ilCtrl = $this->gui_service->ctrl();
500 $tabs = $this->gui_service->tabs();
503 $this->setParameterSubTabs();
504 $tabs->activateTab(
"parameters");
507 $mqs = $this->
object->getMediaQueries();
508 if (count($mqs) > 0) {
511 "" =>
$lng->txt(
"sty_default"),
513 foreach ($mqs as $mq) {
514 $options[$mq[
"id"]] = $mq[
"mquery"];
518 $si->setValue($this->mq_id);
519 $ilToolbar->addInputItem($si,
true);
520 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
521 $ilToolbar->addFormButton(
$lng->txt(
"sty_switch"),
"switchMQuery");
524 $form = $this->initTagStyleForm();
525 $this->getValues($form);
526 $this->outputTagStyleEditScreen($form);
537 $lng = $this->domain_service->lng();
538 $ilCtrl = $this->gui_service->ctrl();
540 $ilCtrl->saveParameter($this, array(
"mq_id"));
544 $avail_pars = $this->
object->getAvailableParameters();
545 $groups = $this->
object->getStyleParameterGroups();
548 foreach ($groups as $k => $group) {
552 if (isset($filtered_groups[$k]) && !in_array($this->current_tag, $filtered_groups[$k])) {
557 $sh->setTitle(
$lng->txt(
"sty_" . $k));
558 $form_gui->addItem($sh);
560 foreach ($group as $par) {
561 $basepar = explode(
".", $par);
562 $basepar = $basepar[0];
564 $var = str_replace(
"-",
"_", $basepar);
570 foreach ($avail_pars[$par] as $p) {
574 $form_gui->addItem($sel_input);
579 $text_input->setMaxLength(200);
580 $text_input->setSize(20);
581 $form_gui->addItem($text_input);
586 $form_gui->addItem($fs_input);
589 case "numeric_no_perc":
593 $num_input->setAllowPercentage(
false);
595 $form_gui->addItem($num_input);
600 $per_input->setMinValue(0);
601 $per_input->setMaxValue(100);
602 $per_input->setMaxLength(3);
603 $per_input->setSize(3);
604 $form_gui->addItem($per_input);
609 $col_input->setDefaultColor(
"");
610 $col_input->setAcceptNamedColors(
true);
611 $form_gui->addItem($col_input);
617 $num_input->setAllowPercentage(
false);
619 $form_gui->addItem($num_input);
624 $form_gui->addItem($bw_input);
629 $form_gui->addItem($bw_input);
634 $col_input->setAcceptNamedColors(
true);
635 $form_gui->addItem($col_input);
638 case "background_image":
641 foreach ($this->image_manager->getImages() as $entry) {
642 $images[] = $entry->getFilename();
644 $im_input->setImages($images);
645 $im_input->setInfo(
$lng->txt(
"sty_bg_img_info"));
646 $form_gui->addItem($im_input);
649 case "background_position":
651 $form_gui->addItem($im_input);
659 $sh->setTitle(
$lng->txt(
"sty_custom"));
660 $form_gui->addItem($sh);
664 $ti->setMaxLength(300);
667 $ti->setInfo(
$lng->txt(
"sty_custom_par_info"));
668 $form_gui->addItem($ti);
672 $form_gui->addCommandButton(
"updateTagStyle",
$lng->txt(
"save_return"));
673 $form_gui->addCommandButton(
"refreshTagStyle",
$lng->txt(
"save_refresh"));
675 $form_gui->setFormAction($ilCtrl->getFormAction($this));
684 $cur_parameters = $this->extractParametersOfTag();
686 foreach ($parameters as $p => $v) {
688 if (isset($filtered_groups[$v[
"group"]]) && !in_array($this->current_tag, $filtered_groups[$v[
"group"]])) {
691 $p = explode(
".", $p);
694 switch ($v[
"input"]) {
702 $input->setAllValue($cur_parameters[$v[
"subpar"][0]] ??
"");
703 $input->setTopValue($cur_parameters[$v[
"subpar"][1]] ??
"");
704 $input->setRightValue($cur_parameters[$v[
"subpar"][2]] ??
"");
705 $input->setBottomValue($cur_parameters[$v[
"subpar"][3]] ??
"");
706 $input->setLeftValue($cur_parameters[$v[
"subpar"][4]] ??
"");
710 $input->setValue($cur_parameters[$p] ??
"");
715 $cust_parameters = $this->extractParametersOfTag(
true);
717 foreach ($cust_parameters as $k =>
$c) {
718 $vals[] = $k .
": " .
$c;
721 $input->setValue($vals);
726 $tpl = $this->gui_service->mainTemplate();
729 $tpl->setCurrentBlock(
"ContentStyle");
731 "LOCATION_CONTENT_STYLESHEET",
735 $ts_tpl =
new ilTemplate(
"tpl.style_tag_edit.html",
true,
true,
"components/ILIAS/Style/Content");
737 $ts_tpl->setVariable(
742 $ts_tpl->setVariable(
749 $tpl->setContent($ts_tpl->get());
754 $tpl = $this->gui_service->mainTemplate();
755 $lng = $this->domain_service->lng();
756 $tpl->setTitle($this->current_class .
" (" .
$lng->txt(
"sty_type_" . $this->style_type) .
")");
761 $ilCtrl = $this->gui_service->ctrl();
763 $form = $this->initTagStyleForm();
765 if ($form->checkInput()) {
766 $this->saveTagStyle($form);
767 $ilCtrl->redirect($this,
"editTagStyle");
769 $form->setValuesByPost();
770 $this->outputTagStyleEditScreen($form);
776 $ilCtrl = $this->gui_service->ctrl();
778 $form = $this->initTagStyleForm();
779 if ($form->checkInput()) {
780 $this->saveTagStyle($form);
781 $ilCtrl->redirectByClass(
"ilobjstylesheetgui",
"edit");
783 $form->setValuesByPost();
784 $this->outputTagStyleEditScreen($form);
791 foreach ($avail_pars as $par => $v) {
792 $var = str_replace(
"-",
"_", $par);
793 $basepar_arr = explode(
".", $par);
794 $basepar = $basepar_arr[0];
795 if (($basepar_arr[1] ??
"") !=
"" && $basepar_arr[1] != $this->current_tag) {
799 switch ($v[
"input"]) {
801 case "numeric_no_perc":
803 case "background_image":
804 case "background_position":
806 $this->writeStylePar($basepar, (
string) $in->getValue());
810 $color = trim($form->
getInput($basepar));
811 if ($color !=
"" && trim(substr($color, 0, 1)) !=
"!") {
812 $color =
"#" . $color;
814 $this->writeStylePar($basepar, $color);
821 $this->writeStylePar($v[
"subpar"][0], (
string) $in->getAllValue());
822 $this->writeStylePar($v[
"subpar"][1], (
string) $in->getTopValue());
823 $this->writeStylePar($v[
"subpar"][2], (
string) $in->getRightValue());
824 $this->writeStylePar($v[
"subpar"][3], (
string) $in->getBottomValue());
825 $this->writeStylePar($v[
"subpar"][4], (
string) $in->getLeftValue());
830 $tblr_p = array(0 =>
"getAllValue", 1 =>
"getTopValue", 2 =>
"getRightValue",
831 3 =>
"getBottomValue", 4 =>
"getLeftValue");
832 foreach ($tblr_p as $k => $func) {
833 $val = trim($in->$func());
834 $val = (($in->getAcceptNamedColors() && substr($val, 0, 1) ==
"!")
838 $this->writeStylePar($v[
"subpar"][$k], $val);
843 $this->writeStylePar($basepar, (
string) $form->
getInput($basepar));
849 $this->
object->deleteCustomStylePars(
851 $this->current_class,
855 $custom_par = $form->
getInput(
"custom_par");
856 foreach ($custom_par as $cpar) {
857 $par_arr = explode(
":", $cpar);
858 if (count($par_arr) == 2) {
859 $par = trim($par_arr[0]);
860 $val = trim(str_replace(
";",
"", $par_arr[1]));
861 $this->writeStylePar($par, $val,
true);
865 $this->
object->update();
871 protected function writeStylePar(
string $par,
string $value,
bool $a_custom =
false): void
873 if ($this->style_type ==
"") {
876 $this->manager->replaceParameter(
878 $this->current_class,
890 $tpl = $this->gui_service->mainTemplate();
891 $ui = $this->gui_service->ui();
892 $tabs = $this->gui_service->tabs();
894 $form = $this->getTagTitlesForm();
896 $tabs->activateTab(
"titles");
897 $tpl->setContent($ui->renderer()->render($form));
905 $ui = $this->gui_service->ui();
907 $ctrl = $this->gui_service->ctrl();
908 $lng = $this->domain_service->lng();
911 $lng->loadLanguageModule(
"meta");
913 $characteristic = $this->manager->getByKey(
915 $this->current_base_class
917 $titles = $characteristic->getTitles();
919 foreach (
$lng->getInstalledLanguages() as $l) {
920 $fields[
"title_" . $l] =
$f->input()->field()->text(
$lng->txt(
"title") .
921 " - " .
$lng->txt(
"meta_l_" . $l))
922 ->withRequired(
false)
923 ->withValue($titles[$l] ??
"");
927 $section1 =
$f->input()->field()->section($fields,
$lng->txt(
"sty_titles"));
929 $form_action = $ctrl->getLinkTarget($this,
"saveTagTitles");
930 return $f->input()->container()->form()->standard($form_action, [
"sec" => $section1]);
935 $request = $this->gui_service->http()->request();
936 $form = $this->getTagTitlesForm();
937 $lng = $this->domain_service->lng();
938 $ctrl = $this->gui_service->ctrl();
939 $manager = $this->manager;
941 if ($request->getMethod() ==
"POST") {
942 $form = $form->withRequest($request);
943 $data = $form->getData();
944 if (isset(
$data[
"sec"])) {
947 foreach (
$lng->getInstalledLanguages() as $l) {
948 $titles[$l] =
$d[
"title_" . $l];
951 $manager->saveTitles(
953 $this->current_base_class,
957 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
960 $ctrl->redirect($this,
"editTagTitles");
970 $ilCtrl = $this->gui_service->ctrl();
971 $lng = $this->domain_service->lng();
973 $all_chars = $this->request->getAllCharacteristics();
974 $hidden = $this->request->getHidden();
975 $order = $this->request->getOrder();
978 foreach ($all_chars as $char) {
979 $ca = explode(
".", $char);
980 $this->manager->saveHidden(
983 (in_array($char, $hidden))
988 if (count($order) > 0) {
990 foreach ($order as $char => $order_nr) {
991 $ca = explode(
".", $char);
992 $order_by_type[$ca[0]][$ca[2]] = $order_nr;
994 foreach ($order_by_type as $type => $order_nrs) {
995 $this->manager->saveOrderNrs(
1002 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1003 $ilCtrl->redirect($this,
"listCharacteristics");
1008 $lng = $this->domain_service->lng();
1009 $ctrl = $this->gui_service->ctrl();
1011 $chars = $this->request->getCharacteristics();
1012 if (count($chars) > 0) {
1013 foreach ($chars as
$c) {
1014 $c_parts = explode(
".",
$c);
1016 $this->manager->saveOutdated(
1021 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1025 $this->manager->saveOutdated(
1027 $this->requested_char,
1030 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1033 $ctrl->redirect($this,
"listCharacteristics");
1038 $lng = $this->domain_service->lng();
1039 $ctrl = $this->gui_service->ctrl();
1040 $chars = $this->request->getCharacteristics();
1042 if (count($chars) > 0) {
1043 foreach ($chars as
$c) {
1044 $c_parts = explode(
".",
$c);
1046 $this->manager->saveOutdated(
1051 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1055 $this->manager->saveOutdated(
1057 $this->requested_char,
1060 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1063 $ctrl->redirect($this,
"listCharacteristics");
1068 $ilCtrl = $this->gui_service->ctrl();
1069 $lng = $this->domain_service->lng();
1071 $chars = $this->request->getCharacteristics();
1074 foreach ($chars as
$c) {
1075 $type_arr = explode(
".",
$c);
1077 $this->main_tpl->setOnScreenMessage(
1079 $lng->txt(
"sty_cannot_be_copied") .
": " .
$lng->txt(
"sty_type_" . $type_arr[0] ??
""),
1082 $ilCtrl->redirect($this,
"listCharacteristics");
1086 if (count($chars) == 0) {
1087 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
1089 $this->manager->setCopyCharacteristics(
1093 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"sty_copied_please_select_target"),
true);
1095 $ilCtrl->redirect($this,
"listCharacteristics");
1100 $tpl = $this->gui_service->mainTemplate();
1101 $ilTabs = $this->gui_service->tabs();
1102 $ui = $this->gui_service->ui();
1104 $ilTabs->clearTargets();
1106 if ($this->manager->getCopyCharacteristicStyleId() ==
1107 $this->object->getId()) {
1108 $form = $this->getPasteWithinStyleForm();
1110 $form = $this->getPasteFromOtherStyleForm();
1112 $tpl->setContent($ui->renderer()->render($form));
1121 $ui = $this->gui_service->ui();
1122 $f = $ui->factory();
1123 $ctrl = $this->gui_service->ctrl();
1126 foreach ($this->manager->getCopyCharacteristics() as $char) {
1128 $char_text = explode(
".", $char);
1129 $sections[$char] =
$f->input()->field()->section(
1130 $this->getCharacterTitleFormFields($char),
1135 $form_action = $ctrl->getLinkTarget($this,
"pasteCharacteristicsWithinStyle");
1136 return $f->input()->container()->form()->standard($form_action, $sections);
1145 $ui = $this->gui_service->ui();
1146 $lng = $this->domain_service->lng();
1147 $f = $ui->factory();
1148 $ctrl = $this->gui_service->ctrl();
1152 foreach ($this->manager->getCopyCharacteristics() as $char) {
1153 $char_text = explode(
".", $char);
1155 foreach ($this->manager->getByType($char_text[0]) as
$c) {
1156 $options[
$c->getCharacteristic()] =
$c->getCharacteristic();
1158 $group1 =
$f->input()->field()->group(
1159 $this->getCharacterTitleFormFields($char),
1160 $lng->txt(
"sty_create_new_class")
1162 $group2 =
$f->input()->field()->group(
1164 "overwrite_class" =>
$f->input()->field()->select(
1165 $lng->txt(
"sty_class"),
1167 )->withRequired(
true)
1169 $lng->txt(
"sty_overwrite_existing_class")
1171 $fields[$char] =
$f->input()->field()->switchableGroup(
1173 "new_" . $char => $group1,
1174 "overwrite_" . $char => $group2
1177 )->withValue(
"new_" . $char);
1179 $sections[
"sec"] =
$f->input()->field()->section(
1181 $lng->txt(
"sty_paste_chars")
1184 $form_action = $ctrl->getLinkTarget($this,
"pasteCharacteristicsFromOtherStyle");
1185 return $f->input()->container()->form()->standard($form_action, $sections);
1193 $ui = $this->gui_service->ui();
1194 $f = $ui->factory();
1195 $refinery = $this->domain_service->refinery();
1196 $lng = $this->domain_service->lng();
1197 $style_type = $this->style_type;
1198 $style_obj = $this->object;
1201 $lng->loadLanguageModule(
"meta");
1203 $char_regexp_constraint =
$refinery->custom()->constraint(
function ($v) use (
$lng) {
1204 return (
bool) preg_match(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/", $v);
1205 },
$lng->txt(
"sty_msg_characteristic_must_only_include") .
" A-Z, a-z, 0-9");
1207 $char_exists_constraint =
$refinery->custom()->constraint(
function ($v) use ($style_obj, $style_type) {
1208 return !$style_obj->characteristicExists($v, $style_type);
1209 },
$lng->txt(
"sty_characteristic_already_exists"));
1212 $fields[
"char_" . $char] =
$f->input()->field()->text(
$lng->txt(
"sty_class_name"))
1213 ->withRequired(
true)
1214 ->withAdditionalTransformation($char_regexp_constraint)
1215 ->withAdditionalTransformation($char_exists_constraint);
1217 foreach (
$lng->getInstalledLanguages() as $l) {
1218 $fields[
"title_" . $char .
"_" . $l] =
$f->input()->field()->text(
$lng->txt(
"title") .
1219 " - " .
$lng->txt(
"meta_l_" . $l))
1220 ->withRequired(
false)
1221 ->withValue($titles[$l] ??
"");
1229 $ui = $this->gui_service->ui();
1230 $request = $this->gui_service->http()->request();
1231 $form = $this->getPasteWithinStyleForm();
1232 $tpl = $this->gui_service->mainTemplate();
1233 $ctrl = $this->gui_service->ctrl();
1234 $lng = $this->domain_service->lng();
1235 $manager = $this->manager;
1237 if ($request->getMethod() ==
"POST") {
1238 $form = $form->withRequest($request);
1239 $data = $form->getData();
1240 if (is_null(
$data)) {
1241 $tpl->setContent($ui->renderer()->render($form));
1244 foreach ($this->manager->getCopyCharacteristics() as $char) {
1245 if (is_array(
$data[$char])) {
1248 foreach (
$lng->getInstalledLanguages() as $l) {
1249 $titles[$l] =
$d[
"title_" . $char .
"_" . $l];
1251 $new_char =
$d[
"char_" . $char];
1252 $char_parts = explode(
".", $char);
1253 $manager->copyCharacteristicFromSource(
1254 $this->manager->getCopyCharacteristicStyleId(),
1262 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1264 $ctrl->redirect($this,
"listCharacteristics");
1273 $request = $this->gui_service->http()->request();
1274 $form = $this->getPasteFromOtherStyleForm();
1275 $tpl = $this->gui_service->mainTemplate();
1276 $ctrl = $this->gui_service->ctrl();
1277 $lng = $this->domain_service->lng();
1278 $ui = $this->gui_service->ui();
1279 $manager = $this->manager;
1281 if ($request->getMethod() ==
"POST") {
1282 $form = $form->withRequest($request);
1283 $data = $form->getData();
1284 if (is_null(
$data)) {
1285 $tpl->setContent($ui->renderer()->render($form));
1288 foreach ($this->manager->getCopyCharacteristics() as $char) {
1289 if (is_array(
$data[
"sec"][$char])) {
1291 $char_parts = explode(
".", $char);
1298 if (isset(
$d[
"overwrite_class"])) {
1299 $manager->copyCharacteristicFromSource(
1300 $manager->getCopyCharacteristicStyleId(),
1303 $d[
"overwrite_class"],
1306 } elseif (isset(
$d[
"char_" . $char])) {
1308 foreach (
$lng->getInstalledLanguages() as $l) {
1309 $titles[$l] =
$d[
"title_" . $char .
"_" . $l];
1311 $new_char =
$d[
"char_" . $char];
1312 $manager->copyCharacteristicFromSource(
1313 $manager->getCopyCharacteristicStyleId(),
1322 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
1324 $ctrl->redirect($this,
"listCharacteristics");
1329 $ilCtrl = $this->gui_service->ctrl();
1330 $lng = $this->domain_service->lng();
1332 $titles = $this->request->getTitles();
1333 $conflict_action = $this->request->getConflictAction();
1334 if (count($titles) > 0) {
1335 foreach ($titles as $from_char => $to_title) {
1336 $fc = explode(
".", $from_char);
1338 if ($conflict_action[$from_char] ==
"overwrite" ||
1339 !$this->
object->characteristicExists($to_title, $fc[0])) {
1341 $this->manager->copyCharacteristicFromSource(
1342 $this->request->getFromStyleId(),
1351 $this->manager->clearCopyCharacteristics();
1352 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"sty_style_classes_copied"),
true);
1355 $ilCtrl->redirect($this,
"listCharacteristics");
1363 $ctrl = $this->gui_service->ctrl();
1364 $ctrl->setParameter($this,
"mq_id", $this->request->getMediaQueryId());
1365 $ctrl->redirectByClass(
"ilstylecharacteristicgui",
"editTagStyle");
1370 $this->domain_service->style($this->
object->getId())->migrateImages();
1371 $ctrl = $this->gui_service->ctrl();
1372 $ctrl->redirectByClass(self::class,
"listCharacteristics");
Manages access to content style editing.
Main business logic for characteristics.
Main business logic for content style images.
Content style internal ui factory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getStyleExampleHTML(string $a_type, string $a_class)
Get style example HTML.
static _getFilteredGroups()
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static isCoreStyle(string $a_type, string $a_class)
static _getStyleParameterInputType(string $par)
static _determineTag(string $a_type)
static _writeUpToDate(int $a_id, bool $a_up_to_date)
static _getStyleSuperTypes()
static _getStyleParameters(string $a_tag="")
static _isExpandable(string $a_type)
Access StyleAccessManager $access_manager
Content CharacteristicManager $manager
outputTagStyleEditScreen(ilPropertyFormGUI $form)
Content StandardGUIRequest $request
string $current_base_class
pasteCharacteristicsWithinStyle()
getPasteWithinStyleForm()
Init past within style form.
deleteCharacteristic()
Delete one or multiple style characteristic.
pasteCharacteristicsOverview()
Content ImageManager $image_manager
__construct(Content\InternalDomainService $domain_service, Content\InternalGUIService $gui_service, ilObjStyleSheet $style_sheet, string $super_type, Access\StyleAccessManager $access_manager, Content\CharacteristicManager $manager, Content\ImageManager $image_manager)
string $current_pseudo_class
ilGlobalTemplateInterface $main_tpl
getCharacterTitleFormFields(string $char)
Get character title form section.
switchMQuery()
Switch media query.
extractParametersOfTag(bool $a_custom=false)
saveTagStyle(ilPropertyFormGUI $form)
Content InternalDomainService $domain_service
pasteCharacteristicsFromOtherStyle()
initTagStyleForm()
Init tag style editing form.
deleteCharacteristicConfirmation()
cancelCharacteristicDeletion()
saveStatus()
Save hide status for characteristics.
getPasteFromOtherStyleForm()
Init past from other style form.
executeCommand()
Execute command.
getValues(ilPropertyFormGUI $form)
FORM: Get current values from persistent object.
writeStylePar(string $par, string $value, bool $a_custom=false)
Write style parameter.
initCharacteristicForm()
Init tag style editing form.
Content InternalGUIService $gui_service
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.