Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 class ilCtrlStructureReader
00035 {
00036 var $class_script;
00037 var $class_childs;
00038 var $executed;
00039
00040 function ilCtrlStructureReader()
00041 {
00042 $this->class_script = array();
00043 $this->class_childs = array();
00044 $this->executed = false;
00045 }
00046
00050 function getStructure()
00051 {
00052
00053 if (!$this->executed)
00054 {
00055 $this->read(ILIAS_ABSOLUTE_PATH);
00056 $this->store();
00057 $this->executed = true;
00058 }
00059 }
00060
00066 function read($a_cdir)
00067 {
00068
00069 if (!@is_dir($a_cdir))
00070 {
00071 return false;
00072 }
00073
00074
00075 $dir = opendir($a_cdir);
00076
00077 while($file = readdir($dir))
00078 {
00079 if ($file != "." and
00080 $file != "..")
00081 {
00082
00083 if (@is_dir($a_cdir."/".$file))
00084 {
00085 if ($a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/data")
00086 {
00087 $this->read($a_cdir."/".$file);
00088 }
00089 }
00090
00091
00092 if (@is_file($a_cdir."/".$file))
00093 {
00094 if (eregi("^class.*php$", $file))
00095 {
00096 $handle = fopen($a_cdir."/".$file, "r");
00097 while (!feof($handle)) {
00098 $line = fgets($handle, 4096);
00099 $pos = strpos(strtolower($line), "@ilctrl_calls");
00100 if (is_int($pos))
00101 {
00102 $com = substr($line, $pos + 14);
00103 $pos2 = strpos($com, ":");
00104 if (is_int($pos2))
00105 {
00106 $com_arr = explode(":", $com);
00107 $parent = strtolower(trim($com_arr[0]));
00108 $this->class_script[$parent] = $a_cdir."/".$file;
00109 $childs = explode(",", $com_arr[1]);
00110 foreach($childs as $child)
00111 {
00112 $child = trim(strtolower($child));
00113 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
00114 {
00115 $this->class_childs[$parent][] = $child;
00116 }
00117 }
00118 }
00119 }
00120 }
00121 fclose($handle);
00122 }
00123 }
00124 }
00125 }
00126 }
00127
00133 function store($a_cdir = "./..")
00134 {
00135 global $ilDB;
00136
00137
00138 $q = "DELETE FROM ctrl_classfile";
00139 $ilDB->query($q);
00140
00141
00142 $q = "DELETE FROM ctrl_calls";
00143 $ilDB->query($q);
00144
00145 foreach($this->class_script as $class => $script)
00146 {
00147 $file = substr($script, strlen(ILIAS_ABSOLUTE_PATH) + 1);
00148
00149
00150 $q = "INSERT INTO ctrl_classfile (class, file) VALUES".
00151 "(".$ilDB->quote($class).",".$ilDB->quote($file).")";
00152 $ilDB->query($q);
00153
00154 if (is_array($this->class_childs[$class]))
00155 {
00156 foreach($this->class_childs[$class] as $child)
00157 {
00158
00159 $q = "INSERT INTO ctrl_calls (parent, child) VALUES".
00160 "(".$ilDB->quote($class).",".$ilDB->quote($child).")";
00161 $ilDB->query($q);
00162 }
00163 }
00164 }
00165
00166 }
00167
00168 }