/** * Effectively bootstrap redCORE. * * @param bool $loadBootstrap Load bootstrap with redcore plugin options * * @return void */ public static function bootstrap($loadBootstrap = true) { if ($loadBootstrap && !defined('REDCORE_BOOTSTRAPPED')) { define('REDCORE_BOOTSTRAPPED', 1); } if (!defined('REDCORE_LIBRARY_LOADED')) { // Sets bootstrapped variable, to avoid bootstrapping redCORE twice define('REDCORE_LIBRARY_LOADED', 1); // Use our own base field if (!class_exists('JFormField', false)) { $baseField = JPATH_LIBRARIES . '/redcore/joomla/form/field.php'; if (file_exists($baseField)) { require_once $baseField; } } // Register the classes for autoload. JLoader::registerPrefix('R', JPATH_REDCORE); // Setup the RLoader. RLoader::setup(); // Make available the redCORE fields JFormHelper::addFieldPath(JPATH_REDCORE . '/form/field'); JFormHelper::addFieldPath(JPATH_REDCORE . '/form/fields'); // Make available the redCORE form rules JFormHelper::addRulePath(JPATH_REDCORE . '/form/rules'); // HTML helpers JHtml::addIncludePath(JPATH_REDCORE . '/html'); RHtml::addIncludePath(JPATH_REDCORE . '/html'); // Load library language $lang = JFactory::getLanguage(); $lang->load('lib_redcore', JPATH_REDCORE); // For Joomla! 2.5 compatibility we add some core functions if (version_compare(JVERSION, '3.0', '<')) { RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redcore/joomla', false, true); } // Make available the fields JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redcore/form/fields'); // Make available the rules JFormHelper::addRulePath(JPATH_LIBRARIES . '/redcore/form/rules'); // Replaces Joomla database driver for redCORE database driver JFactory::$database = null; JFactory::$database = RFactory::getDbo(); if (self::getConfig('enable_translations', 0) == 1 && !JFactory::getApplication()->isAdmin()) { // This is our object now $db = JFactory::getDbo(); // Enable translations $db->translate = self::getConfig('enable_translations', 0) == 1; // Reset plugin translations params if needed RTranslationHelper::resetPluginTranslation(); } } }
/** * Method to process SQL updates previous to the install process * * @param JInstallerAdapter $parent Class calling this method * * @return boolean True on success */ public function preprocessUpdates($parent) { $manifest = $parent->get('manifest'); if (isset($manifest->update)) { if (isset($manifest->update->attributes()->folder)) { $path = $manifest->update->attributes()->folder; if (isset($manifest->update->pre) && isset($manifest->update->pre->schemas)) { $schemapaths = $manifest->update->pre->schemas->children(); if (count($schemapaths)) { $sourcePath = $parent->getParent()->getPath('source'); // If it just upgraded redCORE to a newer version using RFactory for database, it forces using the redCORE database drivers if (substr(get_class(JFactory::$database), 0, 1) == 'J' && $this->extensionElement != 'com_redcore') { RFactory::$database = null; JFactory::$database = null; JFactory::$database = RFactory::getDbo(); } $db = JFactory::getDbo(); $dbDriver = strtolower($db->name); $schemapath = ''; if ($dbDriver == 'mysqli') { $dbDriver = 'mysql'; } foreach ($schemapaths as $entry) { if (isset($entry->attributes()->type)) { $uDriver = strtolower($entry->attributes()->type); if ($uDriver == 'mysqli') { $uDriver = 'mysql'; } if ($uDriver == $dbDriver) { $schemapath = (string) $entry; break; } } } if ($schemapath != '') { $files = str_replace('.sql', '', JFolder::files($sourcePath . '/' . $path . '/' . $schemapath, '\\.sql$')); usort($files, 'version_compare'); if (count($files)) { foreach ($files as $file) { if (version_compare($file, $this->oldVersion) > 0) { $buffer = file_get_contents($sourcePath . '/' . $path . '/' . $schemapath . '/' . $file . '.sql'); $queries = RHelperDatabase::splitSQL($buffer); if (count($queries)) { foreach ($queries as $query) { if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->execute(true)) { JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING, 'jerror'); return false; } } } } } } } } } } } } return true; }