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) {
129 $exp_gui->addFormat(
"xml");
133 case "ilstylecharacteristicgui":
136 $tabs->activateTab(
"sty_style_chars");
137 $gui = $this->gui_service->characteristic()->ilStyleCharacteristicGUI(
138 $this->getStyleSheet(),
140 $this->access_manager,
141 $this->characteristic_manager,
147 case "ilcontentstyleimagegui":
150 $tabs->activateTab(
"sty_images");
151 $gui = $this->gui_service->image()->ilContentStyleImageGUI(
152 $this->access_manager,
180 $tpl = $this->gui_service->ui()->mainTemplate();
187 $ilHelp->setScreenIdComponent(
"sty");
202 $form->
setTitle($this->
lng->txt(
"sty_create_new_stylesheet"));
206 $ti->setMaxLength(128);
208 $ti->setRequired(
true);
227 $form->
setTitle($this->
lng->txt(
"sty_import_stylesheet"));
244 $form->
setTitle($this->
lng->txt(
"sty_copy_other_stylesheet"));
248 $ti->setRequired(
true);
259 $tpl = $this->gui_service->ui()->mainTemplate();
269 $ctrl = $this->gui_service->ctrl();
275 $tpl = $this->gui_service->ui()->mainTemplate();
290 $values[
"style_title"] = $this->
object->getTitle();
291 $values[
"style_description"] = $this->
object->getDescription();
292 $values[
"disable_auto_margins"] = (
int) $this->
object->lookupStyleSetting(
"disable_auto_margins");
294 $this->
form->setValuesByArray($values);
301 string $a_mode =
"edit" 303 $ctrl = $this->gui_service->ctrl();
310 $ti->setMaxLength(128);
312 $ti->setRequired(
true);
313 $this->
form->addItem($ti);
319 $this->
form->addItem($ta);
323 $cb->
setInfo($this->
lng->txt(
"sty_disable_auto_margins_info"));
324 $this->
form->addItem($cb);
328 if ($a_mode ==
"create") {
329 $this->
form->addCommandButton(
"save",
$lng->
txt(
"save"));
330 $this->
form->addCommandButton(
"cancelSave",
$lng->
txt(
"cancel"));
332 if ($this->access_manager->checkWrite()) {
333 $this->
form->addCommandButton(
"update",
$lng->
txt(
"save"));
337 $this->
form->setTitle(
$lng->
txt(
"edit_stylesheet"));
344 $ctrl = $this->gui_service->ctrl();
345 $tpl = $this->gui_service->ui()->mainTemplate();
348 if ($this->
form->checkInput()) {
349 $this->
object->setTitle($this->
form->getInput(
"style_title"));
350 $this->
object->setDescription($this->
form->getInput(
"style_description"));
351 $this->
object->writeStyleSetting(
352 "disable_auto_margins",
353 $this->
form->getInput(
"disable_auto_margins")
355 $this->
object->update();
356 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"msg_obj_modified"),
true);
359 $this->
form->setValuesByPost();
368 $r = $exp->exportObject($this->
object->getType(), $this->
object->getId());
378 $tpl = $this->gui_service->ui()->mainTemplate();
379 $ctrl = $this->gui_service->ctrl();
384 $cgui->setHeaderText($this->
lng->txt(
"info_delete_sure"));
385 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDelete");
386 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedDelete");
390 $cgui->addItem(
"id[]",
"", $caption);
397 $this->gui_service->ctrl()->returnToParent($this);
405 $this->
object->delete();
406 $this->gui_service->ctrl()->returnToParent($this);
411 $ctrl = $this->gui_service->ctrl();
416 if (!trim($form->
getInput(
"style_title"))) {
421 $default_style = $this->
settings->get(
"default_content_style_id");
424 $new_id = $style_obj->ilClone();
429 $style_id = $imp->importObject(
441 $newObj->setTitle($form->
getInput(
"style_title"));
442 $newObj->setDescription($form->
getInput(
"style_description"));
444 $this->
object = $newObj;
450 if ($this->requested_ref_id > 0) {
452 if ($fold->getType() ==
"stys") {
454 $cont_style_settings->addStyle($newObj->getId());
455 $cont_style_settings->update();
465 $ctrl = $this->gui_service->ctrl();
471 if ($form->
getInput(
"source_style") > 0) {
473 $new_id = $style_obj->ilClone();
478 if ($this->requested_ref_id > 0) {
480 if ($fold->getType() ==
"stys") {
482 $cont_style_settings->addStyle($new_id);
483 $cont_style_settings->update();
500 $source = $_FILES[
"importfile"][
"tmp_name"];
502 $this->
ilias->raiseError(
"No file selected!", $this->
ilias->error_obj->MESSAGE);
506 $info = pathinfo($_FILES[
"importfile"][
"name"]);
507 if (strtolower($info[
"extension"]) !=
"zip" && strtolower($info[
"extension"]) !=
"xml") {
508 $this->
ilias->raiseError(
"File must be a zip or xml file!", $this->
ilias->error_obj->MESSAGE);
512 $fname = explode(
"_", $_FILES[
"importfile"][
"name"]);
513 if (strtolower($info[
"extension"]) ==
"zip" && $fname[4] ==
"sty") {
515 $new_id = $imp->importObject(
517 $_FILES[
"importfile"][
"tmp_name"],
518 $_FILES[
"importfile"][
"name"],
526 $newObj->import($_FILES[
"importfile"]);
531 if ($this->requested_ref_id > 0) {
533 if ($fold->getType() ==
"stys") {
535 $cont_style_settings->addStyle($newObj->getId());
536 $cont_style_settings->update();
538 $this->
ctrl->returnToParent($this);
541 $this->
object = $newObj;
542 return $newObj->getId();
550 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"msg_cancel"),
true);
551 $this->
ctrl->returnToParent($this);
563 $tabs = $this->gui_service->tabs();
566 $tabs->setBackTarget(
568 $this->
ctrl->getLinkTarget($this,
"returnToUpperContext")
574 $this->
ctrl->getLinkTarget($this,
"edit"),
582 $this->
ctrl->getLinkTarget($this,
"listColors"),
590 $this->
ctrl->getLinkTargetByClass(
"ilContentStyleImageGUI",
""),
592 "ilContentStyleImageGUI" 598 $this->
ctrl->getLinkTarget($this,
"listMediaQueries"),
607 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
615 $this->
ctrl->getLinkTarget($this,
"properties"),
623 $this->
ctrl->getLinkTargetByClass(
"ilexportgui",
""),
631 $ilTabs = $this->gui_service->tabs();
636 foreach ($types as $t =>
$c) {
637 $ilCtrl->setParameter($this,
"temp_type", $t);
638 $ilTabs->addSubTabTarget(
639 "sty_" . $t .
"_templates",
640 $this->
ctrl->getLinkTarget($this,
"listTemplates"),
641 array(
"listTemplates",
""),
646 $ilCtrl->setParameter($this,
"temp_type", $this->style_request->getTempType());
655 $ilLocator = $this->gui_service->locator();
657 if ($this->style_request->getAdminMode() ==
"settings") {
658 parent::addAdminLocatorItems(
true);
661 $this->
lng->txt(
"obj_stys"),
662 $this->
ctrl->getLinkTargetByClass(
"ilobjstylesettingsgui",
"")
666 $this->
lng->txt(
"content_styles"),
667 $this->
ctrl->getLinkTargetByClass(
"ilcontentstylesettingsgui",
"")
670 if ($this->style_request->getObjId() > 0) {
672 $this->
object->getTitle(),
673 $this->
ctrl->getLinkTarget($this,
"edit")
688 $lng = $DIC->language();
690 $c = explode(
":", $a_class);
693 $ex_tpl =
new ilTemplate(
"tpl.style_example.html",
true,
true,
"Services/Style/Content");
695 if ($ex_tpl->blockExists(
"Example_" . $a_type)) {
696 $ex_tpl->setCurrentBlock(
"Example_" . $a_type);
698 $ex_tpl->setCurrentBlock(
"Example_default");
700 $ex_tpl->setVariable(
"EX_CLASS",
"ilc_" . $a_type .
"_" . $a_class);
701 $ex_tpl->setVariable(
"EX_TEXT",
"ABC abc 123");
702 if (in_array($a_type, array(
"media_cont",
"qimg"))) {
705 if (in_array($a_type, array(
"table",
"table_caption"))) {
706 $ex_tpl->setVariable(
"TXT_CAPTION",
$lng->
txt(
"sty_caption"));
708 if (in_array($a_class, array(
"OrderListItemHorizontal",
"OrderListHorizontal"))) {
709 $ex_tpl->setVariable(
"HOR",
"Horizontal");
711 $ex_tpl->parseCurrentBlock();
713 return $ex_tpl->get();
726 $tpl = $this->gui_service->ui()->mainTemplate();
727 $ilToolbar = $this->gui_service->toolbar();
730 if ($this->access_manager->checkWrite()) {
731 $ilToolbar->addButton(
732 $this->
lng->txt(
"sty_add_color"),
733 $ilCtrl->getLinkTarget($this,
"addColor")
740 $this->getStyleSheet(),
741 $this->access_manager
748 $tpl = $this->gui_service->ui()->mainTemplate();
756 $tpl = $this->gui_service->ui()->mainTemplate();
759 $ilCtrl->
setParameter($this,
"c_name", $this->style_request->getColorName());
767 string $a_mode =
"create" 774 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_color"));
778 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
779 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
780 $name_input->setRequired(
true);
781 $name_input->setSize(15);
782 $name_input->setMaxLength(15);
783 $this->form_gui->addItem($name_input);
788 $color_input->setDefaultColor(
"");
789 $this->form_gui->addItem($color_input);
791 if ($a_mode ==
"create") {
792 $this->form_gui->addCommandButton(
"saveColor",
$lng->
txt(
"save"));
794 $this->form_gui->addCommandButton(
"updateColor",
$lng->
txt(
"save"));
796 $this->form_gui->addCommandButton(
"cancelColorSaving",
$lng->
txt(
"cancel"));
797 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
805 $c_name = $this->style_request->getColorName();
807 $values[
"color_name"] = $c_name;
808 $values[
"color_code"] = $this->
object->getColorCodeForName($c_name);
809 $this->form_gui->setValuesByArray($values);
820 $ilCtrl->
redirect($this,
"listColors");
828 $tpl = $this->gui_service->ui()->mainTemplate();
833 if ($this->form_gui->checkInput()) {
834 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name"))) {
835 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
836 $col_input->setAlert(
$lng->
txt(
"sty_color_already_exists"));
838 $this->color_manager->addColor(
839 $this->form_gui->getInput(
"color_name"),
840 $this->form_gui->getInput(
"color_code")
842 $ilCtrl->redirect($this,
"listColors");
845 $this->form_gui->setValuesByPost();
854 $tpl = $this->gui_service->ui()->mainTemplate();
858 $c_name = $this->style_request->getColorName();
859 $ilCtrl->setParameter($this,
"c_name", $c_name);
862 if ($this->form_gui->checkInput()) {
863 if ($this->color_manager->colorExists($this->form_gui->getInput(
"color_name")) &&
864 $this->form_gui->getInput(
"color_name") != $c_name) {
865 $col_input = $this->form_gui->getItemByPostVar(
"color_name");
866 $col_input->setAlert(
$lng->
txt(
"sty_color_already_exists"));
868 $this->color_manager->updateColor(
870 $this->form_gui->getInput(
"color_name"),
871 $this->form_gui->getInput(
"color_code")
873 $ilCtrl->redirect($this,
"listColors");
876 $this->form_gui->setValuesByPost();
886 $tpl = $this->gui_service->ui()->mainTemplate();
889 $colors = $this->style_request->getColors();
890 if (count($colors) == 0) {
891 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
892 $ilCtrl->redirect($this,
"listColors");
895 $cgui->setFormAction($ilCtrl->getFormAction($this));
896 $cgui->setHeaderText(
$lng->
txt(
"sty_confirm_color_deletion"));
897 $cgui->setCancel(
$lng->
txt(
"cancel"),
"cancelColorDeletion");
898 $cgui->setConfirm(
$lng->
txt(
"delete"),
"deleteColor");
900 foreach ($colors as
$c) {
914 $ilCtrl->
redirect($this,
"listColors");
921 $colors = $this->style_request->getColors();
922 foreach ($colors as
$c) {
923 $this->
object->removeColor($c);
926 $ilCtrl->
redirect($this,
"listColors");
935 $tpl = $this->gui_service->ui()->mainTemplate();
936 $ilToolbar = $this->gui_service->toolbar();
939 if ($this->access_manager->checkWrite()) {
940 $ilToolbar->addButton(
941 $this->
lng->txt(
"sty_add_media_query"),
942 $ilCtrl->getLinkTarget($this,
"addMediaQuery")
949 $this->getStyleSheet(),
950 $this->access_manager
957 $tpl = $this->gui_service->ui()->mainTemplate();
965 $tpl = $this->gui_service->ui()->mainTemplate();
968 $ilCtrl->
setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
979 string $a_mode =
"create" 986 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_media_query"));
990 $ti->setMaxLength(2000);
991 $ti->setInfo(
$lng->
txt(
"sty_add_media_query_info"));
992 $this->form_gui->addItem($ti);
995 if ($a_mode ==
"create") {
996 $this->form_gui->addCommandButton(
"saveMediaQuery",
$lng->
txt(
"save"));
998 $this->form_gui->addCommandButton(
"updateMediaQuery",
$lng->
txt(
"save"));
1000 $this->form_gui->addCommandButton(
"listMediaQueries",
$lng->
txt(
"cancel"));
1001 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1010 if ($this->style_request->getMediaQueryId() > 0) {
1011 foreach ($this->
object->getMediaQueries() as $mq) {
1012 if ($mq[
"id"] == $this->style_request->getMediaQueryId()) {
1013 $values[
"mquery"] = $mq[
"mquery"];
1016 $this->form_gui->setValuesByArray($values);
1025 $tpl = $this->gui_service->ui()->mainTemplate();
1031 if ($this->form_gui->checkInput()) {
1032 $this->
object->addMediaQuery($this->form_gui->getInput(
"mquery"));
1033 $ilCtrl->redirect($this,
"listMediaQueries");
1035 $this->form_gui->setValuesByPost();
1041 $tpl = $this->gui_service->ui()->mainTemplate();
1046 if ($this->form_gui->checkInput()) {
1047 $this->
object->updateMediaQuery(
1048 $this->style_request->getMediaQueryId(),
1049 $this->form_gui->getInput(
"mquery")
1051 $ilCtrl->redirect($this,
"listMediaQueries");
1053 $ilCtrl->setParameter($this,
"mq_id", $this->style_request->getMediaQueryId());
1054 $this->form_gui->setValuesByPost();
1061 $tpl = $this->gui_service->ui()->mainTemplate();
1064 $mq_ids = $this->style_request->getMediaQueryIds();
1065 if (count($mq_ids) == 0) {
1066 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
1067 $ilCtrl->redirect($this,
"listMediaQueries");
1070 $cgui->setFormAction($ilCtrl->getFormAction($this));
1071 $cgui->setHeaderText(
$lng->
txt(
"sty_sure_del_mqueries"));
1072 $cgui->setCancel(
$lng->
txt(
"cancel"),
"listMediaQueries");
1073 $cgui->setConfirm(
$lng->
txt(
"delete"),
"deleteMediaQueries");
1075 foreach ($mq_ids as
$i) {
1076 $mq = $this->
object->getMediaQueryForId($i);
1077 $cgui->addItem(
"mq_id[]", (
string) $i, $mq[
"mquery"]);
1088 $mq_ids = $this->style_request->getMediaQueryIds();
1089 if ($this->access_manager->checkWrite()) {
1090 foreach ($mq_ids as
$id) {
1091 $this->
object->deleteMediaQuery($id);
1094 $ilCtrl->
redirect($this,
"listMediaQueries");
1101 $order = $this->style_request->getOrder();
1102 if (count($order) > 0) {
1103 $this->getStyleSheet()->saveMediaQueryOrder($order);
1105 $ilCtrl->
redirect($this,
"listMediaQueries");
1118 $tpl = $this->gui_service->ui()->mainTemplate();
1119 $ilTabs = $this->gui_service->tabs();
1121 $ilToolbar = $this->gui_service->toolbar();
1123 $ctype = $this->style_request->getTempType();
1129 $ilCtrl->setParameter($this,
"temp_type", $ctype);
1130 $ilTabs->setSubTabActive(
"sty_" . $ctype .
"_templates");
1133 if ($this->access_manager->checkWrite()) {
1134 if ($ctype ==
"table") {
1135 $ilToolbar->addButton(
1136 $this->
lng->txt(
"sty_generate_template"),
1137 $ilCtrl->getLinkTarget($this,
"generateTemplate")
1140 $ilToolbar->addButton(
1141 $this->
lng->txt(
"sty_add_template"),
1142 $ilCtrl->getLinkTarget($this,
"addTemplate")
1153 $this->getStyleSheet(),
1154 $this->access_manager
1161 $tpl = $this->gui_service->ui()->mainTemplate();
1174 $this->style_request->getTemplateId()
1185 bool $a_small_mode =
false 1188 $this->getStyleSheet(),
1202 bool $a_small_mode =
false 1206 $lng = $DIC->language();
1210 if ($a_small_mode) {
1216 $t = $ts[
"classes"];
1219 if ($a_type ==
"table") {
1220 $p_content =
'<PageContent><Table DataTable="y"';
1221 $t[
"row_head"] = $t[
"row_head"] ??
"";
1222 $t[
"row_foot"] = $t[
"row_foot"] ??
"";
1223 $t[
"col_head"] = $t[
"col_head"] ??
"";
1224 $t[
"col_foot"] = $t[
"col_foot"] ??
"";
1225 if ($t[
"row_head"] !=
"") {
1226 $p_content .=
' HeaderRows="1"';
1228 if ($t[
"row_foot"] !=
"") {
1229 $p_content .=
' FooterRows="1"';
1231 if ($t[
"col_head"] !=
"") {
1232 $p_content .=
' HeaderCols="1"';
1234 if ($t[
"col_foot"] !=
"") {
1235 $p_content .=
' FooterCols="1"';
1238 if (!$a_small_mode) {
1239 $p_content .=
'<Caption>' .
$lng->
txt(
"sty_caption") .
'</Caption>';
1241 for (
$i = 1;
$i <= $kr;
$i++) {
1242 $p_content .=
'<TableRow>';
1243 for ($j = 1; $j <= $kc; $j++) {
1244 if ($a_small_mode) {
1245 $cell =
'<div style="height:2px;"></div>';
1249 $p_content .=
'<TableData><PageContent><Paragraph Characteristic="TableContent">' . $cell .
'</Paragraph></PageContent></TableData>';
1251 $p_content .=
'</TableRow>';
1253 $p_content .=
'</Table></PageContent>';
1256 if ($a_type ==
"vaccordion" || $a_type ==
"haccordion" || $a_type ==
"carousel") {
1259 if ($a_small_mode) {
1266 if ($a_type ==
"vaccordion") {
1267 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="VerticalAccordion" ';
1268 if ($a_small_mode) {
1269 $p_content .=
' ContentWidth="70"';
1271 } elseif ($a_type ==
"haccordion") {
1272 $p_content =
'<PageContent><Tabs Type="HorizontalAccordion"';
1273 $p_content .=
' ContentHeight="40"';
1274 if ($a_small_mode) {
1275 $p_content .=
' ContentWidth="70"';
1276 $c =
'&nbsp;&nbsp;&nbsp;&nbsp;';
1278 } elseif ($a_type ==
"carousel") {
1279 $p_content =
'<PageContent><Tabs HorizontalAlign="Left" Type="Carousel" ';
1280 if ($a_small_mode) {
1281 $p_content .=
' ContentWidth="70"';
1287 $p_content .=
'<Tab><PageContent><Paragraph>' .
$c .
'</Paragraph></PageContent>';
1288 $p_content .=
'<TabCaption>' . $h .
'</TabCaption>';
1289 $p_content .=
'</Tab>';
1290 $p_content .=
'</Tabs></PageContent>';
1295 $p_content .= $txml;
1299 if ($a_type ==
"carousel") {
1300 $r_content .=
"<style>.owl-carousel{ display:block !important; }</style>";
1317 if ($a_mode ==
"create") {
1318 $this->form_gui->setTitle(
$lng->
txt(
"sty_add_template"));
1320 $this->form_gui->setTitle(
$lng->
txt(
"sty_edit_template"));
1325 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1326 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1327 $name_input->setRequired(
true);
1328 $name_input->setSize(30);
1329 $name_input->setMaxLength(30);
1330 $this->form_gui->addItem($name_input);
1334 $this->style_request->getTempType()
1337 foreach ($scs as $sc => $st) {
1339 $chars = $this->
object->getCharacteristics($st);
1340 $options = array(
"" =>
"");
1341 foreach ($chars as $char) {
1342 $options[$char] = $char;
1344 $sc_input->setOptions($options);
1345 $this->form_gui->addItem($sc_input);
1348 if ($a_mode ==
"create") {
1349 $this->form_gui->addCommandButton(
"saveTemplate",
$lng->
txt(
"save"));
1351 $this->form_gui->addCommandButton(
"refreshTemplate",
$lng->
txt(
"save_refresh"));
1352 $this->form_gui->addCommandButton(
"updateTemplate",
$lng->
txt(
"save_return"));
1354 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->
txt(
"cancel"));
1355 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1364 $ilCtrl->
redirect($this,
"listTemplates");
1373 $tpl = $this->gui_service->ui()->mainTemplate();
1378 $temp_type = $this->style_request->getTempType();
1380 if ($this->form_gui->checkInput()) {
1381 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1382 $name_input = $this->form_gui->getItemByPostVar(
"name");
1383 $name_input->setAlert(
$lng->
txt(
"sty_table_template_already_exists"));
1387 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1389 $t_id = $this->
object->addTemplate(
1391 $this->form_gui->getInput(
"name"),
1394 $this->
object->writeTemplatePreview(
1398 $ilCtrl->redirect($this,
"listTemplates");
1401 $this->form_gui->setValuesByPost();
1406 bool $a_refresh =
false 1411 $ilCtrl->setParameter($this,
"t_id", $this->style_request->getTemplateId());
1413 $temp_type = $this->style_request->getTempType();
1415 $t_id = $this->style_request->getTemplateId();
1416 if ($this->form_gui->checkInput()) {
1417 if ($this->
object->templateExists($this->form_gui->getInput(
"name")) &&
1419 $name_input = $this->form_gui->getItemByPostVar(
"name");
1420 $name_input->setAlert(
$lng->
txt(
"sty_template_already_exists"));
1424 $classes[$tct] = $this->form_gui->getInput($tct .
"_class");
1427 $this->
object->updateTemplate(
1429 $this->form_gui->getInput(
"name"),
1432 $this->
object->writeTemplatePreview(
1437 $ilCtrl->redirect($this,
"listTemplates");
1442 $this->form_gui->setValuesByPost();
1448 $tpl = $this->gui_service->ui()->mainTemplate();
1451 "tpl.template_edit.html",
1454 "Services/Style/Content" 1457 $a_tpl->setVariable(
"FORM", $this->form_gui->getHTML());
1459 $this->style_request->getTempType(),
1460 $this->style_request->getTemplateId()
1478 $t_id = $this->style_request->getTemplateId();
1480 $t = $this->
object->getTemplate($t_id);
1482 $values[
"name"] = $t[
"name"];
1484 $this->style_request->getTempType()
1486 foreach ($scs as $k =>
$type) {
1487 $values[$k .
"_class"] = $t[
"classes"][$k] ??
"";
1489 $this->form_gui->setValuesByArray($values);
1499 $tpl = $this->gui_service->ui()->mainTemplate();
1502 $tids = $this->style_request->getTemplateIds();
1503 if (count($tids) == 0) {
1504 $this->tpl->setOnScreenMessage(
'info',
$lng->
txt(
"no_checkbox"),
true);
1505 $ilCtrl->redirect($this,
"listTemplates");
1508 $cgui->setFormAction($ilCtrl->getFormAction($this));
1509 $cgui->setHeaderText(
$lng->
txt(
"sty_confirm_template_deletion"));
1510 $cgui->setCancel(
$lng->
txt(
"cancel"),
"cancelTemplateDeletion");
1511 $cgui->setConfirm(
$lng->
txt(
"sty_del_template"),
"deleteTemplate");
1513 foreach ($tids as $tid) {
1514 $classes = $this->
object->getTemplateClasses($tid);
1517 foreach ($classes as $cl) {
1518 if ($cl !=
"" && !($listed[$cl] ??
false)) {
1519 $cl_str .=
'<div>- ' .
1521 $listed[$cl] =
true;
1524 if ($cl_str !=
"") {
1525 $cl_str =
'<div style="padding-left:30px;" class="small">' .
1526 "<div><i>" .
$lng->
txt(
"sty_style_class") .
"</i></div>" . $cl_str .
"</div>";
1528 $cgui->addItem(
"tid[]", (
string) $tid, $this->
object->lookupTemplateName($tid) . $cl_str);
1531 $cgui->addButton(
$lng->
txt(
"sty_del_template_keep_classes"),
"deleteTemplateKeepClasses");
1544 $ilCtrl->
redirect($this,
"listTemplates");
1551 $tids = $this->style_request->getTemplateIds();
1552 foreach ($tids as $tid) {
1553 $this->
object->removeTemplate($tid);
1556 $ilCtrl->
redirect($this,
"listTemplates");
1569 $tids = $this->style_request->getTemplateIds();
1570 foreach ($tids as $tid) {
1571 $cls = $this->
object->getTemplateClasses($tid);
1572 foreach ($cls as $k => $cls2) {
1573 $ty = $this->
object->determineTemplateStyleClassType(
1574 $this->style_request->getTempType(),
1577 $this->characteristic_manager->deleteCharacteristic($ty, $cls2);
1579 $this->
object->removeTemplate($tid);
1582 $ilCtrl->
redirect($this,
"listTemplates");
1587 $tpl = $this->gui_service->ui()->mainTemplate();
1603 $this->form_gui->setTitle(
$lng->
txt(
"sty_generate_template"));
1607 $name_input->
setPattern(
"/^[a-zA-Z]+[a-zA-Z0-9]*$/");
1608 $name_input->setNoMatchMessage(
$lng->
txt(
"sty_msg_color_must_only_include") .
" A-Z, a-z, 1-9");
1609 $name_input->setRequired(
true);
1610 $name_input->setSize(30);
1611 $name_input->setMaxLength(30);
1612 $this->form_gui->addItem($name_input);
1617 "coloredZebra" =>
$lng->
txt(
"sty_table_template_colored_zebra"),
1618 "bwZebra" =>
$lng->
txt(
"sty_table_template_bw_zebra"),
1619 "noZebra" =>
$lng->
txt(
"sty_table_template_no_zebra")
1621 $bl_input->setOptions($options);
1622 $this->form_gui->addItem($bl_input);
1627 $num_input->setValue(
"3px");
1628 $this->form_gui->addItem($num_input);
1633 $num_input->setValue(
"10px");
1634 $this->form_gui->addItem($num_input);
1638 $cs = $this->
object->getColors();
1640 foreach ($cs as
$c) {
1641 $options[$c[
"name"]] = $c[
"name"];
1644 $this->form_gui->addItem($bc_input);
1647 $lss = array(
"border" => 90,
"header_text" => 70,
"header_bg" => 0,
1648 "cell1_text" => -60,
"cell1_bg" => 90,
"cell2_text" => -60,
"cell2_bg" => 75);
1649 foreach ($lss as $ls => $v) {
1652 $l_input->setMinValue(-100);
1653 $l_input->setValue((
string) $v);
1654 $l_input->setSize(4);
1655 $l_input->setMaxLength(4);
1656 $this->form_gui->addItem($l_input);
1659 $this->form_gui->addCommandButton(
"templateGeneration",
$lng->
txt(
"generate"));
1660 $this->form_gui->addCommandButton(
"cancelTemplateSaving",
$lng->
txt(
"cancel"));
1661 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1669 $tpl = $this->gui_service->ui()->mainTemplate();
1675 if ($this->form_gui->checkInput()) {
1676 if ($this->
object->templateExists($this->form_gui->getInput(
"name"))) {
1677 $name_input = $this->form_gui->getItemByPostVar(
"name");
1678 $name_input->setAlert(
$lng->
txt(
"sty_table_template_already_exists"));
1683 $cells = array(
"H" =>
"header",
"C1" =>
"cell1",
"C2" =>
"cell2");
1684 $tb_p = $this->form_gui->getItemByPostVar(
"tb_padding");
1685 $tb_padding = $tb_p->getValue();
1686 $lr_p = $this->form_gui->getItemByPostVar(
"lr_padding");
1687 $lr_padding = $lr_p->getValue();
1688 $cell_color = $this->form_gui->getInput(
"base_color");
1691 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1692 $cell_color =
"MidGray";
1693 if (!$this->color_manager->colorExists($cell_color)) {
1694 $this->color_manager->addColor($cell_color,
"7F7F7F");
1696 $this->color_manager->updateColor($cell_color, $cell_color,
"7F7F7F");
1699 foreach ($cells as $k => $cell) {
1700 $cell_class[$k] = $this->form_gui->getInput(
"name") . $k;
1701 if (!$this->
object->characteristicExists($cell_class[$k],
"table_cell")) {
1702 $this->characteristic_manager->addCharacteristic(
"table_cell", $cell_class[$k],
true);
1704 if ($this->form_gui->getInput(
"layout") ==
"bwZebra" && $k ==
"H") {
1705 $this->characteristic_manager->replaceParameter(
1709 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1712 $this->characteristic_manager->replaceParameter(
1716 "!" . $this->form_gui->getInput(
"base_color") .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1720 $this->characteristic_manager->replaceParameter(
1724 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_text") .
")",
1727 $this->characteristic_manager->replaceParameter(
1731 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_" . $cell .
"_bg") .
")",
1735 $this->characteristic_manager->replaceParameter(
1742 $this->characteristic_manager->replaceParameter(
1749 $this->characteristic_manager->replaceParameter(
1756 $this->characteristic_manager->replaceParameter(
1763 $this->characteristic_manager->replaceParameter(
1770 $this->characteristic_manager->replaceParameter(
1777 $this->characteristic_manager->replaceParameter(
1781 "!" . $cell_color .
"(" . $this->form_gui->getInput(
"lightness_border") .
")",
1784 $this->characteristic_manager->replaceParameter(
1794 $classes[
"table"] = $this->form_gui->getInput(
"name") .
"T";
1795 if (!$this->
object->characteristicExists($classes[
"table"],
"table")) {
1796 $this->characteristic_manager->addCharacteristic(
"table", $classes[
"table"],
true);
1798 $this->characteristic_manager->replaceParameter(
1805 $this->characteristic_manager->replaceParameter(
1812 $this->characteristic_manager->replaceParameter(
1819 $this->characteristic_manager->replaceParameter(
1826 if ($this->form_gui->getInput(
"layout") ==
"bwZebra") {
1827 $this->characteristic_manager->replaceParameter(
1830 "border-bottom-color",
1831 "!" . $this->form_gui->getInput(
"base_color"),
1834 $this->characteristic_manager->replaceParameter(
1837 "border-bottom-style",
1841 $this->characteristic_manager->replaceParameter(
1844 "border-bottom-width",
1848 $sb = array(
"left",
"right",
"top");
1849 foreach ($sb as
$b) {
1850 $this->characteristic_manager->replaceParameter(
1853 "border-" . $b .
"-width",
1860 switch ($this->form_gui->getInput(
"layout")) {
1862 case "coloredZebra":
1863 $classes[
"row_head"] = $cell_class[
"H"];
1864 $classes[
"odd_row"] = $cell_class[
"C1"];
1865 $classes[
"even_row"] = $cell_class[
"C2"];
1869 $classes[
"row_head"] = $cell_class[
"H"];
1870 $classes[
"odd_row"] = $cell_class[
"C1"];
1871 $classes[
"even_row"] = $cell_class[
"C1"];
1872 $classes[
"col_head"] = $cell_class[
"C2"];
1877 $t_id = $this->
object->addTemplate(
1878 $this->style_request->getTempType(),
1879 $this->form_gui->getInput(
"name"),
1882 $this->
object->writeTemplatePreview(
1885 $this->style_request->getTempType(),
1890 $ilCtrl->redirect($this,
"listTemplates");
1893 $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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
lookupTemplateName(int $a_t_id)
Lookup table template name for template ID.
Content ColorManager $color_manager
deleteTemplateConfirmationObject()
Delete table template confirmation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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] don't belong to the current class! The m...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
form( $class_path, string $cmd)
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
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")
__construct(Container $dic, ilPlugin $plugin)
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)
Content style internal service.
getTemplateFormValues()
Set values for table template editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Content CharacteristicManager $characteristic_manager
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.