ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjectTranslation2TableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 {
29 
30  protected bool $incl_desc;
31  protected string $base_cmd;
32  protected string $master_lang;
33  protected bool $fallback_mode;
34  protected string $fallback_lang;
35  protected int $nr;
36 
37  public function __construct(
38  ?object $parent_obj,
39  string $parent_cmd,
40  bool $incl_desc = true,
41  string $base_cmd = "HeaderTitle",
42  string $master_lang = "",
43  bool $fallback_mode = false,
44  string $fallback_lang = ""
45  ) {
46  global $DIC;
47 
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50  $this->access = $DIC->access();
51  $ilCtrl = $DIC->ctrl();
52 
53  parent::__construct($parent_obj, $parent_cmd);
54 
55  $this->incl_desc = $incl_desc;
56  $this->base_cmd = $base_cmd;
57  $this->master_lang = $master_lang;
58  $this->fallback_mode = $fallback_mode;
59  $this->fallback_lang = $fallback_lang;
60 
61  $this->setLimit(9999);
62 
63  $this->addColumn("", "", "1");
64  $this->addColumn($this->lng->txt("language"));
65  $this->addColumn($this->lng->txt("default"));
66  $this->addColumn($this->lng->txt("title"));
67  if ($incl_desc) {
68  $this->addColumn($this->lng->txt("description"));
69  }
70 
71  $this->setEnableHeader(true);
72  $this->setFormAction($ilCtrl->getFormAction($parent_obj));
73  $this->setRowTemplate("tpl.obj_translation2_row.html", "Services/Object");
74  $this->disable("footer");
75  $this->setEnableTitle(true);
76 
77  $this->nr = 0;
78  }
79 
80  protected function prepareOutput(): void
81  {
82  $this->addMultiCommand("delete" . $this->base_cmd . "s", $this->lng->txt("remove"));
83  if ($this->fallback_mode) {
84  $this->addMultiCommand("setFallback", $this->lng->txt("obj_set_fallback_lang"));
85  }
86  if ($this->dataExists()) {
87  $this->addCommandButton("save" . $this->base_cmd . "s", $this->lng->txt("save"));
88  }
89  }
90 
91  protected function fillRow(array $set): void
92  {
93  $this->nr++;
94 
95  if (!$set["default"] && $set["lang"] != $this->master_lang) {
96  $this->tpl->setCurrentBlock("cb");
97  $this->tpl->setVariable("CB_NR", $this->nr);
98  $this->tpl->parseCurrentBlock();
99  }
100 
101  if ($this->master_lang == "") {
102  $this->tpl->setCurrentBlock("rb");
103  $this->tpl->setVariable("RB_NR", $this->nr);
104  if ($set["default"]) {
105  $this->tpl->setVariable("DEF_CHECKED", "checked=\"checked\"");
106  }
107  $this->tpl->parseCurrentBlock();
108  } elseif ($set["lang"] == $this->master_lang) {
109  $this->tpl->setVariable("MASTER_LANG", $this->lng->txt("obj_master_lang"));
110  }
111  if ($this->master_lang != "" && $set["lang"] == $this->fallback_lang) {
112  $this->tpl->setVariable("FALLBACK_LANG", $this->lng->txt("obj_fallback_lang"));
113  }
114 
115  if ($this->incl_desc) {
116  $this->tpl->setCurrentBlock("desc_row");
117  $this->tpl->setVariable("VAL_DESC", ilLegacyFormElementsUtil::prepareFormOutput($set["desc"]));
118  $this->tpl->setVariable("DNR", $this->nr);
119  $this->tpl->parseCurrentBlock();
120  }
121 
122  $this->tpl->setVariable("NR", $this->nr);
123 
124  // lang selection
125  $languages = ilMDLanguageItem::_getLanguages();
126  $this->tpl->setVariable(
127  "LANG_SELECT",
129  $set["lang"],
130  "lang[" . $this->nr . "]",
131  $languages,
132  false,
133  true
134  )
135  );
136 
137 
138  $this->tpl->setVariable("VAL_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($set["title"]));
139  }
140 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static prepareFormOutput($a_str, bool $a_strip=false)
global $DIC
Definition: feed.php:28
__construct(?object $parent_obj, string $parent_cmd, bool $incl_desc=true, string $base_cmd="HeaderTitle", string $master_lang="", bool $fallback_mode=false, string $fallback_lang="")
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
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)
disable(string $a_module_name)
addMultiCommand(string $a_cmd, string $a_text)
setEnableHeader(bool $a_enableheader)