Dokeos 1.8 Code walkthrough

From Dokeos

Jump to: navigation, search

Contents

Introduction

This page will help new developers get a good idea of how the code is presented and how to change things in Dokeos

Code guidelines

For coding guidelines, please see the Coding conventions page.

Important files

This chapter show which files are important in the normal Dokeos loadin process.

Loading order

A request in Dokeos, let's say a request to /index.php, will always enter the given script and start processing the code sequentially. A typical Dokeos script will be made of:

  1. a code header
  2. the definition of the language_files array that will tell global.inc.php which files to load
  3. an include call to global.inc.php
  4. a series of libraries inclusions
  5. a series of code initialisations (including filtering of POST/GET variables)
  6. the sequential code in itself

When loading, any script should load the main/inc/global.inc.php file, which will initiate a series of files inclusions and get your script ready to run.

global.inc.php

This file makes sure the global environment of the HTTP + PHP request is ready to go. It includes the configuration files, all the general-use library files, the local.inc.php file and the finally the language files. The configuration files loaded are:

  • main/inc/conf/configuration.php
  • main/inc/conf/mail.conf.php
  • ...

The general-use libraries are:

  • main/inc/lib/main_api.lib.php
  • main/inc/lib/database.lib.php
  • ...

Language files are loaded depending on the language files required before including global.inc.php

local.inc.php

This file has the same role as global.inc.php but acts at a finer level and has a notion of the location of the user inside Dokeos. As such, it checks if the user has access to this section (if it is protected) and otherwise initiates the login process.

Configuration files

Configuration files define:

  • how to connect to the database,
  • which campus url to use
  • which e-mail server type to use
  • some limits regarding courses

Initialisation files

Initialisation files have already been spoken about. These are the global.inc.php and local.inc.php files. However, they also include headers and footers, which have been defined below in a section of their own.

Libraries

Global-utility libraries are located in main/inc/lib and are generally named by a meaningful name + ".lib.php" or ".class.php" in the case of a class definition.

Language files

Language files are loaded at the end of the main/inc/global.inc.php file and are located in the main/lang/ directory New languages and new translation packs are managed by an external tool called Dokeos Language Translation Tool which you can access here http://www.dokeos.com/DLTT/

The database

The database diagrams and explanations can be found here: Database schema 1.8

The tools

Each Dokeos tool should reside in a directory of its own, inside the main/ directory. For example, the "document" tool resides in the main/document/ directory.

Headers/Footers

Headers (HTTP and HTML) and the footer are defined in main/inc/ as

  • header.inc.php for the HTTP and HTML headers
  • banner.inc.php for the *visual* header
  • footer.inc.php for the *visual* footer and the HTML footer.
  • reduced_header.inc.php is offered as a convenient way of loading HTTP and HTML headers without a *visual* header

Plugins

Plugins can be developed following the very short example of the *date* plugin and be placed inside the plugins/ directory

Personal tools