Archived

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

From Joomla! Documentation

Line 106: Line 106:
 
or you can try the following method that allows you to have your extention install on both Joomla 1.5 and Joomla 1.6:
 
or you can try the following method that allows you to have your extention install on both Joomla 1.5 and Joomla 1.6:
 
http://www.netshinesoftware.com/component/option,com_myblog/Itemid,65/show,Creating-a-single-install-package-for-a-plugin-that-works-on-Joomla-1.-1.5-AND-1.6.html/
 
http://www.netshinesoftware.com/component/option,com_myblog/Itemid,65/show,Creating-a-single-install-package-for-a-plugin-that-works-on-Joomla-1.-1.5-AND-1.6.html/
 +
 +
 +
 +
== Component conversion planning items ==
 +
Here is an informal and unordered list of things to consider if you are planning to convert your 1.5 extensions to 1.6. They are mostly from the Google general development group around the time of 1.6b15.
 +
 +
1. Language file - J!1.6 enforces strict rules for language
 +
translations.  No more spaces in the keys or values that aren't
 +
enclosed in double quotes. This change will hopefully get much better performance than the previous loose enforcement.
 +
 +
2. Changes to view parameters - J!1.6 has a strict new way of
 +
specifying parameters for views.  J!1.5 allowed a bit of freedom where
 +
the parameters could be defined at the view.html.php level but now it
 +
has to be at the tmpl level.  AE believes the view paramters were removed.
 +
 +
3. Plugins - J!1.6 now creates a different hierarchy structure for
 +
plugin types.  Files are no longer placed where they used to be, so if
 +
your other parts of your application (comp, mods, etc.) expects them to be in a certain position, it won't
 +
work.  If you only load your plugins via the 1.5 API you should be fine.
 +
 +
4. Installation process - preflight, postflight, etc - These are new
 +
events that can screw up an existing installlation process.  -1 on me for not documenting the process while stepping through xdebug.
 +
They should be totally optional access points to the installation process.  But if your 1.5 install process is tricky for some reason, then these can be used to do clean up activities.
 +
 +
5. Custom fields - This could be a could be huge depending the volume and vagaries your 1.5 usage of custom fields. The entire process changed and now the custom fields must inherit from J! base classes.  (AE) This is no different from 1.5 inheriting from JElement.  In 1.6 you inherit from JFormField which is a much more robust class.
 +
 +
6. Admin template changes - Admin functions that depended on certain
 +
functions, naming conventions etc no longer work.  Khepri has been removed.  Other admin functions/libraries may have changed. 
 +
 +
7. ACL - gid and aid have been removed.  Significant changes to ACL archtecture.  Bricking refers to totally locking your self and everyone else out - Last chance backdoor involves adding a emergency pw to the config file.
 +
 +
8. Renamed methods, table names, etc.
 +
  
  
 
[[Category:Joomla! 1.6]]
 
[[Category:Joomla! 1.6]]

Revision as of 00:07, 18 December 2010

This page has been archived. This page contains information for an unsupported Joomla! version or is no longer relevant. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Quill icon.png
Content is Incomplete

This article or section is incomplete, which means it may be lacking information. You are welcome to assist in its completion by editing it as well. If this article or section has not been edited in several days, please consider helping complete the content.
This article was last edited by Mrroyce (talk| contribs) 13 years ago. (Purge)


This article is written to help developers upgrade their extensions from Joomla 1.5 to Joomla 1.6. If you have any further tips, feel free to add them onto this wiki article.

System setup[edit]

This document assumes that you are running the program eclipse for your development. This will allow you to automate most of the Joomla conversion process. For more instructions on how to setup eclipse visit: http://docs.joomla.org/Setting_up_your_workstation_for_Joomla!_development

Background reading[edit]

The following article describes most changes of Joomla 1.6 and how this affect developers. http://docs.joomla.org/What%27s_new_in_Joomla_1.6#Developers

Updating your Joomla 1.5 language files to work on Joomla 1.6[edit]

