ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 @inheritDoc More...
 
 getObjNameByCid (string $cid)
 @inheritDoc More...
 
 getObjNameByName (string $class_name)
 @inheritDoc More...
 
 getClassNameByCid (string $cid)
 @inheritDoc More...
 
 getClassCidByName (string $class_name)
 @inheritDoc More...
 
 getRelativePathByName (string $class_name)
 @inheritDoc More...
 
 getRelativePathByCid (string $cid)
 @inheritDoc More...
 
 getChildrenByCid (string $cid)
 @inheritDoc More...
 
 getChildrenByName (string $class_name)
 @inheritDoc More...
 
 getParentsByCid (string $cid)
 @inheritDoc More...
 
 getParentsByName (string $class_name)
 @inheritDoc More...
 
 setPermanentParameterByClass (string $class_name, string $parameter_name)
 @inheritDoc More...
 
 removePermanentParametersByClass (string $class_name)
 @inheritDoc More...
 
 getPermanentParametersByClass (string $class_name)
 @inheritDoc More...
 
 setTemporaryParameterByClass (string $class_name, string $parameter_name, $value)
 @inheritDoc More...
 
 removeTemporaryParametersByClass (string $class_name)
 @inheritDoc More...
 
 getTemporaryParametersByClass (string $class_name)
 @inheritDoc More...
 
 removeSingleParameterByClass (string $class_name, string $parameter_name)
 @inheritDoc More...
 
 setReturnTargetByClass (string $class_name, string $target_url)
 @inheritDoc More...
 
 getReturnTargetByClass (string $class_name)
 @inheritDoc More...
 
 getUnsafeCommandsByCid (string $cid)
 @inheritDoc More...
 
 getUnsafeCommandsByName (string $class_name)
 @inheritDoc More...
 
 getSafeCommandsByCid (string $cid)
 @inheritDoc More...
 
 getSafeCommandsByName (string $class_name)
 @inheritDoc More...
 
 isBaseClass (string $class_name)
 Returns whether the given class is registered as a valid baseclass (module or service class) in the database. More...
 
 getObjNameByCid (string $cid)
 Returns the qualified object name of a class for the given CID, which can be used to instantiate the object. More...
 
 getObjNameByName (string $class_name)
 Returns the qualified object name of a given class, which can be used to instantiate the object. More...
 
 getClassNameByCid (string $cid)
 Returns the lower-cased name of a class for the given CID. More...
 
 getClassCidByName (string $class_name)
 Returns the CID of the given classname. More...
 
 getRelativePathByName (string $class_name)
 Returns the absolute path of a class for the given name. More...
 
 getRelativePathByCid (string $cid)
 Returns the absolute path of a class for the given CID. More...
 
 getChildrenByCid (string $cid)
 Returns all classes that can be called by a class for the given CID. More...
 
 getChildrenByName (string $class_name)
 Returns all classes that can be called by the given class. More...
 
 getParentsByCid (string $cid)
 Returns all classes that can call a class for the given CID. More...
 
 getParentsByName (string $class_name)
 Returns all classes that can call the given class. More...
 
 setPermanentParameterByClass (string $class_name, string $parameter_name)
 Saves a parameter for the given class, that should be fetched with every request including it. More...
 
 removePermanentParametersByClass (string $class_name)
 Removes all permanent parameters for the given class. More...
 
 getPermanentParametersByClass (string $class_name)
 Returns all permanent parameters for the given class. More...
 
 setTemporaryParameterByClass (string $class_name, string $parameter_name, $value)
 Sets a parameter => value pair for the given class which will be appended for the next request. More...
 
 removeTemporaryParametersByClass (string $class_name)
 Removes all temporarily set parameter => value pairs for the given class. More...
 
 getTemporaryParametersByClass (string $class_name)
 Returns all temporary parameters currently set for a given class. More...
 
 removeSingleParameterByClass (string $class_name, string $parameter_name)
 Removes a specific permanent or temporary parameter for the given class. More...
 
 setReturnTargetByClass (string $class_name, string $target_url)
 Sets a target URL for the given class in order to reach it. More...
 
 getReturnTargetByClass (string $class_name)
 Returns a target URL for the given class in order to reach it. More...
 
 getUnsafeCommandsByCid (string $cid)
 Returns all unsafe GET commands for a given cid. More...
 
 getUnsafeCommandsByName (string $class_name)
 Returns all unsafe GET commands for a given classname. More...
 
 getSafeCommandsByCid (string $cid)
 Returns all safe POST commands for a given cid. More...
 
 getSafeCommandsByName (string $class_name)
 Returns all safe POST commands for a given classname. More...
 

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.

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

References $base_classes.

Member Function Documentation

◆ getChildrenByCid()

ilCtrlStructure::getChildrenByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
getValueForKeyByCid(string $identifier_key, string $cid)
Returns a stored structure value of the given key from the corresponding class mapped by CID.

References getValueForKeyByCid().

+ Here is the call graph for this function:

◆ getChildrenByName()

ilCtrlStructure::getChildrenByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
getValueForKeyByName(string $identifier_key, string $class_name)
Returns a stored structure value of the given key from the corresponding class mapped by name.

References getValueForKeyByName().

+ Here is the call graph for this function:

◆ getClassCidByName()

ilCtrlStructure::getClassCidByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

139 : ?string
140 {
141 return $this->getValueForKeyByName(self::KEY_CLASS_CID, $class_name);
142 }

References getValueForKeyByName().

Referenced by isBaseClass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClassNameByCid()

ilCtrlStructure::getClassNameByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
lowercase(string $string)
Helper function to lowercase strings.

References getValueForKeyByCid(), and lowercase().

Referenced by getSafeCommandsByCid(), and getUnsafeCommandsByCid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjNameByCid()

ilCtrlStructure::getObjNameByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

110 : ?string
111 {
112 return $this->getValueForKeyByCid(self::KEY_CLASS_NAME, $cid);
113 }

References getValueForKeyByCid().

+ Here is the call graph for this function:

◆ getObjNameByName()

ilCtrlStructure::getObjNameByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

118 : ?string
119 {
120 return $this->getValueForKeyByName(self::KEY_CLASS_NAME, $class_name);
121 }

References getValueForKeyByName().

+ Here is the call graph for this function:

◆ getParentsByCid()

ilCtrlStructure::getParentsByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References getValueForKeyByCid().

+ Here is the call graph for this function:

◆ getParentsByName()

ilCtrlStructure::getParentsByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References getValueForKeyByName().

+ Here is the call graph for this function:

◆ getPermanentParametersByClass()

ilCtrlStructure::getPermanentParametersByClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

242 : ?array
243 {
244 return $this->permanent_parameters[$this->lowercase($class_name)] ?? null;
245 }

References lowercase().

+ Here is the call graph for this function:

◆ getRelativePathByCid()

ilCtrlStructure::getRelativePathByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

155 : ?string
156 {
157 return $this->getValueForKeyByCid(self::KEY_CLASS_PATH, $cid);
158 }

References getValueForKeyByCid().

+ Here is the call graph for this function:

◆ getRelativePathByName()

ilCtrlStructure::getRelativePathByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

147 : ?string
148 {
149 return $this->getValueForKeyByName(self::KEY_CLASS_PATH, $class_name);
150 }

References getValueForKeyByName().

+ Here is the call graph for this function:

◆ getReturnTargetByClass()

ilCtrlStructure::getReturnTargetByClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

319 : ?string
320 {
321 return $this->return_targets[$this->lowercase($class_name)] ?? null;
322 }

References lowercase().

+ Here is the call graph for this function:

◆ getSafeCommandsByCid()

ilCtrlStructure::getSafeCommandsByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
getSafeCommandsByName(string $class_name)
@inheritDoc
getClassNameByCid(string $cid)
@inheritDoc

References getClassNameByCid(), and getSafeCommandsByName().

+ Here is the call graph for this function:

◆ getSafeCommandsByName()

ilCtrlStructure::getSafeCommandsByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

361 : array
362 {
363 return $this->security[$this->lowercase($class_name)][self::KEY_SAFE_COMMANDS] ?? [];
364 }

References ilCtrlStructureInterface\KEY_SAFE_COMMANDS, and lowercase().

Referenced by getSafeCommandsByCid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTemporaryParametersByClass()

ilCtrlStructure::getTemporaryParametersByClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

273 : ?array
274 {
275 return $this->temporary_parameters[$this->lowercase($class_name)] ?? null;
276 }

References lowercase().

+ Here is the call graph for this function:

◆ getUnsafeCommandsByCid()

ilCtrlStructure::getUnsafeCommandsByCid ( string  $cid)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
getUnsafeCommandsByName(string $class_name)
@inheritDoc

References getClassNameByCid(), and getUnsafeCommandsByName().

+ Here is the call graph for this function:

◆ getUnsafeCommandsByName()

ilCtrlStructure::getUnsafeCommandsByName ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

340 : array
341 {
342 return $this->security[$this->lowercase($class_name)][self::KEY_UNSAFE_COMMANDS] ?? [];
343 }

References ilCtrlStructureInterface\KEY_UNSAFE_COMMANDS, and lowercase().

Referenced by getUnsafeCommandsByCid().

+ 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.

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 }

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

+ 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.

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 }

References lowercase().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBaseClass()

ilCtrlStructure::isBaseClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }
getClassCidByName(string $class_name)
@inheritDoc

References getClassCidByName(), and lowercase().

+ Here is the call graph for this function:

◆ lowercase()

ilCtrlStructure::lowercase ( string  $string)
private

◆ removePermanentParametersByClass()

ilCtrlStructure::removePermanentParametersByClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References lowercase().

+ Here is the call graph for this function:

◆ removeSingleParameterByClass()

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

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References $permanent_parameters, and lowercase().

+ Here is the call graph for this function:

◆ removeTemporaryParametersByClass()

ilCtrlStructure::removeTemporaryParametersByClass ( string  $class_name)

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References lowercase().

+ Here is the call graph for this function:

◆ setPermanentParameterByClass()

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

@inheritDoc

Implements ilCtrlStructureInterface.

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

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...

References lowercase(), and ilCtrlInterface\PROTECTED_PARAMETERS.

+ Here is the call graph for this function:

◆ setReturnTargetByClass()

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

@inheritDoc

Implements ilCtrlStructureInterface.

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

311 : void
312 {
313 $this->return_targets[$this->lowercase($class_name)] = $target_url;
314 }

References lowercase().

+ Here is the call graph for this function:

◆ setTemporaryParameterByClass()

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

@inheritDoc

Implements ilCtrlStructureInterface.

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

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 }

References lowercase().

+ 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.

Referenced by removeSingleParameterByClass().

◆ $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: