ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilCtrlStructureReader Class Reference

Class ilCtrlStructureReader. More...

+ Collaboration diagram for ilCtrlStructureReader:

Public Member Functions

 ilCtrlStructureReader ()
 
 setIniFile ($a_ini_file)
 
 setErrorObject (&$err)
 
 getStructure ()
 parse code files and store call structure in db More...
 
 readStructure ($a_force=false, $a_dir="", $a_comp_prefix="", $a_plugin_path="")
 read structure More...
 
 read ($a_cdir)
 read structure into internal variables More...
 
 store ($a_cdir="./..")
 read structure into internal variables More...
 
 determineClassFileIds ()
 Determine class file IDS. More...
 

Data Fields

 $class_script
 
 $class_childs
 
 $executed
 

Detailed Description

Class ilCtrlStructureReader.

Reads call structure of classes into db

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilCtrlStructureReader.php.

Member Function Documentation

◆ determineClassFileIds()

ilCtrlStructureReader::determineClassFileIds ( )

Determine class file IDS.

Definition at line 311 of file class.ilCtrlStructureReader.php.

312 {
313 global $ilDB;
314
315 $ilDB->manipulate("UPDATE ctrl_classfile SET ".
316 " cid = ".$ilDB->quote("", "text")
317 );
318 $set = $ilDB->query("SELECT * FROM ctrl_classfile ");
319 $cnt = 1;
320 while ($rec = $ilDB->fetchAssoc($set))
321 {
322 $cid = base_convert((string) $cnt, 10, 36);
323 $ilDB->manipulate("UPDATE ctrl_classfile SET ".
324 " cid = ".$ilDB->quote($cid, "text").
325 " WHERE class = ".$ilDB->quote($rec["class"], "text")
326 );
327 $cnt++;
328 }
329 }
global $ilDB

References $ilDB.

Referenced by readStructure().

+ Here is the caller graph for this function:

◆ getStructure()

ilCtrlStructureReader::getStructure ( )

parse code files and store call structure in db

Definition at line 40 of file class.ilCtrlStructureReader.php.

41 {
42 global $ilDB;
43
44 $this->ini->setVariable("db","structure_reload", "1");
45 $this->ini->write();
46 if ($this->ini->readVariable("db","structure_reload") != "1")
47 {
48 echo "Error Cannot write client.ini.file.";
49 }
50 //$this->get_structure = true;
51 }

References $ilDB.

◆ ilCtrlStructureReader()

ilCtrlStructureReader::ilCtrlStructureReader ( )

Definition at line 19 of file class.ilCtrlStructureReader.php.

20 {
21 $this->class_script = array();
22 $this->class_childs = array();
23 $this->executed = false;
24 $this->ini = $a_ini_file;
25 }

◆ read()

ilCtrlStructureReader::read (   $a_cdir)

read structure into internal variables

@access private

Definition at line 113 of file class.ilCtrlStructureReader.php.

