function com_install() { $database =& JFactory::getDBO(); $lang =& JFactory::getLanguage(); $lang->load('com_rsgallery2'); require_once JPATH_ADMINISTRATOR . '/components/com_rsgallery2/includes/install.class.php'; //Initialize install $rsgInstall = new rsgInstall(); //Change the menu icon $rsgInstall->changeMenuIcon(); //Initialize rsgallery migration $migrate_com_rsgallery = new migrate_com_rsgallery(); //If previous version detected if ($migrate_com_rsgallery->detect()) { // now that we know a previous rsg2 was installed, we need to reload it's config global $rsgConfig; $rsgConfig = new rsgConfig(); $rsgInstall->writeInstallMsg(JText::_('Migrating from RSGallery2') . ' ' . $rsgConfig->get('version'), 'ok'); //Migrate from earlier version $result = $migrate_com_rsgallery->migrate(); if ($result === true) { $rsgInstall->writeInstallMsg(JText::_('SUCCESS NOW USING RSGALLERY2') . ' ' . $rsgConfig->get('version'), 'ok'); } else { $result = print_r($result, true); $rsgInstall->writeInstallMsg(JText::_('FAILURE-') . "\n<br><pre>{$result}\n</pre>", 'error'); } } else { //No earlier version detected, do a fresh install $rsgInstall->freshInstall(); } }
/** * Shows Migration main screen * It shows detected gallerysystem and offers a migration option */ function showMigration() { require_once JPATH_RSGALLERY2_ADMIN . '/includes/install.class.php'; //Initialize new install instance $rsgInstall = new rsgInstall(); if (isset($_REQUEST['type'])) { $type = mosGetParam($_REQUEST, 'type', ''); } else { $type = NULL; } if ($type == '') { $rsgInstall->showMigrationOptions(); } else { $result = $rsgInstall->doMigration($type); if ($result !== true) { echo $result; HTML_RSGallery::showCP(); } else { echo JText::_('migration successful'); HTML_RSGallery::showCP(); } } }
function upgradeTo_2_2_1() { //There is a new field 'alias in tables #__rsgallery2_galleries and // #__rsgallery2_files and it needs to be filled as our SEF router uses it $error = false; $db =& JFactory::getDBO(); //Get id, name for the galleries $query = 'SELECT id, name FROM #__rsgallery2_galleries'; $db->setQuery($query); $result = $db->loadAssocList(); //...and make alias from name foreach ($result as $key => $value) { jimport('joomla.filter.filteroutput'); $result[$key]['alias'] = JFilterOutput::stringURLSafe($value['name']); } //save the alias foreach ($result as $key => $value) { $query = 'UPDATE #__rsgallery2_galleries ' . ' SET `alias` = ' . $db->quote($value['alias']) . ' WHERE `id` = ' . $db->quote($value['id']); $db->setQuery($query); $result = $db->query(); if (!$result) { $msg = JText::_('COM_RSGALLERY2_MIGRATE_ERROR_FILLING_ALIAS_GALLERY', $value[id], $value[name]); JError::raiseNotice(100, $msg); $error = true; } } //Get id, title for the items $query = 'SELECT id, title FROM #__rsgallery2_files'; $db->setQuery($query); $result = $db->loadAssocList(); //...and make alias from title foreach ($result as $key => $value) { jimport('joomla.filter.filteroutput'); $result[$key]['alias'] = JFilterOutput::stringURLSafe($value['title']); } //save the alias foreach ($result as $key => $value) { $query = 'UPDATE #__rsgallery2_files ' . ' SET `alias` = ' . $db->quote($value['alias']) . ' WHERE `id` = ' . $db->quote($value['id']); $db->setQuery($query); $result = $db->query(); if (!$result) { $msg = JText::_('COM_RSGALLERY2_MIGRATE_ERROR_FILLING_ALIAS_ITEM', $value[id], $value[title]); JError::raiseNotice(100, $msg); $error = true; } } if ($error) { rsgInstall::writeInstallMsg(JText::_('COM_RSGALLERY2_FINISHED_CREATING_ALIASES'), 'error'); } else { rsgInstall::writeInstallMsg(JText::_('COM_RSGALLERY2_FINISHED_CREATING_ALIASES'), 'ok'); } }