Customising Jomres to work on other CMSs
From Jomres v4 manual
This page will give a brief summary of how Jomres could be edited to run in another CMS. It is intended for the intermediate/advanced PHP developer only.
In May 2009 Jomres v4 was released which is considered to be the first iteration of a truly CMS agnostic Jomres. Before then, it would run exclusively in the Mambo family of products (Mambo and Joomla 1.0.x).
Whilst many new features were added in v4, the main thrust of the changes were designed to identify and extricate the Joomla dependant calls and move them over into new, dynamically called function files.
These files reside in /jomres/libraries/jomres/cms_specific. In a default installation of Jomres there are two different folders /cmsms (for CMS Made Simple) and /joomla15 (for Joomla). The CMS Made Simple code was used mainly to test the extraction of the CMS dependant code from the core of Jomres and should be considered example software only, but the Joomla specific code will always be kept up to date. We would like to investigate adding code for integration with Drupal at a later date, but for now that's on the "nice to have, but we don't have time for it yet" list.
How Jomres finds the CMS specific files
When Jomres runs, one of the first things it does is it runs detect_cms.php which exists in the main Jomres folder. This script will test for certain files to help it to decide which CMS it's running under. If it cannot detect a CMS from the cms_specific folder it will then look in the remote_plugins folder's subfolders for a file detect_cms.php, and if it finds it, then that will be run instead.
Once that file has been run and the constants _JOMRES_DETECTED_CMS and _JOMRES_DETECTED_CMS_SPECIFIC_FILES have been defined then Jomres will know what the current CMS is called, and more importantly where to find the files.
An example will help, but it's based on the understanding that you are already experienced in developing extensions for your CMS of choice. We can't describe in any detail the specific steps required for integrating into your CMS, that one's down to you.
Let's say you're modifying the CMS specific handling for the CMS FOO. You will have three tasks:
- Create a plugin for your CMS where you will require the jomres/jomres.php script.
- Tell Jomres where to find the cms specific libraries for the FOO cms.
- Modify the cms specific files so that the functions contained therein access the FOO CMS's data in such a way as to make it usable by Jomres.
You would have your CMS's files in a public_html/www folder, and in a sub-folder of their own called foo. To start off with you'd make sure that your installation of FOO is running as expected.
The next step is to create an extension for your CMS and tell it to include jomres.php. This is essentially a bridge between your CMS and Jomres but it doesn't do much. For example, the Joomla -> Jomres bridge looks roughly like this:
Next, you'd extract Jomres into it's folder so the directory structure would look something like /public_html/foo/jomres.
Jomres looks in the remote_plugins folder for a copy of detect_cms.php, so we need to create detect_cms.php. The following contents should be enough.
This file would then be placed in the /public_html/foo/jomres/remote_plugins/foo directory.
Finally, copy the contents of the /foo/jomres/libraries/jomres/cms_specific/joomla15 folder into /public_html/foo/jomres/remote_plugins/foo and start working on them to modify the functions in there so that they pass data back to Jomres when called.
Exactly what changes you need to make can't be addressed by this article as this will be specific to each CMS. The joomla15 files will have some code that's only available in Joomla. If your CMS doesn't have a comparable function then you may need to simply return the data unaltered. For example, the function jomres_cmsspecific_parseByBots is designed to allow Joomla to do some jiggery pokery via it's own plugins (AKA mambots) before the data is presented on the page, it's quite possible that your CMS will not have an equivalent function and you might need to simply return the data it's been sent unadultered, like so:
One last note:
It is possible that your CMS will not be happy with Jomres just echoing it's output when the bridge is run. Instead, it might want to do other stuff to that code first. If the bridge defines the constant JOMRES_RETURNDATA like so
then instead of running ob_end_flush(), Jomres will do define("JOMRES_RETURNDATA_CONTENT", ob_get_contents() ); which puts the entire rendered content into the JOMRES_RETURNDATA_CONTENT constant which your bridge can then access to do with as it needs.