Using the native php ini parser for language files has many benefits including much faster performace. Converting your exisiting Joomla 1.5 into the new format is very easy if you use a coding platform like eclipse. Search your file for *.ini in your project of choice. Then use the following search/replace values to automatically, replace exisiting quotes, add quotes to string values and update your comments

  1. Double quotes are now not allowed and this can be easily bypassed by searching " and replace with '
  2. Put a closing double quote at end of line if not empty or a comment. Find ^((?!#).+)\R replace with $1"\R
  3. Put an opening quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1"$2\R
  4. Now replace the hash comments with the new semi colon. Find ^# and replace with ;
  5. Remove any illegal strings that can prevent files loading. Find ^(null|yes|no|true|false|on|off|none)=(.+)\R and replace with nothing.

If you do not remove these illegal strings, then your language file won't load and you won't get any error message. The now "illegal" strings in the language file like NO, are now handled by adding a 'J' in-front of them. Just make sure you change these language strings in your XML files as well. You can include in your language file:

;forbidden words
JNULL="Null"
JYES="Yes"
JNO="No"
JTRUE="True"
JFALSE="False"
JON="On"
JOFF="Off"
JNONE="None"

Change in method on how to override javascript functions[edit]

Joomla now has its jabascript functions with Joomla. this means the functions are always unique and won't clash with other javascript function on your server/webpage. However you now need a different method to override the default joomla javascript. The Joomla 1.5 method was:

function submitbutton(pressbutton) {
var form = document.adminForm;
    if (pressbutton == 'applyconfig') {
        //do something unique
        form.action.value = 'apply'
        submitform('saveconfig');
        return;
    }

    submitform(pressbutton);
    return;
}

for joomla 1.6 you need to copy your exisiting function but modify your top line to:

Joomla.submitbutton = function(pressbutton) {
var form = document.adminForm;
    if (pressbutton == 'applyconfig') {
        //do something unique
        form.action.value = 'apply'
        submitform('saveconfig');
        return;
    }

    submitform(pressbutton);
    return;
}

removed functions[edit]

Some functions were removed for various reasons, you can find this list on: http://docs.joomla.org/What%27s_new_in_Joomla_1.6#Removed_features

Note that the ADODB compatibility methods included function like $db->Execute($query) which now need a separate $db->setQuery($query);$db->Query();

the use of name="adminForm" has changed[edit]

To create your own admin forms in joomla you now need to use id="adminForm". This is because the use of the tag "name" is not valid html strict. Although there is build in compatibility check to look for the old name="adminForm" tag, it is best to add the new id tag. An example of the new form code is:

<form method="post" action="index.php" name="adminForm" id="adminForm">

removed index2.php and index3.php[edit]

Joomla 1.0 had different index files to serve admin content in different manners. Joomla 1.6 has now got better way to handle this and you need to search your codebase for "index2.php" and "index3.php" to ensure you don't have any Joomla 1.0 style links. If you need to display your component without any of the other Joomla 1.6 admin content (menus, etc) then add the following to the url: "&tmpl=component"

renamed core tables and field names in Joomla 1.6[edit]

Many of the core Joomla tables have been simplified, combined or renamed. This was needed to get rid of some limitation dating back to Joomla 1.0. This means however that if you have code that directly manipulates Joomla tables, that you need to add a function that detects Joomla 1.6 and had different SQL queries based on the joomla version. An example is the following function that can find if a plugin is published on both Joomla 1.5 and 1.6:

		
function getPluginStatus($element,$folder) {
    //get joomla specs
    $db = & JFactory::getDBO();		
    $version = new JVersion;
    $joomla = $version->getShortVersion();
    if(substr($joomla,0,3) == '1.6'){
        //Joomla 1.6 code
        $query = 'SELECT published FROM #__extensions WHERE element=' . $db->Quote($element) . ' AND folder=' . $db->Quote($folder);
    } else {
        //Joomla 1.0/1.5 code
        $query = 'SELECT published FROM #__plugins WHERE element=' . $db->Quote($element) . ' AND folder=' .   $db->Quote($folder); 
    }
    $db->setQuery($query);
    $result = $db->loadResult();
    return $result;
}	


Changes in the XML installer manifest file[edit]

Joomla 1.6 now uses a more streamlined approach to the XML file inside the ZIP file that installs Joomla extentions. You can either change your current XML file so that it only works with Joomla 1.6: http://www.theartofjoomla.com/home/9-developer/112-upgrading-a-plugin-to-joomla-16.html or you can try the following method that allows you to have your extention install on both Joomla 1.5 and Joomla 1.6: http://www.netshinesoftware.com/component/option,com_myblog/Itemid,65/show,Creating-a-single-install-package-for-a-plugin-that-works-on-Joomla-1.-1.5-AND-1.6.html/


Component conversion planning items[edit]

Here is an informal and unordered list of things to consider if you are planning to convert your 1.5 extensions to 1.6. They are mostly from the Google general development group around the time of 1.6b15.

1. Language file - J!1.6 enforces strict rules for language translations. No more spaces in the keys or values that aren't enclosed in double quotes. This change will hopefully get much better performance than the previous loose enforcement.

2. Changes to view parameters - J!1.6 has a strict new way of specifying parameters for views. J!1.5 allowed a bit of freedom where the parameters could be defined at the view.html.php level but now it has to be at the tmpl level. AE believes the view paramters were removed.

3. Plugins - J!1.6 now creates a different hierarchy structure for plugin types. Files are no longer placed where they used to be, so if your other parts of your application (comp, mods, etc.) expects them to be in a certain position, it won't work. If you only load your plugins via the 1.5 API you should be fine.

4. Installation process - preflight, postflight, etc - These are new events that can screw up an existing installlation process. -1 on me for not documenting the process while stepping through xdebug. They should be totally optional access points to the installation process. But if your 1.5 install process is tricky for some reason, then these can be used to do clean up activities.

5. Custom fields - This could be a could be huge depending the volume and vagaries your 1.5 usage of custom fields. The entire process changed and now the custom fields must inherit from J! base classes. (AE) This is no different from 1.5 inheriting from JElement. In 1.6 you inherit from JFormField which is a much more robust class.

6. Admin template changes - Admin functions that depended on certain functions, naming conventions etc no longer work. Khepri has been removed. Other admin functions/libraries may have changed.

7. ACL - gid and aid have been removed. Significant changes to ACL archtecture. Bricking refers to totally locking your self and everyone else out - Last chance backdoor involves adding a emergency pw to the config file.

8. Renamed methods, table names, etc.