3 declare(strict_types=1);
53 bool $a_call_by_reference
59 $this->service = $DIC->contentStyle()
61 $this->gui_service = $this->service->gui();
62 $this->
help = $this->gui_service->help();
63 $this->
lng->loadLanguageModule(
"style");
64 $this->
ctrl->saveParameter($this, array(
"tag",
"style_type",
"temp_type"));
65 $this->style_request = $DIC->contentStyle()
70 $this->super_type =
"";
71 if ($this->style_request->getStyleType() !=
"") {
73 $this->style_request->getStyleType()
78 $ref_id = (is_object($this->
object))
79 ? $this->
object->getRefId()
81 $style_id = (is_object($this->
object))
85 $this->access_manager = $this->service->domain()->access(
89 $this->characteristic_manager = $this->service->domain()->characteristic(
93 $this->color_manager = $this->service->domain()->color(
97 $this->image_manager = $this->service->domain()->image(
108 $this->access_manager->enableWrite($a_write);
113 $tabs = $this->gui_service->tabs();
114 $ctrl = $this->gui_service->ctrl();
120 if (!$this->
object || $cmd ==
"create") {
124 switch ($next_class) {
128 $exp_gui->addFormat(
"xml");
132 case "ilstylecharacteristicgui":
135 $tabs->activateTab(
"sty_style_chars");
136 $gui = $this->gui_service->characteristic()->ilStyleCharacteristicGUI(
137 $this->getStyleSheet(),
139 $this->access_manager,
140 $this->characteristic_manager,
146 case "ilcontentstyleimagegui":
149 $tabs->activateTab(
"sty_images");
150 $gui = $this->gui_service->image()->ilContentStyleImageGUI(
151 $this->access_manager,
179 $tpl = $this->gui_service->ui()->mainTemplate();
186 $ilHelp->setScreenIdComponent(
"sty");
201 $form->
setTitle($this->
lng->txt(
"sty_create_new_stylesheet"));
205 $ti->setMaxLength(128);
207 $ti->setRequired(
true);
226 $form->
setTitle($this->
lng->txt(
"sty_import_stylesheet"));
243 $form->
setTitle($this->
lng->txt(
"sty_copy_other_stylesheet"));
258 $tpl = $this->gui_service->ui()->mainTemplate();
268 $ctrl = $this->gui_service->ctrl();
274 $tpl = $this->gui_service->ui()->mainTemplate();
289 $values[
"style_title"] = $this->
object->getTitle();
290 $values[
"style_description"] = $this->
object->getDescription();
291 $values[
"disable_auto_margins"] = (
int) $this->
object->lookupStyleSetting(
"disable_auto_margins");
293 $this->
form->setValuesByArray($values);
300 string $a_mode =
"edit" 302 $ctrl = $this->gui_service->ctrl();
309 $ti->setMaxLength(128);
311 $ti->setRequired(
true);
312 $this->
form->addItem($ti);
318 $this->
form->addItem($ta);
322 $cb->setInfo($this->
lng->txt(
"sty_disable_auto_margins_info"));
323 $this->
form->addItem($cb);
327 if ($a_mode ==
"create") {
328 $this->
form->addCommandButton(
"save",
$lng->
txt(
"save"));
329 $this->
form->addCommandButton(
"cancelSave",
$lng->
txt(
"cancel"));
331 if ($this->access_manager->checkWrite()) {
332 $this->
form->addCommandButton(
"update",
$lng->
txt(
"save"));
336 $this->
form->setTitle(
$lng->
txt(
"edit_stylesheet"));
343 $ctrl = $this->gui_service->ctrl();
344 $tpl = $this->gui_service->ui()->mainTemplate();
347 if ($this->
form->checkInput()) {
348 $this->
object->setTitle($this->
form->getInput(
"style_title"));
349 $this->
object->setDescription($this->
form->getInput(
"style_description"));
350 $this->
object->writeStyleSetting(
351 "disable_auto_margins",
352 $this->
form->getInput(
"disable_auto_margins")
354 $this->
object->update();
355 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"msg_obj_modified"),
true);
358 $this->
form->setValuesByPost();
367 $r = $exp->exportObject($this->
object->getType(), $this->
object->getId());
377 $tpl = $this->gui_service->ui()->mainTemplate();
378 $ctrl = $this->gui_service->ctrl();
383 $cgui->setHeaderText($this->
lng->txt(
"info_delete_sure"));
384 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDelete");
385 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedDelete");
389 $cgui->addItem(
"id[]",
"", $caption);
396 $this->gui_service->ctrl()->returnToParent($this);
404 $this->
object->delete();
405 $this->gui_service->ctrl()->returnToParent($this);
410 $ctrl = $this->gui_service->ctrl();
415 if (!trim($form->
getInput(
"style_title"))) {
420 $default_style = $this->
settings->get(
"default_content_style_id");
423 $new_id = $style_obj->ilClone();
428 $style_id = $imp->importObject(
440 $newObj->setTitle($form->
getInput(
"style_title"));
441 $newObj->setDescription($form->
getInput(
"style_description"));
443 $this->
object = $newObj;
449 if ($this->requested_ref_id > 0) {
451 if ($fold->getType() ==
"stys") {
453 $cont_style_settings->addStyle($newObj->getId());
454 $cont_style_settings->update();
457 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
458 $this->
ctrl->setParameterByClass(self::class,
"obj_id", (
string) $newObj->getId());
459 $this->
ctrl->redirectByClass(self::class,
"");
466 $ctrl = $this->gui_service->ctrl();
472 if ($form->
getInput(
"source_style") > 0) {
474 $new_id = $style_obj->ilClone();
479 if ($this->requested_ref_id > 0) {
481 if ($fold->getType() ==
"stys") {
483 $cont_style_settings->addStyle($new_id);
484 $cont_style_settings->update();
501 $source = $_FILES[
"importfile"][
"tmp_name"];
502 if (($source ==
'none') || (!$source)) {
503 $this->
ilias->raiseError(
"No file selected!", $this->
ilias->error_obj->MESSAGE);
507 $info = pathinfo($_FILES[
"importfile"][
"name"]);
508 if (strtolower($info[
"extension"]) !=
"zip" && strtolower($info[
"extension"]) !=
"xml") {
509 $this->
ilias->raiseError(
"File must be a zip or xml file!", $this->
ilias->error_obj->MESSAGE);
513 $fname = explode(
"_", $_FILES[
"importfile"][
"name"]);
514 if (strtolower($info[
"extension"]) ==
"zip" && $fname[4] ==
"sty") {
516 $new_id = $imp->importObject(
518 $_FILES[
"importfile"][
"tmp_name"],
519 $_FILES[
"importfile"][
"name"],
527 $newObj->import($_FILES[
"importfile"]);
532 if ($this->requested_ref_id > 0) {
534 if ($fold->getType() ==
"stys") {
536 $cont_style_settings->addStyle($newObj->getId());
537 $cont_style_settings->update();
539 $this->
ctrl->returnToParent($this);
542 $this->
object = $newObj;
543 return $newObj->getId();
551 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"msg_cancel"),
true);
552 $this->
ctrl->returnToParent($this);
564 $tabs = $this->gui_service->tabs();
567 $tabs->setBackTarget(
569 $this->
ctrl->getLinkTarget($this,
"returnToUpperContext")
575 $this->
ctrl->getLinkTarget($this,
"edit"),
583 $this->
ctrl->getLinkTarget($this,
"listColors"),
591 $this->
ctrl->getLinkTargetByClass(
"ilContentStyleImageGUI",
""),
593 "ilContentStyleImageGUI" 599 $this->
ctrl->getLinkTarget($this,
"listMediaQueries"),
608 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
616 $this->
ctrl->getLinkTarget($this,
"properties"),
624 $this->
ctrl->getLinkTargetByClass(
"ilexportgui",
""),
632 $ilTabs = $this->gui_service->tabs();
637 foreach ($types as $t =>
$c) {
638 $ilCtrl->setParameter($this,
"temp_type", $t);
639 $ilTabs->addSubTabTarget(
640 "sty_" . $t .
"_templates",
641 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
642 array(
"listTemplates",
""),
647 $ilCtrl->setParameter($this,
"temp_type", $this->style_request->getTempType());
656 $ilLocator = $this->gui_service->locator();
658 if ($this->style_request->getAdminMode() ==
"settings") {
659 parent::addAdminLocatorItems(
true);
662 $this->
lng->txt(
"obj_stys"),
663 $this->
ctrl->getLinkTargetByClass(
"ilobjstylesettingsgui",
"")
667 $this->
lng->txt(
"content_styles"),
668 $this->
ctrl->getLinkTargetByClass(
"ilcontentstylesettingsgui",
"")
671 if ($this->style_request->getObjId() > 0) {
673 $this->
object->getTitle(),
674 $this->
ctrl->getLinkTarget($this,
"edit")
689 $lng = $DIC->language();
691 $c = explode(
":", $a_class);
694 $ex_tpl =
new ilTemplate(
"tpl.style_example.html",
true,
true,
"Services/Style/Content");
696 if ($ex_tpl->blockExists(
"Example_" . $a_type)) {
697 $ex_tpl->setCurrentBlock(
"Example_" . $a_type);
699 $ex_tpl->setCurrentBlock(
"Example_default");
701 $ex_tpl->setVariable(
"EX_CLASS",
"ilc_" . $a_type .
"_" . $a_class);
702 $ex_tpl->setVariable(
"EX_TEXT",
"ABC abc 123");
703 if (in_array($a_type, array(
"media_cont",
"qimg"))) {
706 if (in_array($a_type, array(
"table",
"table_caption"))) {
707 $ex_tpl->setVariable(
"TXT_CAPTION",
$lng->
txt(
"sty_caption"));
709 if (in_array($a_class, array(
"OrderListItemHorizontal",
"OrderListHorizontal"))) {
710 $ex_tpl->setVariable(
"HOR",
"Horizontal");
712 $ex_tpl->parseCurrentBlock();
714 return $ex_tpl->get();
727 $tpl = $this->gui_service->ui()->mainTemplate();
728 $ilToolbar = $this->gui_service->toolbar();
731 if ($this->access_manager->checkWrite()) {
732 $ilToolbar->addButton(
733 $this->
lng->txt(
"sty_add_color"),
734 $ilCtrl->getLinkTarget($this,
"addColor")
741 $this->getStyleSheet(),
742 $this->access_manager
749 $tpl = $this->gui_service->ui()->mainTemplate();
757 $tpl = $this->gui_service->ui()->mainTemplate();
760 $ilCtrl->
setParameter($this,
"c_name", $this->style_request->getColorName());
768 string $a_mode =
"create" 775 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_color"));
779 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
780 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
781 $name_input->setRequired(
true);
782 $name_input->setSize(15);
783 $name_input->setMaxLength(15);
784 $this->form_gui->addItem($name_input);
789 $color_input->setDefaultColor(
"");
790 $this->form_gui->addItem($color_input);
792 if ($a_mode ==
"create") {
793 $this->form_gui->addCommandButton(
"saveColor",
$lng->
txt(
"save"));
795 $this->form_gui->addCommandButton(
"updateColor",
$lng->
txt(
"save"));
797 $this->form_gui->addCommandButton(
"cancelColorSaving",
$lng->
txt(
"cancel"));
798 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
806 $c_name = $this->style_request->getColorName();
808 $values[
"color_name"] = $c_name;
809 $values[
"color_code"] = $this->
object->getColorCodeForName($c_name);
810 $this->form_gui->setValuesByArray($values);
821 $ilCtrl->
redirect($this,
"listColors");
829 $tpl = $this->gui_service->ui()->mainTemplate();
834 if ($this->form_gui->checkInput()) {
835 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name"))) {
836 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
837 $col_input->setAlert(
$lng->
txt(
"sty_color_already_exists"));
839 $this->color_manager->addColor(
840 $this->form_gui->getInput(
"color_name"),
841 $this->form_gui->getInput(
"color_code")
843 $ilCtrl->redirect($this,
"listColors");
846 $this->form_gui->setValuesByPost();
855 $tpl = $this->gui_service->ui()->mainTemplate();
859 $c_name = $this->style_request->getColorName();
860 $ilCtrl->setParameter($this,
"c_name", $c_name);
863 if ($this->form_gui->checkInput()) {
864 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name")) &&
865 $this->form_gui->getInput(
"color_name") != $c_name) {
866 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
867 $col_input->setAlert(
$lng->
txt(
"sty_color_already_exists"));
869 $this->color_manager->updateColor(
871 $this->form_gui->getInput(
"color_name"),
872 $this->form_gui->getInput(
"color_code")
874 $ilCtrl->redirect($this,
"listColors");
877 $this->form_gui->setValuesByPost();
887 $tpl = $this->gui_service->ui()->mainTemplate();
890 $colors = $this->style_request->getColors();
891 if (count($colors) == 0) {
892 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
893 $ilCtrl->redirect($this,
"listColors");
896 $cgui->setFormAction($ilCtrl->getFormAction($this));
897 $cgui->setHeaderText(
$lng->
txt(
"sty_confirm_color_deletion"));
898 $cgui->setCancel(
$lng->
txt(
"cancel"),
"cancelColorDeletion");
899 $cgui->setConfirm(
$lng->
txt(
"delete"),
"deleteColor");
901 foreach ($colors as
$c) {
915 $ilCtrl->
redirect($this,
"listColors");
922 $colors = $this->style_request->getColors();
923 foreach ($colors as
$c) {
924 $this->
object->removeColor($c);
927 $ilCtrl->
redirect($this,
"listColors");
936 $tpl = $this->gui_service->ui()->mainTemplate();
937 $ilToolbar = $this->gui_service->toolbar();
940 if ($this->access_manager->checkWrite()) {
941 $ilToolbar->addButton(
942 $this->
lng->txt(
"sty_add_media_query"),
943 $ilCtrl->getLinkTarget($this,
"addMediaQuery")
950 $this->getStyleSheet(),
951 $this->access_manager
958 $tpl = $this->gui_service->ui()->mainTemplate();
966 $tpl = $this->gui_service->ui()->mainTemplate();
969 $ilCtrl->
setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
980 string $a_mode =
"create" 987 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_media_query"));
991 $ti->setMaxLength(2000);
992 $ti->setInfo(
$lng->
txt(
"sty_add_media_query_info"));
993 $this->form_gui->addItem($ti);
996 if ($a_mode ==
"create") {
997 $this->form_gui->addCommandButton(
"saveMediaQuery",
$lng->
txt(
"save"));
999 $this->form_gui->addCommandButton(
"updateMediaQuery",
$lng->
txt(
"save"));
1001 $this->form_gui->addCommandButton(
"listMediaQueries",
$lng->
txt(
"cancel"));
1002 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1011 if ($this->style_request->getMediaQueryId() > 0) {
1012 foreach ($this->
object->getMediaQueries() as $mq) {
1013 if ($mq[
"id"] == $this->style_request->getMediaQueryId()) {
1014 $values[
"mquery"] = $mq[
"mquery"];
1017 $this->form_gui->setValuesByArray($values);
1026 $tpl = $this->gui_service->ui()->mainTemplate();
1032 if ($this->form_gui->checkInput()) {
1033 $this->
object->addMediaQuery($this->form_gui->getInput(
"mquery"));
1034 $ilCtrl->redirect($this,
"listMediaQueries");
1036 $this->form_gui->setValuesByPost();
1042 $tpl = $this->gui_service->ui()->mainTemplate();
1047 if ($this->form_gui->checkInput()) {
1048 $this->
object->updateMediaQuery(
1049 $this->style_request->getMediaQueryId(),
1050 $this->form_gui->getInput(
"mquery")
1052 $ilCtrl->redirect($this,
"listMediaQueries");
1054 $ilCtrl->setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
1055 $this->form_gui->setValuesByPost();
1062 $tpl = $this->gui_service->ui()->mainTemplate();
1065 $mq_ids = $this->style_request->getMediaQueryIds();
1066 if (count($mq_ids) == 0) {
1067 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
1068 $ilCtrl->redirect($this,
"listMediaQueries");
1071 $cgui->setFormAction($ilCtrl->getFormAction($this));
1072 $cgui->setHeaderText(
$lng->
txt(
"sty_sure_del_mqueries"));
1073 $cgui->setCancel(
$lng->
txt(
"cancel"),
"listMediaQueries");
1074 $cgui->setConfirm(
$lng->
txt(
"delete"),
"deleteMediaQueries");
1076 foreach ($mq_ids as $i) {
1077 $mq = $this->
object->getMediaQueryForId($i);
1078 $cgui->addItem(
"mq_id[]", (
string) $i, $mq[
"mquery"]);
1089 $mq_ids = $this->style_request->getMediaQueryIds();
1090 if ($this->access_manager->checkWrite()) {
1091 foreach ($mq_ids as
$id) {
1092 $this->
object->deleteMediaQuery($id);
1095 $ilCtrl->
redirect($this,
"listMediaQueries");
1102 $order = $this->style_request->getOrder();
1103 if (count($order) > 0) {
1104 $this->getStyleSheet()->saveMediaQueryOrder($order);
1106 $ilCtrl->
redirect($this,
"listMediaQueries");
1119 $tpl = $this->gui_service->ui()->mainTemplate();
1120 $ilTabs = $this->gui_service->tabs();
1122 $ilToolbar = $this->gui_service->toolbar();
1124 $ctype = $this->style_request->getTempType();
1130 $ilCtrl->setParameter($this,
"temp_type", $ctype);
1131 $ilTabs->setSubTabActive(
"sty_" . $ctype .
"_templates");
1134 if ($this->access_manager->checkWrite()) {
1135 if ($ctype ==
"table") {
1136 $ilToolbar->addButton(
1137 $this->
lng->txt(
"sty_generate_template"),
1138 $ilCtrl->getLinkTarget($this,
"generateTemplate")
1141 $ilToolbar->addButton(
1142 $this->
lng->txt(
"sty_add_template"),
1143 $ilCtrl->getLinkTarget($this,
"addTemplate")
1154 $this->getStyleSheet(),
1155 $this->access_manager
1162 $tpl = $this->gui_service->ui()->mainTemplate();
1175 $this->style_request->getTemplateId()
1186 bool $a_small_mode =
false 1189 $this->getStyleSheet(),
1203 bool $a_small_mode =
false 1207 $lng = $DIC->language();
1211 if ($a_small_mode) {
1217 $t = $ts[
"classes"];
1220 if ($a_type ==
"table") {
1221 $p_content =
'<PageContent><Table DataTable="y"';
1222 $t[
"row_head"] = $t[
"row_head"] ??
"";
1223 $t[
"row_foot"] = $t[
"row_foot"] ??
"";
1224 $t[
"col_head"] = $t[
"col_head"] ??
"";
1225 $t[
"col_foot"] = $t[
"col_foot"] ??
"";
1226 if ($t[
"row_head"] !=
"") {
1227 $p_content .=
' HeaderRows="1"';
1229 if ($t[
"row_foot"] !=
"") {
1230 $p_content .=
' FooterRows="1"';
1232 if ($t[
"col_head"] !=
"") {
1233 $p_content .=
' HeaderCols="1"';
1235 if ($t[
"col_foot"] !=
"") {
1236 $p_content .=
' FooterCols="1"';
1239 if (!$a_small_mode) {
1240 $p_content .=
'<Caption>' .
$lng->
txt(
"sty_caption") .
'</Caption>';
1242 for ($i = 1; $i <= $kr; $i++) {
1243 $p_content .=
'<TableRow>';
1244 for ($j = 1; $j <= $kc; $j++) {
1245 if ($a_small_mode) {
1246 $cell =
'<div style="height:2px;"></div>';
1250 $p_content .=
'<TableData><PageContent><Paragraph Characteristic="TableContent">' . $cell .
'</Paragraph></PageContent></TableData>';
1252 $p_content .=
'</TableRow>';
1254 $p_content .=
'</Table></PageContent>';
1257 if ($a_type ==
"vaccordion" || $a_type ==
"haccordion" || $a_type ==
"carousel") {
1260 if ($a_small_mode) {
1267 if ($a_type ==
"vaccordion") {
1268 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
1269 if ($a_small_mode) {
1270 $p_content .=
' ContentWidth="70"';
1272 } elseif ($a_type ==
"haccordion") {
1273 $p_content =
'<PageContent><Tabs Type="HorizontalAccordion"';
1274 $p_content .=
' ContentHeight="40"';
1275 if ($a_small_mode) {
1276 $p_content .=
' ContentWidth="70"';
1277 $c =
'&nbsp;&nbsp;&nbsp;&nbsp;';
1279 } elseif ($a_type ==
"carousel") {
1280 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="Carousel" ';
1281 if ($a_small_mode) {
1282 $p_content .=
' ContentWidth="70"';
1288 $p_content .=
'<Tab><PageContent><Paragraph>' .
$c .
'</Paragraph></PageContent>';
1289 $p_content .=
'<TabCaption>' . $h .
'</TabCaption>';
1290 $p_content .=
'</Tab>';
1291 $p_content .=
'</Tabs></PageContent>';
1296 $p_content .= $txml;
1300 if ($a_type ==
"carousel") {
1301 $r_content .=
"<style>.owl-carousel{ display:block !important; }</style>";
1318 if ($a_mode ==
"create") {
1319 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_template"));
1321 $this->form_gui->setTitle(
$lng->
txt(
"sty_edit_template"));
1326 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1327 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1328 $name_input->setRequired(
true);
1329 $name_input->setSize(30);
1330 $name_input->setMaxLength(30);
1331 $this->form_gui->addItem($name_input);
1335 $this->style_request->getTempType()
1338 foreach ($scs as $sc => $st) {
1340 $chars = $this->
object->getCharacteristics($st);
1341 $options = array(
"" =>
"");
1342 foreach ($chars as $char) {
1343 $options[$char] = $char;
1345 $sc_input->setOptions($options);
1346 $this->form_gui->addItem($sc_input);
1349 if ($a_mode ==
"create") {
1350 $this->form_gui->addCommandButton(
"saveTemplate",
$lng->
txt(
"save"));
1352 $this->form_gui->addCommandButton(
"refreshTemplate",
$lng->
txt(
"save_refresh"));
1353 $this->form_gui->addCommandButton(
"updateTemplate",
$lng->
txt(
"save_return"));
1355 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->
txt(
"cancel"));
1356 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1365 $ilCtrl->
redirect($this,
"listTemplates");
1374 $tpl = $this->gui_service->ui()->mainTemplate();
1379 $temp_type = $this->style_request->getTempType();
1381 if ($this->form_gui->checkInput()) {
1382 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1383 $name_input = $this->form_gui->getItemByPostVar(
"name");
1384 $name_input->setAlert(
$lng->
txt(
"sty_table_template_already_exists"));
1388 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1390 $t_id = $this->
object->addTemplate(
1392 $this->form_gui->getInput(
"name"),
1395 $this->
object->writeTemplatePreview(
1399 $ilCtrl->redirect($this,
"listTemplates");
1402 $this->form_gui->setValuesByPost();
1407 bool $a_refresh =
false 1412 $ilCtrl->setParameter($this,
"t_id", $this->style_request->getTemplateId());
1414 $temp_type = $this->style_request->getTempType();
1416 $t_id = $this->style_request->getTemplateId();
1417 if ($this->form_gui->checkInput()) {
1418 if ($this->
object->templateExists($this->form_gui->getInput(
"name")) &&
1420 $name_input = $this->form_gui->getItemByPostVar(
"name");
1421 $name_input->setAlert(
$lng->
txt(
"sty_template_already_exists"));
1425 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1428 $this->
object->updateTemplate(
1430 $this->form_gui->getInput(
"name"),
1433 $this->
object->writeTemplatePreview(
1438 $ilCtrl->redirect($this,
"listTemplates");
1443 $this->form_gui->setValuesByPost();
1449 $tpl = $this->gui_service->ui()->mainTemplate();
1452 "tpl.template_edit.html",
1455 "Services/Style/Content" 1458 $a_tpl->setVariable(
"FORM", $this->form_gui->getHTML());
1460 $this->style_request->getTempType(),
1461 $this->style_request->getTemplateId()
1479 $t_id = $this->style_request->getTemplateId();
1481 $t = $this->
object->getTemplate($t_id);
1483 $values[
"name"] = $t[
"name"];
1485 $this->style_request->getTempType()
1487 foreach ($scs as $k =>
$type) {
1488 $values[$k .
"_class"] = $t[
"classes"][$k] ??
"";
1490 $this->form_gui->setValuesByArray($values);
1500 $tpl = $this->gui_service->ui()->mainTemplate();
1503 $tids = $this->style_request->getTemplateIds();
1504 if (count($tids) == 0) {
1505 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
1506 $ilCtrl->redirect($this,
"listTemplates");
1509 $cgui->setFormAction($ilCtrl->getFormAction($this));
1510 $cgui->setHeaderText(
$lng->
txt(
"sty_confirm_template_deletion"));
1511 $cgui->setCancel(
$lng->
txt(
"cancel"),
"cancelTemplateDeletion");
1512 $cgui->setConfirm(
$lng->
txt(
"sty_del_template"),
"deleteTemplate");
1514 foreach ($tids as $tid) {
1515 $classes = $this->
object->getTemplateClasses($tid);
1518 foreach ($classes as $cl) {
1519 if ($cl !=
"" && !($listed[$cl] ??
false)) {
1520 $cl_str .=
'<div>- ' .
1522 $listed[$cl] =
true;
1525 if ($cl_str !=
"") {
1526 $cl_str =
'<div style="padding-left:30px;" class="small">' .
1527 "<div><i>" .
$lng->
txt(
"sty_style_class") .
"</i></div>" . $cl_str .
"</div>";
1529 $cgui->addItem(
"tid[]", (
string) $tid, $this->
object->lookupTemplateName($tid) . $cl_str);
1532 $cgui->addButton(
$lng->
txt(
"sty_del_template_keep_classes"),
"deleteTemplateKeepClasses");
1545 $ilCtrl->
redirect($this,
"listTemplates");
1552 $tids = $this->style_request->getTemplateIds();
1553 foreach ($tids as $tid) {
1554 $this->
object->removeTemplate($tid);
1557 $ilCtrl->
redirect($this,
"listTemplates");
1570 $tids = $this->style_request->getTemplateIds();
1571 foreach ($tids as $tid) {
1572 $cls = $this->
object->getTemplateClasses($tid);
1573 foreach ($cls as $k => $cls2) {
1574 $ty = $this->
object->determineTemplateStyleClassType(
1575 $this->style_request->getTempType(),
1578 $this->characteristic_manager->deleteCharacteristic($ty, $cls2);
1580 $this->
object->removeTemplate($tid);
1583 $ilCtrl->
redirect($this,
"listTemplates");
1588 $tpl = $this->gui_service->ui()->mainTemplate();
1604 $this->form_gui->setTitle(
$lng->
txt(
"sty_generate_template"));
1608 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1609 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1610 $name_input->setRequired(
true);
1611 $name_input->setSize(30);
1612 $name_input->setMaxLength(30);
1613 $this->form_gui->addItem($name_input);
1618 "coloredZebra" =>
$lng->
txt(
"sty_table_template_colored_zebra"),
1619 "bwZebra" =>
$lng->
txt(
"sty_table_template_bw_zebra"),
1620 "noZebra" =>
$lng->
txt(
"sty_table_template_no_zebra")
1623 $this->form_gui->addItem($bl_input);
1628 $num_input->setValue(
"3px");
1629 $this->form_gui->addItem($num_input);
1634 $num_input->setValue(
"10px");
1635 $this->form_gui->addItem($num_input);
1639 $cs = $this->
object->getColors();
1641 foreach ($cs as
$c) {
1642 $options[$c[
"name"]] = $c[
"name"];
1645 $this->form_gui->addItem($bc_input);
1648 $lss = array(
"border" => 90,
"header_text" => 70,
"header_bg" => 0,
1649 "cell1_text" => -60,
"cell1_bg" => 90,
"cell2_text" => -60,
"cell2_bg" => 75);
1650 foreach ($lss as $ls => $v) {
1652 $l_input->setMaxValue(100);
1653 $l_input->setMinValue(-100);
1654 $l_input->setValue((
string) $v);
1655 $l_input->setSize(4);
1656 $l_input->setMaxLength(4);
1657 $this->form_gui->addItem($l_input);
1660 $this->form_gui->addCommandButton(
"templateGeneration",
$lng->
txt(
"generate"));
1661 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->
txt(
"cancel"));
1662 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1670 $tpl = $this->gui_service->ui()->mainTemplate();
1676 if ($this->form_gui->checkInput()) {
1677 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1678 $name_input = $this->form_gui->getItemByPostVar(
"name");
1679 $name_input->setAlert(
$lng->
txt(
"sty_table_template_already_exists"));
1684 $cells = array(
"H" =>
"header",
"C1" =>
"cell1",
"C2" =>
"cell2");
1685 $tb_p = $this->form_gui->getItemByPostVar(
"tb_padding");
1686 $tb_padding = $tb_p->getValue();
1687 $lr_p = $this->form_gui->getItemByPostVar(
"lr_padding");
1688 $lr_padding = $lr_p->getValue();
1689 $cell_color = $this->form_gui->getInput(
"base_color");
1692 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1693 $cell_color =
"MidGray";
1694 if (!$this->color_manager->colorExists($cell_color)) {
1695 $this->color_manager->addColor($cell_color,
"7F7F7F");
1697 $this->color_manager->updateColor($cell_color, $cell_color,
"7F7F7F");
1700 foreach ($cells as $k => $cell) {
1701 $cell_class[$k] = $this->form_gui->getInput(
"name") . $k;
1702 if (!$this->
object->characteristicExists($cell_class[$k],
"table_cell")) {
1703 $this->characteristic_manager->addCharacteristic(
"table_cell", $cell_class[$k],
true);
1705 if ($this->form_gui->getInput(
"layout") ==
"bwZebra" && $k ==
"H") {
1706 $this->characteristic_manager->replaceParameter(
1710 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1713 $this->characteristic_manager->replaceParameter(
1717 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1721 $this->characteristic_manager->replaceParameter(
1725 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1728 $this->characteristic_manager->replaceParameter(
1732 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1736 $this->characteristic_manager->replaceParameter(
1743 $this->characteristic_manager->replaceParameter(
1750 $this->characteristic_manager->replaceParameter(
1757 $this->characteristic_manager->replaceParameter(
1764 $this->characteristic_manager->replaceParameter(
1771 $this->characteristic_manager->replaceParameter(
1778 $this->characteristic_manager->replaceParameter(
1782 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_border") .
")",
1785 $this->characteristic_manager->replaceParameter(
1795 $classes[
"table"] = $this->form_gui->getInput(
"name") .
"T";
1796 if (!$this->
object->characteristicExists($classes[
"table"],
"table")) {
1797 $this->characteristic_manager->addCharacteristic(
"table", $classes[
"table"],
true);
1799 $this->characteristic_manager->replaceParameter(
1806 $this->characteristic_manager->replaceParameter(
1813 $this->characteristic_manager->replaceParameter(
1820 $this->characteristic_manager->replaceParameter(
1827 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1828 $this->characteristic_manager->replaceParameter(
1831 "border-bottom-color",
1832 "!" . $this->form_gui->getInput(
"base_color"),
1835 $this->characteristic_manager->replaceParameter(
1838 "border-bottom-style",
1842 $this->characteristic_manager->replaceParameter(
1845 "border-bottom-width",
1849 $sb = array(
"left",
"right",
"top");
1850 foreach ($sb as
$b) {
1851 $this->characteristic_manager->replaceParameter(
1854 "border-" . $b .
"-width",
1861 switch ($this->form_gui->getInput(
"layout")) {
1863 case "coloredZebra":
1864 $classes[
"row_head"] = $cell_class[
"H"];
1865 $classes[
"odd_row"] = $cell_class[
"C1"];
1866 $classes[
"even_row"] = $cell_class[
"C2"];
1870 $classes[
"row_head"] = $cell_class[
"H"];
1871 $classes[
"odd_row"] = $cell_class[
"C1"];
1872 $classes[
"even_row"] = $cell_class[
"C1"];
1873 $classes[
"col_head"] = $cell_class[
"C2"];
1878 $t_id = $this->
object->addTemplate(
1879 $this->style_request->getTempType(),
1880 $this->form_gui->getInput(
"name"),
1883 $this->
object->writeTemplatePreview(
1886 $this->style_request->getTempType(),
1891 $ilCtrl->redirect($this,
"listTemplates");
1894 $this->form_gui->setValuesByPost();
deleteTemplateKeepClassesObject()
Content StandardGUIRequest $style_request
cancelColorDeletionObject()
Cancel color deletion.
deleteMediaQueriesObject()
Content InternalService $service
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)
Content ImageManager $image_manager
static _renderTable(string $content, string $a_mode="table_edit", string $a_submode="", ilPCTable $a_table_obj=null, bool $unmask=true, ilPageObject $page_object=null)
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...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
deleteMediaQueryConfirmationObject()
listColorsObject()
List colors of style.
refreshTemplateObject()
Refresh table template.
Content style internal ui factory.
ilPropertyFormGUI $form_gui
getCmd(string $fallback_command=null)
prepareOutput(bool $show_sub_objects=true)
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded) ...
initTemplateForm(string $a_mode="create")
Init table template form.
getCreationFormsHTML(array $forms)
Get HTML for creation forms (accordion)
getPropertiesValues()
Get current values for properties from.
confirmedDeleteObject()
delete selected style objects
cancelTemplateDeletionObject()
Cancel table template deletion.
updateColorObject()
Update color.
lookupTemplateName(int $a_t_id)
Lookup table template name for template ID.
Content ColorManager $color_manager
deleteTemplateConfirmationObject()
Delete table template confirmation.
static _getClonableContentStyles()
Get all clonable styles (active standard styles and individual learning module styles with write perm...
deleteColorConfirmationObject()
Delete color confirmation.
static _getTemplatePreview(ilObjStyleSheet $a_style, string $a_type, int $a_t_id, bool $a_small_mode=false)
Get table template preview.
returnToParent(object $a_gui_obj, string $a_anchor=null)
static _writeStandard(int $a_id, bool $a_std)
Write standard flag.
static getStyleExampleHTML(string $a_type, string $a_class)
Get style example HTML.
enableWrite(bool $a_write)
Enable writing.
forwardCommand(object $a_gui_object)
ilObjectDefinition $obj_definition
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getStyleSuperTypeForType(string $a_type)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
cancelColorSavingObject()
Cancel color saving.
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
Export User Interface Class.
Content InternalGUIService $gui_service
parses the objects.xml it handles the xml-description of all ilias objects
getNextClass($a_gui_class=null)
__construct( $a_data, int $a_id, bool $a_call_by_reference)
Main business logic for content style images.
static addCss()
Add required css.
getTemplatePreview(string $a_type, int $a_t_id, bool $a_small_mode=false)
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
importStyleObject()
Import style sheet.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMediaQueryFormValues()
Set values for media query editing.
saveMediaQueryOrderObject()
setScreenIdComponent(string $a_comp)
getTemplateXML()
Get table template xml.
Class ilObjectGUI Basic methods of all Output classes.
initMediaQueryForm(string $a_mode="create")
Init media query form.
deleteTemplateObject()
Delete template.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Access StyleAccessManager $access_manager
returnToUpperContextObject()
header include for all ilias files.
Main business logic for characteristics.
saveTemplateObject()
Save table template.
editObject()
Edit -> List characteristics.
templateGenerationObject()
Table template generation.
getColorFormValues()
Set values for color editing.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
saveColorObject()
Save color.
updateTemplateObject(bool $a_refresh=false)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
form( $class_path, string $cmd, string $submit_caption="")
static _lookupTemplateName(int $a_t_id)
Lookup table template name for template ID.
static _addMissingStyleClassesToStyle(int $a_id)
Add missing style classes to all styles.
saveMediaQueryObject()
Save media query.
initColorForm(string $a_mode="create")
Manages access to content style editing.
This class represents a text area property in a property form.
deleteObject($a_error=false)
display deletion confirmation screen
listTemplatesObject()
List templates.
cancelTemplateSavingObject()
Cancel color saving.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
initPropertiesForm(string $a_mode="edit")
FORM: Init properties form.
static _lookupType(int $id, bool $reference=false)
static _getTemplateClassTypes(string $a_template_type="")
Get template class types.
initTemplateGenerationForm()
Init table template generation form.
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
displayTemplateEditForm()
TableGUI class for style editor (image list)
getTemplateFormValues()
Set values for table template editing.
Content CharacteristicManager $characteristic_manager
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.