Esempio n. 1
0
 function getManifestObject($path)
 {
     $installer = new JInstaller();
     $installer->setPath('source', $path);
     if (!$installer->setupInstall()) {
         return null;
     }
     $manifest =& $installer->getManifest();
     return $manifest;
 }
Esempio n. 2
0
 /**
  * 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;
     }
 }
Esempio n. 3
0
 /**
  * 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;
     }
 }