Public Member Functions | |
ilCtrl () | |
control class constructor | |
& | 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 | |
getNodeIdForTargetClass ($a_par_node, $a_class) | |
Searchs a node for a given class ($a_class) "near" the another node ($a_par_node). | |
getCmdNode () | |
get command target node | |
addLocation ($a_title, $a_link, $a_target="") | |
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 | |
getCallStructure ($a_class, $a_nr=0, $a_parent=0) | |
get call structure of class context | |
forwards ($a_from_class, $a_to_class) | |
stores which classes forward to which other classes | |
saveParameter (&$a_obj, $a_parameter) | |
set parameters that must be saved in forms an links | |
setParameter (&$a_obj, $a_parameter, $a_value) | |
Set a parameter (note: if this is also a saved parameter, the saved value will be overwritten). | |
setParameterByClass ($a_class, $a_parameter, $a_value) | |
Set a parameter (note: if this is also a saved parameter, the saved value will be overwritten). | |
getNextClass () | |
Get next class of the way 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). | |
getPathNew ($a_source_node, $a_target_node) | |
get path in call structure | |
setTargetScript ($a_target_script) | |
private | |
getTargetScript () | |
get target script name | |
getCmd ($a_default_cmd="") | |
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_transits="", $a_prepend_transits=false) | |
getFormActionByClass ($a_class, $a_transits="", $a_prepend_transits=false) | |
redirect (&$a_gui_obj, $a_cmd="") | |
redirectByClass ($a_class, $a_cmd="") | |
redirect to other gui class | |
getLinkTarget (&$a_gui_obj, $a_cmd="") | |
get link target for (current) gui class | |
getLinkTargetByClass ($a_class, $a_cmd="", $a_transits="", $a_prepend_transits=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) | |
searchReturnClass ($a_class) | |
get current return 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="") | |
Data Fields | |
$target_script | |
$forward | |
$parent | |
$save_parameter | |
$return |
Definition at line 32 of file class.ilCtrl.php.
ilCtrl::addLocation | ( | $ | a_title, | |
$ | a_link, | |||
$ | a_target = "" | |||
) |
add a location to the locator array
string | $a_title link text | |
string | $a_link link | |
string | $a_target target frame |
Definition at line 167 of file class.ilCtrl.php.
{ $this->location[] = array("title" => $a_title, "link" => $a_link, "target" => $a_target); }
ilCtrl::addTab | ( | $ | a_lang_var, | |
$ | a_link, | |||
$ | a_cmd, | |||
$ | a_class | |||
) |
add a tab to tabs array
string | $a_lang_var language variable | |
string | $a_link link | |
string | $a_cmd command (must be same as in link) | |
string | $a_class command class (must be same as in link) |
Definition at line 191 of file class.ilCtrl.php.
{ $a_class = strtolower($a_class); $this->tab[] = array("lang_var" => $a_lang_var, "link" => $a_link, "cmd" => $a_cmd, "class" => $a_class); }
ilCtrl::addTransit | ( | $ | a_class | ) |
Definition at line 800 of file class.ilCtrl.php.
References $_GET.
{ $a_class = strtolower($a_class); $_GET["cmdTransit"][] = $a_class; }
ilCtrl::appendTransitClasses | ( | $ | a_str | ) |
Definition at line 773 of file class.ilCtrl.php.
References $_GET, and ilUtil::appendUrlParameterString().
{ if (is_array($_GET["cmdTransit"])) { reset($_GET["cmdTransit"]); foreach ($_GET["cmdTransit"] as $transit) { $a_str = ilUtil::appendUrlParameterString($a_str, "cmdTransit[]=".$transit); } } return $a_str; }
& ilCtrl::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
object | $a_gui_object gui object that should receive the flow of control |
Definition at line 67 of file class.ilCtrl.php.
References exit, and getNodeIdForTargetClass().
{ $class = strtolower(get_class($a_gui_object)); $nr = $this->getNodeIdForTargetClass($this->current_node, $class); if ($nr > 0) { $this->current_node = $nr; return $a_gui_object->executeCommand(); } echo "ERROR: Can't forward to class $class."; exit; //echo "end forward<br>"; }
ilCtrl::forwards | ( | $ | a_from_class, | |
$ | a_to_class | |||
) |
stores which classes forward to which other classes
Definition at line 244 of file class.ilCtrl.php.
Referenced by getCallStructure().
{ $a_from_class = strtolower($a_from_class); if (is_array($a_to_class)) { foreach($a_to_class as $to_class) { $this->forward[$a_from_class][] = strtolower($to_class); $this->parent[strtolower($to_class)][] = $a_from_class; } } else { $this->forward[strtolower(get_class($a_obj))][] = strtolower($a_to_class); $this->parent[strtolower($a_to_class)][] = strtolower(get_class($a_obj)); } }
ilCtrl::getCallStructure | ( | $ | a_class, | |
$ | a_nr = 0 , |
|||
$ | a_parent = 0 | |||
) |
get call structure of class context
Definition at line 213 of file class.ilCtrl.php.
References $q, and forwards().
{ global $ilDB; $a_class = strtolower($a_class); $a_nr++; $this->call_node[$a_nr] = array("class" => $a_class, "parent" => $a_parent); //echo "nr:$a_nr:class:$a_class:parent:$a_parent:<br>"; $q = "SELECT * FROM ctrl_calls WHERE parent=". $ilDB->quote(strtolower($a_class)). " ORDER BY child"; $call_set = $ilDB->query($q); //$forw = array(); $a_parent = $a_nr; while($call_rec = $call_set->fetchRow(DB_FETCHMODE_ASSOC)) { $a_nr = $this->getCallStructure($call_rec["child"], $a_nr, $a_parent); $forw[] = $call_rec["child"]; } $this->forwards($a_class, $forw); //echo "<br><br>forwards:".$a_class."<br>"; var_dump($forw); $this->root_class = $a_class; return $a_nr; }
ilCtrl::getCmd | ( | $ | a_default_cmd = "" |
) |
ilCtrl::getCmdClass | ( | ) |
determines responsible class for current command
Definition at line 579 of file class.ilCtrl.php.
References $_GET.
{ return strtolower($_GET["cmdClass"]); }
ilCtrl::getCmdNode | ( | ) |
get command target node
Definition at line 155 of file class.ilCtrl.php.
References $_GET.
Referenced by getNextClass().
{ return $_GET["cmdNode"]; }
ilCtrl::getFormAction | ( | &$ | a_gui_obj, | |
$ | a_transits = "" , |
|||
$ | a_prepend_transits = false | |||
) |
Definition at line 584 of file class.ilCtrl.php.
References $script, and getFormActionByClass().
{ $script = $this->getFormActionByClass(strtolower(get_class($a_gui_obj)), $a_transits, $a_prepend_transits); return $script; }
ilCtrl::getFormActionByClass | ( | $ | a_class, | |
$ | a_transits = "" , |
|||
$ | a_prepend_transits = false | |||
) |
Definition at line 590 of file class.ilCtrl.php.
References $script, and getLinkTargetByClass().
Referenced by getFormAction().
{ $a_class = strtolower($a_class); $script = $this->getLinkTargetByClass($a_class, "post", $a_transits, $a_prepend_transits); return $script; }
ilCtrl::getLinkTarget | ( | &$ | a_gui_obj, | |
$ | a_cmd = "" | |||
) |
get link target for (current) gui class
object | $a_gui_obj (current) gui object (usually $this) | |
string | $a_cmd command |
Definition at line 633 of file class.ilCtrl.php.
References $script, and getLinkTargetByClass().
{ //echo "<br>getLinkTarget"; $script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd); return $script; }
ilCtrl::getLinkTargetByClass | ( | $ | a_class, | |
$ | a_cmd = "" , |
|||
$ | a_transits = "" , |
|||
$ | a_prepend_transits = false | |||
) |
get link target for a target class
string | $a_class command target class | |
string | $a_cmd command | |
array | $a_transits transit classes (deprecated) |
Definition at line 650 of file class.ilCtrl.php.
References $script, getTargetScript(), and getUrlParameters().
Referenced by getFormActionByClass(), getLinkTarget(), redirect(), and redirectByClass().
{ // note: $a_class may be an array //$a_class = strtolower($a_class); //echo "<br>getLinkTargetByClass"; $script = $this->getTargetScript(); $script = $this->getUrlParameters($a_class, $script, $a_cmd, $transits); return $script; }
ilCtrl::getLocations | ( | ) |
get locations array
Definition at line 178 of file class.ilCtrl.php.
{
return $this->location;
}
ilCtrl::getNextClass | ( | ) |
Get next class of the way 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).
Definition at line 313 of file class.ilCtrl.php.
References $path, getCmdNode(), and getPathNew().
{ //echo "getNextClass:"; $cmdNode = $this->getCmdNode(); 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); //echo "2:".$this->call_node[$path[1]]["class"]."<br>"; return $this->call_node[$path[1]]["class"]; } } }
ilCtrl::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.
$a_par_node | id of starting node for the search | |
$a_class | class that should be searched |
private
Definition at line 103 of file class.ilCtrl.php.
References exit.
Referenced by forwardCommand(), getParameterArrayByClass(), searchReturnClass(), and setCmdClass().
{ $class = strtolower($a_class); // target class is class of current node id if ($class == $this->call_node[$a_par_node]["class"]) { return $a_par_node; } // target class is child of current node id foreach($this->call_node as $nr => $node) { if (($node["parent"] == $a_par_node) && ($node["class"] == $class)) { return $nr; } } // target class is sibling $par = $this->call_node[$a_par_node]["parent"]; if ($par != 0) { foreach($this->call_node as $nr => $node) { if (($node["parent"] == $par) && ($node["class"] == $class)) { return $nr; } } } // target class is parent while($par != 0) { if ($this->call_node[$par]["class"] == $class) { return $par; } $par = $this->call_node[$par]["parent"]; } echo "ERROR: Can't find target class $a_class for node $a_par_node.<br>"; exit; }
ilCtrl::getParameterArray | ( | &$ | a_gui_obj, | |
$ | a_cmd = "" , |
|||
$ | a_incl_transit = true | |||
) |
Definition at line 806 of file class.ilCtrl.php.
References getParameterArrayByClass().
{ $par_arr = $this->getParameterArrayByClass(strtolower(get_class($a_gui_obj)), $a_cmd, $trans_arr); return $par_arr; }
ilCtrl::getParameterArrayByClass | ( | $ | a_class, | |
$ | a_cmd = "" , |
|||
$ | a_transits = "" | |||
) |
Definition at line 817 of file class.ilCtrl.php.
References $_GET, $params, $path, getNodeIdForTargetClass(), and getPathNew().
Referenced by getParameterArray(), and getUrlParameters().
{ //echo "<br>getparameter for $a_class"; if ($a_class == "") { return array(); } if (!is_array($a_class)) { $a_class = array($a_class); } $nr = $this->current_node; foreach ($a_class as $class) { //echo "<br>-$class-"; $class = strtolower($class); $nr = $this->getNodeIdForTargetClass($nr, $class); $target_class = $class; //echo "-$nr-"; } $path = $this->getPathNew(1, $nr); $params = array(); // append parameters of parent classes foreach($path as $node_id) { $class = $this->call_node[$node_id]["class"]; 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; return $params; }
ilCtrl::getParentReturn | ( | &$ | a_gui_obj | ) |
Definition at line 716 of file class.ilCtrl.php.
References getParentReturnByClass().
Referenced by returnToParent().
{ return $this->getParentReturnByClass(strtolower(get_class($a_gui_obj))); }
ilCtrl::getParentReturnByClass | ( | $ | a_class | ) |
Definition at line 722 of file class.ilCtrl.php.
References searchReturnClass().
Referenced by getParentReturn().
{ $a_class = strtolower($a_class); $ret_class = $this->searchReturnClass($a_class); //echo ":$ret_class:"; if($ret_class) { //echo ":".$this->return[$ret_class].":"; return $this->return[$ret_class]; } }
ilCtrl::getPathNew | ( | $ | a_source_node, | |
$ | a_target_node | |||
) |
get path in call structure
string | $a_source_node source node id | |
string | $a_source_node target node id |
private
Definition at line 347 of file class.ilCtrl.php.
Referenced by getNextClass(), getParameterArrayByClass(), and searchReturnClass().
{ //echo "-".$a_source_node."-"; $path_rev = array(); $c_target = $a_target_node; while ($a_source_node != $c_target) { $path_rev[] = $c_target; $c_target = $this->call_node[$c_target]["parent"]; if(!($c_target > 0)) { echo "ERROR: Path not found. Source:".$a_source_node. ", Target:".$a_target_node; exit; } } if ($a_source_node == $c_target) { $path_rev[] = $c_target; } $path = array(); for ($i=0; $i<count($path_rev); $i++) { $path[] = $path_rev[count($path_rev) - ($i + 1)]; } foreach($path as $node) { //echo "<br>-->".$node.":".$this->call_node[$node]["class"]; } return $path; }
ilCtrl::getRedirectSource | ( | ) |
get current redirect source
Definition at line 708 of file class.ilCtrl.php.
References $_GET.
{ return $_GET["redirectSource"]; }
ilCtrl::getTabs | ( | ) |
get tabs array
Definition at line 204 of file class.ilCtrl.php.
{
return $this->tab;
}
ilCtrl::getTargetScript | ( | ) |
get target script name
Definition at line 517 of file class.ilCtrl.php.
Referenced by getLinkTargetByClass(), setReturn(), and setReturnByClass().
{
return $this->target_script;
}
ilCtrl::getTransitArray | ( | ) |
ilCtrl::getUrlParameters | ( | $ | a_class, | |
$ | a_str, | |||
$ | a_cmd = "" , |
|||
$ | a_transits = "" | |||
) |
Definition at line 758 of file class.ilCtrl.php.
References $params, ilUtil::appendUrlParameterString(), and getParameterArrayByClass().
Referenced by getLinkTargetByClass(), setReturn(), and setReturnByClass().
{ // note: $a_class may be an array! //$a_class = strtolower($a_class); $params = $this->getParameterArrayByClass($a_class, $a_cmd, $a_transits); foreach ($params as $par => $value) { $a_str = ilUtil::appendUrlParameterString($a_str, $par."=".$value); } return $a_str; }
ilCtrl::ilCtrl | ( | ) |
control class constructor
Definition at line 43 of file class.ilCtrl.php.
References $ilBench.
{ global $ilBench; $this->bench =& $ilBench; $this->transit = array(); $this->location = array(); $this->tab = array(); $this->current_node = 0; }
ilCtrl::redirect | ( | &$ | a_gui_obj, | |
$ | a_cmd = "" | |||
) |
Definition at line 598 of file class.ilCtrl.php.
References $script, and getLinkTargetByClass().
Referenced by redirectByClass(), and returnToParent().
{ //echo "<br>class:".get_class($a_gui_obj).":"; $script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd); //echo "<br>script:$script:"; ilUtil::redirect($script); }
ilCtrl::redirectByClass | ( | $ | a_class, | |
$ | a_cmd = "" | |||
) |
redirect to other gui class
string | $a_class command target class | |
string | $a_cmd command |
Definition at line 613 of file class.ilCtrl.php.
References $script, getLinkTargetByClass(), and redirect().
{ // $a_class may be an array //$a_class = strtolower($a_class); //echo "<br>class:".get_class($a_gui_obj).":"; $script = $this->getLinkTargetByClass($a_class, $a_cmd); //echo "<br>script:$script:"; ilUtil::redirect($script); }
ilCtrl::returnToParent | ( | &$ | a_gui_obj, | |
$ | a_anchor = "" | |||
) |
redirects to next parent class that used setReturn
Definition at line 690 of file class.ilCtrl.php.
References $script, ilUtil::appendUrlParameterString(), getParentReturn(), and redirect().
{ $script = $this->getParentReturn($a_gui_obj); $script = ilUtil::appendUrlParameterString($script, "redirectSource=".strtolower(get_class($a_gui_obj))); if ($a_anchor != "") { $script = $script."#".$a_anchor; } ilUtil::redirect($script); }
ilCtrl::saveParameter | ( | &$ | a_obj, | |
$ | a_parameter | |||
) |
set parameters that must be saved in forms an links
object | $a_obj command object for that the parameter should be saved between multiple http requests | |
string | $a_parameter parameter name public |
Definition at line 271 of file class.ilCtrl.php.
{ if (is_array($a_parameter)) { foreach($a_parameter as $parameter) { $this->save_parameter[strtolower(get_class($a_obj))][] = $parameter; } } else { $this->save_parameter[strtolower(get_class($a_obj))][] = $a_parameter; } }
ilCtrl::searchReturnClass | ( | $ | a_class | ) |
get current return class
Definition at line 737 of file class.ilCtrl.php.
References $path, getNodeIdForTargetClass(), and getPathNew().
Referenced by getParentReturnByClass().
{ //echo "<br>searchReturnClass".$a_class; $a_class = strtolower($a_class); $nr = $this->getNodeIdForTargetClass($this->current_node, $a_class); $path = $this->getPathNew(1, $nr); //var_dump($path); for($i = count($path)-2; $i>=0; $i--) { //echo "<br>:$i:".$path[$i].":".$this->call_node[$path[$i]]["class"] // .":".$this->return[$this->call_node[$path[$i]]["class"]].":"; if ($this->return[$this->call_node[$path[$i]]["class"]] != "") { return $this->call_node[$path[$i]]["class"]; } } return false; }
ilCtrl::setCmd | ( | $ | a_cmd | ) |
set the current command
IMPORTANT NOTE:
please use this function only in exceptional cases it is not intended for setting commands in forms or links! use the corresponding parameters of getFormAction() and getLinkTarget() instead.
Definition at line 551 of file class.ilCtrl.php.
References $_GET.
{ $_GET["cmd"] = $a_cmd; }
ilCtrl::setCmdClass | ( | $ | a_cmd_class | ) |
set the current command class
IMPORTANT NOTE:
please use this function only in exceptional cases it is not intended for setting the command class in forms or links! use the corresponding parameters of getFormAction() and getLinkTarget() instead.
Definition at line 566 of file class.ilCtrl.php.
References $_GET, and getNodeIdForTargetClass().
{ $a_cmd_class = strtolower($a_cmd_class); //echo "<br><b>setCmdClass:$a_cmd_class:</b>"; $nr = $this->getNodeIdForTargetClass($this->current_node, $a_cmd_class); $_GET["cmdClass"] = $a_cmd_class; $_GET["cmdNode"] = $nr; }
ilCtrl::setParameter | ( | &$ | a_obj, | |
$ | a_parameter, | |||
$ | a_value | |||
) |
Set a parameter (note: if this is also a saved parameter, the saved value will be overwritten).
Definition at line 290 of file class.ilCtrl.php.
{ $this->parameter[strtolower(get_class($a_obj))][$a_parameter] = $a_value; }
ilCtrl::setParameterByClass | ( | $ | a_class, | |
$ | a_parameter, | |||
$ | a_value | |||
) |
Set a parameter (note: if this is also a saved parameter, the saved value will be overwritten).
Definition at line 299 of file class.ilCtrl.php.
{ $this->parameter[strtolower($a_class)][$a_parameter] = $a_value; }
ilCtrl::setReturn | ( | &$ | a_gui_obj, | |
$ | a_cmd | |||
) |
set return command
Definition at line 665 of file class.ilCtrl.php.
References $script, getTargetScript(), and getUrlParameters().
{ $script = $this->getTargetScript(); $script = $this->getUrlParameters(strtolower(get_class($a_gui_obj)), $script, $a_cmd); //echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>"; $this->return[strtolower(get_class($a_gui_obj))] = $script; }
ilCtrl::setReturnByClass | ( | $ | a_class, | |
$ | a_cmd | |||
) |
set return command
Definition at line 676 of file class.ilCtrl.php.
References $script, getTargetScript(), and getUrlParameters().
{ // may not be an array! $a_class = strtolower($a_class); $script = $this->getTargetScript(); $script = $this->getUrlParameters($a_class, $script, $a_cmd); //echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>"; $this->return[strtolower($a_class)] = $script; }
ilCtrl::setTargetScript | ( | $ | a_target_script | ) |
private
set target script name
string | $a_target_script target script name |
Definition at line 506 of file class.ilCtrl.php.
{ $this->target_script = $a_target_script; }
ilCtrl::$forward |
Definition at line 35 of file class.ilCtrl.php.
ilCtrl::$parent |
Definition at line 36 of file class.ilCtrl.php.
ilCtrl::$return |
Definition at line 38 of file class.ilCtrl.php.
ilCtrl::$save_parameter |
Definition at line 37 of file class.ilCtrl.php.
ilCtrl::$target_script |
Definition at line 34 of file class.ilCtrl.php.