ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCtrlStructure Class Reference

Class ilCtrlStructure holds the currently read control structure. More...

+ Inheritance diagram for ilCtrlStructure:
+ Collaboration diagram for ilCtrlStructure:

Public Member Functions

 __construct (array $ctrl_structure, array $base_classes, array $security_info)
 ilCtrlStructure Constructor More...
 
 isBaseClass (string $class_name)
 
 getObjNameByCid (string $cid)
 
 getObjNameByName (string $class_name)
 
 getClassNameByCid (string $cid)
 
 getClassCidByName (string $class_name)
 
 getRelativePathByName (string $class_name)
 
 getRelativePathByCid (string $cid)
 
 getChildrenByCid (string $cid)
 
 getChildrenByName (string $class_name)
 
 getParentsByCid (string $cid)
 
 getParentsByName (string $class_name)
 
 setPermanentParameterByClass (string $class_name, string $parameter_name)
 
 removePermanentParametersByClass (string $class_name)
 
 getPermanentParametersByClass (string $class_name)
 
 setTemporaryParameterByClass (string $class_name, string $parameter_name, $value)
 
 removeTemporaryParametersByClass (string $class_name)
 
 getTemporaryParametersByClass (string $class_name)
 
 removeSingleParameterByClass (string $class_name, string $parameter_name)
 
 setReturnTargetByClass (string $class_name, string $target_url)
 
 getReturnTargetByClass (string $class_name)
 
 getUnsafeCommandsByCid (string $cid)
 
 getUnsafeCommandsByName (string $class_name)
 
 getSafeCommandsByCid (string $cid)
 
 getSafeCommandsByName (string $class_name)
 

Private Member Functions

 getValueForKeyByCid (string $identifier_key, string $cid)
 Returns a stored structure value of the given key from the corresponding class mapped by CID. More...
 
 getValueForKeyByName (string $identifier_key, string $class_name)
 Returns a stored structure value of the given key from the corresponding class mapped by name. More...
 
 lowercase (string $string)
 Helper function to lowercase strings. More...
 

Private Attributes

const PARAM_NAME_REGEX = '/^[A-Za-z0-9_-]*$/'
 
array $temporary_parameters = []
 
array $permanent_parameters = []
 
array $return_targets = []
 
array $structure
 
array $base_classes
 
array $security
 
array $mapped_structure = []
 

Additional Inherited Members

- Data Fields inherited from ilCtrlStructureInterface
const KEY_CLASS_CID = 'cid'
 array key constants that are used for certain information. More...
 
const KEY_CLASS_PATH = 'class_path'
 
const KEY_CLASS_NAME = 'class_name'
 
const KEY_CLASS_CID_PATHS = 'cid_paths'
 
const KEY_CLASS_PARENTS = 'parents'
 
const KEY_CLASS_CHILDREN = 'children'
 
const KEY_UNSAFE_COMMANDS = 'unsafe_commands'
 
const KEY_SAFE_COMMANDS = 'safe_commands'
 

Detailed Description

Class ilCtrlStructure holds the currently read control structure.

Author
Thibeau Fuhrer thf@s.nosp@m.tude.nosp@m.r-rai.nosp@m.mann.nosp@m..ch

Definition at line 26 of file class.ilCtrlStructure.php.

Constructor & Destructor Documentation

◆ __construct()

ilCtrlStructure::__construct ( array  $ctrl_structure,
array  $base_classes,
array  $security_info 
)

ilCtrlStructure Constructor

Parameters
array$ctrl_structure
array$base_classes
array$security_info

Definition at line 85 of file class.ilCtrlStructure.php.

References $base_classes.

89  {
90  $this->base_classes = $base_classes;
91  $this->security = $security_info;
92  $this->structure = $ctrl_structure;
93  }

Member Function Documentation

◆ getChildrenByCid()

ilCtrlStructure::getChildrenByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 163 of file class.ilCtrlStructure.php.

References getValueForKeyByCid(), and null.

