ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSystemStylesTableGUI.php
Go to the documentation of this file.
1<?php
2include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
3include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
4
5
6include_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
45 function __construct($a_parent_obj, $a_parent_cmd)
46 {
47
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->lng = $DIC->language();
52
53 parent::__construct($a_parent_obj, $a_parent_cmd);
54 $this->getStyles();
55
56 $this->setLimit(9999);
57 $this->addColumn($this->lng->txt(""));
58 $this->addColumn($this->lng->txt("style_name"),"style_name");
59 $this->addColumn($this->lng->txt("skin_name"),"style_id");
60 $this->addColumn($this->lng->txt("sty_substyle_of"));
61 $this->addColumn($this->lng->txt("default"));
62 $this->addColumn($this->lng->txt("active"));
63 $this->addColumn($this->lng->txt("users"),"users");
64 $this->setRowTemplate("tpl.sys_styles_row.html", "Services/Style/System");
65 $this->setEnableHeader(true);
66
67
68 }
69
74 $this->setWithActions(true);
76
77 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
78 $this->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
79 $this->setRowTemplate("tpl.sys_styles_row_with_actions.html", "Services/Style/System");
80
82 $this->addColumn($this->lng->txt("actions"));
83 $this->addMultiCommand("deleteStyles",$this->lng->txt("delete"));
84 }
85 }
86
90 function getStyles()
91 {
92 // get all user assigned styles
93 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
94
95 // output "other" row for all users, that are not assigned to
96 // any existing style
97 $users_missing_styles = 0;
98 foreach($all_user_styles as $skin_style_id)
99 {
100 $style_arr = explode(":", $skin_style_id);
101 if (!ilStyleDefinition::styleExists($style_arr[1]))
102 {
103
104 $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
105 }
106 }
107 $all_styles = ilStyleDefinition::getAllSkinStyles();
108 if ($users_missing_styles > 0)
109 {
110 $all_styles["other"] =
111 array (
112 "title" => $this->lng->txt("other"),
113 "id" => "other",
114 "template_id" => "",
115 "skin_id" => "other",
116 "style_id" => "",
117 "skin_name" => "other",
118 "style_name" => "",
119 "users" => $users_missing_styles
120 );
121 }
122
123 $this->setData($all_styles);
124 }
125
126
130 protected function fillRow($a_set)
131 {
132 global $DIC;
133
134 $this->tpl->setVariable("STYLE_NAME", $a_set["style_name"]);
135 $this->tpl->setVariable("SKIN_NAME", $a_set["skin_name"]);
136 $is_substyle = $a_set["substyle_of"] != "";
137
138 if(!$is_substyle) {
139 $this->tpl->setVariable("USERS", $a_set["users"]);
140 }else{
141 $this->tpl->setVariable("USERS", "-");
142 }
143
144 if($a_set["id"] != "other"){
145 $this->tpl->setCurrentBlock("default_input");
146
147 if(!$is_substyle) {
148 $this->tpl->setVariable("DEFAULT_ID", $a_set["id"]);
149 if (ilSystemStyleSettings::getCurrentDefaultSkin() == $a_set["skin_id"] &&
151 ) {
152 $this->tpl->setVariable("CHECKED_DEFAULT", ' checked="checked" ');
153 } else {
154 $this->tpl->setVariable("CHECKED_DEFAULT", '');
155 }
156 $this->tpl->parseCurrentBlock();
157 }
158
159 $this->tpl->setCurrentBlock("active_input");
160 $this->tpl->setVariable("ACTIVE_ID", $a_set["id"]);
161
162 if($is_substyle){
163 $this->tpl->setVariable("DISABLED_ACTIVE", 'disabled');
164
165 if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["substyle_of"])){
166 $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
167 }else{
168 $this->tpl->setVariable("CHECKED_ACTIVE", '');
169 }
170 }else{
171 if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["style_id"])){
172 $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
173 }else{
174 $this->tpl->setVariable("CHECKED_ACTIVE", '');
175 }
176 }
177
178 $this->tpl->parseCurrentBlock();
179
180 }
181
182 if($is_substyle){
183 $this->tpl->setCurrentBlock("substyle");
184 $this->tpl->setVariable("SUB_STYLE_OF", $a_set["substyle_of_name"]);
185
187 $a_set["skin_id"],
188 $a_set["substyle_of"],
189 $a_set["style_id"]
190 );
191
192 $categories = [];
193
194 foreach($assignments as $assignment) {
195 $categories[] = ilObject::_lookupTitle(ilObject::_lookupObjId($assignment["ref_id"]));
196 }
197
198 $listing = $DIC->ui()->factory()->listing()->unordered($categories);
199 $this->tpl->setVariable("CATEGORIES",$DIC->ui()->renderer()->render($listing) );
200 $this->tpl->parseCurrentBlock();
201 }
202
203 if($this->isWithActions() && $this->isManagementEnabled()){
204 if($a_set["skin_id"]!="default" && $a_set["skin_id"]!="other"){
205 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI','skin_id',$a_set["skin_id"]);
206 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI','style_id',$a_set["style_id"]);
207
208 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI','skin_id',$a_set["skin_id"]);
209 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI','style_id',$a_set["style_id"]);
210
211 $selection_list = new ilAdvancedSelectionListGUI();
212 $selection_list->setId("id_action_list_" . $a_set["id"]);
213 $selection_list->setListTitle($this->lng->txt("actions"));
214
215
216 $this->tpl->setCurrentBlock("multi_actions");
217 $this->tpl->setVariable("MULTI_ACTIONS_ID", $a_set["id"]);
218 $this->tpl->parseCurrentBlock();
219
220 $selection_list->addItem($this->lng->txt('edit'),'edit',$this->ctrl->getLinkTargetByClass('ilSystemStyleSettingsGUI'));
221 $selection_list->addItem($this->lng->txt('delete'),'delete',$this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI','deleteStyle'));
222
223 if(!$is_substyle){
224 $selection_list->addItem($this->lng->txt('export'),'export',$this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI','export'));
225 }
226
227 $this->tpl->setCurrentBlock("actions");
228 $this->tpl->setVariable("ACTIONS", $selection_list->getHTML());
229 $this->tpl->parseCurrentBlock();
230
231
232 }else{
233 $this->tpl->setCurrentBlock("actions");
234 $this->tpl->setVariable("ACTIONS", "");
235 $this->tpl->parseCurrentBlock();
236 }
237 }
238 }
239
243 public function isWithActions()
244 {
245 return $this->with_actions;
246 }
247
252 {
253 $this->with_actions = $with_actions;
254 }
255
259 public function isManagementEnabled()
260 {
262 }
263
268 {
269 $this->management_enabled = $management_enabled;
270 }
271
272
273}
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static _getAllUserAssignedStyles()
skins and styles
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static styleExists($style_id)
static getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_sub_style_id)
Get all system category assignments of exactly one substyle.
static getCurrentDefaultStyle()
Gets default style of the system.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
static getCurrentDefaultSkin()
Gets default Skin of the System.
TableGUI class for system styles.
__construct($a_parent_obj, $a_parent_cmd)
ilSystemStylesTableGUI constructor.
setManagementEnabled($management_enabled)
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
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.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
global $DIC