function _installPackage() { $installer = JSNISInstaller::getInstance(); if ($this->_packageExtract) { $objJSNPlugins = JSNISFactory::getObj('classes.jsn_is_plugins'); $countSource = count($this->_listCurrentSources); $currentSources = array(); if ($countSource) { for ($i = 0; $i < $countSource; $i++) { $item = $this->_listCurrentSources[$i]; $currentSources[$item->element] = $objJSNPlugins->getXmlFile($item); } } if (!$installer->install($this->_packageExtract['dir'])) { $this->_msgError = JText::_('INSTALLER_IMAGE_SOURCE_PACKAGE_UNSUCCESSFULLY_INSTALLED'); $this->_error = true; return false; } $this->_upgradeSourceDB($currentSources, $installer); if (!is_file($this->_packageExtract['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $this->_packageExtract['packagefile']; } JInstallerHelper::cleanupInstall($this->_packageExtract['packagefile'], $this->_packageExtract['extractdir']); } }
function install() { global $mainframe; switch (JRequest::getWord('installtype')) { case 'upload': $package = $this->_getPackageFromUpload(); break; default: $this->setState('message', 'No Install Type Found'); return false; break; } if (!$package) { $this->setState('message', 'Unable to find install package'); return false; } $installer =& JSNISInstaller::getInstance(); if (!$installer->install($package['dir'])) { //$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error')); $result = false; } else { //$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success')); $msg = JText::_('Theme package successfully installed'); $result = true; } $mainframe->enqueueMessage(@$msg); $this->setState('name', $installer->get('name')); $this->setState('result', $result); $this->setState('message', $installer->message); $this->setState('extension.message', $installer->get('extension.message')); if (!is_file($package['packagefile'])) { $config =& JFactory::getConfig(); $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); return $result; }
function uninstall($eid = array()) { // Initialise variables. $failed = array(); if (!is_array($eid)) { $eid = array($eid => 0); } // Get a database connector $db = JFactory::getDBO(); // Get an installer object for the extension type jimport('joomla.installer.installer'); $installer = JSNISInstaller::getInstance(); $row = JTable::getInstance('extension'); // Uninstall the chosen extensions foreach ($eid as $id) { $id = trim($id); $row->load($id); if ($row->type) { $result = $installer->uninstall($row->type, $id); if ($result === false) { $failed[] = $id; } } else { $failed[] = $id; } } $langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type); $rowtype = JText::_($langstring); if (strpos($rowtype, $langstring) !== false) { $rowtype = $row->type; } if (count($failed)) { $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype); $result = false; } else { $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype); $result = true; } $app = JFactory::getApplication(); $app->enqueueMessage($msg); //$this->setState('action', 'remove'); //$this->setState('name', $installer->get('name')); //$app->setUserState('com_installer.message', $installer->message); //$app->setUserState('com_installer.extension_message', $installer->get('extension_message')); return $result; }