isAdmin()) { return; } // Joom!Fish bot get's only activated if essential files are missing //if ( !file_exists( JPATH_PLUGINS .DS. 'system' .DS. 'jfdatabase' .DS. 'jfdatabase.class.php' )) { if ( !file_exists( dirname(__FILE__) .DS. 'jfdatabase' .DS. 'jfdatabase_inherit.php' )) { JError::raiseNotice('no_jf_plugin', JText::_('Joom!Fish plugin not installed correctly. Plugin not executed')); return; } jimport('joomla.filesystem.file'); if(JFile::exists(JPATH_SITE .DS. 'components' .DS. 'com_joomfish' .DS. 'helpers' .DS. 'defines.php')) { require_once( JPATH_SITE .DS. 'components' .DS. 'com_joomfish' .DS. 'helpers' .DS. 'defines.php' ); JLoader::register('JoomfishManager', JOOMFISH_ADMINPATH .DS. 'classes' .DS. 'JoomfishManager.class.php' ); JLoader::register('JoomFishVersion', JOOMFISH_ADMINPATH .DS. 'version.php' ); JLoader::register('JoomFish', JOOMFISH_PATH .DS. 'helpers' .DS. 'joomfish.class.php' ); } else { JError::raiseNotice('no_jf_extension', JText::_('Joom!Fish extension not installed correctly. Plugin not executed')); return; } /** * Exchange of the database abstraction layer for multi lingual translations. */ class plgSystemJFDatabase extends JPlugin{ /** * stored configuration from plugin * * @var object configuration information */ var $_config = null; function plgSystemJFDatabase(& $subject, $config) { global $mainframe; if ($mainframe->isAdmin()) { // This plugin is only relevant for use within the frontend! return; } parent::__construct($subject, $config); // put params in registry so I have easy access to them later $conf =& JFactory::getConfig(); $conf->setValue("jfdatabase.params",$this->params); $this->_config = array( 'adapter' => $this->params->get('dbadapter', "inheritor") ); if(defined('JOOMFISH_PATH')) { $this->_jfInitialize(); } else { JError::raiseNotice('no_jf_component', JText::_('Joom!Fish component not installed correctly. Plugin not executed')); } } /** * During this event we setup the database and link it to the Joomla! ressources for future use * @return void */ function onAfterInitialise() { global $mainframe; if ($mainframe->isAdmin()) { // This plugin is only relevant for use within the frontend! return; } $this->_setupJFDatabase(); } function onAfterRender() { $buffer = JResponse::getBody(); $info = ""; $db =& JFactory::getDBO(); $info .= "
"; uasort($db->profileData,array($this,"sortprofile")); foreach ($db->profileData as $func=>$data) { $info .= "$func = ".round($data["total"],4)." (".$data["count"].")
"; } $info .= "
"; $buffer = str_replace("JFTimings",$info,$buffer); JResponse::setBody($buffer); } function sortprofile($a,$b){ return $a["total"]>=$b["total"]?-1:1; } /** * Setup for the Joom!Fish database connectors, overwriting the original instances of Joomla! * Which connector is used and which technique is based on the extension configuration * @return void */ function _setupJFDatabase(){ if ($this->_config["adapter"] == "decorator") { if (file_exists( JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_joomfish' .DS. 'jfdatabase_decorator.class.php' )) { require_once( JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_joomfish' .DS. 'jfdatabase_decorator.class.php' ); $db = & JFactory::getDBO(); $db = new JFDatabase(); $conf =& JFactory::getConfig(); $conf->setValue('config.mbf_content', 1 ); $conf->setValue('config.multilingual_support', 1 ); // TODO: check on legacy mode on or off $GLOBALS['database'] = $db; } } else { if (file_exists( dirname(__FILE__).DS.'jfdatabase'.DS.'jfdatabase_inherit.php' )) { require_once( dirname(__FILE__).DS.'jfdatabase'.DS.'jfdatabase_inherit.php' ); $conf =& JFactory::getConfig(); $host = $conf->getValue('config.host'); $user = $conf->getValue('config.user'); $password = $conf->getValue('config.password'); $db = $conf->getValue('config.db'); $dbprefix = $conf->getValue('config.dbprefix'); $dbtype = $conf->getValue('config.dbtype'); $debug = $conf->getValue('config.debug'); $driver = $conf->getValue('config.dbtype'); $options = array("driver"=>$driver, "host"=>$host, "user"=>$user, "password"=>$password, "database"=>$db, "prefix"=>$dbprefix,"select"=>true); $db = & JFactory::getDBO(); $db = new JFDatabase($options); $debug = $conf->getValue('config.debug'); $db->debug($debug); if ($db->getErrorNum() > 2) { JError::raiseError('joomla.library:'.$db->getErrorNum(), 'JDatabase::getInstance: Could not connect to database
' . $db->getErrorMsg() ); } $conf->setValue('config.mbf_content', 1 ); $conf->setValue('config.multilingual_support', 1 ); // legacy mode only // check on legacy mode on/off by testing existence of $database global if (defined('_JLEGACY') && array_key_exists('database',$GLOBALS)){ $GLOBALS['database'] = new mldatabase($options); $GLOBALS['database']->debug($conf->getValue('config.debug')); } //echo phpinfo(); } } } /** This function initialize the Joom!Fish manager in order to have * easy access and prepare certain information. * @access private */ function _jfInitialize ( ) { /* ToDo: check if we really need this any longer. Should be removed latest with 2.1 * @deprecated */ $GLOBALS[ '_JOOMFISH_MANAGER'] =& JoomFishManager::getInstance(); } }