114 {
115 global $ilDB, $lng;
116
117 // check wether $a_cdir is a directory
118 if (!@is_dir($a_cdir))
119 {
120 return false;
121 }
122
123 // read current directory
124 $dir = opendir($a_cdir);
125
126 while($file = readdir($dir))
127 {
128 if ($file != "." and
129 $file != "..")
130 {
131 // directories
132 if (@is_dir($a_cdir."/".$file))
133 {
134 if ($a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/data" &&
135 $a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/Customizing")
136 {
137 $this->read($a_cdir."/".$file);
138 }
139 }
140
141 // files
142 if (@is_file($a_cdir."/".$file))
143 {
144 if (eregi("^class.*php$", $file) || eregi("^ilSCORM13Player.php$", $file))
145 {
146 $handle = fopen($a_cdir."/".$file, "r");
147//echo "<br>".$a_cdir."/".$file;
148 while (!feof($handle)) {
149 $line = fgets($handle, 4096);
150
151 // handle @ilctrl_calls
152 $pos = strpos(strtolower($line), "@ilctrl_calls");
153 if (is_int($pos))
154 {
155 $com = substr($line, $pos + 14);
156 $pos2 = strpos($com, ":");
157 if (is_int($pos2))
158 {
159 $com_arr = explode(":", $com);
160 $parent = strtolower(trim($com_arr[0]));
161
162 // check file duplicates
163 if ($parent != "" && isset($this->class_script[$parent]) &&
164 $this->class_script[$parent] != $a_cdir."/".$file)
165 {
166 // delete all class to file assignments
167 $ilDB->manipulate("DELETE FROM ctrl_classfile WHERE comp_prefix = ".
168 $ilDB->quote($this->comp_prefix, "text"));
169 if ($this->comp_prefix == "")
170 {
171 $ilDB->manipulate($q = "DELETE FROM ctrl_classfile WHERE ".
172 $ilDB->equals("comp_prefix", "", "text", true));
173 }
174
175 // delete all call entries
176 $ilDB->manipulate("DELETE FROM ctrl_calls WHERE comp_prefix = ".
177 $ilDB->quote($this->comp_prefix, "text"));
178 if ($this->comp_prefix == "")
179 {
180 $ilDB->manipulate("DELETE FROM ctrl_calls WHERE comp_prefix IS NULL");
181 }
182
183 $this->err_object->raiseError(
184 sprintf($lng->txt("duplicate_ctrl"),
185 $parent,
186 $this->class_script[$parent],
187 $a_cdir."/".$file)
188 , $this->err_object->MESSAGE);
189 }
190
191 $this->class_script[$parent] = $a_cdir."/".$file;
192 $childs = explode(",", $com_arr[1]);
193 foreach($childs as $child)
194 {
195 $child = trim(strtolower($child));
196 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
197 {
198 $this->class_childs[$parent][] = $child;
199 }
200 }
201 }
202 }
203
204 // handle isCalledBy comments
205 $pos = strpos(strtolower($line), "@ilctrl_iscalledby");
206 if (is_int($pos))
207 {
208 $com = substr($line, $pos + 19);
209 $pos2 = strpos($com, ":");
210 if (is_int($pos2))
211 {
212 $com_arr = explode(":", $com);
213 $child = strtolower(trim($com_arr[0]));
214 $this->class_script[$child] = $a_cdir."/".$file;
215
216 $parents = explode(",", $com_arr[1]);
217 foreach($parents as $parent)
218 {
219 $parent = trim(strtolower($parent));
220 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
221 {
222 $this->class_childs[$parent][] = $child;
223 }
224 }
225 }
226 }
227
228 if (eregi("^class\.(.*GUI)\.php$", $file, $res))
229 {
230 $cl = strtolower($res[1]);
231 $pos = strpos(strtolower($line), "class ".$cl);
232 if (is_int($pos) && $this->class_script[$cl] == "")
233 {
234 $this->class_script[$cl] = $a_cdir."/".$file;
235 //echo "<br>".$cl."-".$this->class_script[$cl]."-";
236 }
237 }
238 }
239 fclose($handle);
240 }
241 }
242 }
243 }
244 }
print $file
read($a_cdir)
read structure into internal variables
global $lng
Definition: privfeed.php:40
const ILIAS_ABSOLUTE_PATH

References $file, $ilDB, $lng, $res, ILIAS_ABSOLUTE_PATH, and read().

Referenced by read(), and readStructure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readStructure()

ilCtrlStructureReader::readStructure (   $a_force = false,
  $a_dir = "",
  $a_comp_prefix = "",
  $a_plugin_path = "" 
)

read structure

Definition at line 56 of file class.ilCtrlStructureReader.php.

58 {
59 global $ilDB;
60
61 if (!$a_force && $this->ini->readVariable("db","structure_reload") != "1")
62 {
63 return;
64 }
65
66 require_once('./Services/UICore/classes/class.ilCachedCtrl.php');
68 require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
69 ilGlobalCache::flushAll();
70
71 // prefix for component
72 $this->comp_prefix = $a_comp_prefix;
73
74 // plugin path
75 $this->plugin_path = $a_plugin_path;
76
77 // only run one time per db_update request
78 if (!$this->executed)
79 {
80 if ($a_dir == "")
81 {
82 $this->start_dir = ILIAS_ABSOLUTE_PATH;
84 }
85 else
86 {
87 $this->start_dir = $a_dir;
88 $this->read($a_dir);
89 }
90 $this->store();
91 $this->determineClassFileIds();
92 $this->executed = true;
93 if (!$a_force)
94 {
95 $this->ini->setVariable("db","structure_reload", "0");
96 $this->ini->write();
97 }
98 }
99
100 // read module information
101 // not clear whether this is a good place for module reading info
102 // or not
103 include_once("./Services/UICore/classes/class.ilCtrl.php");
104 $ctrl = new ilCtrl();
105// $ctrl->storeCommonStructures();
106 }
determineClassFileIds()
Determine class file IDS.
store($a_cdir="./..")
read structure into internal variables
This class provides processing control methods.

References $ilDB, determineClassFileIds(), ilCachedCtrl\flush(), ILIAS_ABSOLUTE_PATH, read(), and store().

+ Here is the call graph for this function:

◆ setErrorObject()

ilCtrlStructureReader::setErrorObject ( $err)

Definition at line 32 of file class.ilCtrlStructureReader.php.

33 {
34 $this->err_object =& $err;
35 }

◆ setIniFile()

ilCtrlStructureReader::setIniFile (   $a_ini_file)

Definition at line 27 of file class.ilCtrlStructureReader.php.

28 {
29 $this->ini = $a_ini_file;
30 }

◆ store()

ilCtrlStructureReader::store (   $a_cdir = "./..")

read structure into internal variables

@access private

Definition at line 251 of file class.ilCtrlStructureReader.php.

252 {
253 global $ilDB;
254
255 // delete all class to file assignments
256 $ilDB->manipulate("DELETE FROM ctrl_classfile WHERE comp_prefix = ".
257 $ilDB->quote($this->comp_prefix, "text"));
258 if ($this->comp_prefix == "")
259 {
260 $ilDB->manipulate($q = "DELETE FROM ctrl_classfile WHERE ".
261 $ilDB->equals("comp_prefix", "", "text", true));
262 }
263
264 // delete all call entries
265 $ilDB->manipulate("DELETE FROM ctrl_calls WHERE comp_prefix = ".
266 $ilDB->quote($this->comp_prefix, "text"));
267 if ($this->comp_prefix == "")
268 {
269 $ilDB->manipulate("DELETE FROM ctrl_calls WHERE ".
270 $ilDB->equals("comp_prefix", "", "text", true));
271 }
272
273 foreach($this->class_script as $class => $script)
274 {
275 $file = substr($script, strlen($this->start_dir) + 1);
276
277 // store class to file assignment
278 $ilDB->manipulate(sprintf("INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) ".
279 " VALUES (%s,%s,%s,%s)",
280 $ilDB->quote($class, "text"),
281 $ilDB->quote($file, "text"),
282 $ilDB->quote($this->comp_prefix, "text"),
283 $ilDB->quote($this->plugin_path, "text")
284 ));
285 }
286//$this->class_childs[$parent][] = $child;
287 foreach($this->class_childs as $parent => $v)
288 {
289 if (is_array($this->class_childs[$parent]))
290 {
291 foreach($this->class_childs[$parent] as $child)
292 {
293 if(strlen(trim($child)) and strlen(trim($parent)))
294 {
295 // store call entry
296 $ilDB->manipulate(sprintf("INSERT INTO ctrl_calls (parent, child, comp_prefix) ".
297 "VALUES (%s,%s,%s)",
298 $ilDB->quote($parent, "text"),
299 $ilDB->quote($child, "text"),
300 $ilDB->quote($this->comp_prefix, "text")));
301 }
302 }
303 }
304 }
305
306 }

References $file, and $ilDB.

Referenced by readStructure().

+ Here is the caller graph for this function:

Field Documentation

◆ $class_childs

ilCtrlStructureReader::$class_childs

Definition at line 16 of file class.ilCtrlStructureReader.php.

◆ $class_script

ilCtrlStructureReader::$class_script

Definition at line 15 of file class.ilCtrlStructureReader.php.

◆ $executed

ilCtrlStructureReader::$executed

Definition at line 17 of file class.ilCtrlStructureReader.php.


The documentation for this class was generated from the following file: