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;
82 $this->start_dir = ILIAS_ABSOLUTE_PATH;
83 $this->
read(ILIAS_ABSOLUTE_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))
134 if ($a_cdir.
"/".
$file != ILIAS_ABSOLUTE_PATH.
"/data" &&
135 $a_cdir.
"/".
$file != ILIAS_ABSOLUTE_PATH.
"/Customizing")
142 if (@is_file($a_cdir.
"/".
$file))
144 if (preg_match(
"~^class.*php$~i",
$file) || preg_match(
"~^ilSCORM13Player.php$~i",
$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 throw new \Exception(
185 $lng->txt(
"duplicate_ctrl"),
187 $this->class_script[$parent],
193 $this->class_script[$parent] = $a_cdir.
"/".
$file;
194 $childs = explode(
",", $com_arr[1]);
195 foreach($childs as $child)
197 $child = trim(strtolower($child));
198 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
200 $this->class_childs[$parent][] = $child;
207 $pos = strpos(strtolower($line),
"@ilctrl_iscalledby");
210 $com = substr($line, $pos + 19);
211 $pos2 = strpos($com,
":");
214 $com_arr = explode(
":", $com);
215 $child = strtolower(trim($com_arr[0]));
216 $this->class_script[$child] = $a_cdir.
"/".
$file;
218 $parents = explode(
",", $com_arr[1]);
219 foreach($parents as $parent)
221 $parent = trim(strtolower($parent));
222 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
224 $this->class_childs[$parent][] = $child;
230 if (preg_match(
"~^class\.(.*GUI)\.php$~i",
$file,
$res))
232 $cl = strtolower(
$res[1]);
233 $pos = strpos(strtolower($line),
"class ".$cl);
234 if (is_int($pos) && $this->class_script[$cl] ==
"")
236 $this->class_script[$cl] = $a_cdir.
"/".
$file;
258 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
259 $ilDB->quote($this->comp_prefix,
"text"));
260 if ($this->comp_prefix ==
"")
262 $ilDB->manipulate($q =
"DELETE FROM ctrl_classfile WHERE ".
263 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
267 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
268 $ilDB->quote($this->comp_prefix,
"text"));
269 if ($this->comp_prefix ==
"")
271 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE ".
272 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
275 foreach($this->class_script as $class => $script)
277 $file = substr($script, strlen($this->start_dir) + 1);
280 $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) ".
281 " VALUES (%s,%s,%s,%s)",
282 $ilDB->quote($class,
"text"),
283 $ilDB->quote(
$file,
"text"),
284 $ilDB->quote($this->comp_prefix,
"text"),
285 $ilDB->quote($this->plugin_path,
"text")
289 foreach($this->class_childs as $parent => $v)
291 if (is_array($this->class_childs[$parent]))
293 foreach($this->class_childs[$parent] as $child)
295 if(strlen(trim($child))
and strlen(trim($parent)))
298 $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_calls (parent, child, comp_prefix) ".
300 $ilDB->quote($parent,
"text"),
301 $ilDB->quote($child,
"text"),
302 $ilDB->quote($this->comp_prefix,
"text")));
317 $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
318 " cid = ".$ilDB->quote(
"",
"text")
320 $set = $ilDB->query(
"SELECT * FROM ctrl_classfile ");
322 while ($rec = $ilDB->fetchAssoc($set))
324 $cid = base_convert((
string) $cnt, 10, 36);
325 $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
326 " cid = ".$ilDB->quote($cid,
"text").
327 " WHERE class = ".$ilDB->quote($rec[
"class"],
"text")
This class provides processing control methods.
determineClassFileIds()
Determine class file IDS.
Class ilCtrlStructureReader.
getStructure()
parse code files and store call structure in db
Create styles array
The data for the language used.
store($a_cdir="./..")
read structure into internal variables
readStructure($a_force=false, $a_dir="", $a_comp_prefix="", $a_plugin_path="")
read structure
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
read($a_cdir)
read structure into internal variables