ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSystemStylesTableGUI.php
Go to the documentation of this file.
1 <?php
2 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
3 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
4 
5 
6 include_once("./Services/Table/classes/class.ilTable2GUI.php");
7 
19 {
23  protected $ctrl;
24 
28  protected $lng;
29 
33  protected $with_actions = false;
34 
38  protected $management_enabled = false;
39 
43  protected $read_documentation = true;
44 
50  public function __construct($a_parent_obj, $a_parent_cmd)
51  {
52  global $DIC;
53 
54  $this->ctrl = $DIC->ctrl();
55  $this->lng = $DIC->language();
56 
57  parent::__construct($a_parent_obj, $a_parent_cmd);
58  $this->getStyles();
59 
60  $this->setLimit(9999);
61  $this->setTitle($this->lng->txt("manage_system_styles"));
62  $this->addColumn($this->lng->txt(""));
63  $this->addColumn($this->lng->txt("style_name"), "style_name");
64  $this->addColumn($this->lng->txt("skin_name"), "skin_name");
65  $this->addColumn($this->lng->txt("sty_substyle_of"));
66  $this->addColumn($this->lng->txt("scope"));
67  $this->addColumn($this->lng->txt("default"));
68  $this->addColumn($this->lng->txt("active"));
69  $this->addColumn($this->lng->txt("users"), "users");
70  $this->setRowTemplate("tpl.sys_styles_row.html", "Services/Style/System");
71  $this->setEnableHeader(true);
72  }
73 
79  {
82 
83  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
84  $this->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
85  $this->setRowTemplate("tpl.sys_styles_row_with_actions.html", "Services/Style/System");
86 
88  $this->setWithActions(true);
89 
90  $this->addColumn($this->lng->txt("actions"));
91  }
92  if ($management_enabled) {
93  $this->addMultiCommand("deleteStyles", $this->lng->txt("delete"));
94  }
95  }
96 
100  public function getStyles()
101  {
102  // get all user assigned styles
103  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
104 
105  // output "other" row for all users, that are not assigned to
106  // any existing style
107  $users_missing_styles = 0;
108  foreach ($all_user_styles as $skin_style_id) {
109  $style_arr = explode(":", $skin_style_id);
110  if (!ilStyleDefinition::styleExists($style_arr[1])) {
111  $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
112  }
113  }
114  $all_styles = ilStyleDefinition::getAllSkinStyles();
115  if ($users_missing_styles > 0) {
116  $all_styles["other"] =
117  array(
118  "title" => $this->lng->txt("other"),
119  "id" => "other",
120  "template_id" => "",
121  "skin_id" => "other",
122  "style_id" => "",
123  "skin_name" => "other",
124  "style_name" => "",
125  "users" => $users_missing_styles
126  );
127  }
128 
129  $this->setData($all_styles);
130  }
131 
132 
136  protected function fillRow($a_set)
137  {
138  global $DIC;
139 
140  $this->tpl->setVariable("STYLE_NAME", $a_set["style_name"]);
141  $this->tpl->setVariable("SKIN_NAME", $a_set["skin_name"]);
142  $is_substyle = $a_set["substyle_of"] != "";
143 
144  if (!$is_substyle) {
145  $this->tpl->setVariable("USERS", $a_set["users"]);
146  } else {
147  $this->tpl->setVariable("USERS", "-");
148  }
149 
150  if ($a_set["id"] != "other") {
151  $this->tpl->setCurrentBlock("default_input");
152 
153  if (!$is_substyle) {
154  $this->tpl->setVariable("DEFAULT_ID", $a_set["id"]);
155  if (ilSystemStyleSettings::getCurrentDefaultSkin() == $a_set["skin_id"] &&
156  ilSystemStyleSettings::getCurrentDefaultStyle() == $a_set["style_id"]
157  ) {
158  $this->tpl->setVariable("CHECKED_DEFAULT", ' checked="checked" ');
159  } else {
160  $this->tpl->setVariable("CHECKED_DEFAULT", '');
161  }
162  $this->tpl->parseCurrentBlock();
163  }
164 
165  $this->tpl->setCurrentBlock("active_input");
166  $this->tpl->setVariable("ACTIVE_ID", $a_set["id"]);
167 
168  if ($is_substyle) {
169  $this->tpl->setVariable("DISABLED_ACTIVE", 'disabled');
170 
171  if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["substyle_of"])) {
172  $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
173  } else {
174  $this->tpl->setVariable("CHECKED_ACTIVE", '');
175  }
176  } else {
177  if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["style_id"])) {
178  $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
179  } else {
180  $this->tpl->setVariable("CHECKED_ACTIVE", '');
181  }
182  }
183 
184  $this->tpl->parseCurrentBlock();
185  }
186 
187  if ($is_substyle) {
188  $this->tpl->setVariable("SUB_STYLE_OF", $a_set["substyle_of_name"]);
189 
191  $a_set["skin_id"],
192  $a_set["substyle_of"],
193  $a_set["style_id"]
194  );
195 
196  $categories = [];
197 
198  foreach ($assignments as $assignment) {
199  $category_title = ilObject::_lookupTitle(ilObject::_lookupObjId($assignment["ref_id"]));
200  if ($category_title) {
201  $categories[] = $category_title;
202  }
203  }
204 
205  $listing = $DIC->ui()->factory()->listing()->unordered($categories);
206  $this->tpl->setVariable(
207  "CATEGORIES",
208  $this->lng->txt("local") . $DIC->ui()->renderer()->render($listing)
209  );
210  } else {
211  $this->tpl->setVariable("SUB_STYLE_OF", "");
212  $this->tpl->setVariable("CATEGORIES", $this->lng->txt("global"));
213  }
214 
215  if ($this->isWithActions()) {
216  if ($a_set["skin_id"] == "other") {
217  $this->tpl->setCurrentBlock("actions");
218  $this->tpl->setVariable("ACTIONS", "");
219  $this->tpl->parseCurrentBlock();
220  } else {
221  $action_list = new ilAdvancedSelectionListGUI();
222  $action_list->setId("id_action_list_" . $a_set["id"]);
223  $action_list->setListTitle($this->lng->txt("actions"));
224 
225  if ($this->isReadDocumentation()) {
226  $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'skin_id', $a_set["skin_id"]);
227  $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'style_id', $a_set["style_id"]);
228  $action_list->addItem(
229  $this->lng->txt('open_documentation'),
230  'documentation',
231  $this->ctrl->getLinkTargetByClass('ilSystemStyleDocumentationGUI', 'entries')
232  );
233  }
234 
235  if ($this->isManagementEnabled()) {
236  $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'skin_id', $a_set["skin_id"]);
237  $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'style_id', $a_set["style_id"]);
238 
239  $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'skin_id', $a_set["skin_id"]);
240  $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'style_id', $a_set["style_id"]);
241 
243  if ($a_set["skin_id"] != $config->getDefaultSkinId()) {
244  $this->addManagementActionsToList($action_list);
245  $this->addMultiActions($a_set["id"]);
246  }
247  if (!$is_substyle && $a_set["skin_id"] != "default") {
248  $action_list->addItem($this->lng->txt('export'), 'export', $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'export'));
249  }
250  }
251 
252 
253  $this->tpl->setCurrentBlock("actions");
254  $this->tpl->setVariable("ACTIONS", $action_list->getHTML());
255  $this->tpl->parseCurrentBlock();
256  }
257  }
258  }
259 
261  {
262  $action_list->addItem($this->lng->txt('edit'), 'edit', $this->ctrl->getLinkTargetByClass('ilSystemStyleSettingsGUI'));
263  $action_list->addItem($this->lng->txt('delete'), 'delete', $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'deleteStyle'));
264  }
265 
266  protected function addMultiActions($id)
267  {
268  $this->tpl->setCurrentBlock("multi_actions");
269  $this->tpl->setVariable("MULTI_ACTIONS_ID", $id);
270  $this->tpl->parseCurrentBlock();
271  }
272 
276  public function isWithActions()
277  {
278  return $this->with_actions;
279  }
280 
284  public function setWithActions($with_actions)
285  {
286  $this->with_actions = $with_actions;
287  }
288 
292  public function isManagementEnabled()
293  {
295  }
296 
301  {
302  $this->management_enabled = $management_enabled;
303  }
304 
308  public function isReadDocumentation()
309  {
311  }
312 
317  {
318  $this->read_documentation = $read_documentation;
319  }
320 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
$config
Definition: bootstrap.php:15
static styleExists($style_id)
static getCurrentDefaultSkin()
Gets default Skin of the System.
global $DIC
Definition: saml.php:7
addManagementActionsToList(ilAdvancedSelectionListGUI $action_list)
static getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_sub_style_id)
Get all system category assignments of exactly one substyle.
if(!array_key_exists('StateId', $_REQUEST)) $id
setManagementEnabled($management_enabled)
static _lookupTitle($a_id)
lookup object title
setReadDocumentation($read_documentation)
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
Class ilTable2GUI.
static _lookupObjId($a_id)
addMultiCommand($a_cmd, $a_text)
Add Command button.
addItem( $a_title, $a_value="", $a_link="", $a_img="", $a_alt="", $a_frame="", $a_html="", $a_prevent_background_click=false, $a_onclick="", $a_ttip="", $a_tt_my="right center", $a_tt_at="left center", $a_tt_use_htmlspecialchars=true, $a_data=array())
Add an item.
__construct($a_parent_obj, $a_parent_cmd)
ilSystemStylesTableGUI constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
User interface class for advanced drop-down selection lists.
addActions($management_enabled, $read_documentation=true)
ilSystemStyleConfig wraps all &#39;constants&#39; to ensure the testability of all classes using those &#39;const...
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setEnableHeader($a_enableheader)
Set Enable Header.
TableGUI class for system styles.
static getCurrentDefaultStyle()
Gets default style of the system.
static _getAllUserAssignedStyles()
skins and styles
setLimit($a_limit=0, $a_default_limit=0)
with_actions()
Base.
Definition: with_actions.php:5