163  : ?array
164  {
165  $children = $this->getValueForKeyByCid(self::KEY_CLASS_CHILDREN, $cid);
166  if (empty($children)) {
167  return null;
168  }
169 
170  return $children;
171  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID...
+ Here is the call graph for this function:

◆ getChildrenByName()

ilCtrlStructure::getChildrenByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 176 of file class.ilCtrlStructure.php.

References getValueForKeyByName(), and null.

176  : ?array
177  {
178  $children = $this->getValueForKeyByName(self::KEY_CLASS_CHILDREN, $class_name);
179  if (empty($children)) {
180  return null;
181  }
182 
183  return $children;
184  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name...
+ Here is the call graph for this function:

◆ getClassCidByName()

ilCtrlStructure::getClassCidByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 139 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

Referenced by isBaseClass().

139  : ?string
140  {
141  return $this->getValueForKeyByName(self::KEY_CLASS_CID, $class_name);
142  }
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClassNameByCid()

ilCtrlStructure::getClassNameByCid ( string  $cid)

Implements ilCtrlStructureInterface.

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

References getValueForKeyByCid(), lowercase(), and null.

Referenced by getSafeCommandsByCid(), and getUnsafeCommandsByCid().

126  : ?string
127  {
128  $class_name = $this->getValueForKeyByCid(
129  self::KEY_CLASS_NAME,
130  $cid
131  );
132 
133  return (null !== $class_name) ? $this->lowercase($class_name) : null;
134  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjNameByCid()

ilCtrlStructure::getObjNameByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 110 of file class.ilCtrlStructure.php.

References getValueForKeyByCid().

110  : ?string
111  {
112  return $this->getValueForKeyByCid(self::KEY_CLASS_NAME, $cid);
113  }
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID...
+ Here is the call graph for this function:

◆ getObjNameByName()

ilCtrlStructure::getObjNameByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 118 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

118  : ?string
119  {
120  return $this->getValueForKeyByName(self::KEY_CLASS_NAME, $class_name);
121  }
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name...
+ Here is the call graph for this function:

◆ getParentsByCid()

ilCtrlStructure::getParentsByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 189 of file class.ilCtrlStructure.php.

References getValueForKeyByCid(), and null.

189  : ?array
190  {
191  $parents = $this->getValueForKeyByCid(self::KEY_CLASS_PARENTS, $cid);
192  if (empty($parents)) {
193  return null;
194  }
195 
196  return $parents;
197  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID...
+ Here is the call graph for this function:

◆ getParentsByName()

ilCtrlStructure::getParentsByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 202 of file class.ilCtrlStructure.php.

References getValueForKeyByName(), and null.

202  : ?array
203  {
204  $parents = $this->getValueForKeyByName(self::KEY_CLASS_PARENTS, $class_name);
205  if (empty($parents)) {
206  return null;
207  }
208 
209  return $parents;
210  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name...
+ Here is the call graph for this function:

◆ getPermanentParametersByClass()

ilCtrlStructure::getPermanentParametersByClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 242 of file class.ilCtrlStructure.php.

References lowercase(), and null.

242  : ?array
243  {
244  return $this->permanent_parameters[$this->lowercase($class_name)] ?? null;
245  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ getRelativePathByCid()

ilCtrlStructure::getRelativePathByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 155 of file class.ilCtrlStructure.php.

References getValueForKeyByCid().

155  : ?string
156  {
157  return $this->getValueForKeyByCid(self::KEY_CLASS_PATH, $cid);
158  }
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID...
+ Here is the call graph for this function:

◆ getRelativePathByName()

ilCtrlStructure::getRelativePathByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 147 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

147  : ?string
148  {
149  return $this->getValueForKeyByName(self::KEY_CLASS_PATH, $class_name);
150  }
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name...
+ Here is the call graph for this function:

◆ getReturnTargetByClass()

ilCtrlStructure::getReturnTargetByClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 319 of file class.ilCtrlStructure.php.

References lowercase(), and null.

319  : ?string
320  {
321  return $this->return_targets[$this->lowercase($class_name)] ?? null;
322  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ getSafeCommandsByCid()

ilCtrlStructure::getSafeCommandsByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 348 of file class.ilCtrlStructure.php.

References getClassNameByCid(), getSafeCommandsByName(), and null.

348  : array
349  {
350  $class_name = $this->getClassNameByCid($cid);
351  if (null !== $class_name) {
352  return $this->getSafeCommandsByName($class_name);
353  }
354 
355  return [];
356  }
getClassNameByCid(string $cid)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSafeCommandsByName(string $class_name)
+ Here is the call graph for this function:

◆ getSafeCommandsByName()

ilCtrlStructure::getSafeCommandsByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 361 of file class.ilCtrlStructure.php.

References lowercase().

Referenced by getSafeCommandsByCid().

361  : array
362  {
363  return $this->security[$this->lowercase($class_name)][self::KEY_SAFE_COMMANDS] ?? [];
364  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTemporaryParametersByClass()

ilCtrlStructure::getTemporaryParametersByClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 273 of file class.ilCtrlStructure.php.

References lowercase(), and null.

273  : ?array
274  {
275  return $this->temporary_parameters[$this->lowercase($class_name)] ?? null;
276  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ getUnsafeCommandsByCid()

ilCtrlStructure::getUnsafeCommandsByCid ( string  $cid)

Implements ilCtrlStructureInterface.

Definition at line 327 of file class.ilCtrlStructure.php.

References getClassNameByCid(), getUnsafeCommandsByName(), and null.

327  : array
328  {
329  $class_name = $this->getClassNameByCid($cid);
330  if (null !== $class_name) {
331  return $this->getUnsafeCommandsByName($class_name);
332  }
333 
334  return [];
335  }
getClassNameByCid(string $cid)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getUnsafeCommandsByName(string $class_name)
+ Here is the call graph for this function:

◆ getUnsafeCommandsByName()

ilCtrlStructure::getUnsafeCommandsByName ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 340 of file class.ilCtrlStructure.php.

References lowercase().

Referenced by getUnsafeCommandsByCid().

340  : array
341  {
342  return $this->security[$this->lowercase($class_name)][self::KEY_UNSAFE_COMMANDS] ?? [];
343  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValueForKeyByCid()

ilCtrlStructure::getValueForKeyByCid ( string  $identifier_key,
string  $cid 
)
private

Returns a stored structure value of the given key from the corresponding class mapped by CID.

Parameters
string$identifier_key
string$cid
Returns
array|string|null

Definition at line 373 of file class.ilCtrlStructure.php.

References null.

Referenced by getChildrenByCid(), getClassNameByCid(), getObjNameByCid(), getParentsByCid(), and getRelativePathByCid().

374  {
375  if (isset($this->mapped_structure[$cid][$identifier_key])) {
376  return $this->mapped_structure[$cid][$identifier_key];
377  }
378 
379  foreach ($this->structure as $class_info) {
380  if (isset($class_info[$identifier_key]) && $class_info[self::KEY_CLASS_CID] === $cid) {
381  $this->mapped_structure[$cid] = $class_info;
382  return $class_info[$identifier_key];
383  }
384  }
385 
386  return null;
387  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getValueForKeyByName()

ilCtrlStructure::getValueForKeyByName ( string  $identifier_key,
string  $class_name 
)
private

Returns a stored structure value of the given key from the corresponding class mapped by name.

Parameters
string$identifier_key
string$class_name
Returns
array|string|null

Definition at line 396 of file class.ilCtrlStructure.php.

References lowercase(), and null.

Referenced by getChildrenByName(), getClassCidByName(), getObjNameByName(), getParentsByName(), and getRelativePathByName().

397  {
398  $class_name = $this->lowercase($class_name);
399  if (isset($this->structure[$class_name])) {
400  return $this->structure[$class_name][$identifier_key];
401  }
402 
403  return null;
404  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBaseClass()

ilCtrlStructure::isBaseClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 98 of file class.ilCtrlStructure.php.

References getClassCidByName(), lowercase(), and null.

98  : bool
99  {
100  // baseclass must be contained within the current structure
101  // and within the current baseclass array.
102  return
103  null !== $this->getClassCidByName($class_name) &&
104  in_array($this->lowercase($class_name), $this->base_classes, true);
105  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lowercase(string $string)
Helper function to lowercase strings.
getClassCidByName(string $class_name)
+ Here is the call graph for this function:

◆ lowercase()

ilCtrlStructure::lowercase ( string  $string)
private

◆ removePermanentParametersByClass()

ilCtrlStructure::removePermanentParametersByClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 231 of file class.ilCtrlStructure.php.

References lowercase().

231  : void
232  {
233  $class_name = $this->lowercase($class_name);
234  if (isset($this->permanent_parameters[$class_name])) {
235  unset($this->permanent_parameters[$class_name]);
236  }
237  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ removeSingleParameterByClass()

ilCtrlStructure::removeSingleParameterByClass ( string  $class_name,
string  $parameter_name 
)

Implements ilCtrlStructureInterface.

Definition at line 281 of file class.ilCtrlStructure.php.

References lowercase().

281  : void
282  {
283  $class_name = $this->lowercase($class_name);
284 
285  // permanent parameters are lists of parameter names
286  // mapped to the classname, therefore the index is
287  // unknown and has to be figured out.
288  if (!empty($this->permanent_parameters[$class_name])) {
289  foreach ($this->permanent_parameters[$class_name] as $index => $permanent_parameter) {
290  if ($parameter_name === $permanent_parameter) {
291  unset($this->permanent_parameters[$class_name][$index]);
292 
293  // reindex the array values.
294  $permanent_parameters = &$this->permanent_parameters[$class_name];
296  }
297  }
298  }
299 
300  // the temporary parameters are key => value pairs mapped
301  // to the classname, whereas key is the parameter name.
302  // The index is therefore known and can be unset directly.
303  if (isset($this->temporary_parameters[$class_name])) {
304  unset($this->temporary_parameters[$class_name][$parameter_name]);
305  }
306  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ removeTemporaryParametersByClass()

ilCtrlStructure::removeTemporaryParametersByClass ( string  $class_name)

Implements ilCtrlStructureInterface.

Definition at line 262 of file class.ilCtrlStructure.php.

References lowercase().

262  : void
263  {
264  $class_name = $this->lowercase($class_name);
265  if (isset($this->temporary_parameters[$class_name])) {
266  unset($this->temporary_parameters[$class_name]);
267  }
268  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ setPermanentParameterByClass()

ilCtrlStructure::setPermanentParameterByClass ( string  $class_name,
string  $parameter_name 
)

Implements ilCtrlStructureInterface.

Definition at line 215 of file class.ilCtrlStructure.php.

References lowercase(), and ilCtrlInterface\PROTECTED_PARAMETERS.

215  : void
216  {
217  if (in_array($parameter_name, ilCtrlInterface::PROTECTED_PARAMETERS, true)) {
218  throw new ilCtrlException("Parameter '$parameter_name' must not be saved, it could mess with the control flow.");
219  }
220 
221  if (!preg_match(self::PARAM_NAME_REGEX, $parameter_name)) {
222  throw new ilCtrlException("Cannot save parameter '$parameter_name', as it contains invalid characters.");
223  }
224 
225  $this->permanent_parameters[$this->lowercase($class_name)][] = $parameter_name;
226  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ setReturnTargetByClass()

ilCtrlStructure::setReturnTargetByClass ( string  $class_name,
string  $target_url 
)

Implements ilCtrlStructureInterface.

Definition at line 311 of file class.ilCtrlStructure.php.

References lowercase().

311  : void
312  {
313  $this->return_targets[$this->lowercase($class_name)] = $target_url;
314  }
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

◆ setTemporaryParameterByClass()

ilCtrlStructure::setTemporaryParameterByClass ( string  $class_name,
string  $parameter_name,
  $value 
)

Implements ilCtrlStructureInterface.

Definition at line 250 of file class.ilCtrlStructure.php.

References lowercase().

250  : void
251  {
252  if (!preg_match(self::PARAM_NAME_REGEX, $parameter_name)) {
253  throw new ilCtrlException("Cannot save parameter '$parameter_name', as it contains invalid characters.");
254  }
255 
256  $this->temporary_parameters[$this->lowercase($class_name)][$parameter_name] = $value;
257  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
lowercase(string $string)
Helper function to lowercase strings.
+ Here is the call graph for this function:

Field Documentation

◆ $base_classes

array ilCtrlStructure::$base_classes
private

Definition at line 64 of file class.ilCtrlStructure.php.

Referenced by __construct().

◆ $mapped_structure

array ilCtrlStructure::$mapped_structure = []
private

Definition at line 77 of file class.ilCtrlStructure.php.

◆ $permanent_parameters

array ilCtrlStructure::$permanent_parameters = []
private

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

◆ $return_targets

array ilCtrlStructure::$return_targets = []
private

Definition at line 52 of file class.ilCtrlStructure.php.

◆ $security

array ilCtrlStructure::$security
private

Definition at line 70 of file class.ilCtrlStructure.php.

◆ $structure

array ilCtrlStructure::$structure
private

Definition at line 58 of file class.ilCtrlStructure.php.

◆ $temporary_parameters

array ilCtrlStructure::$temporary_parameters = []
private

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

◆ PARAM_NAME_REGEX

const ilCtrlStructure::PARAM_NAME_REGEX = '/^[A-Za-z0-9_-]*$/'
private

Definition at line 32 of file class.ilCtrlStructure.php.


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