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;
 
   39        $this->ini->setVariable(
"db", 
"structure_reload", 
"1");
 
   41        if ($this->ini->readVariable(
"db", 
"structure_reload") != 
"1") {
 
   42            echo 
"Error Cannot write client.ini.file.";
 
   58        if (!$a_force && $this->ini->readVariable(
"db", 
"structure_reload") != 
"1") {
 
   62        require_once(
'./Services/UICore/classes/class.ilCachedCtrl.php');
 
   64        require_once(
'./Services/GlobalCache/classes/class.ilGlobalCache.php');
 
   65        ilGlobalCache::flushAll();
 
   68        $this->comp_prefix = $a_comp_prefix;
 
   71        $this->plugin_path = $a_plugin_path;
 
   74        if (!$this->executed) {
 
   76                $this->start_dir = ILIAS_ABSOLUTE_PATH;
 
   77                $this->
read(ILIAS_ABSOLUTE_PATH);
 
   79                $this->start_dir = $a_dir;
 
   84            $this->executed = 
true;
 
   86                $this->ini->setVariable(
"db", 
"structure_reload", 
"0");
 
   97    public function read($a_cdir)
 
  102        if (!@is_dir($a_cdir)) {
 
  107        $dir = opendir($a_cdir);
 
  109        while ($file = readdir($dir)) {
 
  113                if (@is_dir($a_cdir . 
"/" . $file)) {
 
  114                    if ($a_cdir . 
"/" . $file != ILIAS_ABSOLUTE_PATH . 
"/data" &&
 
  115                        $a_cdir . 
"/" . $file != ILIAS_ABSOLUTE_PATH . 
"/Customizing") {
 
  116                        $this->
read($a_cdir . 
"/" . $file);
 
  121                if (@is_file($a_cdir . 
"/" . $file)) {
 
  122                    if (preg_match(
"~^class.*php$~i", $file) || preg_match(
"~^ilSCORM13Player.php$~i", $file)) {
 
  123                        $handle = fopen($a_cdir . 
"/" . $file, 
"r");
 
  125                        while (!feof($handle)) {
 
  126                            $line = fgets($handle, 4096);
 
  129                            $pos = strpos(strtolower($line), 
"@ilctrl_calls");
 
  131                                $com = substr($line, $pos + 14);
 
  132                                $pos2 = strpos($com, 
":");
 
  134                                    $com_arr = explode(
":", $com);
 
  135                                    $parent = strtolower(trim($com_arr[0]));
 
  138                                    if ($parent != 
"" && isset($this->class_script[$parent]) &&
 
  139                                        $this->class_script[$parent] != $a_cdir . 
"/" . $file) {
 
  141                                        $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = " .
 
  142                                            $ilDB->quote($this->comp_prefix, 
"text"));
 
  143                                        if ($this->comp_prefix == 
"") {
 
  144                                            $ilDB->manipulate($q = 
"DELETE FROM ctrl_classfile WHERE " .
 
  145                                                $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  149                                        $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = " .
 
  150                                            $ilDB->quote($this->comp_prefix, 
"text"));
 
  151                                        if ($this->comp_prefix == 
"") {
 
  152                                            $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix IS NULL");
 
  155                                        throw new \Exception(
 
  157                                                $lng->txt(
"duplicate_ctrl"),
 
  159                                                $this->class_script[$parent],
 
  160                                                $a_cdir . 
"/" . $file
 
  165                                    $this->class_script[$parent] = $a_cdir . 
"/" . $file;
 
  166                                    $childs = explode(
",", $com_arr[1]);
 
  167                                    foreach ($childs as $child) {
 
  168                                        $child = trim(strtolower($child));
 
  169                                        if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent])) {
 
  170                                            $this->class_childs[$parent][] = $child;
 
  177                            $pos = strpos(strtolower($line), 
"@ilctrl_iscalledby");
 
  179                                $com = substr($line, $pos + 19);
 
  180                                $pos2 = strpos($com, 
":");
 
  182                                    $com_arr = explode(
":", $com);
 
  183                                    $child = strtolower(trim($com_arr[0]));
 
  184                                    $this->class_script[$child] = $a_cdir . 
"/" . $file;
 
  186                                    $parents = explode(
",", $com_arr[1]);
 
  187                                    foreach ($parents as $parent) {
 
  188                                        $parent = trim(strtolower($parent));
 
  189                                        if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent])) {
 
  190                                            $this->class_childs[$parent][] = $child;
 
  196                            if (preg_match(
"~^class\.(.*GUI)\.php$~i", $file, 
$res)) {
 
  197                                $cl = strtolower(
$res[1]);
 
  198                                $pos = strpos(strtolower($line), 
"class " . $cl);
 
  199                                if (is_int($pos) && $this->class_script[$cl] == 
"") {
 
  200                                    $this->class_script[$cl] = $a_cdir . 
"/" . $file;
 
  217    public function store($a_cdir = 
"./..")
 
  222        $ilDB->manipulate(
"DELETE FROM ctrl_classfile WHERE comp_prefix = " .
 
  223            $ilDB->quote($this->comp_prefix, 
"text"));
 
  224        if ($this->comp_prefix == 
"") {
 
  225            $ilDB->manipulate($q = 
"DELETE FROM ctrl_classfile WHERE " .
 
  226                $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  230        $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE comp_prefix = " .
 
  231            $ilDB->quote($this->comp_prefix, 
"text"));
 
  232        if ($this->comp_prefix == 
"") {
 
  233            $ilDB->manipulate(
"DELETE FROM ctrl_calls WHERE " .
 
  234                $ilDB->equals(
"comp_prefix", 
"", 
"text", 
true));
 
  237        foreach ($this->class_script as $class => $script) {
 
  238            $file = substr($script, strlen($this->start_dir) + 1);
 
  241            $ilDB->manipulate(sprintf(
 
  242                "INSERT INTO ctrl_classfile (class, filename, comp_prefix, plugin_path) " .
 
  243                " VALUES (%s,%s,%s,%s)",
 
  244                $ilDB->quote($class, 
"text"),
 
  245                $ilDB->quote($file, 
"text"),
 
  246                $ilDB->quote($this->comp_prefix, 
"text"),
 
  247                $ilDB->quote($this->plugin_path, 
"text")
 
  251        foreach ($this->class_childs as $parent => $v) {
 
  252            if (is_array($this->class_childs[$parent])) {
 
  253                foreach ($this->class_childs[$parent] as $child) {
 
  254                    if (strlen(trim($child)) and strlen(trim($parent))) {
 
  256                        $ilDB->manipulate(sprintf(
 
  257                            "INSERT INTO ctrl_calls (parent, child, comp_prefix) " .
 
  259                            $ilDB->quote($parent, 
"text"),
 
  260                            $ilDB->quote($child, 
"text"),
 
  261                            $ilDB->quote($this->comp_prefix, 
"text")
 
  277            "UPDATE ctrl_classfile SET " .
 
  278            " cid = " . 
$ilDB->quote(
"", 
"text")
 
  280        $set = 
$ilDB->query(
"SELECT * FROM ctrl_classfile ");
 
  282        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  283            $cid = base_convert((
string) $cnt, 10, 36);
 
  285                "UPDATE ctrl_classfile SET " .
 
  286                " cid = " . 
$ilDB->quote($cid, 
"text") .
 
  287                " WHERE class = " . 
$ilDB->quote($rec[
"class"], 
"text")
 
An exception for terminatinating execution or to throw for unit testing.
Class ilCtrlStructureReader.
determineClassFileIds()
Determine class file IDS.
store($a_cdir="./..")
read structure into internal variables
readStructure( $a_force=false, $a_dir="", $a_comp_prefix="", $a_plugin_path="")
read structure
read($a_cdir)
read structure into internal variables
__construct($a_ini_file=null)
getStructure()
parse code files and store call structure in db
foreach($_POST as $key=> $value) $res