J1.5

Difference between revisions of "Adapting a Joomla 1.0 extension to Joomla 1.5"

From Joomla! Documentation

m (→‎Other changes: archiving articles with category removal and addition)
Line 108: Line 108:
 
[[jtopic:36810|Fitting Community builder in 1.5 legacy mode, while preserving compatibility to Joomla 1.0 and Mambo 4.5.x]]
 
[[jtopic:36810|Fitting Community builder in 1.5 legacy mode, while preserving compatibility to Joomla 1.0 and Mambo 4.5.x]]
  
[[Category:Development]]
+
 
[[Category:Tutorials]]
+
 
 +
[[Category:Archived version Joomla! 1.5|{{PAGENAME}}]]

Revision as of 06:43, 30 April 2013

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

This is a first draft... Please complete or comment so we can complete it...

Although Joomla 1.5 has been designed with Joomla 1.0 backwards compatibility in mind, there are a very few items which are not backwards compatible, and require minimal adaptations. This document sumarizes the changes which need to be made to Joomla 1.0 extensions to make them run in Joomla 1.5.

General[edit]

Denying direct access[edit]

The Joomla 1.0 way to deny access for a direct external call is:

defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

which has been changed into:

defined( '_JEXEC' ) or die( 'Restricted access' );

Request/POST parameters[edit]

By default URL parameters are not translated anymore into globals of same name, but should be accessed the standard way. Here too, the change is trivial: instead of looking directly for the variable $reportform, first retrieve it using JRequest. The Joomla 1.0 way of doing this is:

 $form = mosGetParam( $_REQUEST, 'reportform');

The only official way is now:

 $form = JRequest::getVar('reportform');

This will prevent SQL injection attacks by the way, as both mosGetParam and JRequest escape the variables for malicious SQL code.

Start of changes in ACL[edit]

The tables structure of the used phpGACL has changed slightly, due to an update to latest phpGACL. The $acl->.... methods remain backwards compatible, so extensions which do not access ACL tables wildly are ok. Please report incompatibilities, so they can be fixed in the core.

Components[edit]

Global scope[edit]

For security enhancement reasons and better encapsulation reasons, the components are not anymore just included from the main index.php, but called from a function. Thus their variables scope is not the global scope anymore. This means that variables created in the main part of a component, which are not declared as global before creation belong to the component's main execution, and are not accessible as global from the components functions. The adaptation is trivial: just add one line in the begin of the component: global .... enumerating the global variables of the component.

Modules[edit]

Modules path[edit]

Each module is installed in its own sub-directory, like components, meaning if they have images or other files, the path changes.

Joomla Plugins (previously Mambots)[edit]

Change of name[edit]

The mambots have been renamed to joomla plugins, as well as the directory, so same remark applies there.

Event registration[edit]

The Joomla 1.0 way of registering a function for an event is:

$_MAMBOTS->registerFunction( 'onPrepareContent', 'botMybot' );

which has been changed into

$mainframe->registerEvent( 'onPrepareContent', 'botMybot' );

Helper class[edit]

A new core class was developed for helping us to manage plugins, this class is JPluginHelper.

It can be used (for example) to know if a plugin is published or not.

$plugin =& JPluginHelper::getPlugin('content', 'mybot');
if (!$plugin->published){ 
  //plugin not published 
}else  { 
  //plugin published 
}

Parameter management class[edit]

The new core class JParameter was developed for helping us to manage plugins. It can be used to retrieve plugin paramaters, for example:

$pluginParams = new JParameter( $plugin->params );

Please note that we pass to the constructor the params member of the plugin instance created using the JPluginHelper (see above).

Retrieving parameters is now as simple as:

$pluginParams->get( 'P1', 0 );

JParameter can also be used for components and modules, see the documentation at JParameter.

Other changes[edit]

There is another section covering the joomla plugins... link?

Here is one: Fitting Community builder in 1.5 legacy mode, while preserving compatibility to Joomla 1.0 and Mambo 4.5.x