ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 342 of file class.ilIniFile.php.

343 {
344 if ($this->groupExists($a_group_name))
345 {
346 $this->error("Group '".$a_group_name."' exists");
347 return false;
348 }
349
350 $this->GROUPS[$a_group_name] = array();
351 return true;
352 }
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 428 of file class.ilIniFile.php.

429 {
430 $this->ERROR = $a_errmsg;
431
432 return true;
433 }

Referenced by ilObjCertificateSettingsGUI\__construct(), ilIniFile\__construct(), php4DOMDocument\__construct(), ilMailSearchCoursesGUI\__construct(), ilMailSearchGroupsGUI\__construct(), ilForumExportGUI\__construct(), ilContactGUI\__construct(), ilMailingListsGUI\__construct(), Mail_RFC822\_hasUnclosedBrackets(), Mail_RFC822\_splitAddresses(), Mail_RFC822\_splitCheck(), Mail_RFC822\_validateAddress(), addGroup(), GetId3\GetId3Core\analyze(), ilContactGUI\applyContactsTableFilter(), ilDBUpdate\applyCustomUpdates(), ilDBUpdate\applyHotfix(), ilDBUpdate\applyUpdate(), ilDBUpdate\applyUpdateNr(), ilObjForumGUI\askForPostActivationObject(), SMTP\authenticate(), ilContactGUI\changeContactsView(), ilSetup\checkDataDirSetup(), ilSetup\checkErrorLogSetup(), ilSetup\checkLogSetup(), ilSetup\checkPasswordSetup(), ilSetup\checkToolsSetup(), ilSetup\cloneFromSource(), ilObjForumGUI\confirmDeleteThreads(), ilObjForumGUI\confirmMergeThreadsObject(), ilObjTermsOfServiceGUI\confirmReset(), SMTP\connect(), ilClient\connect(), ilClient\create(), ilSetup\createDatabase(), ilObjForumGUI\createThreadObject(), ilObjForumGUI\deliverZipFileObject(), ilForumExportGUI\ensureThreadBelongsToForum(), ilObjForumGUI\ensureThreadBelongsToForum(), ilDBUpdate\execQuery(), ilObjCertificateSettingsGUI\executeCommand(), ilContactGUI\executeCommand(), ilMailSearchCoursesGUI\executeCommand(), ilMailSearchGroupsGUI\executeCommand(), Assetic\Filter\LessFilter\filterLoad(), ilClient\getError(), ilSetup\getError(), GetId3\GetId3Core\getHashdata(), ilClient\init(), ilSetup\init(), CAS_Client\isAuthenticated(), ilSetup\loginAsClient(), ilContactGUI\mailToUsers(), ilObjForumGUI\markPostReadObject(), ilObjForumGUI\markPostUnreadObject(), ilObjForumGUI\mergeThreadsObject(), ilSetup\newClient(), GetId3\GetId3Core\openfile(), ilIniFile\parse(), Mail_RFC822\parseAddressList(), ilMailingListsGUI\performDeleteMembers(), ilObjForumGUI\performDeleteThreadsObject(), ilObjForumGUI\performMoveThreadsObject(), ilObjForumGUI\performPostActivationObject(), ilObjForumGUI\publishDraftObject(), SMTP\quit(), ilObjForumGUI\quotePostObject(), ilIniFile\read(), ilDBUpdate\readDBUpdateFile(), readGroup(), ilDBUpdate\readLastUpdateFile(), readVariable(), removeGroup(), ilObjTermsOfServiceGUI\reset(), ilContactGUI\resetContactsTableFilter(), ilMailingListsGUI\saveAssignmentForm(), ilMailingListsGUI\saveForm(), ilSetup\saveMasterSetup(), ilSetup\saveNewClient(), ilObjTermsOfServiceGUI\saveSettings(), ilObjForumGUI\saveThreadSortingObject(), SMTP\sendCommand(), ilExternalFeed\setError(), ilChatroomServerConnectorMock\setError(), ilClient\setError(), SMTP\setError(), ilSetup\setPassword(), ilObjTermsOfServiceGUI\settings(), setVariable(), ilObjTermsOfServiceGUI\showAcceptanceHistory(), ilObjTermsOfServiceGUI\showAgreementByLanguage(), ilMailingListsGUI\showAssignmentForm(), ilContactGUI\showContacts(), ilMailingListsGUI\showForm(), ilObjForumGUI\showStatisticsObject(), ilObjForumGUI\toggleStickinessObject(), SMTP\turn(), ilSetup\updateMasterSettings(), ilObjForumGUI\updateThreadObject(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ getError()

getError ( )

returns error @access public

Returns
string

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

441 {
442 return $this->ERROR;
443 }

References ilIniFile\$ERROR.

Referenced by trendClass\calculate().

+ Here is the caller graph for this function:

◆ getGroupCount()

getGroupCount ( )

returns number of groups @access public

Returns
integer

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

282 {
283 return count($this->GROUPS);
284 }

◆ groupExists()

groupExists (   $a_group_name)

checks if a group exists @access public

Parameters
stringgroup name
Returns
boolean

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

310 {
311 if (!isset($this->GROUPS[$a_group_name]))
312 {
313 return false;
314 }
315
316 return true;
317 }

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 325 of file class.ilIniFile.php.

326 {
327 if (!$this->groupExists($a_group_name))
328 {
329 $this->error("Group '".$a_group_name."' does not exist");
330 return false;
331 }
332
333 return $this->GROUPS[$a_group_name];
334 }

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 291 of file class.ilIniFile.php.

292 {
293 $groups = array();
294
295 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
296 {
297 $groups[]=$key;
298 }
299
300 return $groups;
301 }

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 392 of file class.ilIniFile.php.

393 {
394 if (!isset($this->GROUPS[$a_group][$a_var_name]))
395 {
396 $this->error("'".$a_var_name."' does not exist in '".$a_group."'");
397 return false;
398 }
399
400 return trim($this->GROUPS[$a_group][$a_var_name]);
401 }

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 360 of file class.ilIniFile.php.

361 {
362 if (!$this->groupExists($a_group_name))
363 {
364 $this->error("Group '".$a_group_name."' does not exist");
365 return false;
366 }
367
368 unset($this->GROUPS[$a_group_name]);
369 return true;
370 }

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 411 of file class.ilIniFile.php.

412 {
413 if (!$this->groupExists($a_group_name))
414 {
415 $this->error("Group '".$a_group_name."' does not exist");
416 return false;
417 }
418
419 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
420 return true;
421 }

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 242 of file class.ilIniFile.php.

243 {
244 $groups = $this->readGroups();
245 $group_cnt = count($groups);
246
247 //clear content
248 $content = "";
249
250 // go through all groups
251 for ($i=0; $i<$group_cnt; $i++)
252 {
253 $group_name = $groups[$i];
254 //prevent empty line at beginning of ini-file
255 if ($i==0)
256 {
257 $content = sprintf("[%s]\n",$group_name);
258 }
259 else
260 {
261 $content .= sprintf("\n[%s]\n",$group_name);
262 }
263
264 $group = $this->readGroup($group_name);
265
266 //go through group an display all variables
267 for (reset($group); $key=key($group);next($group))
268 {
269 $content .= sprintf("%s = %s\n",$key,$group[$key]);
270 }
271 }
272
273 return $content;
274 }
sprintf('%.4f', $callTime)
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(), readGroups(), and sprintf.

Referenced by ilPersonalDesktopGUI\executeCommand(), ilChatroomBanGUI\executeDefault(), 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 379 of file class.ilIniFile.php.

380 {
381 return isset($this->GROUPS[$a_group][$a_var_name]);
382 }