Joomla plugin upgrade/migration from 1.0 to 1.5
Recently I had to migrate some custom Joomla plugins on an old 1.0.x Joomla website to a 1.5 based Joomla website. I am noting down how I did this since there doesn’t seem to be a similar document out there.
Installation XML
You can keep the name (plugin.xml).
Make sure to change the first two lines and the last line:
<?xml version="1.0" encoding="iso-8859-1"?> <mosinstall version="1.0" type="mambots" group="content"> ... </mosinstall>
to:
<?xml version="1.0" encoding="utf-8"?> <install version="1.5" type="plugin" group="content"> ... </install>
Add an author e-mail as well:
<authorEmail>aaa@aaa.com</authorEmail>
Change the attribute from “mambot” to “plugin”:
<filename mambot="etplugin">etplugin.php</filename>
<filename plugin="etplugin">etplugin.php</filename>
Plugin code
Keep the same file name : plugin.php
Change the first line from:
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
to
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
Change registerFunction() to registerEvent():
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botFnCall' );
to
$mainframe->registerEvent( 'onPrepareContent', 'plgFnCall' );
Make sure to change references for variables such as $mosConfig_live_site, $mosConfig_absolute_path, $database, etc as specified here.
The function call construct no longer has four arguments:
function botFnCall( $published, &$row, $mask=0, $page=0 ) {
Instead it has three:
function plgFnCall( &$row, &$params, $page=0 ) {
Add a performance check for good measure:
// simple performance check to determine whether bot should process further
if ( JString::strpos( $row->text, 'pluginTag' ) === false ) {
return true;
}
Change the published check:
if (!$published) {
return true;
}
to:
if ( !$params->get( 'enabled', 1 ) ) {
return true;
}
Change any references to the “/mambots/” directory to “/plugins/” (if you’re including custom CSS, JS, and the like.)
