Refactoring and add some backward compability for Joomla 2.5.x