Ocs-server/Gfx4/Global and local configuration: Difference between revisions

From KDE Community Wiki
 
Line 57: Line 57:
* '''protectheaders''': can be "yes" or "no"
* '''protectheaders''': can be "yes" or "no"
* '''database''': can be "yes" or "no"
* '''database''': can be "yes" or "no"
* '''databasedriver''': can be "EMysql" or "ESQLite"
* '''rewrite''': can be "yes" or "no"
* '''rewrite''': can be "yes" or "no"
* '''users''': can be "yes" or "no"
* '''users''': can be "yes" or "no"
Line 70: Line 71:
protectheaders|yes
protectheaders|yes
database|yes
database|yes
databasedriver|EMysql
rewrite|yes
rewrite|yes
users|no
users|no

Latest revision as of 13:22, 20 May 2016

GFX use a class to load config every time from a bunch of files. You can also create your config and find them placed under EConfig.

Most of the gfx-related configurations are on the file /config/generic.conf.php. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.

If you edit your /config/database.conf.php like this:

<?php die(); ?>
name|test
host|localhost
user|root
password|asd

You will automatically find them mapped into an associative array:

EConfig::$data["database"]["name"];

Note that "database" is the name of the config file without extensions and "name" is the variable name.

Also note that PHP code in config files will just be ignored, so it's good practice to put a die(); on the first line so no one will be able to see your inner configuration.

You can also use multi value properties like this:


Filename: /config/myname.conf.php

<?php die(); ?>
info|Claudio|Desideri|kde

If you access EConfig::$data["myname"]["info"]; you get an array containing all the values. You can iterate on it using:

foreach(EConfig::$data["myname"]["info"] as $item){
    echo $item;
}

This will print:

   Claudio
   Desideri
   kde

And via code that will be accessible using:

$info = EConfig::$data["myname"]["info"];
$info[0];
$info[1];
$info[2];

Generic.conf.php

Each website (or subsite) must have a generic.conf.php file inside the config folder. These are the properties that can be setted through generic:

  • render: can be "yes" or "no"
  • protectheaders: can be "yes" or "no"
  • database: can be "yes" or "no"
  • databasedriver: can be "EMysql" or "ESQLite"
  • rewrite: can be "yes" or "no"
  • users: can be "yes" or "no"
  • mvc: can be "yes" or "no"
  • errormode: can be "normal", "formatted", "file" or "suppressed"
  • enabled: can be "yes" or "protected"
  • password: password of your choice

Example of a generic.conf.php file:

<?php die(); ?>
render|yes
protectheaders|yes
database|yes
databasedriver|EMysql
rewrite|yes
users|no
mvc|yes
errormode|normal
enabled|protected
password|esempio