Example #1
0
 /**
  * Tries to find the package manifest file
  *
  * @return  boolean  True on success, False on error
  */
 public function findManifest()
 {
     jimport('joomla.filesystem.folder');
     // Get an array of all the XML files from the installation directory
     $xmlfiles = JFolder::files($this->installer->getPath('source'), '.xml$', 1, true);
     // If at least one XML file exists
     if (!empty($xmlfiles)) {
         foreach ($xmlfiles as $file) {
             // Is it a valid Joomla installation manifest file?
             $manifest = $this->isManifest($file);
             if (!is_null($manifest)) {
                 // If the root method attribute is set to upgrade, allow file overwrite
                 if ((string) $manifest->attributes()->method == 'upgrade') {
                     if (method_exists($this->installer, 'setUpgrade')) {
                         $this->installer->setUpgrade(true);
                     }
                     $this->installer->setOverwrite(true);
                 }
                 // If the overwrite option is set, allow file overwriting
                 if ((string) $manifest->attributes()->overwrite == 'true') {
                     $this->installer->setOverwrite(true);
                 }
                 // Set the manifest object and path
                 $this->installer->manifest = $manifest;
                 $this->installer->setPath('manifest', $file);
                 // Set the installation source path to that of the manifest file
                 $this->installer->setPath('source', dirname($file));
                 return true;
             }
         }
         // None of the XML files found were valid install files
         JError::addWarning(JText::_('JLIB_INSTALLER_ERROR_NOTFINDJOOMLAXMLSETUPFILE'));
         return false;
     } else {
         // No XML files were found in the install folder
         JError::addWarning(JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'));
         return false;
     }
 }