This is version 2 specification.

1. What is IncPlugins Open Technology?

IncPlugins Open Technology is a roylty-free technology of creation PHP-based scalable web site engines and web site plugins.

We hope our open technology will become an industrial standard for web site engine extensions in the future. We invite PHP scripts developers to create IncPlugins-compatible plugins.

2. Basic principles

Web Site Structure

Any IncPlugins compatible web site should contain these components:

  • Web Site Engine - core php scripts. You can use our IncPlugins Free Edition.
  • Plugins - specially designed php scripts.
  • Web Site Content - HTML files, documents, images, information in a database, etc.

Key Ideas

  • Plugins and php scripts should be standartized.
  • Webmasters can add, remove or replace any plugin without modifying of another parts.
  • A web site design may be available as a plugin.
  • An information is separated from a php code.
  • Any HTML layout may be divided to a header and a footer parts.

3. Engine

What is Engine?

The Engine is a php script file that manages IncPlugins-compatible plugins.

Engine Variables

Any Engine should support these global variables:

  • $script_dir — Directory of the running script
  • $inc_dir — Directory of plugins
  • $root_dir — Web site root directory
  • $root — Relative URL to a web site root directory
  • $inc — Relative URL to the plugins directory
  • $homepage — Relative URL to a Web site index page
  • $title — Current document title
  • $lang — Current document language code. ISO 639-1 compatible
  • $T — Associative array of language string resources
  • $ob_on — Using an output buffering mode. Bool variable

IncPlugins supports 40+ variables.

Engine Functions

The Engine should contain these functions:

  • T($text, $language='') — Returns a localized text
  • inc_plugin($name) — Regesters new plugin. Plugin installation sequency is important.

PHP Output Buffering Management

The Engine should manage php output buffering if variable $ob_on is true. It should call all plugin functions plugin_ob($text) if they are anabled.

CSS and JavaScript Files Management

The Engine should manage web site CSS and JavaScript files to enable using of plugin functions plugin_js(), plugin_css() if they are installed. It is recommended to use PHP scripts instead of a static files, because plugins can generate dynamic CSS and JavaScript.

Errors Management

The Engine should manage HTTP errors and call plugin_error($code) if an error is found. The parameter $code should contain an error code, like 404. HTTP error codes (range: 400-500) should not be used for an internal error handling use.

Plugin Calling Sequence

The Engine should call plugins if they are enabled in a sequence:

Header part of a page:

  1. All plugins functions plugin_header() in a direct sequence
  2. All plugins functions plugin_head() in a direct sequence

Footer part of a page:

  1. All plugins functions plugin_foot() in a reversed sequence

Multilingual Support

User can provide multilingual strings resources. Example:

$T['en']['Home'] = 'Home';
$T['de']['Home'] = 'Haupt';
$T['pt']['Home'] = 'Centro';

Function T($text, $language='') should return a corrected resource or $text if a language resource is not found.

Variable $lang should be used to set and get a current language code.

Advanced Features

If an Engine provides advanced features, they should be compatible with our IncPlugins. This requirement includes variable and function names compatibility.

4. Plugins

What is Plugin?

The Plugin is a PHP script file that may contain PHP, CSS and JavaScript code. The Engine automatically adds these CSS and JavaScript parts to website CSS/JavaScript files if the plugin is installed.

Plugin Variables

A plugin should contain these global variables:

  • $plugin_version — Version string
  • $plugin_copyright — Copyright string in a form: {date(s)}, {holder name}
  • $plugin_website — Plugin homepage URL

All these variables should contain an unique prefix (plugin name) instead of a “plugin”.

Example code:

$myplugin_version   = '1.0.0';
$myplugin_copyright = '2007, IncPlugins';
$myplugin_website   = 'http://www.incplugins.com/';

Plugin Functions

Any plugin may contain these functions (all are optional):

  • plugin_header() — A code to initialize plugin modes and to send a HTTP header.
  • plugin_head() — Returns a page header HTML code as a string.
  • plugin_foot() — Returns a page footer HTML code as a string.
  • plugin_ob($text) — Returns a modified HTML code if PHP output buffering is used.
  • plugin_js() — Returns an JavaScript code for all website pages.
  • plugin_css() — Returns a CSS code for all website pages.
  • plugin_error($code) — A website HTTP error or user error/debug handler.

All these functions should contain an unique name prefix instead of “plugin”.

Plugin Installation

A plugin should be installed using a global scope code, simular:

inc_plugin('myplugin');

Plugin Enabling and Disabling

A bool variable $plugin_on should be used to enable or disable a plugin. All plugins are enabled by default. End users may disable some web page plugins using this variable.

If you use your own functions, please use this variable to check of the enable state. Write a code simular:

function myplugin_myfunc()
{
    if ($GLOBALS['myplugin_on'] !== false)
        return;
    ...
}

Plugin functions: plugin_header(), plugin_head(), plugin_foot(), plugin_ob($text) are called if a plugin is enabled, so you may not write a check code for them.

Always Called Plugin Functions

Functions: plugin_js(), plugin_css(), plugin_error($code) are always called from corresponded PHP scripts if a plugin is installed. An JavaScript and a CSS code can be fully dynamic, so you may use $_GET[] variables to correct an JavaScript and a CSS code.

Your Own Functions

If plugin contains an additional HTML layout functions, they should return a string. If you use functions pair, the second function should have an _end prefix. Example:

function h1($class='yellow')
{
    return '<h1 class="'.$class.'">';
}

function h1_end()
{
    return '</h1>';
}

Using example:

<?=h1('red')?>My Super Header<?=h1_end()?>

For most functions we recommend you to use a function name prefix with your plugin name.

IncPlugins Functions and Variables

Your own plugin may use IncPlugins functions and variables. See IncPlugins User’s Manual to get a compatible list.

Third Party Plugins

You can also use third party plugin functions and variables. To detect a plugin version check a corresponded variable $someplugin_version. The third party plugin may be not installed, so you may detect this variable.

Plugin Testing

Your own plugin should work correctly with IncPlugins.

Standalone Mode

Your own plugin may be used in a standalone mode. This feature is optional, but you may support it.

User should call plugin functions manually. If your plugin uses IncPlugins functions and variables, please write a special compatible code to emulate them.