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
00061
00062
00063
00064
00065
00066
00067
00068
00069 }
00070
00076 function read($a_cdir)
00077 {
00078
00079 if (!@is_dir($a_cdir))
00080 {
00081 return false;
00082 }
00083
00084
00085 $dir = opendir($a_cdir);
00086
00087 while($file = readdir($dir))
00088 {
00089 if ($file != "." and
00090 $file != "..")
00091 {
00092
00093 if (@is_dir($a_cdir."/".$file))
00094 {
00095 if ($a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/data")
00096 {
00097 $this->read($a_cdir."/".$file);
00098 }
00099 }
00100
00101
00102 if (@is_file($a_cdir."/".$file))
00103 {
00104 if (eregi("^class.*php$", $file))
00105 {
00106 $handle = fopen($a_cdir."/".$file, "r");
00107 while (!feof($handle)) {
00108 $line = fgets($handle, 4096);
00109 $pos = strpos(strtolower($line), "@ilctrl_calls");
00110 if (is_int($pos))
00111 {
00112 $com = substr($line, $pos + 14);
00113 $pos2 = strpos($com, ":");
00114 if (is_int($pos2))
00115 {
00116 $com_arr = explode(":", $com);
00117 $parent = strtolower(trim($com_arr[0]));
00118 $this->class_script[$parent] = $a_cdir."/".$file;
00119 $childs = explode(",", $com_arr[1]);
00120 foreach($childs as $child)
00121 {
00122 $child = trim(strtolower($child));
00123 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
00124 {
00125 $this->class_childs[$parent][] = $child;
00126 }
00127 }
00128 }
00129 }
00130 }
00131 fclose($handle);
00132 }
00133 }
00134 }
00135 }
00136 }
00137
00143 function store($a_cdir = "./..")
00144 {
00145 global $ilDB;
00146
00147
00148 $q = "DELETE FROM ctrl_classfile";
00149 $ilDB->query($q);
00150
00151
00152 $q = "DELETE FROM ctrl_calls";
00153 $ilDB->query($q);
00154
00155 foreach($this->class_script as $class => $script)
00156 {
00157 $file = substr($script, strlen(ILIAS_ABSOLUTE_PATH) + 1);
00158
00159
00160 $q = "INSERT INTO ctrl_classfile (class, file) VALUES".
00161 "(".$ilDB->quote($class).",".$ilDB->quote($file).")";
00162 $ilDB->query($q);
00163
00164 if (is_array($this->class_childs[$class]))
00165 {
00166 foreach($this->class_childs[$class] as $child)
00167 {
00168
00169 $q = "INSERT INTO ctrl_calls (parent, child) VALUES".
00170 "(".$ilDB->quote($class).",".$ilDB->quote($child).")";
00171 $ilDB->query($q);
00172 }
00173 }
00174 }
00175
00176 }
00177
00178 }