ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExportIDTableGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
28  protected bool $dup_info_given;
29  protected array $cnt_exp_ids;
30  protected bool $validation = false;
32  public bool $online_help_mode = false;
34  protected \ilGlobalTemplateInterface $main_tpl;
35 
36  public function __construct(
37  object $a_parent_obj,
38  string $a_parent_cmd,
39  bool $a_validation = false,
40  bool $a_oh_mode = false
41  ) {
42  global $DIC;
43  $this->main_tpl = $DIC->ui()->mainTemplate();
44 
45  $this->ctrl = $DIC->ctrl();
46  $this->lng = $DIC->language();
47  $this->access = $DIC->access();
48 
49  $this->request = $DIC
50  ->learningModule()
51  ->internal()
52  ->gui()
53  ->editing()
54  ->request();
55 
56  $ilCtrl = $DIC->ctrl();
57  $lng = $DIC->language();
58 
59  $this->setOnlineHelpMode($a_oh_mode);
60  $this->setId("lm_expids");
61  $this->validation = $a_validation;
62 
63  parent::__construct($a_parent_obj, $a_parent_cmd);
64 
65  if ($this->getOnlineHelpMode()) {
66  $this->setData(ilStructureObject::getChapterList($this->parent_obj->getObject()->getId()));
67  $this->cnt_exp_ids = ilLMPageObject::getDuplicateExportIDs(
68  $this->parent_obj->getObject()->getId(),
69  "st"
70  );
71  } else {
72  $this->setData(ilLMPageObject::getPageList($this->parent_obj->getObject()->getId()));
73  $this->cnt_exp_ids = ilLMPageObject::getDuplicateExportIDs(
74  $this->parent_obj->getObject()->getId()
75  );
76  }
77 
78  $this->setTitle($lng->txt("cont_html_export_ids"));
79 
80  $this->addColumn($this->lng->txt("pg"), "title");
81  $this->addColumn($this->lng->txt("cont_export_id"));
82 
83  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
84  $this->setRowTemplate("tpl.export_id_row.html", "Modules/LearningModule");
85  $this->setDefaultOrderField("title");
86  $this->setDefaultOrderDirection("asc");
87 
88  $this->addCommandButton("saveExportIDs", $lng->txt("save"));
89  }
90 
91  public function setOnlineHelpMode(bool $a_val): void
92  {
93  $this->online_help_mode = $a_val;
94  }
95 
96  public function getOnlineHelpMode(): bool
97  {
99  }
100 
101  protected function fillRow(array $a_set): void
102  {
103  $lng = $this->lng;
104 
105  $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
106  $this->tpl->setVariable("PAGE_ID", $a_set["obj_id"]);
107 
108  $exp_id = ilLMPageObject::getExportId(
109  $this->parent_obj->getObject()->getId(),
110  $a_set["obj_id"],
111  $a_set["type"]
112  );
113 
114  $req_export_ids = $this->request->getExportIds();
115  if ($this->validation) {
116  if (!preg_match(
117  "/^[a-zA-Z_]*$/",
118  trim($req_export_ids[$a_set["obj_id"]])
119  )) {
120  // @todo: move to style
121  $this->tpl->setVariable(
122  "STYLE",
123  " style='background-color: #FCEAEA;' "
124  );
125  $this->tpl->setVariable(
126  "ALERT_IMG",
127  ilUtil::img(
128  ilUtil::getImagePath("icon_alert.svg"),
129  $lng->txt("alert"),
130  "",
131  "",
132  0,
133  "",
134  "ilIcon"
135  )
136  );
137  }
138  $this->tpl->setVariable(
139  "EXPORT_ID",
141  ilUtil::stripSlashes($req_export_ids[$a_set["obj_id"]])
142  )
143  );
144  } else {
145  $this->tpl->setVariable(
146  "EXPORT_ID",
148  );
149  }
150 
151  if (($this->cnt_exp_ids[$exp_id] ?? 0) > 1) {
152  $this->tpl->setVariable(
153  "ITEM_ADD_TXT",
154  $lng->txt("cont_exp_id_used_multiple")
155  );
156  $this->tpl->setVariable(
157  "ALERT_IMG",
158  ilUtil::img(
159  ilUtil::getImagePath("icon_alert.svg"),
160  $lng->txt("alert"),
161  "",
162  "",
163  0,
164  "",
165  "ilIcon"
166  )
167  );
168  if (!$this->dup_info_given) {
169  $this->main_tpl->setOnScreenMessage('info', $lng->txt("content_some_export_ids_multiple_times"));
170  $this->dup_info_given = true;
171  }
172  }
173  }
174 }
setData(array $a_data)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
static getExportId(int $a_lm_id, int $a_lmobj_id, string $a_type="pg")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, bool $a_strip=false)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
static getChapterList(int $a_lm_id)
setDefaultOrderField(string $a_defaultorderfield)
ilGlobalTemplateInterface $main_tpl
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
static getPageList(int $lm_id)
__construct(Container $dic, ilPlugin $plugin)
static getDuplicateExportIDs(int $a_lm_id, string $a_type="pg")
Get duplicate export IDs (count export ID usages)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
__construct(object $a_parent_obj, string $a_parent_cmd, bool $a_validation=false, bool $a_oh_mode=false)