21 $this->class_script = array();
22 $this->class_childs = array();
23 $this->executed =
false;
24 $this->ini = $a_ini_file;
29 $this->ini = $a_ini_file;
34 $this->err_object =& $err;
44 $this->ini->setVariable(
"db",
"structure_reload",
"1");
46 if ($this->ini->readVariable(
"db",
"structure_reload") !=
"1")
48 echo
"Error Cannot write client.ini.file.";
56 function readStructure($a_force =
false, $a_dir =
"", $a_comp_prefix =
"",
61 if (!$a_force && $this->ini->readVariable(
"db",
"structure_reload") !=
"1")
66 require_once(
'./Services/UICore/classes/class.ilCachedCtrl.php');
68 require_once(
'./Services/GlobalCache/classes/class.ilGlobalCache.php');
69 ilGlobalCache::flushAll();
72 $this->comp_prefix = $a_comp_prefix;
75 $this->plugin_path = $a_plugin_path;
87 $this->start_dir = $a_dir;
92 $this->executed =
true;
95 $this->ini->setVariable(
"db",
"structure_reload",
"0");
103 include_once(
"./Services/UICore/classes/class.ilCtrl.php");
118 if (!@is_dir($a_cdir))
124 $dir = opendir($a_cdir);
126 while(
$file = readdir($dir))
132 if (@is_dir($a_cdir.
"/".
$file))
142 if (@is_file($a_cdir.
"/".
$file))
144 if (eregi(
"^class.*php$",
$file) || eregi(
"^ilSCORM13Player.php$",
$file))
146 $handle = fopen($a_cdir.
"/".
$file,
"r");
148 while (!feof($handle)) {
149 $line = fgets($handle, 4096);
152 $pos = strpos(strtolower($line),
"@ilctrl_calls");
155 $com = substr($line, $pos + 14);
156 $pos2 = strpos($com,
":");
159 $com_arr = explode(
":", $com);
160 $parent = strtolower(trim($com_arr[0]));
163 if ($parent !=
"" && isset($this->class_script[$parent]) &&
164 $this->class_script[$parent] != $a_cdir.
"/".
$file)
167 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
168 $ilDB->quote($this->comp_prefix,
"text"));
169 if ($this->comp_prefix ==
"")
171 $ilDB->manipulate($q =
"DELETE FROM ctrl_classfile WHERE ".
172 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
176 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
177 $ilDB->quote($this->comp_prefix,
"text"));
178 if ($this->comp_prefix ==
"")
180 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix IS NULL");
183 $this->err_object->raiseError(
184 sprintf($lng->txt(
"duplicate_ctrl"),
186 $this->class_script[$parent],
188 , $this->err_object->MESSAGE);
191 $this->class_script[$parent] = $a_cdir.
"/".
$file;
192 $childs = explode(
",", $com_arr[1]);
193 foreach($childs as $child)
195 $child = trim(strtolower($child));
196 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
198 $this->class_childs[$parent][] = $child;
205 $pos = strpos(strtolower($line),
"@ilctrl_iscalledby");
208 $com = substr($line, $pos + 19);
209 $pos2 = strpos($com,
":");
212 $com_arr = explode(
":", $com);
213 $child = strtolower(trim($com_arr[0]));
214 $this->class_script[$child] = $a_cdir.
"/".
$file;
216 $parents = explode(
",", $com_arr[1]);
217 foreach($parents as $parent)
219 $parent = trim(strtolower($parent));
220 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
222 $this->class_childs[$parent][] = $child;
228 if (eregi(
"^class\.(.*GUI)\.php$",
$file,
$res))
230 $cl = strtolower(
$res[1]);
231 $pos = strpos(strtolower($line),
"class ".$cl);
232 if (is_int($pos) && $this->class_script[$cl] ==
"")
234 $this->class_script[$cl] = $a_cdir.
"/".
$file;
256 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
257 $ilDB->quote($this->comp_prefix,
"text"));
258 if ($this->comp_prefix ==
"")
260 $ilDB->manipulate($q =
"DELETE FROM ctrl_classfile WHERE ".
261 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
265 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
266 $ilDB->quote($this->comp_prefix,
"text"));
267 if ($this->comp_prefix ==
"")
269 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE ".
270 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
273 foreach($this->class_script as $class => $script)
275 $file = substr($script, strlen($this->start_dir) + 1);
278 $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) ".
279 " VALUES (%s,%s,%s,%s)",
280 $ilDB->quote($class,
"text"),
281 $ilDB->quote(
$file,
"text"),
282 $ilDB->quote($this->comp_prefix,
"text"),
283 $ilDB->quote($this->plugin_path,
"text")
287 foreach($this->class_childs as $parent => $v)
289 if (is_array($this->class_childs[$parent]))
291 foreach($this->class_childs[$parent] as $child)
294 $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_calls (parent, child, comp_prefix) ".
296 $ilDB->quote($parent,
"text"),
297 $ilDB->quote($child,
"text"),
298 $ilDB->quote($this->comp_prefix,
"text")));
312 $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
313 " cid = ".$ilDB->quote(
"",
"text")
315 $set = $ilDB->query(
"SELECT * FROM ctrl_classfile ");
317 while ($rec = $ilDB->fetchAssoc($set))
319 $cid = base_convert((
string) $cnt, 10, 36);
320 $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
321 " cid = ".$ilDB->quote($cid,
"text").
322 " WHERE class = ".$ilDB->quote($rec[
"class"],
"text")