ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 12 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 71 of file class.ilCtrlStructure.php.

References $base_classes.

75  {
76  $this->base_classes = $base_classes;
77  $this->security = $security_info;
78  $this->structure = $ctrl_structure;
79  }

Member Function Documentation

◆ getChildrenByCid()

ilCtrlStructure::getChildrenByCid ( string  $cid)

Implements ilCtrlStructureInterface.

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

References getValueForKeyByCid().

149  : ?array
150  {
151  $children = $this->getValueForKeyByCid(self::KEY_CLASS_CHILDREN, $cid);
152  if (empty($children)) {
153  return null;
154  }
155 
156  return $children;
157  }
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 162 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

162  : ?array
163  {
164  $children = $this->getValueForKeyByName(self::KEY_CLASS_CHILDREN, $class_name);
165  if (empty($children)) {
166  return null;
167  }
168 
169  return $children;
170  }
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 125 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

Referenced by isBaseClass().

125  : ?string
126  {
127  return $this->getValueForKeyByName(self::KEY_CLASS_CID, $class_name);
128  }
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 112 of file class.ilCtrlStructure.php.

References getValueForKeyByCid(), and lowercase().

Referenced by getSafeCommandsByCid(), and getUnsafeCommandsByCid().

112  : ?string
113  {
114  $class_name = $this->getValueForKeyByCid(
115  self::KEY_CLASS_NAME,
116  $cid
117  );
118 
119  return (null !== $class_name) ? $this->lowercase($class_name) : null;
120  }
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 96 of file class.ilCtrlStructure.php.

References getValueForKeyByCid().

96  : ?string
97  {
98  return $this->getValueForKeyByCid(self::KEY_CLASS_NAME, $cid);
99  }
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 104 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

104  : ?string
105  {
106  return $this->getValueForKeyByName(self::KEY_CLASS_NAME, $class_name);
107  }
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 175 of file class.ilCtrlStructure.php.

References getValueForKeyByCid().

175  : ?array
176  {
177  $parents = $this->getValueForKeyByCid(self::KEY_CLASS_PARENTS, $cid);
178  if (empty($parents)) {
179  return null;
180  }
181 
182  return $parents;
183  }
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 188 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

188  : ?array
189  {
190  $parents = $this->getValueForKeyByName(self::KEY_CLASS_PARENTS, $class_name);
191  if (empty($parents)) {
192  return null;
193  }
194 
195  return $parents;
196  }
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 228 of file class.ilCtrlStructure.php.

References lowercase().

228  : ?array
229  {
230  return $this->permanent_parameters[$this->lowercase($class_name)] ?? null;
231  }
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 141 of file class.ilCtrlStructure.php.

References getValueForKeyByCid().

141  : ?string
142  {
143  return $this->getValueForKeyByCid(self::KEY_CLASS_PATH, $cid);
144  }
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 133 of file class.ilCtrlStructure.php.

References getValueForKeyByName().

133  : ?string
134  {
135  return $this->getValueForKeyByName(self::KEY_CLASS_PATH, $class_name);
136  }
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 305 of file class.ilCtrlStructure.php.

References lowercase().

305  : ?string
306  {
307  return $this->return_targets[$this->lowercase($class_name)] ?? null;
308  }
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 334 of file class.ilCtrlStructure.php.

References getClassNameByCid(), and getSafeCommandsByName().

334  : array
335  {
336  $class_name = $this->getClassNameByCid($cid);
337  if (null !== $class_name) {
338  return $this->getSafeCommandsByName($class_name);
339  }
340 
341  return [];
342  }
getClassNameByCid(string $cid)
getSafeCommandsByName(string $class_name)
+ Here is the call graph for this function:

◆ getSafeCommandsByName()

ilCtrlStructure::getSafeCommandsByName ( string  $class_name)

Implements ilCtrlStructureInterface.

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

References lowercase().

Referenced by getSafeCommandsByCid().

347  : array
348  {
349  return $this->security[$this->lowercase($class_name)][self::KEY_SAFE_COMMANDS] ?? [];
350  }
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 259 of file class.ilCtrlStructure.php.

References lowercase().

259  : ?array
260  {
261  return $this->temporary_parameters[$this->lowercase($class_name)] ?? null;
262  }
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 313 of file class.ilCtrlStructure.php.

References getClassNameByCid(), and getUnsafeCommandsByName().

313  : array
314  {
315  $class_name = $this->getClassNameByCid($cid);
316  if (null !== $class_name) {
317  return $this->getUnsafeCommandsByName($class_name);
318  }
319 
320  return [];
321  }
getClassNameByCid(string $cid)
getUnsafeCommandsByName(string $class_name)
+ Here is the call graph for this function:

◆ getUnsafeCommandsByName()

ilCtrlStructure::getUnsafeCommandsByName ( string  $class_name)

Implements ilCtrlStructureInterface.

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

References lowercase().

Referenced by getUnsafeCommandsByCid().

326  : array
327  {
328  return $this->security[$this->lowercase($class_name)][self::KEY_UNSAFE_COMMANDS] ?? [];
329  }
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 359 of file class.ilCtrlStructure.php.

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

360  {
361  if (isset($this->mapped_structure[$cid][$identifier_key])) {
362  return $this->mapped_structure[$cid][$identifier_key];
363  }
364 
365  foreach ($this->structure as $class_info) {
366  if (isset($class_info[$identifier_key]) && $class_info[self::KEY_CLASS_CID] === $cid) {
367  $this->mapped_structure[$cid] = $class_info;
368  return $class_info[$identifier_key];
369  }
370  }
371 
372  return null;
373  }
+ 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 382 of file class.ilCtrlStructure.php.

References lowercase().

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

383  {
384  $class_name = $this->lowercase($class_name);
385  if (isset($this->structure[$class_name])) {
386  return $this->structure[$class_name][$identifier_key];
387  }
388 
389  return null;
390  }
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 84 of file class.ilCtrlStructure.php.

References getClassCidByName(), and lowercase().

84  : bool
85  {
86  // baseclass must be contained within the current structure
87  // and within the current baseclass array.
88  return
89  null !== $this->getClassCidByName($class_name) &&
90  in_array($this->lowercase($class_name), $this->base_classes, true);
91  }
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 217 of file class.ilCtrlStructure.php.

References lowercase().

217  : void
218  {
219  $class_name = $this->lowercase($class_name);
220  if (isset($this->permanent_parameters[$class_name])) {
221  unset($this->permanent_parameters[$class_name]);
222  }
223  }
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 267 of file class.ilCtrlStructure.php.

References $index, and lowercase().

267  : void
268  {
269  $class_name = $this->lowercase($class_name);
270 
271  // permanent parameters are lists of parameter names
272  // mapped to the classname, therefore the index is
273  // unknown and has to be figured out.
274  if (!empty($this->permanent_parameters[$class_name])) {
275  foreach ($this->permanent_parameters[$class_name] as $index => $permanent_parameter) {
276  if ($parameter_name === $permanent_parameter) {
277  unset($this->permanent_parameters[$class_name][$index]);
278 
279  // reindex the array values.
280  $permanent_parameters = &$this->permanent_parameters[$class_name];
282  }
283  }
284  }
285 
286  // the temporary parameters are key => value pairs mapped
287  // to the classname, whereas key is the parameter name.
288  // The index is therefore known and can be unset directly.
289  if (isset($this->temporary_parameters[$class_name])) {
290  unset($this->temporary_parameters[$class_name][$parameter_name]);
291  }
292  }
$index
Definition: metadata.php:145
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 248 of file class.ilCtrlStructure.php.

References lowercase().

248  : void
249  {
250  $class_name = $this->lowercase($class_name);
251  if (isset($this->temporary_parameters[$class_name])) {
252  unset($this->temporary_parameters[$class_name]);
253  }
254  }
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 201 of file class.ilCtrlStructure.php.

References lowercase(), and ilCtrlInterface\PROTECTED_PARAMETERS.

201  : void
202  {
203  if (in_array($parameter_name, ilCtrlInterface::PROTECTED_PARAMETERS, true)) {
204  throw new ilCtrlException("Parameter '$parameter_name' must not be saved, it could mess with the control flow.");
205  }
206 
207  if (!preg_match(self::PARAM_NAME_REGEX, $parameter_name)) {
208  throw new ilCtrlException("Cannot save parameter '$parameter_name', as it contains invalid characters.");
209  }
210 
211  $this->permanent_parameters[$this->lowercase($class_name)][] = $parameter_name;
212  }
ilCtrl exceptions
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 297 of file class.ilCtrlStructure.php.

References lowercase().

297  : void
298  {
299  $this->return_targets[$this->lowercase($class_name)] = $target_url;
300  }
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 236 of file class.ilCtrlStructure.php.

References lowercase().

236  : void
237  {
238  if (!preg_match(self::PARAM_NAME_REGEX, $parameter_name)) {
239  throw new ilCtrlException("Cannot save parameter '$parameter_name', as it contains invalid characters.");
240  }
241 
242  $this->temporary_parameters[$this->lowercase($class_name)][$parameter_name] = $value;
243  }
ilCtrl exceptions
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 50 of file class.ilCtrlStructure.php.

Referenced by __construct().

◆ $mapped_structure

array ilCtrlStructure::$mapped_structure = []
private

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

◆ $permanent_parameters

array ilCtrlStructure::$permanent_parameters = []
private

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

◆ $return_targets

array ilCtrlStructure::$return_targets = []
private

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

◆ $security

array ilCtrlStructure::$security
private

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

◆ $structure

array ilCtrlStructure::$structure
private

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

◆ $temporary_parameters

array ilCtrlStructure::$temporary_parameters = []
private

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

◆ PARAM_NAME_REGEX

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

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


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