Table of Contents

Plugin files organization

General organization of a plugin

ROOT :

Organizing files in the inc/ directory

When you create a class, make sure its name is well chosen. For example, a plugin whose name is « foo » uses its own class. The file name should then be:

If your class extends a Dotclear class, it should be called as a librairy. For example, if you need to create lists in the plugin's administration panel, the classe name will be « fooList » et le nom du fichier sera alors :

To load thoses classes, you can use PHP classes autoload, and put this code in the _prepend.php file :

$__autoload['foo'] = dirname(__FILE__).'/inc/class.foo.php';

You can also include files:

require_once(dirname(__FILE__).'/inc/class.foo.php');

Protecting files

In order to avoid PHP files to be executed outside of Dotclear, we can add a piece of code at the beginning of the files.

For files that are read only in the back-end:

We add this code :

if (!defined('DC_CONTEXT_ADMIN')) {return;}

For other files:

We add:

if (!defined('DC_RC_PATH')) {return;}