Ocs-server/Gfx4/Editing config files programmatically

From KDE Community Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

GFX provides a handy class that lets you edit config files programmatically to create easy admin modes and settings managers.

All changes are made in ram before being saved to disk with the save() method. Remember to call save(), or your changes will be lost at the end of object's life.

<?php
//constructor, $namefile can be empty
$config = new EConfigFile($namefile);
//set $key with $value
$config->set($key, $value);
//get $value associated to $key
$config->get($key);
//delete $key from config file
$config->del($key);
//apply modifications, save
$config->save();
?>