21                 $this->class_script = array();
 
   22                 $this->class_childs = array();
 
   23                 $this->executed = 
false;
 
   24                 $this->ini = $a_ini_file;
 
   29                 $this->ini = $a_ini_file;
 
   34                 $this->err_object =& $err;
 
   44                 $this->ini->setVariable(
"db",
"structure_reload", 
"1");
 
   46                 if ($this->ini->readVariable(
"db",
"structure_reload") != 
"1")
 
   48                         echo 
"Error Cannot write client.ini.file.";
 
   56         function readStructure($a_force = 
false, $a_dir = 
"", $a_comp_prefix = 
"",
 
   61                 if (!$a_force && $this->ini->readVariable(
"db",
"structure_reload") != 
"1")
 
   67                 $this->comp_prefix = $a_comp_prefix;
 
   70                 $this->plugin_path = $a_plugin_path;
 
   82                                 $this->start_dir = $a_dir;
 
   87                         $this->executed = 
true;
 
   90                                 $this->ini->setVariable(
"db",
"structure_reload", 
"0");
 
   98                 include_once(
"./Services/UICore/classes/class.ilCtrl.php");
 
  113                 if (!@is_dir($a_cdir))
 
  119                 $dir = opendir($a_cdir);
 
  121                 while(
$file = readdir($dir))
 
  127                                 if (@is_dir($a_cdir.
"/".
$file))
 
  137                                 if (@is_file($a_cdir.
"/".
$file))
 
  139                                         if (eregi(
"^class.*php$", 
$file) || eregi(
"^ilSCORM13Player.php$", 
$file))
 
  141                                                 $handle = fopen($a_cdir.
"/".
$file, 
"r");
 
  143                                                 while (!feof($handle)) {
 
  144                                                         $line = fgets($handle, 4096);
 
  147                                                         $pos = strpos(strtolower($line), 
"@ilctrl_calls");
 
  150                                                                 $com = substr($line, $pos + 14);
 
  151                                                                 $pos2 = strpos($com, 
":");
 
  154                                                                         $com_arr = explode(
":", $com);
 
  155                                                                         $parent = strtolower(trim($com_arr[0]));
 
  158                                                                         if ($parent != 
"" && isset($this->class_script[$parent]) &&
 
  159                                                                                 $this->class_script[$parent] != $a_cdir.
"/".
$file)
 
  162                                                                                 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
 
  163                                                                                         $ilDB->quote($this->comp_prefix, 
"text"));
 
  164                                                                                 if ($this->comp_prefix == 
"")
 
  166                                                                                         $ilDB->manipulate($q = 
"DELETE FROM ctrl_classfile WHERE ".
 
  167                                                                                                 $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  171                                                                                 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
 
  172                                                                                         $ilDB->quote($this->comp_prefix, 
"text"));
 
  173                                                                                 if ($this->comp_prefix == 
"")
 
  175                                                                                         $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix IS NULL");
 
  178                                                                                 $this->err_object->raiseError(
 
  179                                                                                         sprintf($lng->txt(
"duplicate_ctrl"),
 
  181                                                                                                 $this->class_script[$parent],
 
  183                                                                                         , $this->err_object->MESSAGE);
 
  186                                                                         $this->class_script[$parent] = $a_cdir.
"/".
$file;
 
  187                                                                         $childs = explode(
",", $com_arr[1]);
 
  188                                                                         foreach($childs as $child)
 
  190                                                                                 $child = trim(strtolower($child));
 
  191                                                                                 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
 
  193                                                                                         $this->class_childs[$parent][] = $child;
 
  200                                                         $pos = strpos(strtolower($line), 
"@ilctrl_iscalledby");
 
  203                                                                 $com = substr($line, $pos + 19);
 
  204                                                                 $pos2 = strpos($com, 
":");
 
  207                                                                         $com_arr = explode(
":", $com);
 
  208                                                                         $child = strtolower(trim($com_arr[0]));
 
  209                                                                         $this->class_script[$child] = $a_cdir.
"/".
$file;
 
  211                                                                         $parents = explode(
",", $com_arr[1]);
 
  212                                                                         foreach($parents as $parent)
 
  214                                                                                 $parent = trim(strtolower($parent));
 
  215                                                                                 if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
 
  217                                                                                         $this->class_childs[$parent][] = $child;
 
  223                                                         if (eregi(
"^class\.(.*GUI)\.php$", 
$file, 
$res))
 
  225                                                                 $cl = strtolower(
$res[1]);
 
  226                                                                 $pos = strpos(strtolower($line), 
"class ".$cl);
 
  227                                                                 if (is_int($pos) && $this->class_script[$cl] == 
"")
 
  229                                                                         $this->class_script[$cl] = $a_cdir.
"/".
$file;
 
  251                 $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = ".
 
  252                         $ilDB->quote($this->comp_prefix, 
"text"));
 
  253                 if ($this->comp_prefix == 
"")
 
  255                         $ilDB->manipulate($q = 
"DELETE FROM ctrl_classfile WHERE ".
 
  256                                 $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  260                 $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = ".
 
  261                         $ilDB->quote($this->comp_prefix, 
"text"));
 
  262                 if ($this->comp_prefix == 
"")
 
  264                         $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE ".
 
  265                                 $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  268                 foreach($this->class_script as $class => $script)
 
  270                         $file = substr($script, strlen($this->start_dir) + 1);
 
  273                         $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) ".
 
  274                                 " VALUES (%s,%s,%s,%s)",
 
  275                                 $ilDB->quote($class, 
"text"),
 
  276                                 $ilDB->quote(
$file, 
"text"),
 
  277                                 $ilDB->quote($this->comp_prefix, 
"text"),
 
  278                                 $ilDB->quote($this->plugin_path, 
"text")
 
  282                 foreach($this->class_childs as $parent => $v)
 
  284                         if (is_array($this->class_childs[$parent]))
 
  286                                 foreach($this->class_childs[$parent] as $child)
 
  289                                         $ilDB->manipulate(sprintf(
"INSERT INTO ctrl_calls (parent, child, comp_prefix) ".
 
  291                                                 $ilDB->quote($parent, 
"text"),
 
  292                                                 $ilDB->quote($child, 
"text"),
 
  293                                                 $ilDB->quote($this->comp_prefix, 
"text")));
 
  307                 $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
 
  308                         " cid = ".$ilDB->quote(
"", 
"text")
 
  310                 $set = $ilDB->query(
"SELECT * FROM ctrl_classfile ");
 
  312                 while ($rec  = $ilDB->fetchAssoc($set))
 
  314                         $cid = base_convert((
string) $cnt, 10, 36);
 
  315                         $ilDB->manipulate(
"UPDATE ctrl_classfile SET ".
 
  316                                 " cid = ".$ilDB->quote($cid, 
"text").
 
  317                                 " WHERE class = ".$ilDB->quote($rec[
"class"], 
"text")