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

INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other services Description: A Simpe Ini File Implementation to keep settings in a simple file instead of in a DB Based upon class.INIfile.php by Mircho Mirev mirch.nosp@m.o@ma.nosp@m.cropo.nosp@m.int..nosp@m.com Usage Examples: $ini = new IniFile("./ini.ini"); Read entire group in an associative array $grp = $ini->read_group("MAIN"); //prints the variables in the group if ($grp) for(reset($grp); $key=key($grp); next($grp)) { echo "GROUP ". More...

+ Collaboration diagram for ilIniFile:

Public Member Functions

 __construct (string $a_ini_file_name)
 Constructor. More...
 
 read ()
 read from ini file More...
 
 parse ()
 load and parse an inifile More...
 
 write ()
 save ini-file-data to filesystem More...
 

Data Fields

string $INI_FILE_NAME = ""
 name of file More...
 
string $ERROR = ""
 error var More...
 
array $GROUPS = array()
 sections in ini-file More...
 
string $CURRENT_GROUP = ""
 actual section More...
 

Detailed Description

INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other services Description: A Simpe Ini File Implementation to keep settings in a simple file instead of in a DB Based upon class.INIfile.php by Mircho Mirev mirch.nosp@m.o@ma.nosp@m.cropo.nosp@m.int..nosp@m.com Usage Examples: $ini = new IniFile("./ini.ini"); Read entire group in an associative array $grp = $ini->read_group("MAIN"); //prints the variables in the group if ($grp) for(reset($grp); $key=key($grp); next($grp)) { echo "GROUP ".

$key."=".$grp[$key]."<br>"; } //set a variable to a value $ini->setVariable("NEW","USER","JOHN"); //Save the file $ini->save_data();

Author
Mircho Mirev mirch.nosp@m.o@ma.nosp@m.cropo.nosp@m.int..nosp@m.com
Peter Gabriel peter.nosp@m.@gab.nosp@m.riel-.nosp@m.onli.nosp@m.ne.ne.nosp@m.t
Version
$Id$

Definition at line 47 of file class.ilIniFile.php.

Constructor & Destructor Documentation

◆ __construct()

ilIniFile::__construct ( string  $a_ini_file_name)

Constructor.

Definition at line 72 of file class.ilIniFile.php.

73 {
74 //check if a filename is given
75 if (empty($a_ini_file_name)) {
76 $this->error("no_file_given");
77 }
78
79 $this->INI_FILE_NAME = $a_ini_file_name;
80 }
error(string $a_errmsg)

References error().

+ Here is the call graph for this function:

Member Function Documentation

◆ parse()

ilIniFile::parse ( )

load and parse an inifile

Definition at line 102 of file class.ilIniFile.php.

102 : bool
103 {
104 try {
105 $ini_file_readable = is_readable($this->INI_FILE_NAME);
106 if (!$ini_file_readable) {
107 $this->error("file_not_accessible");
108 return false;
109 }
110 $this->GROUPS = parse_ini_file($this->INI_FILE_NAME, true);
111 if (!$this->GROUPS) {
112 $this->error("error_parseing_inifile");
113 return false;
114 }
115 } catch (Exception $e) {
116 $this->error($e->getMessage());
117 return false;
118 }
119
120
121 //set current group
122 $temp = array_keys($this->GROUPS);
123 $this->CURRENT_GROUP = $temp[count($temp) - 1];
124 return true;
125 }

References Vendor\Package\$e, and error().

Referenced by read().

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

◆ read()

ilIniFile::read ( )

read from ini file

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

85 : bool
86 {
87 //check if file exists
88 if (!file_exists($this->INI_FILE_NAME)) {
89 $this->error("file_does_not_exist");
90 return false;
91 }
92 if (!$this->parse()) {
93 //parse the file
94 return false;
95 }
96 return true;
97 }
parse()
load and parse an inifile

References error(), and parse().

+ Here is the call graph for this function:

◆ write()

ilIniFile::write ( )

save ini-file-data to filesystem

Definition at line 130 of file class.ilIniFile.php.

References $res, error(), ILIAS\User\Profile\ChangeMail\next, readGroup(), and readGroups().

Referenced by ilGlobalCacheSettingsAdapter\storeToIniFile().

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

Field Documentation

◆ $CURRENT_GROUP

string ilIniFile::$CURRENT_GROUP = ""

actual section

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

◆ $ERROR

string ilIniFile::$ERROR = ""

error var

Definition at line 57 of file class.ilIniFile.php.

Referenced by getError().

◆ $GROUPS

array ilIniFile::$GROUPS = array()

sections in ini-file

Definition at line 62 of file class.ilIniFile.php.

◆ $INI_FILE_NAME

string ilIniFile::$INI_FILE_NAME = ""

name of file

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


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