41 $this->class_script = array();
42 $this->class_childs = array();
43 $this->executed =
false;
48 $this->err_object =& $err;
56 $this->get_structure =
true;
62 function readStructure($a_force =
false, $a_dir =
"", $a_comp_prefix =
"")
65 if (!$this->get_structure && !$a_force)
71 $this->comp_prefix = $a_comp_prefix;
83 $this->start_dir = $a_dir;
87 $this->executed =
true;
93 require_once(
"../classes/class.ilCtrl.php");
95 $ctrl->storeCommonStructures();
108 if (!@is_dir($a_cdir))
114 $dir = opendir($a_cdir);
122 if (@is_dir($a_cdir.
"/".
$file))
132 if (@is_file($a_cdir.
"/".
$file))
134 if (eregi(
"^class.*php$",
$file))
136 $handle = fopen($a_cdir.
"/".
$file,
"r");
138 while (!feof($handle)) {
139 $line = fgets($handle, 4096);
142 $pos = strpos(strtolower($line),
"@ilctrl_calls");
145 $com = substr($line, $pos + 14);
146 $pos2 = strpos($com,
":");
149 $com_arr = explode(
":", $com);
150 $parent = strtolower(trim($com_arr[0]));
153 if ($parent !=
"" && isset($this->class_script[$parent]) &&
154 $this->class_script[$parent] != $a_cdir.
"/".
$file)
157 $q =
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
158 $ilDB->quote($this->comp_prefix);
162 $q =
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
163 $ilDB->quote($this->comp_prefix);
166 $this->err_object->raiseError(
167 sprintf($lng->txt(
"duplicate_ctrl"),
169 $this->class_script[$parent],
171 , $this->err_object->MESSAGE);
174 $this->class_script[$parent] = $a_cdir.
"/".
$file;
175 $childs = explode(
",", $com_arr[1]);
176 foreach($childs as $child)
178 $child = trim(strtolower($child));
179 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
181 $this->class_childs[$parent][] = $child;
188 $pos = strpos(strtolower($line),
"@ilctrl_iscalledby");
191 $com = substr($line, $pos + 19);
192 $pos2 = strpos($com,
":");
195 $com_arr = explode(
":", $com);
196 $child = strtolower(trim($com_arr[0]));
197 $this->class_script[$child] = $a_cdir.
"/".
$file;
199 $parents = explode(
",", $com_arr[1]);
200 foreach($parents as $parent)
202 $parent = trim(strtolower($parent));
203 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
205 $this->class_childs[$parent][] = $child;
228 $q =
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
229 $ilDB->quote($this->comp_prefix);
233 $q =
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
234 $ilDB->quote($this->comp_prefix);
237 foreach($this->class_script as $class => $script)
239 $file = substr($script, strlen($this->start_dir) + 1);
242 $q =
"INSERT INTO ctrl_classfile (class, file, comp_prefix) VALUES".
243 "(".$ilDB->quote($class).
",".$ilDB->quote(
$file).
244 ",".$ilDB->quote($this->comp_prefix).
")";
248 foreach($this->class_childs as $parent => $v)
250 if (is_array($this->class_childs[$parent]))
252 foreach($this->class_childs[$parent] as $child)
255 $q =
"INSERT INTO ctrl_calls (parent, child, comp_prefix) VALUES".
256 "(".$ilDB->quote($parent).
",".$ilDB->quote($child).
257 ",".$ilDB->quote($this->comp_prefix).
")";