API

Last Updated on Friday, 10 May 2013 13:34

We are keen to construct the gallery on a way that it is accplicable universally. For this it is necessary to integrate other components, modules und plugins which aren't written by us (e.g. Community Builder, AlphaUserPoints or JComments to just mention a few).
For some, we already developed additional add-ons which establish a connection between the particular third party extension and JoomGallery. You can find them in our downloads and here is a small summary of all of them.

Since we aren't able to create JoomGallery add-ons for every available extension or some of you have a special intent JoomGallery offers a huge API, which you may use. So this article is mainly interesting for the developers among you.

If you have decided to write your own extension for JoomGallery you will find below a full description of the JoomGallery API.
Examining already existent extensions may also help you for your own development.

The API of JoomGallery is divisible into three main areas:


Interface class

In order to use the interface class it needs to be included in your extension first. This happens with the follwing code:

$file = JPATH_ROOT.DS.'components'.DS.'com_joomgallery'.DS.'interface.php';
if(!file_exists($file))
{
JError::raiseError(500, 'JoomGallery seems not to be installed');
}
else
{
require_once $file;
$interface = new JoomInterface();
}

The variable '$interface' now holds the interface object (provided that JoomGallery is installed).

By now you are able to use the functions the interface provides.
A call looks like this, for example:

$interface->getPageHeader();

or like this if something you need is returned by the function:

$images = $interface->getPicsOfUser($userid);

The funktion 'getPageHeader' will be important if your extension shall output images or the like and you want to use the style definitions of the gallery, because it loads the CSS files of JoomGallery.

Please have a look at the interface class on your own ('components/com_joomgallery/interface.php'). There are descriptions in the header of every function, which list what the function does, what it returns possibly and which parameters it needs.

At this point only the function 'addConfig()' shall be mentioned additionally. With this one, you are able to configure the interface. For example, you may define the method which will be used to open an image:

$interface->addConfig('openimage', 6);

The number 6 is mapped with Slimbox, other assignments are listed below:

0 => Default view
1 => New window
2 => JavaScript window
3 => DHTML Container
5 => Thickbox3
6 => Slimbox
12 => additional plugins

If 'openimage' isn't set, the interface will use the correspondent setting of JoomGallery's configuration manager ('Entering Detail View' in tab 'Category View' -> 'General Settings').

Further options are 'group', 'limit' or 'type', for example.


Module positions

For the module positions of the gallery, there is a separate article in the documentation which you can find here: Module positions.

You may also add your own module positions at any point inside the gallery with the help of template overrides by using the following code:

<?php $this->loadModules('positionname'); ?>

With this, the new module positions can be used with suffixes right like the already integrated ones. Please note, that you have to specify the prefix 'jg_' in module manager also with this positions ('jg_positionname'), but please omit it in the function call.


Plugin events

Developers among you know that there are different plugin types in Joomla, e.g. content plugins, user plugins or system plugins.

Of course, you may write JoomGallery extensions for this types which use the interface class, for example, like the content plugin 'JoomPlu'.

In this section of the API documentation, however, we want to concentrate on plugin events which are triggered solely by JoomGallery and its extensions. For this, JoomGallery accesses an additional plugin type which is called 'joomgallery'.

So if you want to create a plugin which is able to influence the gallery, the 'install' element of the correspondant XML install file should look like this:

<install version="1.5" type="plugin" group="joomgallery" method="upgrade">

For the general constitution of a plugin, please have a look at one or more of the example plugins which are delivered with Joomla.

In the following, there is a list with all plugin events currently built-in JoomGallery:

onJoomBeforeComment

Description:

Parameter:

Return value:

onJoomAfterComment

Description:

Parameter:

onJoomBeforeUpload

Description:

Parameter:

Return value:

onJoomAfterUpload

Description:

Parameter:

onJoomBeforeVote

Description:

Parameter:

Return value:

onJoomAfterVote

Description:

Parameter:

onJoomBeforeSendMessage

Description:

Parameter:

Return value:

onJoomAfterAddFavourite

Description:

Parameter:

onJoomAfterRemoveFavourite

Description:

Parameter:

onJoomAfterClearFavourites

Description:

Parameter:

onJoomAfterDisplayThumb

Description:

Parameter:

Return value:

onJoomAfterDisplayCatThumb

Description:

Parameter:

Return value:

onJoomAfterSend2Friend

Description:

Parameter:

onJoomAfterTag

Description:

Parameter:

onJoomDisplayIcons

Description:

Parameter:

Return value:

onJoomDisplayUser

Description:

Parameter:

Return value:

onJoomGetCaptcha

Description:

Parameter:

Return value:

onJoomCheckCaptcha

Description:

Parameter:

Return value:

onJoomGetLastComments

Description:

Parameter:

onJoomGetSmileys

Description:

Parameter:

onJoomOpenImage

Description:

Parameter:

onJoomSearch

Description:

Parameter:

Return value: