ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 require_once "./Services/Object/classes/class.ilObject.php";
14 
16 {
17  var $styles;
18 
25  function ilObjStyleSettings($a_id = 0,$a_call_by_reference = true)
26  {
27  $this->type = "stys";
28  $this->ilObject($a_id,$a_call_by_reference);
29 
30  $this->styles = array();
31  }
32 
38  function addStyle($a_style_id)
39  {
40  $this->styles[$a_style_id] =
41  array("id" => $a_style_id,
42  "title" => ilObject::_lookupTitle($a_style_id));
43  }
44 
45 
49  function removeStyle($a_id)
50  {
51  unset($a_id);
52  }
53 
54 
61  function update()
62  {
63  global $ilDB;
64 
65  if (!parent::update())
66  {
67  return false;
68  }
69 
70  // save styles of style folder
71  $q = "DELETE FROM style_folder_styles WHERE folder_id = ".
72  $ilDB->quote($this->getId(), "integer");
73  $ilDB->manipulate($q);
74  foreach($this->styles as $style)
75  {
76  $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
77  "(".$ilDB->quote((int) $this->getId(), "integer").", ".
78  $ilDB->quote((int) $style["id"], "integer").")";
79  $ilDB->manipulate($q);
80  }
81 
82  return true;
83  }
84 
88  function read()
89  {
90  global $ilDB;
91 
92  parent::read();
93 
94  // get styles of style folder
95  $q = "SELECT * FROM style_folder_styles, style_data WHERE folder_id = ".
96  $ilDB->quote($this->getId(), "integer").
97  " AND style_id = style_data.id";
98 
99  $style_set = $ilDB->query($q);
100  $this->styles = array();
101  while ($style_rec = $ilDB->fetchAssoc($style_set))
102  {
103  $this->styles[$style_rec["style_id"]] =
104  array("id" => $style_rec["style_id"],
105  "title" => ilObject::_lookupTitle($style_rec["style_id"]),
106  "category" => $style_rec["category"]);
107  }
108  $this->styles =
109  ilUtil::sortArray($this->styles, "title", "asc", false, true);
110  }
111 
115  function _lookupActivatedStyle($a_skin, $a_style)
116  {
117  global $ilDB;
118 
119  $q = "SELECT count(*) cnt FROM settings_deactivated_s".
120  " WHERE skin = ".$ilDB->quote($a_skin, "text").
121  " AND style = ".$ilDB->quote($a_style, "text")." ";
122 
123  $cnt_set = $ilDB->query($q);
124  $cnt_rec = $ilDB->fetchAssoc($cnt_set);
125 
126  if ($cnt_rec["cnt"] > 0)
127  {
128  return false;
129  }
130  else
131  {
132  return true;
133  }
134  }
135 
139  function _deactivateStyle($a_skin, $a_style)
140  {
141  global $ilDB;
142 
143  ilObjStyleSettings::_activateStyle($a_skin, $a_style);
144  $q = "INSERT into settings_deactivated_s".
145  " (skin, style) VALUES ".
146  " (".$ilDB->quote($a_skin, "text").",".
147  " ".$ilDB->quote($a_style, "text").")";
148 
149  $ilDB->manipulate($q);
150  }
151 
155  function _activateStyle($a_skin, $a_style)
156  {
157  global $ilDB;
158 
159  $q = "DELETE FROM settings_deactivated_s".
160  " WHERE skin = ".$ilDB->quote($a_skin, "text").
161  " AND style = ".$ilDB->quote($a_style, "text");
162 
163  $ilDB->manipulate($q);
164  }
165 
171  function getStyles()
172  {
173  return $this->styles;
174  }
175 
176 
183  function delete()
184  {
185  // always call parent delete function first!!
186  if (!parent::delete())
187  {
188  return false;
189  }
190 
191  //put here your module specific stuff
192 
193  return true;
194  }
195 
196 
210  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
211  {
212  global $tree;
213 
214  switch ($a_event)
215  {
216  case "link":
217 
218  //var_dump("<pre>",$a_params,"</pre>");
219  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
220  //exit;
221  break;
222 
223  case "cut":
224 
225  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
226  //exit;
227  break;
228 
229  case "copy":
230 
231  //var_dump("<pre>",$a_params,"</pre>");
232  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
233  //exit;
234  break;
235 
236  case "paste":
237 
238  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
239  //exit;
240  break;
241 
242  case "new":
243 
244  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
245  //exit;
246  break;
247  }
248 
249  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
250  if ($a_node_id==$_GET["ref_id"])
251  {
252  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
253  $parent_type = $parent_obj->getType();
254  if($parent_type == $this->getType())
255  {
256  $a_node_id = (int) $tree->getParentId($a_node_id);
257  }
258  }
259 
260  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
261  }
262 } // END class.ilObjStyleSettings
263 ?>