本文整理汇总了PHP中JInstallerHelper::unpack方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstallerHelper::unpack方法的具体用法?PHP JInstallerHelper::unpack怎么用?PHP JInstallerHelper::unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstallerHelper
的用法示例。
在下文中一共展示了JInstallerHelper::unpack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPackageFromUpload
function getPackageFromUpload()
{
$install_file = JRequest::getVar('package', null, 'files', 'array');
if (!(bool) ini_get('file_uploads')) {
$msg = 'File upload function is disabled, please enable it in file "php.ini"';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if (!extension_loaded('zlib')) {
$msg = 'Zlib library is disabled, please enable it in file "php.ini"';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if ($install_file['name'] == '') {
$msg = 'The package is not selected, please download and select it';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if (JFile::getExt($install_file['name']) != 'zip') {
$msg = 'The package has incorrect format, please use exactly the file you downloaded';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
$tmp_dest = JPATH_ROOT . DS . 'tmp' . DS . $install_file['name'];
$tmp_src = $install_file['tmp_name'];
if (!JFile::upload($tmp_src, $tmp_dest)) {
$msg = 'Folder "tmp" is Unwritable, please set it to Writable (chmod 777). You can set the folder back to Unwritable after sample data installation';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
$package = JInstallerHelper::unpack($tmp_dest);
return $package;
}
示例2: install
public function install(InputInterface $input, OutputInterface $output)
{
$app = Bootstrapper::getApplication($this->target_dir);
// Output buffer is used as a guard against Joomla including ._ files when searching for adapters
// See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html
ob_start();
$installer = $app->getInstaller();
foreach ($this->extension as $package) {
$remove = false;
if (is_file($package)) {
$result = \JInstallerHelper::unpack($package);
$directory = isset($result['dir']) ? $result['dir'] : false;
$remove = true;
} else {
$directory = $package;
}
if ($directory !== false) {
$path = realpath($directory);
if (!file_exists($path)) {
$output->writeln("<info>File not found: " . $directory . "</info>\n");
continue;
}
try {
$installer->install($path);
} catch (\Exception $e) {
$output->writeln("<info>Caught exception during install: " . $e->getMessage() . "</info>\n");
}
if ($remove) {
\JFolder::delete($path);
}
}
}
ob_end_clean();
}
示例3: install
/**
* Download and install
*/
function install($id, $url)
{
if (!is_string($url)) {
return JText::_('NNEM_ERROR_NO_VALID_URL');
}
$url = 'http://' . str_replace('http://', '', $url);
if (!($target = JInstallerHelper::downloadPackage($url))) {
return JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE');
}
$target = JFactory::getConfig()->get('tmp_path') . '/' . $target;
NNFrameworkFunctions::loadLanguage('com_installer', JPATH_ADMINISTRATOR);
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
// Get an installer instance
$installer = JInstaller::getInstance();
// Unpack the package
$package = JInstallerHelper::unpack($target);
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['packagefile']);
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
return JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
}
return true;
}
示例4: installGiantExtensionsPlugin
private function installGiantExtensionsPlugin()
{
$pluginPath = dirname(__FILE__) . '/plg_content_giantcontent.zip';
$installResult = JInstallerHelper::unpack($pluginPath);
if (empty($installResult)) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
return false;
}
$installer = new JInstaller();
$installer->setOverwrite(true);
if (!$installer->install($installResult['extractdir'])) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
return false;
}
$db = JFactory::getDBO();
$db->setQuery('UPDATE #__extensions SET enabled = 1 WHERE type = "plugin" AND folder = "content" AND element = "giantcontent"');
$db->query();
if ($db->getErrorNum()) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not enable "Content - Giant Content" plugin. Please enable plugin manually in the plugin manager.', 'warning');
}
return true;
}
示例5: postflight
function postflight($type, $parent)
{
if (version_compare(JVERSION, '3.0.0', '>')) {
$messages = array();
// Import required modules
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
jimport('joomla.filesystem.file');
//$db = JFactory::getDBO();
//$query = "ALTER TABLE #__k2_items ADD FULLTEXT(extra_fields)";
//$db->setQuery($query);
//$db->query();
// Get packages
$p_dir = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_jak2filter' . DS . 'packages');
// Did you give us a valid directory?
if (!is_dir($p_dir)) {
$messages[] = JText::_('Package directory(Related modules, plugins) is missing');
} else {
$subpackages = JFolder::files($p_dir);
$result = true;
$installer = new JInstaller();
if ($subpackages) {
$app = JFactory::getApplication();
$templateDir = 'templates/' . $app->getTemplate();
foreach ($subpackages as $zpackage) {
if (JFile::getExt($p_dir . DS . $zpackage) != "zip") {
continue;
}
$subpackage = JInstallerHelper::unpack($p_dir . DS . $zpackage);
if ($subpackage) {
$type = JInstallerHelper::detectType($subpackage['dir']);
if (!$type) {
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::_($zpackage . " Not valid package") . '</span>';
$result = false;
}
if (!$installer->install($subpackage['dir'])) {
// There was an error installing the package
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Error')) . '</span>';
} else {
$messages[] = '<img src="' . $templateDir . '/images/admin/tick.png" alt="" width="16" height="16" /> <span style="color:#00FF00;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Success')) . '</span>';
}
if (!is_file($subpackage['packagefile'])) {
$subpackage['packagefile'] = $p_dir . DS . $subpackage['packagefile'];
}
if (is_dir($subpackage['extractdir'])) {
JFolder::delete($subpackage['extractdir']);
}
if (is_file($subpackage['packagefile'])) {
JFile::delete($subpackage['packagefile']);
}
}
}
}
JFolder::delete($p_dir);
}
}
}
示例6: update
public function update()
{
// Make sure there are updates available
$updates = $this->getModel('update')->getUpdates(false);
if (!$updates->update_available) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_NOUPDATES'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Download the package
$config = JFactory::getConfig();
$target = $config->get('tmp_path') . '/joomailermailchimpintegration_update.zip';
$result = $this->getModel('update')->downloadPackage($updates->packageUrl, $target);
if ($result === false) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTDOWNLOAD'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Extract the package
jimport('joomla.installer.helper');
$result = JInstallerHelper::unpack($target);
if ($result === false) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTEXTRACT'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Package extracted; run the installer
$tempdir = $result['dir'];
@ob_end_clean();
?>
<html>
<head></head>
<body>
<form action="<?php
echo JURI::base() . 'index.php?option=com_installer&view=install';
?>
" method="post" name="frm" id="frm">
<input type="hidden" name="task" value="install.install" />
<input type="hidden" name="installtype" value="folder" />
<input type="hidden" name="install_directory" value="<?php
echo htmlspecialchars($tempdir);
?>
" />
<input type="hidden" name="<?php
echo JSession::getFormToken();
?>
" value="1" />
</form>
<script type="text/javascript">
document.frm.submit();
</script>
</body>
<html><?php
exit;
}
示例7: install
/**
* method to install the component
*
* @return void
* <div id="system-message-container">
<div id="system-message">
<div class="alert alert-message"><a class="close" data-dismiss="alert">×</a>
<h4 class="alert-heading">Message</h4>
<div>
<p>Installing component was successful.</p>
</div>
</div>
</div>
</div>
*/
function install($parent)
{
// $parent is the class calling this method
echo '<div id="system-message-container">';
$msgtext = "";
echo '<div id="system-message">
<div style=" overflow:hidden; margin:8px 0 8px 0; padding:5px;" >
<div style=" font-size:12px; margin:0px 0 0px 0; padding:5px; position:relative; float:right;"><div>Powered by Percha.com</div></div>
<div style="float:left; margin:0 20px 20px 0;"><img src="http://www.fieldsattach.com/images/logo_fieldsattach_small.png" alt="fieldsattach.com" /></div>
<div style=" margin:30px 0 8px 0; padding:5px; font-size:23px; color:#4892AB;">Thanks for install the Fieldsattach component.</div>
</div>';
//INSTALL THE PLUGINS *******************************************************************************
$installer = new JInstaller();
//$installer->_overwrite = true;
$pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS;
$pkgs = array('input.zip' => 'Plugin fieldsattachment <strong>Input</strong>', 'file.zip' => 'Plugin fieldsattachment <strong>File</strong>', 'image.zip' => 'Plugin fieldsattachment <strong>image</strong>', 'imagegallery.zip' => 'Plugin fieldsattachment <strong>imagegallery</strong>', 'select.zip' => 'Plugin fieldsattachment <strong>select</strong>', 'textarea.zip' => 'Plugin fieldsattachment <strong>textarea</strong>', 'content_fieldsattachment.zip' => 'Plugin Content FieldsAttachment', 'system_fieldsattachment.zip' => 'Plugin System FieldsAttachment', 'advancedsearch_fieldsattachment.zip' => 'Plugin Advanced Search FieldsAttachment', 'filterarticles.zip' => 'Plugin Advanced FILTER FieldsAttachment');
foreach ($pkgs as $pkg => $pkgname) {
$package = JInstallerHelper::unpack($pkg_path . $pkg);
if ($installer->install($package['dir'])) {
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">' . $pkgname . ' successfully installed.</div></div>';
//ACTIVE IT
} else {
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">ERROR: Could not install the $pkgname. Please install manually</div></div>';
}
//ACTIVE THE PLUGINS *******************************************************************************
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachment'";
$db->setQuery($sql);
$db->query();
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachmentadvanced'";
$db->setQuery($sql);
$db->query();
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE folder = 'fieldsattachment'";
$db->setQuery($sql);
$db->query();
//DESACTIVE OLD SEARCH
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 0 WHERE element = 'fieldsattachment' AND folder='search'";
$db->setQuery($sql);
$db->query();
JInstallerHelper::cleanupInstall($pkg_path . $pkg, $package['dir']);
}
//DELETE EXTENSIONS
$pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS;
destroy_dir($pkg_path);
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">Clean install directory: ' . $pkg_path . '</div></div>';
echo $msgtext;
echo '</div>';
//$parent->getParent()->setRedirectURL('index.php?option=com_helloworld');
}
示例8: com_install
function com_install()
{
JAVoiceHelpers::Install_Db();
$messages = array();
// Import required modules
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
jimport('joomla.filesystem.file');
// Get packages
$p_dir = JPath::clean(JPATH_SITE . '/components/com_javoice/packages');
// Did you give us a valid directory?
if (!is_dir($p_dir)) {
$messages[] = JText::_('Package directory(Related modules, plugins) is missing');
} else {
$subpackages = JFolder::files($p_dir);
$result = true;
$installer = new JInstaller();
if ($subpackages) {
$app = JFactory::getApplication();
$templateDir = 'templates/' . $app->getTemplate();
foreach ($subpackages as $zpackage) {
if (JFile::getExt($p_dir . DS . $zpackage) != "zip") {
continue;
}
$subpackage = JInstallerHelper::unpack($p_dir . DS . $zpackage);
if ($subpackage) {
$type = JInstallerHelper::detectType($subpackage['dir']);
if (!$type) {
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::_($zpackage . " Not valid package") . '</span>';
$result = false;
}
if (!$installer->install($subpackage['dir'])) {
// There was an error installing the package
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Error')) . '</span>';
} else {
$messages[] = '<img src="' . $templateDir . '/images/admin/tick.png" alt="" width="16" height="16" /> <span style="color:#00FF00;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Success')) . '</span>';
}
if (!is_file($subpackage['packagefile'])) {
$subpackage['packagefile'] = $p_dir . DS . $subpackage['packagefile'];
}
if (is_dir($subpackage['extractdir'])) {
JFolder::delete($subpackage['extractdir']);
}
if (is_file($subpackage['packagefile'])) {
JFile::delete($subpackage['packagefile']);
}
}
}
}
JFolder::delete($p_dir);
}
}
示例9: installExtension
public static function installExtension($url, $label)
{
// Include Joomla! libraries
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
// System variables
$app = JFactory::getApplication();
// Download the package-file
$package_file = self::downloadPackage($url);
// Simple check for the result
if ($package_file == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_EMPTY', $url));
return false;
}
// Check if the downloaded file exists
$tmp_path = JFactory::getApplication()->getCfg('tmp_path');
$package_path = $tmp_path . '/' . $package_file;
if (!is_file($package_path)) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_EXIST', $package_path));
return false;
}
// Check if the file is readable
if (!is_readable($package_path)) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_READABLE', $package_path));
return false;
}
// Now we assume this is an archive, so let's unpack it
$package = JInstallerHelper::unpack($package_path);
if ($package == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_NO_ARCHIVE', $extension['name']));
return false;
}
// Call the actual installer to install the package
$installer = JInstaller::getInstance();
if ($installer->install($package['dir']) == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_FAIL', $extension['name']));
return false;
}
// Get the name of downloaded package
if (!is_file($package['packagefile'])) {
$package['packagefile'] = JFactory::getApplication()->getCfg('tmp_path') . '/' . $package['packagefile'];
}
// Clean up the installation
@JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_SUCCESS', $label));
// Clean the Joomla! plugins cache
$options = array('defaultgroup' => 'com_plugins', 'cachebase' => JPATH_ADMINISTRATOR . '/cache');
$cache = JCache::getInstance('callback', $options);
$cache->clean();
return true;
}
示例10: _getPackageFromDistributives
private function _getPackageFromDistributives($plugin_distr)
{
// Make sure that zlib is loaded so that the package can be unpacked
if (!extension_loaded('zlib')) {
return false;
}
//Check file exist
if (!file_exists($plugin_distr)) {
return false;
}
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($plugin_distr);
return $package;
}
示例11: autoupdate
function autoupdate()
{
$update = $this->parseXMLFile();
$config =& JFactory::getConfig();
$tmp_dest = $config->getValue('config.tmp_path');
if (!is_object($update)) {
// parseXMLFile will have set a message hopefully
//$this->setState('message', 'XML Parse failed');
return false;
} else {
$destination = $tmp_dest . DS . 'com_jupdateman_auto.tgz';
$download = downloadFile($update->updaterurl, $destination);
if ($download !== true) {
$this->setState('message', $download->error_message);
return false;
} else {
$package = JInstallerHelper::unpack($destination);
if (!$package) {
$this->setState('message', 'Unable to find install package');
return false;
}
$installer =& JInstaller::getInstance();
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
$result = false;
} else {
// Package installed sucessfully
$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
$result = true;
}
// Grab the application
$mainframe =& JFactory::getApplication();
// Set some model state values
$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'));
// Cleanup the install files
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;
}
}
}
示例12: postflight
function postflight($type, $parent)
{
$url = "http://www.jhackguard.com/downloads/com_jhackguard.zip";
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true);
// Was the package unpacked?
if (!$package || !$package['type']) {
if (in_array($installType, array('upload', 'url'))) {
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
}
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
return false;
}
// Get an installer instance
$installer = new JInstaller();
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = false;
} else {
// Package installed sucessfully
$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = true;
}
// Set some model state values
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
$app->setUserState('com_installer.redirect_url', $installer->get('redirect_url'));
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
$app->enqueueMessage("The default installation of jHackGuard has no filters included. Please download the latest filters by going to the '<b>Filter Maintenance</b>' page in the component menu.", "error");
}
示例13: process
public function process($limitstart = 0)
{
require_once JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php';
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models');
// Path to the pf 4 package
$pkg = JPATH_ADMINISTRATOR . '/components/com_pfmigrator/_install/pkg_projectfork_4.1.0.zip';
$dest = JFactory::getConfig()->get('tmp_path') . '/pkg_projectfork_4.1.0.zip';
// Check if the package exists
if (!file_exists($pkg)) {
$this->success = false;
$this->log[] = JText::_('COM_PFMIGRATOR_PKG_NOT_FOUND');
return false;
}
// Copy package to tmp dir
if (!JFile::copy($pkg, $dest)) {
$this->success = false;
$this->log[] = JText::_('COM_PFMIGRATOR_PKG_COPY_FAILED');
return false;
}
// Unpack the package file
$package = JInstallerHelper::unpack($dest);
if (!$package) {
if (JFile::exists($dest)) {
JFile::delete($dest);
}
$this->success = false;
$this->log[] = JText::_('COM_PFMIGRATOR_PKG_EXTRACT_FAILED');
return false;
}
$installer = JInstaller::getInstance();
// Install the package
if (!$installer->install($package['dir'])) {
if (JFile::exists($dest)) {
JFile::delete($dest);
}
$this->success = false;
$this->log[] = JText::_('COM_PFMIGRATOR_PKG_INSTALL_FAILED') . ' ' . $installer->message . ' ' . $installer->get('extension_message');
return false;
}
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
$this->log[] = JText::_('COM_PFMIGRATOR_PKG_INSTALL_SUCCESS');
return true;
}
示例14: com_install
function com_install()
{
$db =& JFactory::getDBO();
// install the plugin
jimport('joomla.installer.installer');
/*
// Get the path to the package to install
$p_dir = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_sef'.DS.'plugin';
// Detect the package type
$type = JInstallerHelper::detectType($p_dir);
$package = array();
$package['packagefile'] = null;
$package['extractdir'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
*/
// Get the path to the package to install
$p_filename = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sef' . DS . 'plugin' . DS . 'sef_advance.tgz';
// Unpack and verify
$package = JInstallerHelper::unpack($p_filename);
// Get an installer instance
//$installer =& JInstaller::getInstance();
$installer = new JInstaller();
// Install the package
if (!$installer->install($package['dir'])) {
$msg = 'Error installing the plugin<br />Please install the SEF Advance plugin manually.';
} else {
$msg = 'SEF Advance system plugin installed';
$query = "UPDATE #__plugins " . "SET published=1, ordering=-200 " . "WHERE element='sef_advance'";
$db->setQuery($query);
if ($db->query()) {
$msg .= ' and published';
}
}
// Cleanup
JInstallerHelper::cleanupInstall($p_filename, $package['dir']);
echo $msg;
echo '<br />';
$query = "UPDATE #__components " . "SET name = '. SEF Advance .', admin_menu_alt = '. SEF Advance .' " . "WHERE admin_menu_link = 'option=com_sef' AND name = 'SEF Advance'";
$db->setQuery($query);
$db->query();
echo '<a href="index.php?option=com_sef">Proceed to SEF Advance control panel</a><br />';
return true;
}
示例15: _getPackageFromUrl
/**
* Install an extension from a URL
*
* @return Package details or false on failure
*
* @since 1.5
*/
protected function _getPackageFromUrl()
{
$input = JFactory::getApplication()->input;
// Get the URL of the package to install
$url = $input->getString('install_url');
// Did you give us a URL?
if (!$url) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}