Extension Changes for Joomla 3.0/3.1
- Details
- Created on Thursday, 11 October 2012 10:33
- Last Updated on Thursday, 25 April 2013 12:09
This article started off as a Blog entry but as things have been discovered it was decided to make it a full article. It describes the changes that have been made to our extensions as a result of enabling them to run under Joomla 3.0. When we are satisfied that the extensions are fully tested we will release updates to the wider community. Some of the changes required were the result of features deprecated in earlier versions which only now have started to bite.
There is a document listing backward compatibility issues with Joomla 2.5 and the Joomla Platform 12.1. Also this link.
Description of 12.1 MVC framework is here.
Some of the following changes have been identified in the document referred to above, but others are the result of our own testing. So far we have discovered (and made the following changes):
1. In the Joomla! 3.0.0 version get an installation error that shows Directory separator constant DS error. Solution is to add the following code:
if(!defined('DS')){
define('DS',DIRECTORY_SEPARATOR);
}
This is still present in the full release as well. This code has been added to all of the files where required.
2. Seems that JController::getInstance is no longer around. Need to use JControllerLegacy instead.
The old JController, JModel and JView classes have been renamed to JControllerLegacy etc.
The ‘new’ JController,JView, JModel are now classes in the new MVC implementation.
The solution is to use the legacy classes.
The following code does work:
$jversion = new JVersion();
if( version_compare( $jversion->getShortVersion(), '2.5.6', 'lt' ) ) {
$controller = JController::getInstance('IssueTracker');
else {
$controller = JControllerLegacy::getInstance('IssueTracker');
}
However there are numerous places particularly with class definition where we refer to JController, JView and JModel where such a construct will not work which will all require changing.
So in the situation of a moving 2.5 extension to 3.0, we have to
- modify JController::getInstance to JControllerLegacy::getInstance in master component file.
- modify extends JController to JControllerLegacy in master/default controller.
- modify extends JView to JViewLegacy in all view classes.
In the general case, we have to change JController to JControllerLegacy, JModel to JModelLegacy and JView to JViewLegacy. [We have only found once instamce where the change to JModel has been required.]
3. JHtmlBehavior::mootools not found.
Use JHtmlBehavior::framework instead.
This includes constructs such as : JHTML::_('behavior.mootools'); which becomes: JHTML::_('behavior.framework');
4. A few database class routines have changed.
Instead of $db->nameQuote we have to use $db->quoteName
and instead of $db->getEscaped we use $db->escape
5. The library routine jgrid has moved its directory. It was formally in libraries/joomla/html/html/jgrid.php
It is now located in libraries/joomla/html/jgrid.php.
6. Our templates do not display nicely in the Isis template with a lot of items overlapping. Thus there is a need to rework our displays. [See section below on handling both templates.] Hathor template looks OK (as far as it goes!) Seems that the adminlist class has been replaced with the table class (from code inspection). Also the 'btn-group' class has replaced classes such as filter-select, and there are pull-right and pull-left classes as well instead of fltlft and fltrgt.
Note: A number of these changes are related to the change to use BootStrap templates.
These changes have been handled by extending our use of the css definitions file, introducing our own table class. [Note that we have also introduced colour coding for priority and these are handled in the css classes as well.]
7. JDate::toMysql() has been removed. Use JDate::toSql() instead.
Change: $get_date= JFactory::getDate();
$date=$get_date->toMysql();
To: $get_date=JFactory::getDate();
$date=$get_date->toSql();
8. JUtility::sendMail() has been removed. Use JMail::sendMail() instead.
9. JUtility::sendAdminMail() has been removed. Use JMail::sendAdminMail() instead.
10. JDatabase::query() is deprecated, use JDatabaseDriver::execute() instead.
Change: $db->query();
To: $db->execute();
11. JFile::read is deprecated. Use native file_get_contents() syntax.
Change: $textfile= JFile::read(JPATH_COMPONENT . DS . 'text.txt');
To: $textfile=file_get_contents(JPATH_COMPONENT.DS.'text.txt');
12. JRequest is deprecated. Use JFactory::getApplication()->input
See: http://docs.joomla.org/Retrieving_request_data_using_JInput
Change: $post=JRequest::get('post');
JRequest::getVar('badwords');
To: $input =JFactory::getApplication()->input;
$post=$input->post;
$input->post->get('badwords')
Change: $task= JRequest::getVar('task');
To: $task=$input->get('task');
Change: $groupid= JRequest::getVar('id');
To: $groupid=$input->get('id');
Change: $limitstart=JRequest::getVar('limitstart', 0, '', 'int');
To: $limitstart=$input<->get('limitstart','0','INT');
Change: $controller=JRequest::getWord('controller');
To: $controller=$input->get('controller');
Change: $controller->execute(JRequest::getCmd('action'));
To: $controller->execute($input->get('action'));
13. JViewLegacy::assignRef is deprecated. Use native PHP syntax.
Change: $this->assignRef( 'userlist', $userlist);
To: $this->userlist=$userlist
14. JParameter is deprecated.
Change: $retval [] = new JParameter(JPluginHelper::getPlugin('system', 'passwordcontrol')->params);
To: $plugin = JPluginHelper::getPlugin('system','passwordcontrol');
$pluginParameters = new JRegistry();
$pluginParameters->loadString($plugin->params);
$retval [] = $pluginParameters;
15. A number of function calls have been changed to resolved warning messages encountered when site reporting is set to 'Development'. Most of these involve removing the '&' from the the calls to JFactory etc.
16. Discovered that modal windows are not opened and a full window is presented if the XML description text contains a window link when a plugin is installed (or displayed in the plugin manager). In Joomla 2.5. the self same code opens a modal window, but with the Isis template a full window is opened. We are using the modal window to display a changelog for our plug-ins. Not a show stopper but slightly annoying never the less. Resolved by adding JHtml::_('behavior.modal') to template.
17. Review usage of jimport. Should we be using JLoader::import instead? jimport is a simple wrapper around the JLoader call and has been there since Joomla 1.0 but does it have a future?
Handling both Isis and Hathor admin templates
With the change to using bootstrap in the Joomla back end, provides a new 'opportunity' to have to support two possible admin templates. If one converts all the views to use bootstrap so that Isis displays are correct. they do not display correctly if one uses the Hathor template.
The answer is of course to make use of template overrides. Fortunately the 'old' templates designed for Joomla 2.5 display corrrectly with only a few minor changes in the Hathor template.
It is desirable to install the Hathor template overriides when the component is installed, and likewise remove them when the component is uninstalled. There does not appear to be any way in which one can automate this process using the standard manifest file. Instead it is necessary to perform the task within the 'installation script' itself. This works well with our components and is relatively easy to implement.
Of course changes would be required if any of the 'new' Joomla 3.x features are required, such as tag support.
Note that the JHtml tabs work with the Hathor template but it is necessary to use the JHtml bootstrap panes with the Isis template.
Joomla 3.1 observations
1. Observed that the use of the JHtml:: bootstrap tabs has changed between 3.0 and 3.1. This resulted in the 3.0 changes failing in 3.1. Most of the documentation still refers to the 3.0 code base, and has not been modified for Joomla 3.1.
With the official release it has changed yet again. Instead of using bootstrap.startPane use bootstrap.startTabSet, instead of addPane use addTab, etc.
2. Tags component is nice and reasonably easy to add to our component. [Pity in one way that it keeps changing between each beta release, but such is the way with beta code. :-) ].
Tags support doesn't seem to be present in base components with Hathor template!
3. Differences between protostar and Beez 3 templates means that chosing a style that is consistent with both is difficult.
4. Table sort not available with protostar template(?). Could use tablesorter or DataTables code but not sure which is the preferred method.
Known Problems
1. Front end column sort does not work in Joomla 3.1. Even the distribution base components (i.e. contacts) doesn't sort. Code call to Joomla.tableordering suspected to be the cause. Works in back end fine. This is with Beez 3 template, protostar template doesn't provide the same (contacts) display table.
Comments
- No comments found
Additional information
If you use and find our Joomla extensions useful please consider supporting their further development.
Most Recent Forum entries
Issue Tracker - Recently Closed Issues
-
AMS1CJCZ7G - Possible changes to use and setting>Project Name: Issue Tracker - Rel 1.3.1
Close date: 2013-05-24 19:17:18 -
ATECJK2OSI - Introduce purge button on back end >Project Name: Issue Tracker - Rel 1.3.1
Close date: 2013-05-23 19:22:14 -
AN4IGZU1PQ - Change redirection after issue crea>Project Name: Issue Tracker - Rel 1.3.1
Close date: 2013-05-21 16:21:20 -
A5LSHJOSS9 - Add button to issue list to 'view' >Project Name: Issue Tracker - Rel 1.3.1
Close date: 2013-05-21 14:58:14 -
AXSLWZW64W - Add a create button to the issue li>Project Name: Issue Tracker - Rel 1.3.1
Close date: 2013-05-20 16:56:53
Quote(s) of the Day
The chief obstacle to the progress of the human race is the human race.
Don Marquis
If the lessons of history teach us anything it is that nobody learns the lessons that history teaches us.
Anonymous


Leave your comments