From: Brian Shaughnessy Date: Wed, 24 Apr 2013 00:13:59 +0000 (-0400) Subject: CRM-12096 joomla 3.0 support cli X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6fde79f5c2249e44a0feddb183bb4117efc4934e;p=civicrm-core.git CRM-12096 joomla 3.0 support cli --- diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index 04ad66536c..043e00a315 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -43,14 +43,21 @@ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { // not execute hooks if joomla is not loaded if (defined('_JEXEC')) { //Invoke the Joomla plugin system to observe to civicrm events. - jimport( 'joomla.plugin.helper' ); + jimport( 'joomla.plugin.helper' ); JPluginHelper::importPlugin('civicrm'); - // get app based on cli or web - if ( PHP_SAPI != 'cli' ) { - $app = JFactory::getApplication( 'administrator' ); - } else { - $app = JCli::getInstance(); + // get app based on cli or web + if ( PHP_SAPI != 'cli' ) { + $app = JFactory::getApplication( 'administrator' ); + } + else { + // condition on Joomla version + if( version_compare(JVERSION, '3.0', 'lt') ) { + $app = JCli::getInstance(); + } + else { + $app = JApplicationCli::getInstance(); + } } $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5)); diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 518d85f439..fc7eb8f71b 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -603,10 +603,24 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { // Get the framework. require $joomlaBase . '/libraries/import.php'; require $joomlaBase . '/libraries/joomla/event/dispatcher.php'; - require $joomlaBase . '/libraries/joomla/environment/uri.php'; - require $joomlaBase . '/libraries/joomla/application/component/helper.php'; require $joomlaBase . '/configuration.php'; + // Files may be in different places depending on Joomla version + if ( !defined('JVERSION') ) { + require $joomlaBase . '/libraries/cms/version/version.php'; + $jversion = new JVersion; + define('JVERSION', $jversion->getShortVersion()); + } + + if( version_compare(JVERSION, '3.0', 'lt') ) { + require $joomlaBase . '/libraries/joomla/environment/uri.php'; + require $joomlaBase . '/libraries/joomla/application/component/helper.php'; + } + else { + require $joomlaBase . '/libraries/joomla/uri/uri.php'; + require $joomlaBase . '/libraries/legacy/component/helper.php'; + } + jimport('joomla.application.cli'); return TRUE;