ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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

Member Function Documentation

◆ determineClassFileIds()

ilCtrlStructureReader::determineClassFileIds ( )

Determine class file IDS.

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

285 {
286 global $ilDB;
287
288 $ilDB->manipulate(
289 "UPDATE ctrl_classfile SET " .
290 " cid = " . $ilDB->quote("", "text")
291 );
292 $set = $ilDB->query("SELECT * FROM ctrl_classfile ");
293 $cnt = 1;
294 while ($rec = $ilDB->fetchAssoc($set)) {
295 $cid = base_convert((string) $cnt, 10, 36);
296 $ilDB->manipulate(
297 "UPDATE ctrl_classfile SET " .
298 " cid = " . $ilDB->quote($cid, "text") .
299 " WHERE class = " . $ilDB->quote($rec["class"], "text")
300 );
301 $cnt++;
302 }
303 }
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 echo "Error Cannot write client.ini.file.";
48 }
49 //$this->get_structure = true;
50 }

References $ilDB.

◆ read()

ilCtrlStructureReader::read (   $a_cdir)

read structure into internal variables

@access private

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

110 {
111 global $ilDB, $lng;
112
113 // check wether $a_cdir is a directory
114 if (!@is_dir($a_cdir)) {
115 return false;
116 }
117
118 // read current directory
119 $dir = opendir($a_cdir);
120
121 while ($file = readdir($dir)) {
122 if ($file != "." and
123 $file != "..") {
124 // directories
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);
129 }
130 }
131
132 // files
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");
136 //echo "<br>".$a_cdir."/".$file;
137 while (!feof($handle)) {
138 $line = fgets($handle, 4096);
139
140 // handle @ilctrl_calls
141 $pos = strpos(strtolower($line), "@ilctrl_calls");
142 if (is_int($pos)) {
143 $com = substr($line, $pos + 14);
144 $pos2 = strpos($com, ":");
145 if (is_int($pos2)) {
146 $com_arr = explode(":", $com);
147 $parent = strtolower(trim($com_arr[0]));
148
149 // check file duplicates
150 if ($parent != "" && isset($this->class_script[$parent]) &&
151 $this->class_script[$parent] != $a_cdir . "/" . $file) {
152 // delete all class to file assignments
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));
158 }
159
160 // delete all call entries
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");
165 }
166
167 throw new \Exception(
168 sprintf(
169 $lng->txt("duplicate_ctrl"),
170 $parent,
171 $this->class_script[$parent],
172 $a_cdir . "/" . $file
173 )
174 );
175 }
176
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;
183 }
184 }
185 }
186 }
187
188 // handle isCalledBy comments
189 $pos = strpos(strtolower($line), "@ilctrl_iscalledby");
190 if (is_int($pos)) {
191 $com = substr($line, $pos + 19);
192 $pos2 = strpos($com, ":");
193 if (is_int($pos2)) {
194 $com_arr = explode(":", $com);
195 $child = strtolower(trim($com_arr[0]));
196 $this->class_script[$child] = $a_cdir . "/" . $file;
197
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;
203 }
204 }
205 }
206 }
207
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;
213 //echo "<br>".$cl."-".$this->class_script[$cl]."-";
214 }
215 }
216 }
217 fclose($handle);
218 }
219 }
220 }
221 }
222 }
sprintf('%.4f', $callTime)
read($a_cdir)
read structure into internal variables
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res

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

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 55 of file class.ilCtrlStructureReader.php.

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

References $ilDB, determineClassFileIds(), ilCachedCtrl\flush(), 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 229 of file class.ilCtrlStructureReader.php.

230 {
231 global $ilDB;
232
233 // delete all class to file assignments
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));
239 }
240
241 // delete all call entries
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));
247 }
248
249 foreach ($this->class_script as $class => $script) {
250 $file = substr($script, strlen($this->start_dir) + 1);
251
252 // store class to file assignment
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")
260 ));
261 }
262 //$this->class_childs[$parent][] = $child;
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))) {
267 // store call entry
268 $ilDB->manipulate(sprintf(
269 "INSERT INTO ctrl_calls (parent, child, comp_prefix) " .
270 "VALUES (%s,%s,%s)",
271 $ilDB->quote($parent, "text"),
272 $ilDB->quote($child, "text"),
273 $ilDB->quote($this->comp_prefix, "text")
274 ));
275 }
276 }
277 }
278 }
279 }

References $file, $ilDB, and sprintf.

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: