ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCtrlStructureCidGenerator Class Reference

Class ilCtrlStructureCidGenerator. More...

+ Collaboration diagram for ilCtrlStructureCidGenerator:

Public Member Functions

 __construct (int $starting_index=0)
 ilCtrlStructureCidGenerator Constructor More...
 
 getIndexByCid (string $cid)
 Returns the index of a given cid. More...
 
 getCidByIndex (int $index)
 Returns the cid for a given index. More...
 
 getCid ()
 Returns the next available cid. More...
 

Private Member Functions

 invertIndex (int $index)
 Helper function that inverts an integer value. More...
 

Private Attributes

int $index
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCtrlStructureCidGenerator::__construct ( int  $starting_index = 0)

ilCtrlStructureCidGenerator Constructor

Parameters
int$starting_index

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

39 {
40 $this->index = $starting_index;
41 }

Member Function Documentation

◆ getCid()

ilCtrlStructureCidGenerator::getCid ( )

Returns the next available cid.

Returns
string

Definition at line 81 of file class.ilCtrlStructureCidGenerator.php.

81 : string
82 {
83 return $this->getCidByIndex($this->index++);
84 }
getCidByIndex(int $index)
Returns the cid for a given index.

References getCidByIndex().

+ Here is the call graph for this function:

◆ getCidByIndex()

ilCtrlStructureCidGenerator::getCidByIndex ( int  $index)

Returns the cid for a given index.

Parameters
int$index
Returns
string

Definition at line 67 of file class.ilCtrlStructureCidGenerator.php.

67 : string
68 {
69 if (0 > $index) {
70 return '-' . base_convert((string) $this->invertIndex($index), 10, 36);
71 }
72
73 return base_convert((string) $index, 10, 36);
74 }
invertIndex(int $index)
Helper function that inverts an integer value.

References $index, and invertIndex().

Referenced by getCid().

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

◆ getIndexByCid()

ilCtrlStructureCidGenerator::getIndexByCid ( string  $cid)

Returns the index of a given cid.

Parameters
string$cid
Returns
int

Definition at line 49 of file class.ilCtrlStructureCidGenerator.php.

49 : int
50 {
51 if (strpos($cid, '-') === 0) {
52 $inverted_cid = str_replace('-', '', $cid);
53 $index = (int) base_convert($inverted_cid, 36, 10);
54
55 return $this->invertIndex($index);
56 }
57
58 return (int) base_convert($cid, 36, 10);
59 }

References $index, ILIAS\Repository\int(), and invertIndex().

+ Here is the call graph for this function:

◆ invertIndex()

ilCtrlStructureCidGenerator::invertIndex ( int  $index)
private

Helper function that inverts an integer value.

Parameters
int$index
Returns
int

Definition at line 92 of file class.ilCtrlStructureCidGenerator.php.

92 : int
93 {
94 return (-1 * $index);
95 }

References $index.

Referenced by getCidByIndex(), and getIndexByCid().

+ Here is the caller graph for this function:

Field Documentation

◆ $index

int ilCtrlStructureCidGenerator::$index
private

Definition at line 31 of file class.ilCtrlStructureCidGenerator.php.

Referenced by getCidByIndex(), getIndexByCid(), and invertIndex().


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