本文整理汇总了PHP中JInstaller::setupInstall方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::setupInstall方法的具体用法?PHP JInstaller::setupInstall怎么用?PHP JInstaller::setupInstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::setupInstall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getManifestObject
function getManifestObject($path)
{
$installer = new JInstaller();
$installer->setPath('source', $path);
if (!$installer->setupInstall()) {
return null;
}
$manifest =& $installer->getManifest();
return $manifest;
}
示例2: installExtension
/**
* Uses the joomla installer framework to install an extension from a package file
*
* @param $file String the filename of the file to be installed
* @return the extension information if the install is successfull, false otherwise
*/
function installExtension($entry, $entryType = 'archive', $name = null)
{
switch (strtolower($entryType)) {
case "Folder":
case "folder":
// create a package array based on contents of folder
$package = $this->createVirtualPackage($entry);
break;
default:
//Build the appropriate paths
$config = JFactory::getConfig();
$packageFile = $this->_extensionsPath . DS . $entry;
//Unpack the package file
$package = JInstallerHelper::unpack($packageFile);
break;
}
//Get an installer instance, always get a new one
$installer = new JInstaller();
//setup for the install
if ($package['dir'] && JFolder::exists($package['dir'])) {
$installer->setPath('source', $package['dir']);
} else {
$this->setError("DSCInstaller::installExtension: " . JText::_("Package dir does not exist"));
return false;
}
//this makes sure the manifest file is loaded into the installer object
if (!$installer->setupInstall()) {
$this->setError("DSCInstaller::installExtension: " . JText::_("Could not load manifest file"));
return false;
}
//grab the manifest information
$manifestInformation = $this->getManifestInformation($installer, $name);
$savedParameters = new stdClass();
//set the installer to overwrite just encase any files were left on the server
$installer->setOverwrite(true);
//now that the extension was uninstalled if nessecary we can install it
if (!$installer->install($package['dir'])) {
//something blew up with the install if we get here
$this->setError("DSCInstaller::installExtension: " . $installer->getError());
$result = false;
} else {
// Package installed sucessfully so publish the extension if set to yes
$manifestInformation = $this->getManifestInformation($installer, $name);
$publishExtension = $this->get('_publishExtension', false);
if ($publishExtension) {
$this->publishExtension($manifestInformation);
}
//restore extension parameters if requested
if ($this->_saveParameters && isset($savedParameters->params)) {
$this->restoreParameters($manifestInformation, $savedParameters);
}
$result = true;
}
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
}
//decide whether or not to delete the local copy
if (!$this->_keepLocalCopy) {
//delete temporary directory and install file
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
} else {
//just delete the temporary directory
JInstallerHelper::cleanupInstall("", $package['extractdir']);
}
//check to see if the install was successfull and if so return the manifestinformation
if ($result) {
return $manifestInformation;
} else {
// error message is already set
return false;
}
}
示例3: installExtension
/**
* Uses the joomla installer framework to install an extension from a package file
*
* @param $file String the filename of the file to be installed
* @return the extension information if the install is successfull, false otherwise
*/
function installExtension($entry, $entryType = 'archive')
{
switch (strtolower($entryType)) {
case "Folder":
case "folder":
// create a package array based on contents of folder
$package = $this->createVirtualPackage($entry);
break;
default:
//Build the appropriate paths
$config = JFactory::getConfig();
$packageFile = $this->_extensionsPath . DS . $entry;
//Unpack the package file
$package = JInstallerHelper::unpack($packageFile);
break;
}
//Get an installer instance, always get a new one
$installer = new JInstaller();
//setup for the install
if ($package['dir'] && JFolder::exists($package['dir'])) {
$installer->setPath('source', $package['dir']);
} else {
$this->setError("dscInstaller::installExtension: " . JText::_('COM_TIENDA_PACKAGE_DIR_DOES_NOT_EXIST'));
return false;
}
//this makes sure the manifest file is loaded into the installer object
if (!$installer->setupInstall()) {
$this->setError("dscInstaller::installExtension: " . JText::_('COM_TIENDA_COULD_NOT_LOAD_MANIFEST_FILE'));
return false;
}
//grab the manifest information
$manifestInformation = $this->getManifestInformation($installer);
$savedParameters = new stdClass();
//check if the extension is installed already and if so uninstall it
$elementID = $this->checkIfInstalledAlready($manifestInformation);
// This is not necessary if everything has method=upgrade
// if ($elementID != 0) {
// //save the extensions parameters if requested
// $savedParameters = $this->saveParameters($manifestInformation);
//
// //prevent any custom uninstall scripts if requested for components
// if (($this->_preventUninstallScript) && ($manifestInformation["type"] == "component")) {
// $this->preventCustomUninstall($installer);
// }
// //uninstall the extension using the joomla uninstaller
// $installer->uninstall($manifestInformation["type"], $elementID);
// }
//set the installer to overwrite just encase any files were left on the server
$installer->setOverwrite(true);
//now that the extension was uninstalled if nessecary we can install it
if (!$installer->install($package['dir'])) {
//something blew up with the install if we get here
$this->setError("dscInstaller::installExtension: " . $installer->getError());
$result = false;
} else {
// Package installed sucessfully so publish the extension if set to yes
$manifestInformation = $this->getManifestInformation($installer);
$publishExtension = $this->get('_publishExtension', false);
if ($publishExtension) {
$this->publishExtension($manifestInformation);
}
//restore extension parameters if requested
if ($this->_saveParameters && isset($savedParameters->params)) {
$this->restoreParameters($manifestInformation, $savedParameters);
}
$result = true;
}
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
}
//decide whether or not to delete the local copy
if (!$this->_keepLocalCopy) {
//delete temporary directory and install file
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
} else {
//just delete the temporary directory
JInstallerHelper::cleanupInstall("", $package['extractdir']);
}
//check to see if the install was successfull and if so return the manifestinformation
if ($result) {
return $manifestInformation;
} else {
// error message is already set
return false;
}
}