ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilScormEditorDBMigrationUtil.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
16  protected $db;
17 
18 
22  public function __construct()
23  {
24  global $DIC;
25 
26  $this->db = $DIC->database();
27  }
28 
29 
36  public static function copyStyleClass($a_orig_class, $a_class, $a_type, $a_tag, $a_hide = 0)
37  {
38  global $DIC;
39 
40  $ilDB = $DIC->database();
41 
42  $set = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
43  while ($rec = $ilDB->fetchAssoc($set)) { // all styles
44  $set2 = $ilDB->query("SELECT * FROM style_char WHERE " .
45  "style_id = " . $ilDB->quote($rec["obj_id"], "integer") . " AND " .
46  "characteristic = " . $ilDB->quote($a_class, "text") . " AND " .
47  "type = " . $ilDB->quote($a_type, "text"));
48  if (!$ilDB->fetchAssoc($set2)) {
49  $q = "INSERT INTO style_char (style_id, type, characteristic, hide)" .
50  " VALUES (" .
51  $ilDB->quote($rec["obj_id"], "integer") . "," .
52  $ilDB->quote($a_type, "text") . "," .
53  $ilDB->quote($a_class, "text") . "," .
54  $ilDB->quote($a_hide, "integer") . ")";
55  $ilDB->manipulate($q);
56 
57  $set3 = $ilDB->query(
58  "SELECT * FROM style_parameter WHERE " .
59  "style_id = " . $ilDB->quote($rec["obj_id"], "integer") . " AND " .
60  "type = " . $ilDB->quote($a_type, "text") . " AND " .
61  "class = " . $ilDB->quote($a_orig_class, "text") . " AND " .
62  "tag = " . $ilDB->quote($a_tag, "text")
63  );
64  while ($rec3 = $ilDB->fetchAssoc($set3)) { // copy parameters
65  $spid = $ilDB->nextId("style_parameter");
66  $q = "INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value)" .
67  " VALUES (" .
68  $ilDB->quote($spid, "integer") . "," .
69  $ilDB->quote($rec["obj_id"], "integer") . "," .
70  $ilDB->quote($rec3["type"], "text") . "," .
71  $ilDB->quote($a_class, "text") . "," .
72  $ilDB->quote($a_tag, "text") . "," .
73  $ilDB->quote($rec3["parameter"], "text") . "," .
74  $ilDB->quote($rec3["value"], "text") .
75  ")";
76  $ilDB->manipulate($q);
77  }
78  }
79  }
80  }
81 
88  public function addStyleClass($a_class, $a_type, $a_tag, $a_parameters = "", $a_hide = 0)
89  {
90  $ilDB = $this->db;
91 
92  if ($a_parameters == "") {
93  $a_parameters = array();
94  }
95 
96  $set = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
97  while ($rec = $ilDB->fetchAssoc($set)) { // all styles
98  $set2 = $ilDB->query("SELECT * FROM style_char WHERE " .
99  "style_id = " . $ilDB->quote($rec["obj_id"], "integer") . " AND " .
100  "characteristic = " . $ilDB->quote($a_class, "text") . " AND " .
101  "type = " . $ilDB->quote($a_type, "text"));
102  if (!$ilDB->fetchAssoc($set2)) {
103  $q = "INSERT INTO style_char (style_id, type, characteristic, hide)" .
104  " VALUES (" .
105  $ilDB->quote($rec["obj_id"], "integer") . "," .
106  $ilDB->quote($a_type, "text") . "," .
107  $ilDB->quote($a_class, "text") . "," .
108  $ilDB->quote($a_hide, "integer") . ")";
109 
110  $ilDB->manipulate($q);
111  foreach ($a_parameters as $k => $v) {
112  $spid = $ilDB->nextId("style_parameter");
113  $q = "INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value)" .
114  " VALUES (" .
115  $ilDB->quote($spid, "integer") . "," .
116  $ilDB->quote($rec["obj_id"], "integer") . "," .
117  $ilDB->quote($a_type, "text") . "," .
118  $ilDB->quote($a_class, "text") . "," .
119  $ilDB->quote($a_tag, "text") . "," .
120  $ilDB->quote($k, "text") . "," .
121  $ilDB->quote($v, "text") .
122  ")";
123 
124  $ilDB->manipulate($q);
125  }
126  }
127  }
128  }
129 }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
static copyStyleClass($a_orig_class, $a_class, $a_type, $a_tag, $a_hide=0)
Create style class GlossaryLink, link, IntLink.
addStyleClass($a_class, $a_type, $a_tag, $a_parameters="", $a_hide=0)
Add style class.
global $ilDB