19declare(strict_types=1);
54 bool $a_call_by_reference
60 $this->service =
$DIC->contentStyle()
62 $this->gui_service = $this->service->gui();
63 $this->
help = $this->gui_service->help();
64 $this->
lng->loadLanguageModule(
"style");
65 $this->
ctrl->saveParameter($this, array(
"tag",
"style_type",
"temp_type"));
66 $this->style_request =
$DIC->contentStyle()
71 $this->super_type =
"";
72 if ($this->style_request->getStyleType() !=
"") {
74 $this->style_request->getStyleType()
79 $ref_id = (is_object($this->
object))
80 ? $this->
object->getRefId()
82 $style_id = (is_object($this->
object))
86 $this->access_manager = $this->service->domain()->access(
90 $this->characteristic_manager = $this->service->domain()->characteristic(
94 $this->color_manager = $this->service->domain()->color(
98 $this->image_manager = $this->service->domain()->image(
100 $this->access_manager
102 $this->domain = $this->service->domain();
110 $this->access_manager->enableWrite($a_write);
115 $tabs = $this->gui_service->tabs();
116 $ctrl = $this->gui_service->ctrl();
122 if (!$this->
object || $cmd ==
"create") {
126 switch ($next_class) {
130 $exp_gui->addFormat(
"xml");
134 case "ilstylecharacteristicgui":
137 $tabs->activateTab(
"sty_style_chars");
138 $gui = $this->gui_service->characteristic()->ilStyleCharacteristicGUI(
139 $this->getStyleSheet(),
141 $this->access_manager,
142 $this->characteristic_manager,
148 case "ilcontentstyleimagegui":
151 $tabs->activateTab(
"sty_images");
152 $gui = $this->gui_service->image()->ilContentStyleImageGUI(
153 $this->access_manager,
181 $tpl = $this->gui_service->ui()->mainTemplate();
188 $ilHelp->setScreenIdComponent(
"sty");
210 foreach ($forms as $form_type => $cf) {
211 $htpl =
new ilTemplate(
"tpl.creation_acc_head.html",
true,
true,
"components/ILIAS/ILIASObject");
215 if (method_exists($this,
"getCreationFormTitle")) {
219 $form_title = $cf->getTitle();
223 $htpl->setVariable(
"TITLE", $this->
lng->txt(
"option") .
" " . $cnt .
": " . $form_title);
225 $cf->setTitleIcon(
'');
226 $cf->setTableWidth(
"100%");
228 $acc->addItem($htpl->get(), $cf->getHTML());
233 return "<div class='ilCreationFormSection'>" . $acc->getHTML() .
"</div>";
239 return $this->
lng->txt(
"sty_create_new_stylesheet");
252 $ti->setMaxLength(128);
254 $ti->setRequired(
true);
277 $ti->setRequired(
true);
294 $ti->setRequired(
true);
305 $tpl = $this->gui_service->ui()->mainTemplate();
315 $ctrl = $this->gui_service->ctrl();
321 $tpl = $this->gui_service->ui()->mainTemplate();
336 $values[
"style_title"] = $this->
object->getTitle();
337 $values[
"style_description"] = $this->
object->getDescription();
338 $values[
"disable_auto_margins"] = (
int) $this->
object->lookupStyleSetting(
"disable_auto_margins");
340 $this->
form->setValuesByArray($values);
347 string $a_mode =
"edit"
356 $ti->setMaxLength(128);
358 $ti->setRequired(
true);
359 $this->
form->addItem($ti);
365 $this->
form->addItem($ta);
369 $cb->setInfo($this->
lng->txt(
"sty_disable_auto_margins_info"));
370 $this->
form->addItem($cb);
374 if ($a_mode ==
"create") {
375 $this->
form->addCommandButton(
"save",
$lng->
txt(
"save"));
376 $this->
form->addCommandButton(
"cancelSave",
$lng->
txt(
"cancel"));
378 if ($this->access_manager->checkWrite()) {
379 $this->
form->addCommandButton(
"update",
$lng->
txt(
"save"));
383 $this->
form->setTitle(
$lng->
txt(
"edit_stylesheet"));
390 $ctrl = $this->gui_service->ctrl();
391 $tpl = $this->gui_service->ui()->mainTemplate();
393 $this->initPropertiesForm(
"edit");
394 if ($this->
form->checkInput()) {
395 $this->
object->setTitle($this->
form->getInput(
"style_title"));
396 $this->
object->setDescription($this->
form->getInput(
"style_description"));
397 $this->
object->writeStyleSetting(
398 "disable_auto_margins",
399 $this->
form->getInput(
"disable_auto_margins")
401 $this->
object->update();
402 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
403 $ctrl->redirect($this,
"properties");
405 $this->
form->setValuesByPost();
406 $tpl->setContent($this->
form->getHTML());
414 $r = $exp->exportObject($this->
object->getType(), $this->object->getId());
424 $tpl = $this->gui_service->ui()->mainTemplate();
425 $ctrl = $this->gui_service->ctrl();
429 $cgui->setFormAction($ctrl->getFormAction($this));
430 $cgui->setHeaderText($this->
lng->txt(
"info_delete_sure"));
431 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDelete");
432 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedDelete");
436 $cgui->addItem(
"id[]",
"", $caption);
438 $tpl->setContent($cgui->getHTML());
443 $this->gui_service->ctrl()->returnToParent($this);
451 $this->
object->delete();
452 $this->gui_service->ctrl()->returnToParent($this);
457 $ctrl = $this->gui_service->ctrl();
459 $form = $this->getCreateForm();
462 if (!trim($form->
getInput(
"style_title"))) {
463 $ctrl->redirect($this,
"create");
467 $default_style = $this->
settings->get(
"default_content_style_id");
470 $new_id = $style_obj->ilClone();
477 $style_id = $imp->importObject(
482 "components/ILIAS/Style",
489 $newObj->setTitle($form->
getInput(
"style_title"));
490 $newObj->setDescription($form->
getInput(
"style_description"));
492 $this->
object = $newObj;
498 if ($this->requested_ref_id > 0 &&
501 $cont_style_settings->addStyle($newObj->getId());
502 $cont_style_settings->update();
505 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
506 $this->
ctrl->setParameterByClass(self::class,
"obj_id", (
string) $newObj->getId());
507 $this->
ctrl->redirectByClass(self::class,
"");
513 $ctrl = $this->gui_service->ctrl();
515 $form = $this->getCloneForm();
519 if ($form->
getInput(
"source_style") > 0) {
521 $new_id = $style_obj->ilClone();
526 if ($this->requested_ref_id > 0) {
528 if ($fold->getType() ==
"stys") {
530 $cont_style_settings->addStyle($new_id);
531 $cont_style_settings->update();
533 $ctrl->returnToParent($this);
548 $source = $_FILES[
"importfile"][
"tmp_name"];
549 if (($source ==
'none') || (!$source)) {
550 $this->
ilias->raiseError(
"No file selected!", $this->
ilias->error_obj->MESSAGE);
554 $info = pathinfo($_FILES[
"importfile"][
"name"]);
555 if (strtolower(
$info[
"extension"]) !=
"zip" && strtolower(
$info[
"extension"]) !=
"xml") {
556 $this->
ilias->raiseError(
"File must be a zip or xml file!", $this->
ilias->error_obj->MESSAGE);
560 $fname = explode(
"_", $_FILES[
"importfile"][
"name"]);
561 if (strtolower(
$info[
"extension"]) ==
"zip" && $fname[4] ==
"sty") {
563 $new_id = $imp->importObject(
565 $_FILES[
"importfile"][
"tmp_name"],
566 $_FILES[
"importfile"][
"name"],
574 $newObj->import($_FILES[
"importfile"]);
579 if ($this->requested_ref_id > 0) {
581 if ($fold->getType() ==
"stys") {
583 $cont_style_settings->addStyle($newObj->getId());
584 $cont_style_settings->update();
586 $this->
ctrl->returnToParent($this);
589 $this->
object = $newObj;
590 return $newObj->getId();
597 $new_id = $this->domain->style(0)->importFromUploadResult(
600 return new \ILIAS\FileUpload\Handler\BasicHandlerResult(
613 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_cancel"),
true);
614 $this->
ctrl->returnToParent($this);
625 $ilHelp = $this->help;
626 $tabs = $this->gui_service->tabs();
627 $ilHelp->setScreenIdComponent(
"sty");
629 $tabs->setBackTarget(
631 $this->ctrl->getLinkTarget($this,
"returnToUpperContext")
637 $this->
ctrl->getLinkTarget($this,
"edit"),
645 $this->
ctrl->getLinkTarget($this,
"listColors"),
653 $this->
ctrl->getLinkTargetByClass(
"ilContentStyleImageGUI",
""),
655 "ilContentStyleImageGUI"
661 $this->
ctrl->getLinkTarget($this,
"listMediaQueries"),
670 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
678 $this->
ctrl->getLinkTarget($this,
"properties"),
686 $this->
ctrl->getLinkTargetByClass(
"ilexportgui",
""),
694 $ilTabs = $this->gui_service->tabs();
695 $ilCtrl = $this->ctrl;
699 foreach ($types as $t =>
$c) {
700 $ilCtrl->setParameter($this,
"temp_type", $t);
701 $ilTabs->addSubTabTarget(
702 "sty_" . $t .
"_templates",
703 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
704 array(
"listTemplates",
""),
709 $ilCtrl->setParameter($this,
"temp_type", $this->style_request->getTempType());
718 $ilLocator = $this->gui_service->locator();
720 if ($this->style_request->getAdminMode() ==
"settings") {
721 parent::addAdminLocatorItems(
true);
724 $this->
lng->txt(
"obj_stys"),
725 $this->ctrl->getLinkTargetByClass(
"ilobjstylesettingsgui",
"")
729 $this->
lng->txt(
"content_styles"),
730 $this->ctrl->getLinkTargetByClass(
"ilcontentstylesettingsgui",
"")
733 if ($this->style_request->getObjId() > 0) {
735 $this->
object->getTitle(),
736 $this->ctrl->getLinkTarget($this,
"edit")
753 $c = explode(
":", $a_class);
756 $ex_tpl =
new ilTemplate(
"tpl.style_example.html",
true,
true,
"components/ILIAS/Style/Content");
758 if ($ex_tpl->blockExists(
"Example_" . $a_type)) {
759 $ex_tpl->setCurrentBlock(
"Example_" . $a_type);
761 $ex_tpl->setCurrentBlock(
"Example_default");
763 $ex_tpl->setVariable(
"EX_CLASS",
"ilc_" . $a_type .
"_" . $a_class);
764 $ex_tpl->setVariable(
"EX_TEXT",
"ABC abc 123");
765 if (in_array($a_type, array(
"media_cont",
"qimg"))) {
768 if (in_array($a_type, array(
"table",
"table_caption"))) {
769 $ex_tpl->setVariable(
"TXT_CAPTION",
$lng->txt(
"sty_caption"));
771 if (in_array($a_class, array(
"OrderListItemHorizontal",
"OrderListHorizontal"))) {
772 $ex_tpl->setVariable(
"HOR",
"Horizontal");
774 $ex_tpl->parseCurrentBlock();
776 return $ex_tpl->get();
789 $tpl = $this->gui_service->ui()->mainTemplate();
790 $ilToolbar = $this->gui_service->toolbar();
791 $ilCtrl = $this->ctrl;
793 if ($this->access_manager->checkWrite()) {
794 $ilToolbar->addButton(
795 $this->
lng->txt(
"sty_add_color"),
796 $ilCtrl->getLinkTarget($this,
"addColor")
803 $this->getStyleSheet(),
804 $this->access_manager
806 $tpl->setContent($table_gui->getHTML());
811 $tpl = $this->gui_service->ui()->mainTemplate();
813 $this->initColorForm();
814 $tpl->setContent($this->form_gui->getHTML());
819 $tpl = $this->gui_service->ui()->mainTemplate();
820 $ilCtrl = $this->ctrl;
822 $ilCtrl->setParameter($this,
"c_name", $this->style_request->getColorName());
823 $this->initColorForm(
"edit");
824 $this->getColorFormValues();
825 $tpl->setContent($this->form_gui->getHTML());
830 string $a_mode =
"create"
833 $ilCtrl = $this->ctrl;
837 $this->form_gui->setTitle(
$lng->txt(
"sty_add_color"));
841 $name_input->setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
842 $name_input->setNoMatchMessage(
$lng->txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
843 $name_input->setRequired(
true);
844 $name_input->setSize(15);
845 $name_input->setMaxLength(15);
846 $this->form_gui->addItem($name_input);
850 $color_input->setRequired(
true);
851 $color_input->setDefaultColor(
"");
852 $this->form_gui->addItem($color_input);
854 if ($a_mode ==
"create") {
855 $this->form_gui->addCommandButton(
"saveColor",
$lng->txt(
"save"));
857 $this->form_gui->addCommandButton(
"updateColor",
$lng->txt(
"save"));
859 $this->form_gui->addCommandButton(
"cancelColorSaving",
$lng->txt(
"cancel"));
860 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
868 $c_name = $this->style_request->getColorName();
870 $values[
"color_name"] = $c_name;
871 $values[
"color_code"] = $this->
object->getColorCodeForName($c_name);
872 $this->form_gui->setValuesByArray($values);
881 $ilCtrl = $this->ctrl;
883 $ilCtrl->redirect($this,
"listColors");
891 $tpl = $this->gui_service->ui()->mainTemplate();
892 $ilCtrl = $this->ctrl;
895 $this->initColorForm();
896 if ($this->form_gui->checkInput()) {
897 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name"))) {
898 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
899 $col_input->setAlert(
$lng->txt(
"sty_color_already_exists"));
901 $this->color_manager->addColor(
902 $this->form_gui->getInput(
"color_name"),
903 $this->form_gui->getInput(
"color_code")
905 $ilCtrl->redirect($this,
"listColors");
908 $this->form_gui->setValuesByPost();
909 $tpl->setContent($this->form_gui->getHTML());
917 $tpl = $this->gui_service->ui()->mainTemplate();
918 $ilCtrl = $this->ctrl;
921 $c_name = $this->style_request->getColorName();
922 $ilCtrl->setParameter($this,
"c_name", $c_name);
923 $this->initColorForm(
"edit");
925 if ($this->form_gui->checkInput()) {
926 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name")) &&
927 $this->form_gui->getInput(
"color_name") != $c_name) {
928 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
929 $col_input->setAlert(
$lng->txt(
"sty_color_already_exists"));
931 $this->color_manager->updateColor(
933 $this->form_gui->getInput(
"color_name"),
934 $this->form_gui->getInput(
"color_code")
936 $ilCtrl->redirect($this,
"listColors");
939 $this->form_gui->setValuesByPost();
940 $tpl->setContent($this->form_gui->getHTML());
948 $ilCtrl = $this->ctrl;
949 $tpl = $this->gui_service->ui()->mainTemplate();
952 $colors = $this->style_request->getColors();
953 if (count($colors) == 0) {
954 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"no_checkbox"),
true);
955 $ilCtrl->redirect($this,
"listColors");
958 $cgui->setFormAction($ilCtrl->getFormAction($this));
959 $cgui->setHeaderText(
$lng->txt(
"sty_confirm_color_deletion"));
960 $cgui->setCancel(
$lng->txt(
"cancel"),
"cancelColorDeletion");
961 $cgui->setConfirm(
$lng->txt(
"delete"),
"deleteColor");
963 foreach ($colors as
$c) {
967 $tpl->setContent($cgui->getHTML());
976 $ilCtrl = $this->ctrl;
977 $ilCtrl->redirect($this,
"listColors");
982 $ilCtrl = $this->ctrl;
984 $colors = $this->style_request->getColors();
985 foreach ($colors as
$c) {
986 $this->
object->removeColor($c);
989 $ilCtrl->redirect($this,
"listColors");
998 $tpl = $this->gui_service->ui()->mainTemplate();
999 $ilToolbar = $this->gui_service->toolbar();
1000 $ilCtrl = $this->ctrl;
1002 if ($this->access_manager->checkWrite()) {
1003 $ilToolbar->addButton(
1004 $this->
lng->txt(
"sty_add_media_query"),
1005 $ilCtrl->getLinkTarget($this,
"addMediaQuery")
1012 $this->getStyleSheet(),
1013 $this->access_manager
1015 $tpl->setContent($table_gui->getHTML());
1020 $tpl = $this->gui_service->ui()->mainTemplate();
1022 $this->initMediaQueryForm();
1023 $tpl->setContent($this->form_gui->getHTML());
1028 $tpl = $this->gui_service->ui()->mainTemplate();
1029 $ilCtrl = $this->ctrl;
1031 $ilCtrl->setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
1032 $this->initMediaQueryForm(
"edit");
1033 $this->getMediaQueryFormValues();
1034 $tpl->setContent($this->form_gui->getHTML());
1042 string $a_mode =
"create"
1045 $ilCtrl = $this->ctrl;
1049 $this->form_gui->setTitle(
$lng->txt(
"sty_add_media_query"));
1053 $ti->setMaxLength(2000);
1054 $ti->setInfo(
$lng->txt(
"sty_add_media_query_info"));
1055 $this->form_gui->addItem($ti);
1058 if ($a_mode ==
"create") {
1059 $this->form_gui->addCommandButton(
"saveMediaQuery",
$lng->txt(
"save"));
1061 $this->form_gui->addCommandButton(
"updateMediaQuery",
$lng->txt(
"save"));
1063 $this->form_gui->addCommandButton(
"listMediaQueries",
$lng->txt(
"cancel"));
1064 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1073 if ($this->style_request->getMediaQueryId() > 0) {
1074 foreach ($this->
object->getMediaQueries() as $mq) {
1075 if ($mq[
"id"] == $this->style_request->getMediaQueryId()) {
1076 $values[
"mquery"] = $mq[
"mquery"];
1079 $this->form_gui->setValuesByArray($values);
1088 $tpl = $this->gui_service->ui()->mainTemplate();
1089 $ilCtrl = $this->ctrl;
1092 $this->initMediaQueryForm();
1094 if ($this->form_gui->checkInput()) {
1095 $this->
object->addMediaQuery($this->form_gui->getInput(
"mquery"));
1096 $ilCtrl->redirect($this,
"listMediaQueries");
1098 $this->form_gui->setValuesByPost();
1099 $tpl->setContent($this->form_gui->getHTML());
1104 $tpl = $this->gui_service->ui()->mainTemplate();
1105 $ilCtrl = $this->ctrl;
1107 $this->initMediaQueryForm(
"edit");
1109 if ($this->form_gui->checkInput()) {
1110 $this->
object->updateMediaQuery(
1111 $this->style_request->getMediaQueryId(),
1112 $this->form_gui->getInput(
"mquery")
1114 $ilCtrl->redirect($this,
"listMediaQueries");
1116 $ilCtrl->setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
1117 $this->form_gui->setValuesByPost();
1118 $tpl->setContent($this->form_gui->getHTML());
1123 $ilCtrl = $this->ctrl;
1124 $tpl = $this->gui_service->ui()->mainTemplate();
1127 $mq_ids = $this->style_request->getMediaQueryIds();
1128 if (count($mq_ids) == 0) {
1129 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"no_checkbox"),
true);
1130 $ilCtrl->redirect($this,
"listMediaQueries");
1133 $cgui->setFormAction($ilCtrl->getFormAction($this));
1134 $cgui->setHeaderText(
$lng->txt(
"sty_sure_del_mqueries"));
1135 $cgui->setCancel(
$lng->txt(
"cancel"),
"listMediaQueries");
1136 $cgui->setConfirm(
$lng->txt(
"delete"),
"deleteMediaQueries");
1138 foreach ($mq_ids as $i) {
1139 $mq = $this->
object->getMediaQueryForId($i);
1140 $cgui->addItem(
"mq_id[]", (
string) $i, $mq[
"mquery"]);
1143 $tpl->setContent($cgui->getHTML());
1149 $ilCtrl = $this->ctrl;
1151 $mq_ids = $this->style_request->getMediaQueryIds();
1152 if ($this->access_manager->checkWrite()) {
1153 foreach ($mq_ids as
$id) {
1154 $this->
object->deleteMediaQuery($id);
1157 $ilCtrl->redirect($this,
"listMediaQueries");
1162 $ilCtrl = $this->ctrl;
1164 $order = $this->style_request->getOrder();
1165 if (count($order) > 0) {
1166 $this->getStyleSheet()->saveMediaQueryOrder($order);
1168 $ilCtrl->redirect($this,
"listMediaQueries");
1181 $tpl = $this->gui_service->ui()->mainTemplate();
1182 $ilTabs = $this->gui_service->tabs();
1183 $ilCtrl = $this->ctrl;
1184 $ilToolbar = $this->gui_service->toolbar();
1186 $ctype = $this->style_request->getTempType();
1191 $this->setTemplatesSubTabs();
1192 $ilCtrl->setParameter($this,
"temp_type", $ctype);
1193 $ilTabs->setSubTabActive(
"sty_" . $ctype .
"_templates");
1196 if ($this->access_manager->checkWrite()) {
1197 if ($ctype ==
"table") {
1198 $ilToolbar->addButton(
1199 $this->
lng->txt(
"sty_generate_template"),
1200 $ilCtrl->getLinkTarget($this,
"generateTemplate")
1203 $ilToolbar->addButton(
1204 $this->
lng->txt(
"sty_add_template"),
1205 $ilCtrl->getLinkTarget($this,
"addTemplate")
1211 $this->includeCSS();
1216 $this->getStyleSheet(),
1217 $this->access_manager
1219 $tpl->setContent($table_gui->getHTML());
1224 $tpl = $this->gui_service->ui()->mainTemplate();
1226 $this->initTemplateForm();
1227 $tpl->setContent($this->form_gui->getHTML());
1232 $ilCtrl = $this->ctrl;
1234 $ilCtrl->setParameter(
1237 $this->style_request->getTemplateId()
1239 $this->initTemplateForm(
"edit");
1240 $this->getTemplateFormValues();
1242 $this->displayTemplateEditForm();
1248 bool $a_small_mode =
false
1250 return $this->_getTemplatePreview(
1251 $this->getStyleSheet(),
1265 bool $a_small_mode =
false
1273 if ($a_small_mode) {
1279 $t = $ts[
"classes"];
1282 if ($a_type ==
"table") {
1283 $p_content =
'<PageContent><Table DataTable="y"';
1284 $t[
"row_head"] = $t[
"row_head"] ??
"";
1285 $t[
"row_foot"] = $t[
"row_foot"] ??
"";
1286 $t[
"col_head"] = $t[
"col_head"] ??
"";
1287 $t[
"col_foot"] = $t[
"col_foot"] ??
"";
1288 if ($t[
"row_head"] !=
"") {
1289 $p_content .=
' HeaderRows="1"';
1291 if ($t[
"row_foot"] !=
"") {
1292 $p_content .=
' FooterRows="1"';
1294 if ($t[
"col_head"] !=
"") {
1295 $p_content .=
' HeaderCols="1"';
1297 if ($t[
"col_foot"] !=
"") {
1298 $p_content .=
' FooterCols="1"';
1301 if (!$a_small_mode) {
1302 $p_content .=
'<Caption>' .
$lng->txt(
"sty_caption") .
'</Caption>';
1304 for ($i = 1; $i <= $kr; $i++) {
1305 $p_content .=
'<TableRow>';
1306 for ($j = 1; $j <= $kc; $j++) {
1307 if ($a_small_mode) {
1308 $cell =
'<div style="height:2px;"></div>';
1312 $p_content .=
'<TableData><PageContent><Paragraph Characteristic="TableContent">' . $cell .
'</Paragraph></PageContent></TableData>';
1314 $p_content .=
'</TableRow>';
1316 $p_content .=
'</Table></PageContent>';
1319 if ($a_type ==
"vaccordion" || $a_type ==
"haccordion" || $a_type ==
"carousel") {
1322 if ($a_small_mode) {
1329 if ($a_type ==
"vaccordion") {
1330 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
1331 if ($a_small_mode) {
1332 $p_content .=
' ContentWidth="70"';
1334 } elseif ($a_type ==
"haccordion") {
1335 $p_content =
'<PageContent><Tabs Type="HorizontalAccordion"';
1336 $p_content .=
' ContentHeight="40"';
1337 if ($a_small_mode) {
1338 $p_content .=
' ContentWidth="70"';
1339 $c =
'&nbsp;&nbsp;&nbsp;&nbsp;';
1341 } elseif ($a_type ==
"carousel") {
1342 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="Carousel" ';
1343 if ($a_small_mode) {
1344 $p_content .=
' ContentWidth="70"';
1350 $p_content .=
'<Tab><PageContent><Paragraph>' .
$c .
'</Paragraph></PageContent>';
1351 $p_content .=
'<TabCaption>' . $h .
'</TabCaption>';
1352 $p_content .=
'</Tab>';
1353 $p_content .=
'</Tabs></PageContent>';
1358 $p_content .= $txml;
1362 if ($a_type ==
"carousel") {
1363 $r_content .=
"<style>.owl-carousel{ display:block !important; }</style>";
1376 $ilCtrl = $this->ctrl;
1380 if ($a_mode ==
"create") {
1381 $this->form_gui->setTitle(
$lng->txt(
"sty_add_template"));
1383 $this->form_gui->setTitle(
$lng->txt(
"sty_edit_template"));
1388 $name_input->setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1389 $name_input->setNoMatchMessage(
$lng->txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1390 $name_input->setRequired(
true);
1391 $name_input->setSize(30);
1392 $name_input->setMaxLength(30);
1393 $this->form_gui->addItem($name_input);
1397 $this->style_request->getTempType()
1400 foreach ($scs as $sc => $st) {
1402 $chars = $this->
object->getCharacteristics($st);
1404 foreach ($chars as $char) {
1408 $this->form_gui->addItem($sc_input);
1411 if ($a_mode ==
"create") {
1412 $this->form_gui->addCommandButton(
"saveTemplate",
$lng->txt(
"save"));
1414 $this->form_gui->addCommandButton(
"refreshTemplate",
$lng->txt(
"save_refresh"));
1415 $this->form_gui->addCommandButton(
"updateTemplate",
$lng->txt(
"save_return"));
1417 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->txt(
"cancel"));
1418 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1426 $ilCtrl = $this->ctrl;
1427 $ilCtrl->redirect($this,
"listTemplates");
1436 $tpl = $this->gui_service->ui()->mainTemplate();
1437 $ilCtrl = $this->ctrl;
1440 $this->initTemplateForm();
1441 $temp_type = $this->style_request->getTempType();
1443 if ($this->form_gui->checkInput()) {
1444 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1445 $name_input = $this->form_gui->getItemByPostVar(
"name");
1446 $name_input->setAlert(
$lng->txt(
"sty_table_template_already_exists"));
1450 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1452 $t_id = $this->
object->addTemplate(
1454 $this->form_gui->getInput(
"name"),
1457 $this->
object->writeTemplatePreview(
1459 $this->getTemplatePreview($temp_type, $t_id,
true)
1461 $ilCtrl->redirect($this,
"listTemplates");
1464 $this->form_gui->setValuesByPost();
1465 $tpl->setContent($this->form_gui->getHTML());
1469 bool $a_refresh =
false
1471 $ilCtrl = $this->
ctrl;
1474 $ilCtrl->setParameter($this,
"t_id", $this->style_request->getTemplateId());
1475 $this->initTemplateForm(
"edit");
1476 $temp_type = $this->style_request->getTempType();
1478 $t_id = $this->style_request->getTemplateId();
1479 if ($this->form_gui->checkInput()) {
1480 if ($this->
object->templateExists($this->form_gui->getInput(
"name")) &&
1482 $name_input = $this->form_gui->getItemByPostVar(
"name");
1483 $name_input->setAlert(
$lng->txt(
"sty_template_already_exists"));
1487 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1490 $this->
object->updateTemplate(
1492 $this->form_gui->getInput(
"name"),
1495 $this->
object->writeTemplatePreview(
1497 $this->getTemplatePreview($temp_type, $t_id,
true)
1500 $ilCtrl->redirect($this,
"listTemplates");
1505 $this->form_gui->setValuesByPost();
1506 $this->displayTemplateEditForm();
1511 $tpl = $this->gui_service->ui()->mainTemplate();
1514 "tpl.template_edit.html",
1517 "components/ILIAS/Style/Content"
1519 $this->includeCSS();
1520 $a_tpl->setVariable(
"FORM", $this->form_gui->getHTML());
1521 $a_tpl->setVariable(
"PREVIEW", $this->getTemplatePreview(
1522 $this->style_request->getTempType(),
1523 $this->style_request->getTemplateId()
1525 $tpl->setContent($a_tpl->get());
1533 $this->updateTemplateObject(
true);
1541 $t_id = $this->style_request->getTemplateId();
1543 $t = $this->
object->getTemplate($t_id);
1545 $values[
"name"] = $t[
"name"];
1547 $this->style_request->getTempType()
1549 foreach ($scs as $k => $type) {
1550 $values[$k .
"_class"] = $t[
"classes"][$k] ??
"";
1552 $this->form_gui->setValuesByArray($values);
1561 $ilCtrl = $this->ctrl;
1562 $tpl = $this->gui_service->ui()->mainTemplate();
1565 $tids = $this->style_request->getTemplateIds();
1566 if (count($tids) == 0) {
1567 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"no_checkbox"),
true);
1568 $ilCtrl->redirect($this,
"listTemplates");
1571 $cgui->setFormAction($ilCtrl->getFormAction($this));
1572 $cgui->setHeaderText(
$lng->txt(
"sty_confirm_template_deletion"));
1573 $cgui->setCancel(
$lng->txt(
"cancel"),
"cancelTemplateDeletion");
1574 $cgui->setConfirm(
$lng->txt(
"sty_del_template"),
"deleteTemplate");
1576 foreach ($tids as $tid) {
1577 $classes = $this->
object->getTemplateClasses($tid);
1580 foreach ($classes as $cl) {
1581 if ($cl !=
"" && !($listed[$cl] ??
false)) {
1582 $cl_str .=
'<div>- ' .
1584 $listed[$cl] =
true;
1587 if ($cl_str !=
"") {
1588 $cl_str =
'<div style="padding-left:30px;" class="small">' .
1589 "<div><i>" .
$lng->txt(
"sty_style_class") .
"</i></div>" . $cl_str .
"</div>";
1591 $cgui->addItem(
"tid[]", (
string) $tid, $this->
object->lookupTemplateName($tid) . $cl_str);
1594 $cgui->addButton(
$lng->txt(
"sty_del_template_keep_classes"),
"deleteTemplateKeepClasses");
1596 $tpl->setContent($cgui->getHTML());
1605 $ilCtrl = $this->ctrl;
1607 $ilCtrl->redirect($this,
"listTemplates");
1612 $ilCtrl = $this->ctrl;
1614 $tids = $this->style_request->getTemplateIds();
1615 foreach ($tids as $tid) {
1616 $this->
object->removeTemplate($tid);
1619 $ilCtrl->redirect($this,
"listTemplates");
1630 $ilCtrl = $this->ctrl;
1632 $tids = $this->style_request->getTemplateIds();
1633 foreach ($tids as $tid) {
1634 $cls = $this->
object->getTemplateClasses($tid);
1635 foreach ($cls as $k => $cls2) {
1636 $ty = $this->
object->determineTemplateStyleClassType(
1637 $this->style_request->getTempType(),
1640 $this->characteristic_manager->deleteCharacteristic($ty, $cls2);
1642 $this->
object->removeTemplate($tid);
1645 $ilCtrl->redirect($this,
"listTemplates");
1650 $tpl = $this->gui_service->ui()->mainTemplate();
1652 $this->initTemplateGenerationForm();
1653 $tpl->setContent($this->form_gui->getHTML());
1662 $ilCtrl = $this->ctrl;
1666 $this->form_gui->setTitle(
$lng->txt(
"sty_generate_template"));
1670 $name_input->setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1671 $name_input->setNoMatchMessage(
$lng->txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1672 $name_input->setRequired(
true);
1673 $name_input->setSize(30);
1674 $name_input->setMaxLength(30);
1675 $this->form_gui->addItem($name_input);
1680 "coloredZebra" =>
$lng->txt(
"sty_table_template_colored_zebra"),
1681 "bwZebra" =>
$lng->txt(
"sty_table_template_bw_zebra"),
1682 "noZebra" =>
$lng->txt(
"sty_table_template_no_zebra")
1685 $this->form_gui->addItem($bl_input);
1689 $num_input->setAllowPercentage(
false);
1690 $num_input->setValue(
"3px");
1691 $this->form_gui->addItem($num_input);
1695 $num_input->setAllowPercentage(
false);
1696 $num_input->setValue(
"10px");
1697 $this->form_gui->addItem($num_input);
1701 $cs = $this->
object->getColors();
1703 foreach ($cs as
$c) {
1707 $this->form_gui->addItem($bc_input);
1710 $lss = array(
"border" => 90,
"header_text" => 70,
"header_bg" => 0,
1711 "cell1_text" => -60,
"cell1_bg" => 90,
"cell2_text" => -60,
"cell2_bg" => 75);
1712 foreach ($lss as $ls => $v) {
1714 $l_input->setMaxValue(100);
1715 $l_input->setMinValue(-100);
1716 $l_input->setValue((
string) $v);
1717 $l_input->setSize(4);
1718 $l_input->setMaxLength(4);
1719 $this->form_gui->addItem($l_input);
1722 $this->form_gui->addCommandButton(
"templateGeneration",
$lng->txt(
"generate"));
1723 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->txt(
"cancel"));
1724 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1732 $tpl = $this->gui_service->ui()->mainTemplate();
1733 $ilCtrl = $this->ctrl;
1736 $this->initTemplateGenerationForm();
1738 if ($this->form_gui->checkInput()) {
1739 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1740 $name_input = $this->form_gui->getItemByPostVar(
"name");
1741 $name_input->setAlert(
$lng->txt(
"sty_table_template_already_exists"));
1746 $cells = array(
"H" =>
"header",
"C1" =>
"cell1",
"C2" =>
"cell2");
1747 $tb_p = $this->form_gui->getItemByPostVar(
"tb_padding");
1748 $tb_padding = $tb_p->getValue();
1749 $lr_p = $this->form_gui->getItemByPostVar(
"lr_padding");
1750 $lr_padding = $lr_p->getValue();
1751 $cell_color = $this->form_gui->getInput(
"base_color");
1754 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1755 $cell_color =
"MidGray";
1756 if (!$this->color_manager->colorExists($cell_color)) {
1757 $this->color_manager->addColor($cell_color,
"7F7F7F");
1759 $this->color_manager->updateColor($cell_color, $cell_color,
"7F7F7F");
1762 foreach ($cells as $k => $cell) {
1763 $cell_class[$k] = $this->form_gui->getInput(
"name") . $k;
1764 if (!$this->
object->characteristicExists($cell_class[$k],
"table_cell")) {
1765 $this->characteristic_manager->addCharacteristic(
"table_cell", $cell_class[$k],
true);
1767 if ($this->form_gui->getInput(
"layout") ==
"bwZebra" && $k ==
"H") {
1768 $this->characteristic_manager->replaceParameter(
1772 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1775 $this->characteristic_manager->replaceParameter(
1779 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1783 $this->characteristic_manager->replaceParameter(
1787 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1790 $this->characteristic_manager->replaceParameter(
1794 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1798 $this->characteristic_manager->replaceParameter(
1805 $this->characteristic_manager->replaceParameter(
1812 $this->characteristic_manager->replaceParameter(
1819 $this->characteristic_manager->replaceParameter(
1826 $this->characteristic_manager->replaceParameter(
1833 $this->characteristic_manager->replaceParameter(
1840 $this->characteristic_manager->replaceParameter(
1844 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_border") .
")",
1847 $this->characteristic_manager->replaceParameter(
1857 $classes[
"table"] = $this->form_gui->getInput(
"name") .
"T";
1858 if (!$this->
object->characteristicExists($classes[
"table"],
"table")) {
1859 $this->characteristic_manager->addCharacteristic(
"table", $classes[
"table"],
true);
1861 $this->characteristic_manager->replaceParameter(
1868 $this->characteristic_manager->replaceParameter(
1875 $this->characteristic_manager->replaceParameter(
1882 $this->characteristic_manager->replaceParameter(
1889 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1890 $this->characteristic_manager->replaceParameter(
1893 "border-bottom-color",
1894 "!" . $this->form_gui->getInput(
"base_color"),
1897 $this->characteristic_manager->replaceParameter(
1900 "border-bottom-style",
1904 $this->characteristic_manager->replaceParameter(
1907 "border-bottom-width",
1911 $sb = array(
"left",
"right",
"top");
1912 foreach ($sb as
$b) {
1913 $this->characteristic_manager->replaceParameter(
1916 "border-" .
$b .
"-width",
1923 switch ($this->form_gui->getInput(
"layout")) {
1925 case "coloredZebra":
1926 $classes[
"row_head"] = $cell_class[
"H"];
1927 $classes[
"odd_row"] = $cell_class[
"C1"];
1928 $classes[
"even_row"] = $cell_class[
"C2"];
1932 $classes[
"row_head"] = $cell_class[
"H"];
1933 $classes[
"odd_row"] = $cell_class[
"C1"];
1934 $classes[
"even_row"] = $cell_class[
"C1"];
1935 $classes[
"col_head"] = $cell_class[
"C2"];
1940 $t_id = $this->
object->addTemplate(
1941 $this->style_request->getTempType(),
1942 $this->form_gui->getInput(
"name"),
1945 $this->
object->writeTemplatePreview(
1947 $this->getTemplatePreview(
1948 $this->style_request->getTempType(),
1953 $ilCtrl->redirect($this,
"listTemplates");
1956 $this->form_gui->setValuesByPost();
1957 $tpl->setContent($this->form_gui->getHTML());
1962 $ilCtrl = $this->ctrl;
1963 $ilCtrl->returnToParent($this);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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 addCss()
Add required css.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
Export User Interface Class.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjStyleSheetGUI.
ilPropertyFormGUI $form_gui
Access StyleAccessManager $access_manager
saveMediaQueryOrderObject()
getAdminTabs()
administration tabs show only permissions and trash folder
templateGenerationObject()
Table template generation.
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
Content InternalDomainService $domain
cancelObject()
cancel action and go back to previous page
deleteMediaQueryConfirmationObject()
cancelTemplateDeletionObject()
Cancel table template deletion.
Content ImageManager $image_manager
getPropertiesValues()
Get current values for properties from.
Content StandardGUIRequest $style_request
editObject()
Edit -> List characteristics.
deleteObject($a_error=false)
display deletion confirmation screen
refreshTemplateObject()
Refresh table template.
initMediaQueryForm(string $a_mode="create")
Init media query form.
deleteTemplateObject()
Delete template.
deleteColorConfirmationObject()
Delete color confirmation.
cancelColorDeletionObject()
Cancel color deletion.
deleteTemplateKeepClassesObject()
getColorFormValues()
Set values for color editing.
static getStyleExampleHTML(string $a_type, string $a_class)
Get style example HTML.
getTemplateFormValues()
Set values for table template editing.
Content InternalService $service
initTemplateGenerationForm()
Init table template generation form.
deleteTemplateConfirmationObject()
Delete table template confirmation.
cancelColorSavingObject()
Cancel color saving.
Content InternalGUIService $gui_service
updateObject()
updates object entry in object_data
getRenderedCreationFormsHTML(array $forms)
displayTemplateEditForm()
initPropertiesForm(string $a_mode="edit")
FORM: Init properties form.
importStyleObject()
Import style sheet.
static _getTemplatePreview(ilObjStyleSheet $a_style, string $a_type, int $a_t_id, bool $a_small_mode=false)
Get table template preview.
deleteMediaQueriesObject()
enableWrite(bool $a_write)
Enable writing.
initTemplateForm(string $a_mode="create")
Init table template form.
updateTemplateObject(bool $a_refresh=false)
createObject()
create new object form
Content ColorManager $color_manager
handleImport(\ILIAS\FileUpload\FileUpload $upload, \ILIAS\FileUpload\DTO\UploadResult $result)
confirmedDeleteObject()
delete selected style objects
saveColorObject()
Save color.
initColorForm(string $a_mode="create")
listColorsObject()
List colors of style.
saveTemplateObject()
Save table template.
updateColorObject()
Update color.
getMediaQueryFormValues()
Set values for media query editing.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
__construct( $a_data, int $a_id, bool $a_call_by_reference)
getTemplatePreview(string $a_type, int $a_t_id, bool $a_small_mode=false)
returnToUpperContextObject()
ilObjectDefinition $obj_definition
Content CharacteristicManager $characteristic_manager
getTabs()
@abstract overwrite in derived GUI class of your object type
saveMediaQueryObject()
Save media query.
listTemplatesObject()
List templates.
cancelTemplateSavingObject()
Cancel color saving.
static _getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
getTemplateXML()
Get table template xml.
lookupTemplateName(int $a_t_id)
Lookup table template name for template ID.
static _addMissingStyleClassesToStyle(int $a_id)
Add missing style classes to all styles.
static _writeStandard(int $a_id, bool $a_std)
Write standard flag.
static _getTemplateClassTypes(string $a_template_type="")
Get template class types.
static _getStyleSuperTypeForType(string $a_type)
static _lookupTemplateName(int $a_t_id)
Lookup table template name for template ID.
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
prepareOutput(bool $show_sub_objects=true)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static _renderTable(string $content, string $a_mode="table_edit", string $a_submode="", ?ilPCTable $a_table_obj=null, bool $unmask=true, ?ilPageObject $page_object=null)
TableGUI class for style editor (image list)
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.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.