Media Centre aide memoire

The Media Centre for Jomres 7.4 has been written from the ground up to be completely plugin friendly, meaning that other plugins can use the uploading functionality if they include the appropriate minicomponents.

Here I will add notes as a guide to which minicomponents do what.

At the time of writing, there's two "types" of image that can be uploaded. An image for properties, and images for Property Features and Room types.

Update : This functionality has now been extended, you can upload images for Property Main Image, Slideshow images, Room features, Optional Extras and Room images. (Jomres v9)

 

The former functionality is accessed via the frontend under the Media Centre menu option. The latter via the administrator area, Site Structure -> Media Centre option. For the purpose of this document, I will focus on the files used by the Media Centre in the frontend.

Property centric images are all uploaded to the uploadedimages directory under /jomres, then to a subdirectory of the resource type, then finally an identifying ID. Because resources like the main property image and the slideshow don't have resource IDs, their ids are always 0. So, for example slideshow images for a property with the id of 15 will be uploaded into /jomres/uploadedimages/15/slideshow/0/ whereas images for the hypothetical room with an id of 34 will be uploaded to /jomres/uploadedimages/15/rooms/34/.


It will probably help you to look at the source of the individual files as they're mentioned here so that you can see the code in context.

resource_type_gathering_trigger - 03379

The first file required by an external plugin is the 03379 trigger file, for example j03379slideshow

The sole purpose of the 03379 files is to tell Jomres that a particular resource type exists, and a few things about that resource type. For example j03379media_centre_resource_type_slideshow returns an indexed array :

$this->ret_vals = array(
                                'resource_type' => 'slideshow',
                                'resource_id_required' => true,
                                'name' => jr_gettext('_JOMRES_MEDIA_CENTRE_RESOURCE_TYPES_SLIDESHOW', '_JOMRES_MEDIA_CENTRE_RESOURCE_TYPES_SLIDESHOW', false),
                                'upload_root_abs_path' => JOMRES_IMAGELOCATION_ABSPATH.$property_uid.JRDS,
                                'upload_root_rel_path' => JOMRES_IMAGELOCATION_RELPATH.$property_uid.'/',
                                'notes' => '',
                                'preview_link'=>$preview_link
                                );

The resource_type will be used for validation of the type and to make the subdirectory under /jomres/uploadedimages/15/, to tell Jomres if it needs to look for an individual id for the resource, and it's translated, friendly name.

upload_root_abs_path

In the properties context, this refers to the root of an individual property's images, which here is

JOMRES_IMAGELOCATION_ABSPATH . getDefaultProperty() . JRDS

The first is a constant that resolves to /xxx/public_html/jomres/uploadedimages/

Next we have a built in Jomres function that will find the manager's active property id.

Finally JRDS is another constant, and stands for JomRes Directory Seperator (ie. \ in linux, or / in windows).

upload_root_rel_path

In the properties context, this refers to the url of an individual property's images, which here is

JOMRES_IMAGELOCATION_RELPATH . getDefaultProperty() . '/'

The first is a constant that resolves to /jomres/uploadedimages/

Next we have a built in Jomres function that will find the manager's active property id.

resource_id_required

This can be either true or false. So if you want images in paths like this : /uploadedimages/15/rooms/34 or /uploadedimages/15/slideshow/0 , then use true.
If this is set to false, as in the case of property features, then Jomres will not create further subdirectories, instead it will just upload images to, for example, /uploadedimages/pfeatures or /uploadedimages/rmtypes

 

resource_id_gathering_trigger - 03381

The 03381 is called via ajax when a user changes the resource type that they're uploading images for in the Media Centre. The purpose of this is to allow us to show a dropdown list of resource ids if necessary. As already mentioned, slideshows (and the main property image) don't use a resource id, but rooms do. So for example j03381slideshow doesn't do anything so returns an empty string, but j03381rooms returns a dropdown with a dropdown list of room numbers and names. This allows the manager to upload multiple images for individual rooms.


post_upload_processing_trigger - 03382

This trigger is used for post uploaded processing, so it's triggered after an image has been uploaded. For example, j03382slideshow was emptying the /jomres/uploadedimages/15/gifs/ directory, then built a new copy of the slideshow gif which was commonly used in the property list (i.e search results) and module popup. Now the gif has been replaced by a slideshow, but the code is still there commented, so you can use it as example.

 

get_existing_images_trigger - 03383

This is used to find the existing images for a given context, which are then returned as an array. With this array, Jomres can build the existing images column which a user can use to view or delete existing images.


If you're a developer and have a new property resource that you'd like to upload images for, then these triggers are likely all that you'll need.

 

Allowed file types

By default, Jomres only supports uploading of jpg and png images. Whilst you could probably upload other types of resources, that functionality hasn't been tested and we recommend that you only implement uploading of other types at your own risk, and after exhaustive testing. Also, you should read the File Uploader's security notes.