function install($parent) { $app = JFactory::getApplication(); $app->setUserState('com_kunena.install.step', 0); // Install English and default language require_once JPATH_ADMINISTRATOR . '/components/com_kunena/install/model.php'; $installer = new KunenaModelInstall(); $installer->installLanguage('en-GB'); $lang = JFactory::getLanguage(); $tag = $lang->getTag(); if ($tag != 'en-GB') { $installer->installLanguage($tag); } }
function install($parent) { $app = JFactory::getApplication(); $app->setUserState('com_kunena.install.step', 0); // Install English and default language require_once JPATH_ADMINISTRATOR . '/components/com_kunena/install/model.php'; $installer = new KunenaModelInstall(); $success = $installer->installLanguage('en-GB'); if (!$success) { $app->enqueueMessage('Installing Kunena language (en-GB) failed!', 'notice'); } $lang = JFactory::getLanguage(); $tag = $lang->getTag(); if ($tag != 'en-GB') { $success = $installer->installLanguage($tag); if (!$success) { $app->enqueueMessage("Installing Kunena language ({$tag}) failed!", 'notice'); } } }
/** * Migrate custom information. * * This function gets called after all folders and tables have been copied. * * If you want to split this task into smaller chunks, * please store your custom state variables into $this->state and return false. * Returning false will force jUpgrade to call this function again, * which allows you to continue import by reading $this->state before continuing. * * @return boolean Ready (true/false) * @since 1.6.4 * @throws Exception */ protected function migrateExtensionCustom() { require_once $this->api; // Need to initialize application jimport('joomla.environment.uri'); $app = JFactory::getApplication('administrator'); // Get component object $component = JTable::getInstance('extension', 'JTable', array('dbo' => $this->db_new)); $component->load(array('type' => 'component', 'element' => $this->name)); // First fix all broken menu items $query = "UPDATE #__menu SET component_id={$this->db_new->quote($component->extension_id)} WHERE type = 'component' AND link LIKE '%option={$this->name}%'"; $this->db_new->setQuery($query); $this->db_new->query(); $menumap = $this->getMapList('menus'); // Get all menu items from the component (JMenu style) $query = $this->db_new->getQuery(true); $query->select('*'); $query->from('#__menu'); $query->where("component_id = {$component->extension_id}"); $query->where('client_id = 0'); $query->order('lft'); $this->db_new->setQuery($query); $menuitems = $this->db_new->loadObjectList('id'); foreach ($menuitems as &$menuitem) { // Get parent information. $parent_tree = array(); if (isset($menuitems[$menuitem->parent_id])) { $parent_tree = $menuitems[$menuitem->parent_id]->tree; } // Create tree. $parent_tree[] = $menuitem->id; $menuitem->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $menuitem->link); $url = str_replace('&', '&', $url); parse_str($url, $menuitem->query); } // Update menu items foreach ($menuitems as $menuitem) { if (!isset($menuitem->query['view'])) { continue; } $update = false; switch ($menuitem->query['view']) { case 'entrypage': // Update default menu item if (!empty($menuitem->query['defaultmenu'])) { $menuitem->query['defaultmenu'] = $menumap[$menuitem->query['defaultmenu']]->new; $update = true; } break; } if ($update) { // Update menuitem link $query_string = array(); foreach ($menuitem->query as $k => $v) { $query_string[] = $k . '=' . $v; } $menuitem->link = 'index.php?' . implode('&', $query_string); // Save menu object $menu = JTable::getInstance('menu', 'JTable', array('dbo' => $this->db_new)); $menu->bind(get_object_vars($menuitem), array('tree', 'query')); $success = $menu->check(); if ($success) { $success = $menu->store(); } if (!$success) { echo "ERROR"; } } } // Delete old manifest file jimport('joomla.filesystem.file'); if (file_exists(JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.j16.xml')) { JFile::delete(JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.xml'); JFile::move(JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.j16.xml', JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.xml'); } jimport('joomla.plugin.helper'); // Mark Kunena as discovered and install it $component->client_id = 1; $component->state = -1; $component->store(); jimport('joomla.installer.installer'); $installer = JInstaller::getInstance(); $installer->discover_install($component->extension_id); // Start Kunena installer require_once dirname(__FILE__) . '/model.php'; $kunena = new KunenaModelInstall(); // Install system plugin $kunena->installSystemPlugin(); // Install English language $kunena->installLanguage('en-GB', 'English'); return true; }