ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilIniFile.php File Reference

Go to the source code of this file.

Data Structures

class  ilIniFile
 INIFile Parser. More...
 

Functions

 show ()
 returns the content of IniFile @access public More...
 
 getGroupCount ()
 returns number of groups @access public
More...
 
 readGroups ()
 returns an array with the names of all the groups @access public More...
 
 groupExists ($a_group_name)
 checks if a group exists @access public More...
 
 readGroup ($a_group_name)
 returns an associative array of the variables in one group @access public
More...
 
 addGroup ($a_group_name)
 adds a new group @access public More...
 
 removeGroup ($a_group_name)
 removes a group @access public More...
 
 variableExists ($a_group, $a_var_name)
 returns if a variable exists or not @access public More...
 
 readVariable ($a_group, $a_var_name)
 reads a single variable from a group @access public More...
 
 setVariable ($a_group_name, $a_var_name, $a_var_value)
 sets a variable in a group @access public More...
 
 error ($a_errmsg)
 set error message @access public More...
 
 getError ()
 returns error @access public More...
 

Function Documentation

◆ addGroup()

addGroup (   $a_group_name)

adds a new group @access public

Parameters
stringgroup name
Returns
boolean

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

370 {
371 if ($this->groupExists($a_group_name))
372 {
373 $this->error("Group '".$a_group_name."' exists");
374 return false;
375 }
376
377 $this->GROUPS[$a_group_name] = array();
378 return true;
379 }
groupExists($a_group_name)
checks if a group exists @access public
error($a_errmsg)
set error message @access public

References error(), and groupExists().

+ Here is the call graph for this function:

◆ error()

error (   $a_errmsg)

set error message @access public

Parameters
string

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

456 {
457 $this->ERROR = $a_errmsg;
458
459 return true;
460 }

