What is an "add-on" ?

Add-ons are small functions called when the engine get the list of files, and when a template print this list.

Some of them do minor tricks, webimage.php create image thumbnails, others add a javascript to call a plug-in in a popup (convert a file for example).

Add-ons are called "on the fly", plug-ins called by a popup, a form, or the parameter action in the URL... (in forms this is an hidden field).

How to use/create add-ons ?

file.php is the add-on called for all files. For the moment, this does nothing, but you can write here function that will apply to all files, e.g. if admin : delete, rename...

For all add-on (file, images...), you can write two functions :

  • addon_XXX_init
  • addon_XXX_display
...where XXX stands for :
  • a type (audio, prog_php...), see types.php ;
  • an extension (mp3, txt, doc...) ;
  • file (apply to all listed files) ;
  • folder (apply to all listed folders).
In addon_xxx_init, you can change the displayed name, type, size or date. Example : in types.php, I said that .myr, .mus, .myt and .box are Myriad files, for these files I use myriad.php, and I want to display a more detailed type for each extension, because ".mus" is music, ".box" is jukebox, ".myt" is video tutorial...
In addon_myriad_init, a simple switch tests the extension, and I modify the displayed type.

The second function addon_xxx_display is more used. It's called when template call print_addon() (in functions.php).
In this function, we can have image thumbnail generation, a link to get a converted format from a word file... and everything you can create :-)

If you write add-on functions, you must know the following things :

  1. you'll have to read/write in some arrays called :
    • $tabName : array for file names ;
    • $tabTyp : array for file types ;
    • $tabSize : array for file sizes ;
    • $tabDate : array for file dates ;
  2. the functions have one parameter int $idx.
  3. you have never to call directly these functions, PHPmyBrowser will do the calls for you ;-)
  4. if you want, you can create other functions in the PHP file, and you call these functions in addon_xxx_init/display (e.g. addon_webimage_display call several functions for thumbnails creation).

Examples of code...

  • you want to know file size :
    1. if ($tabSize[$idx] < 10*1024)
    2. {
    3. //your file is less than 10 KB
    4. }
    5. else
    6. {
    7. //your file is larger
    8. }
  • you want to change the displayed type :
    1. $tabTyp[$idx] = 'what you want here';

Documentation generated on Sat, 28 Aug 2004 16:52:54 +0200 by phpDocumentor 1.3.0RC3