ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCtrlStructureReader Class Reference

Class ilCtrlStructureReader. More...

+ Collaboration diagram for ilCtrlStructureReader:

Public Member Functions

 ilCtrlStructureReader ()
 setErrorObject (&$err)
 getStructure ()
 parse code files and store call structure in db
 readStructure ($a_force=false, $a_dir="", $a_comp_prefix="")
 read structure
 read ($a_cdir)
 read structure into internal variables
 store ($a_cdir="./..")
 read structure into internal variables

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:
class.ilCtrlStructureReader.php 16085 2008-02-26 13:47:27Z akill

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

Member Function Documentation

ilCtrlStructureReader::getStructure ( )

parse code files and store call structure in db

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

{
$this->get_structure = true;
}
ilCtrlStructureReader::ilCtrlStructureReader ( )

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

{
$this->class_script = array();
$this->class_childs = array();
$this->executed = false;
}
ilCtrlStructureReader::read (   $a_cdir)

read structure into internal variables

private

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

References $dir, $file, $lng, and ILIAS_ABSOLUTE_PATH.

Referenced by readStructure().

{
global $ilDB, $lng;
// check wether $a_cdir is a directory
if (!@is_dir($a_cdir))
{
return false;
}
// read current directory
$dir = opendir($a_cdir);
while($file = readdir($dir))
{
if ($file != "." and
$file != "..")
{
// directories
if (@is_dir($a_cdir."/".$file))
{
if ($a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/data" &&
$a_cdir."/".$file != ILIAS_ABSOLUTE_PATH."/Customizing")
{
$this->read($a_cdir."/".$file);
}
}
// files
if (@is_file($a_cdir."/".$file))
{
if (eregi("^class.*php$", $file))
{
$handle = fopen($a_cdir."/".$file, "r");
//echo "<br>".$a_cdir."/".$file;
while (!feof($handle)) {
$line = fgets($handle, 4096);
// handle @ilctrl_calls
$pos = strpos(strtolower($line), "@ilctrl_calls");
if (is_int($pos))
{
$com = substr($line, $pos + 14);
$pos2 = strpos($com, ":");
if (is_int($pos2))
{
$com_arr = explode(":", $com);
$parent = strtolower(trim($com_arr[0]));
// check file duplicates
if ($parent != "" && isset($this->class_script[$parent]) &&
$this->class_script[$parent] != $a_cdir."/".$file)
{
// delete all class to file assignments
$q = "DELETE FROM ctrl_classfile WHERE comp_prefix = ".
$ilDB->quote($this->comp_prefix);
$ilDB->query($q);
// delete all call entries
$q = "DELETE FROM ctrl_calls WHERE comp_prefix = ".
$ilDB->quote($this->comp_prefix);
$ilDB->query($q);
$this->err_object->raiseError(
sprintf($lng->txt("duplicate_ctrl"),
$parent,
$this->class_script[$parent],
$a_cdir."/".$file)
, $this->err_object->MESSAGE);
}
$this->class_script[$parent] = $a_cdir."/".$file;
$childs = explode(",", $com_arr[1]);
foreach($childs as $child)
{
$child = trim(strtolower($child));
if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
{
$this->class_childs[$parent][] = $child;
}
}
}
}
// handle isCalledBy comments
$pos = strpos(strtolower($line), "@ilctrl_iscalledby");
if (is_int($pos))
{
$com = substr($line, $pos + 19);
$pos2 = strpos($com, ":");
if (is_int($pos2))
{
$com_arr = explode(":", $com);
$child = strtolower(trim($com_arr[0]));
$this->class_script[$child] = $a_cdir."/".$file;
$parents = explode(",", $com_arr[1]);
foreach($parents as $parent)
{
$parent = trim(strtolower($parent));
if (!is_array($this->class_childs[$parent]) || !in_array($child, $this->class_childs[$parent]))
{
$this->class_childs[$parent][] = $child;
}
}
}
}
}
fclose($handle);
}
}
}
}
}

+ Here is the caller graph for this function:

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

read structure

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

References ILIAS_ABSOLUTE_PATH, read(), and store().

{
if (!$this->get_structure && !$a_force)
{
return;
}
// prefix for component
$this->comp_prefix = $a_comp_prefix;
// only run one time per db_update request
if (!$this->executed)
{
if ($a_dir == "")
{
$this->start_dir = ILIAS_ABSOLUTE_PATH;
}
else
{
$this->start_dir = $a_dir;
$this->read($a_dir);
}
$this->store();
$this->executed = true;
}
// read module information
// not clear whether this is a good place for module reading info
// or not
require_once("../classes/class.ilCtrl.php");
$ctrl = new ilCtrl();
$ctrl->storeCommonStructures();
}

+ Here is the call graph for this function:

ilCtrlStructureReader::setErrorObject ( $err)

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

{
$this->err_object =& $err;
}
ilCtrlStructureReader::store (   $a_cdir = "./..")

read structure into internal variables

private

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

References $file.

Referenced by readStructure().

{
global $ilDB;
// delete all class to file assignments
$q = "DELETE FROM ctrl_classfile WHERE comp_prefix = ".
$ilDB->quote($this->comp_prefix);
$ilDB->query($q);
// delete all call entries
$q = "DELETE FROM ctrl_calls WHERE comp_prefix = ".
$ilDB->quote($this->comp_prefix);
$ilDB->query($q);
foreach($this->class_script as $class => $script)
{
$file = substr($script, strlen($this->start_dir) + 1);
// store class to file assignment
$q = "INSERT INTO ctrl_classfile (class, file, comp_prefix) VALUES".
"(".$ilDB->quote($class).",".$ilDB->quote($file).
",".$ilDB->quote($this->comp_prefix).")";
$ilDB->query($q);
}
//$this->class_childs[$parent][] = $child;
foreach($this->class_childs as $parent => $v)
{
if (is_array($this->class_childs[$parent]))
{
foreach($this->class_childs[$parent] as $child)
{
// store call entry
$q = "INSERT INTO ctrl_calls (parent, child, comp_prefix) VALUES".
"(".$ilDB->quote($parent).",".$ilDB->quote($child).
",".$ilDB->quote($this->comp_prefix).")";
$ilDB->query($q);
}
}
}
}

+ Here is the caller graph for this function:

Field Documentation

ilCtrlStructureReader::$class_childs

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

ilCtrlStructureReader::$class_script

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

ilCtrlStructureReader::$executed

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


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