ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCtrlStructureReader Class Reference

Class ilCtrlStructureReader. More...

+ Collaboration diagram for ilCtrlStructureReader:

Public Member Functions

 __construct ()
 
 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.

Constructor & Destructor Documentation

◆ __construct()

ilCtrlStructureReader::__construct ( )

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

References array.

20  {
21  $this->class_script = array();
22  $this->class_childs = array();
23  $this->executed = false;
24  $this->ini = $a_ini_file;
25  }
Create styles array
The data for the language used.

Member Function Documentation

◆ determineClassFileIds()

ilCtrlStructureReader::determineClassFileIds ( )

Determine class file IDS.

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

References $ilDB.

Referenced by readStructure().

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

References $ilDB.

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  }
global $ilDB

◆ read()

ilCtrlStructureReader::read (   $a_cdir)

read structure into internal variables

private

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

References $file, $ilDB, $lng, and $res.

Referenced by readStructure().

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 (preg_match("~^class.*php$~i", $file) || preg_match("~^ilSCORM13Player.php$~i", $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  throw new \Exception(
184  sprintf(
185  $lng->txt("duplicate_ctrl"),
186  $parent,
187  $this->class_script[$parent],
188  $a_cdir."/".$file
189  )
190  );
191  }
192 
193  $this->class_script[$parent] = $a_cdir."/".$file;
194  $childs = explode(",", $com_arr[1]);
195  foreach($childs as $child)
196  {
197  $child = trim(strtolower($child));
198  if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
199  {
200  $this->class_childs[$parent][] = $child;
201  }
202  }
203  }
204  }
205 
206  // handle isCalledBy comments
207  $pos = strpos(strtolower($line), "@ilctrl_iscalledby");
208  if (is_int($pos))
209  {
210  $com = substr($line, $pos + 19);
211  $pos2 = strpos($com, ":");
212  if (is_int($pos2))
213  {
214  $com_arr = explode(":", $com);
215  $child = strtolower(trim($com_arr[0]));
216  $this->class_script[$child] = $a_cdir."/".$file;
217 
218  $parents = explode(",", $com_arr[1]);
219  foreach($parents as $parent)
220  {
221  $parent = trim(strtolower($parent));
222  if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
223  {
224  $this->class_childs[$parent][] = $child;
225  }
226  }
227  }
228  }
229 
230  if (preg_match("~^class\.(.*GUI)\.php$~i", $file, $res))
231  {
232  $cl = strtolower($res[1]);
233  $pos = strpos(strtolower($line), "class ".$cl);
234  if (is_int($pos) && $this->class_script[$cl] == "")
235  {
236  $this->class_script[$cl] = $a_cdir."/".$file;
237  //echo "<br>".$cl."-".$this->class_script[$cl]."-";
238  }
239  }
240  }
241  fclose($handle);
242  }
243  }
244  }
245  }
246  }
global $lng
Definition: privfeed.php:17
global $ilDB
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
read($a_cdir)
read structure into internal variables
+ 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.

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

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;
83  $this->read(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  }
This class provides processing control methods.
determineClassFileIds()
Determine class file IDS.
store($a_cdir="./..")
read structure into internal variables
global $ilDB
read($a_cdir)
read structure into internal variables
+ 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

private

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

References $file, and $ilDB.

Referenced by readStructure().

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