Referenced by ilPurchaseBaseGUI\__construct(), Mail_RFC822\_hasUnclosedBrackets(), Mail_RFC822\_splitAddresses(), Mail_RFC822\_splitCheck(), Mail_RFC822\_validateAddress(), ilPaymentCouponGUI\addCoupon(), addGroup(), ilDBUpdate\applyCustomUpdates(), ilDBUpdate\applyHotfix(), ilDBUpdate\applyUpdate(), ilDBUpdate\applyUpdateNr(), ilClient\checkDatabaseHost(), ilSetup\checkDataDirSetup(), ilSetup\checkLogSetup(), ilSetup\checkPasswordSetup(), ilSetup\checkToolsSetup(), ilSetup\cloneFromSource(), ilClient\connect(), ilClient\create(), ilSetup\createDatabase(), ilObjPaymentSettingsGUI\editVendorObject(), ilDBUpdate\execQuery(), ilPurchaseBaseGUI\getBill(), ilPurchaseBMFGUI\getCreditCard(), ilPurchaseBMFGUI\getDebitEntry(), ilMailingListsGUI\getError(), ilClient\getError(), ilSetup\getError(), ilPurchaseBMFGUI\getPaymentType(), ilPurchaseBaseGUI\getPersonalData(), ilPurchaseBMFGUI\getPersonalData(), ilIniFile\ilIniFile(), ilClient\init(), ilSetup\init(), ilObjPaymentSettingsGUI\InvoiceNumberObject(), ilMailingListsGUI\isError(), ilSetup\loginAsClient(), ilSetup\newClient(), ilIniFile\parse(), Mail_RFC822\parseAddressList(), ilObjPaymentSettingsGUI\performEditVendorObject(), php4DOMDocument\php4DOMDocument(), PHPlot\PrintError(), OLERead\read(), ilIniFile\read(), ilDBUpdate\readDBUpdateFile(), readGroup(), ilDBUpdate\readLastUpdateFile(), readVariable(), removeGroup(), ilPaymentCouponGUI\saveCouponForm(), ilObjPaymentSettingsGUI\saveInvoiceNumberObject(), ilSetup\saveMasterSetup(), ilSetup\saveNewClient(), ilObjPaymentSettingsGUI\savePaypalSettingsObject(), ilExternalFeed\setError(), ilMailingListsGUI\setError(), ilSetup\setPassword(), setVariable(), ilPurchaseBMFGUI\showCreditCard(), ilPurchaseBMFGUI\showDebitEntry(), ilPurchaseBMFGUI\showPaymentType(), ilPurchaseBaseGUI\showPersonalData(), ilPurchaseBMFGUI\showPersonalData(), ilSetup\updateMasterSettings(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ getError()

getError ( )

returns error @access public

Returns
string

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

468 {
469 return $this->ERROR;
470 }

References ilIniFile\$ERROR.

◆ getGroupCount()

getGroupCount ( )

returns number of groups @access public

Returns
integer

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

309 {
310 return count($this->GROUPS);
311 }

◆ groupExists()

groupExists (   $a_group_name)

checks if a group exists @access public

Parameters
stringgroup name
Returns
boolean

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

337 {
338 if (!isset($this->GROUPS[$a_group_name]))
339 {
340 return false;
341 }
342
343 return true;
344 }

Referenced by addGroup(), readGroup(), removeGroup(), and setVariable().

+ Here is the caller graph for this function:

◆ readGroup()

readGroup (   $a_group_name)

returns an associative array of the variables in one group @access public

Parameters
stringgroup name
Returns
mixed return array of values or boolean 'false' on failure

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

353 {
354 if (!$this->groupExists($a_group_name))
355 {
356 $this->error("Group '".$a_group_name."' does not exist");
357 return false;
358 }
359
360 return $this->GROUPS[$a_group_name];
361 }

References error(), and groupExists().

Referenced by show(), and ilIniFile\write().

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

◆ readGroups()

readGroups ( )

returns an array with the names of all the groups @access public

Returns
array groups

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

319 {
320 $groups = array();
321
322 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
323 {
324 $groups[]=$key;
325 }
326
327 return $groups;
328 }

Referenced by show(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ readVariable()

readVariable (   $a_group,
  $a_var_name 
)

reads a single variable from a group @access public

Parameters
stringgroup name
stringvalue
Returns
mixed return value string or boolean 'false' on failure

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

420 {
421 if (!isset($this->GROUPS[$a_group][$a_var_name]))
422 {
423 $this->error("'".$a_var_name."' does not exist in '".$a_group."'");
424 return false;
425 }
426
427 return trim($this->GROUPS[$a_group][$a_var_name]);
428 }

References error().

Referenced by ilSoapInstallationInfoXMLWriter\__buildInstallationInfo(), and ilDB\initFromIniFile().

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

◆ removeGroup()

removeGroup (   $a_group_name)

removes a group @access public

Parameters
stringgroup name
Returns
boolean

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

388 {
389 if (!$this->groupExists($a_group_name))
390 {
391 $this->error("Group '".$a_group_name."' does not exist");
392 return false;
393 }
394
395 unset($this->GROUPS[$a_group_name]);
396 return true;
397 }

References error(), and groupExists().

+ Here is the call graph for this function:

◆ setVariable()

setVariable (   $a_group_name,
  $a_var_name,
  $a_var_value 
)

sets a variable in a group @access public

Parameters
string
string
string
Returns
boolean

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

439 {
440 if (!$this->groupExists($a_group_name))
441 {
442 $this->error("Group '".$a_group_name."' does not exist");
443 return false;
444 }
445
446 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
447 return true;
448 }

References error(), and groupExists().

+ Here is the call graph for this function:

◆ show()

show ( )

returns the content of IniFile @access public

Returns
string content

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

270 {
271 $groups = $this->readGroups();
272 $group_cnt = count($groups);
273
274 //clear content
275 $content = "";
276
277 // go through all groups
278 for ($i=0; $i<$group_cnt; $i++)
279 {
280 $group_name = $groups[$i];
281 //prevent empty line at beginning of ini-file
282 if ($i==0)
283 {
284 $content = sprintf("[%s]\n",$group_name);
285 }
286 else
287 {
288 $content .= sprintf("\n[%s]\n",$group_name);
289 }
290
291 $group = $this->readGroup($group_name);
292
293 //go through group an display all variables
294 for (reset($group); $key=key($group);next($group))
295 {
296 $content .= sprintf("%s = %s\n",$key,$group[$key]);
297 }
298 }
299
300 return $content;
301 }
readGroups()
returns an array with the names of all the groups @access public
readGroup($a_group_name)
returns an associative array of the variables in one group @access public

References readGroup(), and readGroups().

Referenced by ilPersonalDesktopGUI\executeCommand(), ilPersonalDesktopGUI\removeMember(), and ilTemplate\show().

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

◆ variableExists()

variableExists (   $a_group,
  $a_var_name 
)

returns if a variable exists or not @access public

Parameters
stringgroup name
stringvalue
Returns
mixed return true if value exists or false

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

407 {
408 return isset($this->GROUPS[$a_group][$a_var_name]);
409 }