ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCtrl2 Class Reference

This class provides processing control methods. More...

+ Inheritance diagram for ilCtrl2:
+ Collaboration diagram for ilCtrl2:

Public Member Functions

 getCurrentCidOfNode ($a_node)
 Get last cid of node id.
 removeLastCid ($a_node)
 Remove last cid of node.
 getParentCidOfNode ($a_node)
 Get last but one cid of node id.
 getNodeIdForTargetClass ($a_par_node, $a_class)
 Searchs a node for a given class ($a_class) "near" the another node ($a_par_node).
 getCallStructure ($a_class)
 readClassInfo ($a_class)
 Read info of class.
 readNodeInfo ($a_node)
 Read info of node.
 readCidInfo ($a_cid)
 Read information of class per cid.
 getCidForClass ($a_class)
 Get Cid for Class.
 getClassForCid ($a_cid)
 Get class for cid.
 getPathNew ($a_source_node, $a_target_node)
 Get path from node a to node b.
 searchReturnClass ($a_class)
 get current return class
forwardCommand (&$a_gui_object)
 forward flow of control to next gui class this invokes the executeCommand() method of the gui object that is passed via reference
getHTML (&$a_gui_object)
 Gets an HTML output from another GUI class and returns the flow of control to the calling class.
 getNextClass ()
 Get next class in the control path from the current class to the target command class.
 getParameterArrayByClass ($a_class, $a_cmd="")
- Public Member Functions inherited from ilCtrl
 ilCtrl ()
 control class constructor
 debug ($str)
 getDebug ()
 init ()
 initialisation
 callBaseClass ()
 Calls base class of current request.
 getModuleDir ()
 get directory of current module
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set context of current user interface.
 getContextObjId ()
 Get ContextObjId.
 getContextObjType ()
 Get ContextObjType.
 getContextSubObjId ()
 Get ContextSubObjId.
 getContextSubObjType ()
 Get ContextSubObjType.
 getCmdNode ()
 get command target node
 addLocation ($a_title, $a_link, $a_target="", $a_ref_id=0)
 add a location to the locator array
 getLocations ()
 get locations array
 addTab ($a_lang_var, $a_link, $a_cmd, $a_class)
 add a tab to tabs array
 getTabs ()
 get tabs array
 getCallHistory ()
 Get controller call history.
 getCallStructure ($a_class, $a_nr=0, $a_parent=0)
 Get call structure of class context.
 storeCommonStructures ()
 stores often used common call structures (called from db_update script!!!)
 readCallStructure ($a_class, $a_nr=0, $a_parent=0)
 reads call structure from db
 forwards ($a_from_class, $a_to_class)
 Stores which classes forwards commands to which other classes.
 saveParameter (&$a_obj, $a_parameter)
 Set parameters that should be passed in every form and link of a gui class.
 saveParameterByClass ($a_class, $a_parameter)
 setParameter (&$a_obj, $a_parameter, $a_value)
 Set parameters that should be passed a form and link of a gui class.
 setParameterByClass ($a_class, $a_parameter, $a_value)
 Same as setParameterByClass, except that a class name is passed.
 clearParameters (&$a_obj)
 Clears all parameters that have been set via setParameter for a GUI class.
 clearParametersByClass ($a_class)
 Clears all parameters that have been set via setParameter for a GUI class.
 lookupClassPath ($a_class_name)
 Get class path that can be used in include statements for a given class name.
 getClassForClasspath ($a_class_path)
 this method assumes that the class path has the format "dir/class.<class_name>.php"
 setTargetScript ($a_target_script)
 set target script name
 getTargetScript ()
 get target script name
 initBaseClass ($a_base_class)
 initialises new base class
 getCmd ($a_default_cmd="", $a_safe_commands="")
 determines current get/post command
 setCmd ($a_cmd)
 set the current command
 setCmdClass ($a_cmd_class)
 set the current command class
 getCmdClass ()
 determines responsible class for current command
 getFormAction (&$a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false)
 get form action url for gui class object
 getFormActionByClass ($a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false)
 get form action url for gui class name
 appendRequestTokenParameterString ($a_url)
 append request token as url parameter
 getRequestToken ()
 Get request token.
 verifyToken ()
 Verify Token.
 redirect (&$a_gui_obj, $a_cmd="", $a_anchor="")
 redirectByClass ($a_class, $a_cmd="")
 redirect to other gui class
 isAsynch ()
 getLinkTarget (&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
 get link target for (current) gui class
 getLinkTargetByClass ($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
 get link target for a target class
 setReturn (&$a_gui_obj, $a_cmd)
 set return command
 setReturnByClass ($a_class, $a_cmd)
 set return command
 returnToParent (&$a_gui_obj, $a_anchor="")
 redirects to next parent class that used setReturn
 getRedirectSource ()
 get current redirect source
 getParentReturn (&$a_gui_obj)
 getParentReturnByClass ($a_class)
 getUrlParameters ($a_class, $a_str, $a_cmd="", $a_transits="")
 appendTransitClasses ($a_str)
 getTransitArray ()
 addTransit ($a_class)
 getParameterArray (&$a_gui_obj, $a_cmd="", $a_incl_transit=true)
 getParameterArrayByClass ($a_class, $a_cmd="", $a_transits="")

Additional Inherited Members

- Data Fields inherited from ilCtrl
const IL_RTOKEN_NAME = 'rtoken'
 $target_script
 $forward
 $parent
 $save_parameter
 $return
 $call_hist = array()
 $debug = array()

Detailed Description

This class provides processing control methods.

A global instance is available via variable $ilCtrl

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilCtrl.php 20093 2009-05-29 07:17:46Z akill

Definition at line 13 of file class.ilCtrl2.php.

Member Function Documentation

& ilCtrl2::forwardCommand ( $a_gui_object)

forward flow of control to next gui class this invokes the executeCommand() method of the gui object that is passed via reference

Parameters
object$a_gui_objectgui object that should receive the flow of control public
Returns
mixed return data of invoked executeCommand() method

Reimplemented from ilCtrl.

Definition at line 339 of file class.ilCtrl2.php.

References exit, ilCtrl\getCmd(), and getNodeIdForTargetClass().

{
$class = strtolower(get_class($a_gui_object));
//echo "<br>forward to $class";
$nr = $this->getNodeIdForTargetClass($this->current_node, $class);
if ($nr != "")
{
$current_node = $this->current_node;
$this->current_node = $nr;
if (DEVMODE == "1")
{
$this->call_hist[] = array("class" => get_class($a_gui_object),
"mode" => "execComm", "cmd" => $this->getCmd());
}
//echo "<br>class:".get_class($a_gui_object).":";
$html = $a_gui_object->executeCommand();
// reset current node
$this->current_node = $current_node;
return $html;
}
echo "ERROR: Can't forward to class $class."; exit;
//echo "end forward<br>";
}

+ Here is the call graph for this function:

ilCtrl2::getCallStructure (   $a_class)

Definition at line 116 of file class.ilCtrl2.php.

References readClassInfo().

{
$this->readClassInfo($a_class);
}

+ Here is the call graph for this function:

ilCtrl2::getCidForClass (   $a_class)

Get Cid for Class.

Definition at line 219 of file class.ilCtrl2.php.

References readClassInfo().

Referenced by getNodeIdForTargetClass().

{
if ($this->class_cid[$a_class] == "")
{
$this->readClassInfo($a_class);
}
if ($this->class_cid[$a_class] == "")
{
if (DEVMODE == 1)
{
$add = "<br><br>Please make sure your GUI class name ends with 'GUI' and that the filename is 'class.[YourClassName].php'. In exceptional cases you
may solve the issue by putting an empty * @ilCtrl_Calls [YourClassName]: into your class header.".
" In both cases you need to reload the control structure in the setup.";
}
die("Cannot find cid for class ".$a_class.".".$add);
}
return $this->class_cid[$a_class];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl2::getClassForCid (   $a_cid)

Get class for cid.

Definition at line 241 of file class.ilCtrl2.php.

References readCidInfo().

Referenced by getNodeIdForTargetClass(), getParameterArrayByClass(), and searchReturnClass().

{
if ($this->cid_class[$a_cid] == "")
{
$this->readCidInfo($a_cid);
}
if ($this->cid_class[$a_cid] == "")
{
die("Cannot find class for cid ".$a_cid.".");
}
return $this->cid_class[$a_cid];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl2::getCurrentCidOfNode (   $a_node)

Get last cid of node id.

Definition at line 18 of file class.ilCtrl2.php.

Referenced by getNextClass(), getNodeIdForTargetClass(), and getParameterArrayByClass().

{
$n_arr = explode(":", $a_node);
return $n_arr[count($n_arr) - 1];
}

+ Here is the caller graph for this function:

& ilCtrl2::getHTML ( $a_gui_object)

Gets an HTML output from another GUI class and returns the flow of control to the calling class.

Parameters
object$a_gui_objectgui object that returns the HTML block public
Returns
string HTML

Reimplemented from ilCtrl.

Definition at line 377 of file class.ilCtrl2.php.

References exit, ilCtrl\getCmd(), and getNodeIdForTargetClass().

{
$class = strtolower(get_class($a_gui_object));
$nr = $this->getNodeIdForTargetClass($this->current_node, $class);
if ($nr != "")
{
$current_node = $this->current_node;
// set current node to new gui class
$this->current_node = $nr;
if (DEVMODE == "1")
{
$this->call_hist[] = array("class" => get_class($a_gui_object),
"mode" => "getHtml", "cmd" => $this->getCmd());
}
// get block
$html = $a_gui_object->getHTML();
// reset current node
$this->current_node = $current_node;
// return block
return $html;
}
echo "ERROR: Can't getHTML from class $class."; exit;
}

+ Here is the call graph for this function:

ilCtrl2::getNextClass ( )

Get next class in the control path from the current class to the target command class.

This is the class that should be instantiated and be invoked via $ilCtrl->forwardCommand($class) next.

Returns
string class name of next class

Reimplemented from ilCtrl.

Definition at line 415 of file class.ilCtrl2.php.

References ilCtrl\getCmdNode(), getCurrentCidOfNode(), getPathNew(), and readCidInfo().

{
$cmdNode = $this->getCmdNode();
//echo "<br>getNextClass (current node: ".$this->current_node."; cmd node: ".$cmdNode.") ";
if ($cmdNode == "")
{
return false;
}
else
{
if ($this->current_node == $cmdNode)
{
//echo "1:".$this->call_node[$cmdNode]["class"]."<br>";
//return $this->call_node[$cmdNode]["class"];
return "";
}
else
{
$path = $this->getPathNew($this->current_node, $cmdNode);
//var_dump($path);
//echo " - Next Node: ".$path[1];
$this->readCidInfo($this->getCurrentCidOfNode($path[1]));
//echo ":".$this->cid_class[$this->getCurrentCidOfNode($path[1])].":".$this->getCurrentCidOfNode($path[1]).":";
return $this->cid_class[$this->getCurrentCidOfNode($path[1])];
}
}
}

+ Here is the call graph for this function:

ilCtrl2::getNodeIdForTargetClass (   $a_par_node,
  $a_class 
)

Searchs a node for a given class ($a_class) "near" the another node ($a_par_node).

It first looks if the given class is a child class of the current node. If such a child node has been found, its id is returned.

If not, this method determines wether the given class is a sibling of the current node within the call structure. If this is the case then the corresponding id is returned.

At last the methode searchs for the given class along the path from the current node to the root class of the call structure.

Parameters
$a_par_nodeid of starting node for the search
$a_classclass that should be searched

private

Returns
int id of target node that has been found

Reimplemented from ilCtrl.

Definition at line 42 of file class.ilCtrl2.php.

References exit, getCidForClass(), getClassForCid(), getCurrentCidOfNode(), getParentCidOfNode(), readClassInfo(), readNodeInfo(), and removeLastCid().

Referenced by forwardCommand(), getHTML(), getParameterArrayByClass(), and searchReturnClass().

{
$class = strtolower($a_class);
$this->readClassInfo($class);
if ($a_par_node === 0 || $a_par_node == "")
{
return $this->getCidForClass($class);
}
//return parent::getNodeIdForTargetClass($a_par_node, $a_class);
$this->readNodeInfo($a_par_node);
$node_cid = $this->getCurrentCidOfNode($a_par_node);
// target class is class of current node id
if ($class == $this->getClassForCid($node_cid))
{
return $a_par_node;
}
// target class is child of current node id
if (is_array($this->calls[$this->getClassForCid($node_cid)]) &&
in_array($a_class, $this->calls[$this->getClassForCid($node_cid)]))
{
return $a_par_node.":".$this->getCidForClass($class);
}
// target class is sibling
$par_cid = $this->getParentCidOfNode($a_par_node);
if ($par_cid != "")
{
if (is_array($this->calls[$this->getClassForCid($par_cid)]) &&
in_array($a_class, $this->calls[$this->getClassForCid($par_cid)]))
{
return $this->removeLastCid($a_par_node).":".$this->getCidForClass($class);;
}
}
// target class is parent
$temp_node = $this->removeLastCid($a_par_node);
while($temp_node != "")
{
$temp_cid = $this->getCurrentCidOfNode($temp_node);
if ($this->getClassForCid($temp_cid) == $a_class)
{
return $temp_node;
}
$temp_node = $this->removeLastCid($temp_node);
}
// Please do NOT change these lines.
// Developers must be aware, if they use classes unknown to the controller
// otherwise certain problem will be extremely hard to track down...
echo "ERROR: Can't find target class $a_class for node $a_par_node ".
"(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].").<br>";
error_log( "ERROR: Can't find target class $a_class for node $a_par_node ".
"(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].")");
if (DEVMODE == 1)
{
try
{
throw new Exception("");
}
catch(Exception $e)
{
echo "<pre>".$e->getTraceAsString()."</pre>";
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl2::getParameterArrayByClass (   $a_class,
  $a_cmd = "" 
)

Definition at line 446 of file class.ilCtrl2.php.

References $_GET, $params, getClassForCid(), getCurrentCidOfNode(), getNodeIdForTargetClass(), and getPathNew().

{
if ($a_class == "")
{
return array();
}
if (!is_array($a_class))
{
$a_class = array($a_class);
}
$nr = $this->current_node;
foreach ($a_class as $class)
{
$class = strtolower($class);
$nr = $this->getNodeIdForTargetClass($nr, $class);
$target_class = $class;
}
$path = $this->getPathNew(1, $nr);
$params = array();
// append parameters of parent classes
foreach($path as $node_id)
{
$class = ($node_id == "")
? strtolower($_GET["baseClass"])
: $this->getClassForCid($this->getCurrentCidOfNode($node_id));
if (is_array($this->save_parameter[$class]))
{
foreach($this->save_parameter[$class] as $par)
{
$params[$par] = $_GET[$par];
}
}
if (is_array($this->parameter[$class]))
{
foreach($this->parameter[$class] as $par => $value)
{
$params[$par] = $value;
}
}
}
if ($a_cmd != "")
{
$params["cmd"] = $a_cmd;
}
$params["cmdClass"] = $target_class;
$params["cmdNode"] = $nr;
$params["baseClass"] = $_GET["baseClass"];
return $params;
}

+ Here is the call graph for this function:

ilCtrl2::getParentCidOfNode (   $a_node)

Get last but one cid of node id.

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

Referenced by getNodeIdForTargetClass().

{
$n_arr = explode(":", $a_node);
return $n_arr[count($n_arr) - 2];
}

+ Here is the caller graph for this function:

ilCtrl2::getPathNew (   $a_source_node,
  $a_target_node 
)

Get path from node a to node b.

Returns
Parameters
object$a_source_node
object$a_target_node

Reimplemented from ilCtrl.

Definition at line 260 of file class.ilCtrl2.php.

References $cid, $diff, and exit.

Referenced by getNextClass(), and getParameterArrayByClass().

{
//if ($this->getCmdClass() == "ilmailfoldergui") echo "-".$a_source_node."-".$a_target_node."-";
//echo "-".$a_source_node."-".$a_target_node."-";
//echo "<br>:::$a_source_node:::";
if ($a_source_node == "1")
{
$a_source_node = "";
}
if (substr($a_target_node, 0, strlen($a_source_node)) != $a_source_node)
{
echo "ERROR: Path not found. Source:".$a_source_node.
", Target:".$a_target_node;
}
//echo "<br>:::$a_source_node:::";
$temp_node = $a_source_node;
$path = array();
if ($a_source_node != "")
{
$path = array($a_source_node);
}
$diffstart = ($a_source_node == "")
? 0
: strlen($a_source_node) + 1;
$diff = substr($a_target_node, $diffstart);
//echo "=$diff=$diffstart=";
$diff_arr = explode(":", $diff);
foreach($diff_arr as $cid)
{
if ($temp_node != "")
{
$temp_node.= ":";
}
$temp_node.= $cid;
$path[] = $temp_node;
}
//if ($this->getCmdClass() == "ilmailfoldergui") var_dump($path);
//var_dump($path);
return $path;
}

+ Here is the caller graph for this function:

ilCtrl2::readCidInfo (   $a_cid)

Read information of class per cid.

Returns
Parameters
object$a_cidcid

Definition at line 181 of file class.ilCtrl2.php.

References $ilDB.

Referenced by getClassForCid(), getNextClass(), and readNodeInfo().

{
global $ilDB;
if ($this->info_read_cid[$a_cid])
{
return;
}
$set = $ilDB->query("SELECT * FROM ctrl_classfile ".
" WHERE cid = ".$ilDB->quote($a_cid, "text")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$this->cid_class[$a_cid] = $rec["class"];
$this->class_cid[$rec["class"]] = $a_cid;
$set = $ilDB->query("SELECT * FROM ctrl_calls ".
" WHERE parent = ".$ilDB->quote($rec["class"], "text")
);
while ($rec2 = $ilDB->fetchAssoc($set))
{
if (!is_array($this->calls[$rec["class"]]) || !in_array($rec2["child"], $this->calls[$rec["class"]]))
{
if ($rec2["child"] != "")
{
$this->calls[$rec["class"]][] = $rec2["child"];
}
}
}
$this->info_read_class[$rec["class"]] = true;
}
$this->info_read_cid[$a_cid] = true;
}

+ Here is the caller graph for this function:

ilCtrl2::readClassInfo (   $a_class)

Read info of class.

Parameters
object$a_classclass name

Definition at line 126 of file class.ilCtrl2.php.

References $ilDB.

Referenced by getCallStructure(), getCidForClass(), and getNodeIdForTargetClass().

{
global $ilDB;
$a_class = strtolower($a_class);
if ($this->info_read_class[$a_class])
{
return;
}
$set = $ilDB->query("SELECT * FROM ctrl_classfile ".
" WHERE class = ".$ilDB->quote($a_class, "text")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$this->cid_class[$rec["cid"]] = $a_class;
$this->class_cid[$a_class] = $rec["cid"];
}
$set = $ilDB->query("SELECT * FROM ctrl_calls ".
" WHERE parent = ".$ilDB->quote($a_class, "text")
);
while ($rec = $ilDB->fetchAssoc($set))
{
if (!is_array($this->calls[$a_class]) || !in_array($rec["child"], $this->calls[$a_class]))
{
if ($rec["child"] != "")
{
$this->calls[$a_class][] = $rec["child"];
}
}
}
$this->info_read_class[$a_class] = true;
$this->info_read_cid[$this->class_cid[$a_class]] = true;
}

+ Here is the caller graph for this function:

ilCtrl2::readNodeInfo (   $a_node)

Read info of node.

Parameters
object$a_classclass name

Definition at line 167 of file class.ilCtrl2.php.

References $cid, and readCidInfo().

Referenced by getNodeIdForTargetClass().

{
$n_arr = explode(":", $a_node);
foreach ($n_arr as $cid)
{
$this->readCidInfo($cid);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl2::removeLastCid (   $a_node)

Remove last cid of node.

Definition at line 27 of file class.ilCtrl2.php.

Referenced by getNodeIdForTargetClass().

{
$lpos = strrpos($a_node, ":");
return substr($a_node, 0, $lpos);
}

+ Here is the caller graph for this function:

ilCtrl2::searchReturnClass (   $a_class)

get current return class

Reimplemented from ilCtrl.

Definition at line 307 of file class.ilCtrl2.php.

References getClassForCid(), and getNodeIdForTargetClass().

{
$a_class = strtolower($a_class);
$node = $this->getNodeIdForTargetClass($this->current_node, $a_class);
$n_arr = explode(":", $node);
for($i = count($n_arr)-2; $i>=0; $i--)
{
if ($this->return[$this->getClassForCid($n_arr[$i])] != "")
{
return $this->getClassForCid($n_arr[$i]);
}
}
return false;
}

+ Here is the call graph for this function:


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