ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSystemStylesTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Table/classes/class.ilTable2GUI.php");
6 
16 {
20  function __construct($a_parent_obj, $a_parent_cmd)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem;
23 
24  parent::__construct($a_parent_obj, $a_parent_cmd);
25  $this->getStyles();
26 // $this->setTitle($lng->txt(""));
27 
28  $this->setLimit(9999);
29 
30  $this->addColumn($this->lng->txt("title"));
31  $this->addColumn($this->lng->txt("default"));
32  $this->addColumn($this->lng->txt("users"));
33  $this->addColumn($this->lng->txt("active"));
34  $this->addColumn($this->lng->txt("sty_substyles"));
35  $this->addColumn($this->lng->txt("actions"));
36 
37  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
38  $this->setRowTemplate("tpl.sys_styles_row.html", "Services/Style");
39 
40  if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"]))
41  {
42  $this->addCommandButton("saveStyleSettings", $lng->txt("save"));
43  }
44  }
45 
52  function getStyles()
53  {
54  global $styleDefinition;
55 
57 
58  // get all user assigned styles
59  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
60 
61  // output "other" row for all users, that are not assigned to
62  // any existing style
63  $users_missing_styles = 0;
64  foreach($all_user_styles as $style)
65  {
66  if (!isset($all_styles[$style]))
67  {
68  $style_arr = explode(":", $style);
69  $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
70  }
71  }
72 
73  if ($users_missing_styles > 0)
74  {
75  $all_styles["other"] =
76  array (
77  "title" => $this->lng->txt("other"),
78  "id" => "other",
79  "template_id" => "",
80  "style_id" => "",
81  "template_name" => "",
82  "style_name" => "",
83  "users" => $users_missing_styles
84  );
85  }
86 
87 
88  $this->setData($all_styles);
89  }
90 
91 
95  protected function fillRow($a_set)
96  {
97  global $lng, $ilClientIniFile, $ilCtrl;
98 
99  $cat_ass = ilStyleDefinition::getSystemStyleCategoryAssignments($a_set["template_id"],
100  $a_set["style_id"]);
101 
102  if (is_array($a_set["substyle"]))
103  {
104  foreach ($a_set["substyle"] as $substyle)
105  {
106  reset($cat_ass);
107  $cats = false;
108  foreach($cat_ass as $ca)
109  {
110  if ($ca["substyle"] == $substyle["id"])
111  {
112  $this->tpl->setCurrentBlock("cat");
113  $this->tpl->setVariable("CAT", ilObject::_lookupTitle(
114  ilObject::_lookupObjId($ca["ref_id"])));
115  $this->tpl->parseCurrentBlock();
116  $cats = true;
117  }
118  }
119  if ($cats)
120  {
121  $this->tpl->touchBlock("cats");
122  }
123 
124  $this->tpl->setCurrentBlock("substyle");
125  $this->tpl->setVariable("SUB_STYLE", $substyle["name"]);
126  $this->tpl->parseCurrentBlock();
127  }
128  $this->tpl->touchBlock("substyles");
129 
130  $ilCtrl->setParameter($this->parent_obj, "style_id", urlencode($a_set["id"]));
131  $this->tpl->setCurrentBlock("cmd");
132  $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj,
133  "assignStylesToCats"));
134  $this->tpl->setVariable("TXT_CMD", $lng->txt("sty_assign_categories"));
135  $this->tpl->parseCurrentBlock();
136  }
137 
138  $this->tpl->setVariable("TITLE", $a_set["title"]);
139  $this->tpl->setVariable("ID", $a_set["id"]);
140 
141  // number of users
142  $this->tpl->setVariable("USERS", $a_set["users"]);
143 
144  // activation
145  if (ilObjStyleSettings::_lookupActivatedStyle($a_set["template_id"], $a_set["style_id"]))
146  {
147  $this->tpl->setVariable("CHECKED", ' checked="checked" ');
148  }
149 
150  if ($ilClientIniFile->readVariable("layout","skin") == $a_set["template_id"] &&
151  $ilClientIniFile->readVariable("layout","style") == $a_set["style_id"])
152  {
153  $this->tpl->setVariable("CHECKED_DEFAULT", ' checked="checked" ');
154  }
155 
156  }
157 
158 }
159 ?>