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") {
47 echo
"Error Cannot write client.ini.file.";
63 if (!$a_force && $this->ini->readVariable(
"db",
"structure_reload") !=
"1") {
67 require_once(
'./Services/UICore/classes/class.ilCachedCtrl.php');
69 require_once(
'./Services/GlobalCache/classes/class.ilGlobalCache.php');
70 ilGlobalCache::flushAll();
73 $this->comp_prefix = $a_comp_prefix;
76 $this->plugin_path = $a_plugin_path;
79 if (!$this->executed) {
81 $this->start_dir = ILIAS_ABSOLUTE_PATH;
82 $this->
read(ILIAS_ABSOLUTE_PATH);
84 $this->start_dir = $a_dir;
89 $this->executed =
true;
91 $this->ini->setVariable(
"db",
"structure_reload",
"0");
99 include_once(
"./Services/UICore/classes/class.ilCtrl.php");
114 if (!@is_dir($a_cdir)) {
119 $dir = opendir($a_cdir);
121 while (
$file = readdir($dir)) {
125 if (@is_dir($a_cdir .
"/" .
$file)) {
126 if ($a_cdir .
"/" . $file != ILIAS_ABSOLUTE_PATH .
"/data" &&
127 $a_cdir .
"/" . $file != ILIAS_ABSOLUTE_PATH .
"/Customizing") {
128 $this->
read($a_cdir .
"/" . $file);
133 if (@is_file($a_cdir .
"/" . $file)) {
134 if (preg_match(
"~^class.*php$~i", $file) || preg_match(
"~^ilSCORM13Player.php$~i", $file)) {
135 $handle = fopen($a_cdir .
"/" . $file,
"r");
137 while (!feof($handle)) {
138 $line = fgets($handle, 4096);
141 $pos = strpos(strtolower($line),
"@ilctrl_calls");
143 $com = substr($line, $pos + 14);
144 $pos2 = strpos($com,
":");
146 $com_arr = explode(
":", $com);
147 $parent = strtolower(trim($com_arr[0]));
150 if ($parent !=
"" && isset($this->class_script[$parent]) &&
151 $this->class_script[$parent] != $a_cdir .
"/" . $file) {
153 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = " .
154 $ilDB->quote($this->comp_prefix,
"text"));
155 if ($this->comp_prefix ==
"") {
156 $ilDB->manipulate($q =
"DELETE FROM ctrl_classfile WHERE " .
157 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
161 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = " .
162 $ilDB->quote($this->comp_prefix,
"text"));
163 if ($this->comp_prefix ==
"") {
164 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix IS NULL");
167 throw new \Exception(
169 $lng->txt(
"duplicate_ctrl"),
171 $this->class_script[$parent],
172 $a_cdir .
"/" .
$file 177 $this->class_script[$parent] = $a_cdir .
"/" .
$file;
178 $childs = explode(
",", $com_arr[1]);
179 foreach ($childs as $child) {
180 $child = trim(strtolower($child));
181 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent])) {
182 $this->class_childs[$parent][] = $child;
189 $pos = strpos(strtolower($line),
"@ilctrl_iscalledby");
191 $com = substr($line, $pos + 19);
192 $pos2 = strpos($com,
":");
194 $com_arr = explode(
":", $com);
195 $child = strtolower(trim($com_arr[0]));
196 $this->class_script[$child] = $a_cdir .
"/" .
$file;
198 $parents = explode(
",", $com_arr[1]);
199 foreach ($parents as $parent) {
200 $parent = trim(strtolower($parent));
201 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent])) {
202 $this->class_childs[$parent][] = $child;
208 if (preg_match(
"~^class\.(.*GUI)\.php$~i", $file,
$res)) {
209 $cl = strtolower(
$res[1]);
210 $pos = strpos(strtolower($line),
"class " . $cl);
211 if (is_int($pos) && $this->class_script[$cl] ==
"") {
212 $this->class_script[$cl] = $a_cdir .
"/" .
$file;
229 public function store($a_cdir =
"./..")
234 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = " .
235 $ilDB->quote($this->comp_prefix,
"text"));
236 if ($this->comp_prefix ==
"") {
237 $ilDB->manipulate($q =
"DELETE FROM ctrl_classfile WHERE " .
238 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
242 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = " .
243 $ilDB->quote($this->comp_prefix,
"text"));
244 if ($this->comp_prefix ==
"") {
245 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE " .
246 $ilDB->equals(
"comp_prefix",
"",
"text",
true));
249 foreach ($this->class_script as $class => $script) {
250 $file = substr($script, strlen($this->start_dir) + 1);
253 $ilDB->manipulate(sprintf(
254 "INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) " .
255 " VALUES (%s,%s,%s,%s)",
256 $ilDB->quote($class,
"text"),
257 $ilDB->quote(
$file,
"text"),
258 $ilDB->quote($this->comp_prefix,
"text"),
259 $ilDB->quote($this->plugin_path,
"text")
263 foreach ($this->class_childs as $parent => $v) {
264 if (is_array($this->class_childs[$parent])) {
265 foreach ($this->class_childs[$parent] as $child) {
266 if (strlen(trim($child)) and strlen(trim($parent))) {
268 $ilDB->manipulate(sprintf(
269 "INSERT INTO ctrl_calls (parent, child, comp_prefix) " .
271 $ilDB->quote($parent,
"text"),
272 $ilDB->quote($child,
"text"),
273 $ilDB->quote($this->comp_prefix,
"text")
289 "UPDATE ctrl_classfile SET " .
290 " cid = " . $ilDB->quote(
"",
"text")
292 $set = $ilDB->query(
"SELECT * FROM ctrl_classfile ");
294 while ($rec = $ilDB->fetchAssoc($set)) {
295 $cid = base_convert((
string) $cnt, 10, 36);
297 "UPDATE ctrl_classfile SET " .
298 " cid = " . $ilDB->quote($cid,
"text") .
299 " WHERE class = " . $ilDB->quote($rec[
"class"],
"text")
This class provides processing control methods.
determineClassFileIds()
Determine class file IDS.
readStructure( $a_force=false, $a_dir="", $a_comp_prefix="", $a_plugin_path="")
read structure
Class ilCtrlStructureReader.
foreach($_POST as $key=> $value) $res
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
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
read($a_cdir)
read structure into internal variables