Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > Installing external libraries

Installing external libraries

Plpugins may also require external libraries that they are dependent upon to be downloaded. This requires several things: a specific declaration in the plugin.xml file, and the existence of a /lib directory that is write accessible in the SPIP root directory, into which the library will be automatically (or manually) loaded.

  1. <necessite id="lib:nom" src="address of the zip file" />
  • nom specifies the name of the zip’s uncompressed folder
  • src is the address of the library archive in zip format

Example

A plugin called "loupe photo"" uses a javascript library that it installs as a library (therefore outside of the plugin itself) in this manner:

  1. <necessite id="lib:tjpzoom" src="http://valid.tjp.hu/tjpzoom/tjpzoom.zip" />

In the plugin, the names of the files that the plugin uses are listed like this:

  1. $tjp = find_in_path('lib/tjpzoom/tjpzoom.js');

The "Open ID" plugin also uses a library that is external to the plugin. It loads it in the following manner:

  1. <necessite id="lib:php-openid-2.1.2" src="http://openidenabled.com/files/php-openid/packages/php-openid-2.1.2.zip" />

And then uses that library as below:

  1. // options
  2. if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . 'lib/');
  3. define('_DIR_OPENID_LIB', _DIR_LIB . 'php-openid-2.1.2/');
  4.  
  5. // usage (somewhat more complicated!)
  6. function init_auth_openid() {
  7. // ...
  8. $cwd = getcwd();
  9. chdir(realpath(_DIR_OPENID_LIB));
  10. require_once "Auth/OpenID/Consumer.php";
  11. require_once "Auth/OpenID/FileStore.php";
  12. require_once "Auth/OpenID/SReg.php";
  13. chdir($cwd);
  14. // ...
  15. }

Download