/**
  * Constructor.
  *
  * @param EcrProjectBase $project
  *
  * @throws DomainException
  */
 public function __construct(EcrProjectBase $project)
 {
     $this->project = $project;
     $comParams = JComponentHelper::getComponent('com_easycreator')->params;
     $this->localPath = $comParams->get('local_updateserver_dir');
     $this->serverUrl = $comParams->get('updateserver_url');
     $this->serverTitle = $comParams->get('updateserver_title');
     $this->releaseUrl = $comParams->get('updateserver_release_url') ?: $this->serverUrl;
     $this->developmentUrl = $comParams->get('updateserver_development_url') ?: $this->serverUrl;
     //-- Check the base directory
     if (false == JFolder::exists(ECRPATH_UPDATESERVER)) {
         if (false == JFolder::copy(JPATH_COMPONENT_ADMINISTRATOR . '/data/updateserver', ECRPATH_UPDATESERVER)) {
             throw new DomainException(sprintf('%s - Can not create the update server directory: %s', __METHOD__, ECRPATH_UPDATESERVER));
         }
         EcrHtml::message(sprintf(jgettext('The update server directory has been created in: %s'), ECRPATH_UPDATESERVER));
     }
     //-- Check the extension directory
     $base = ECRPATH_UPDATESERVER . '/' . $this->project->comName;
     if (false == JFolder::exists($base)) {
         if (false == JFolder::create($base)) {
             throw new DomainException(sprintf('%s - Can not create the extension update server directory: %s', __METHOD__, $base));
         }
         EcrHtml::message(sprintf(jgettext('The update server extension directory has been created in: %s'), $base));
         JFolder::create($base . '/release');
         JFolder::create($base . '/development');
         JFile::copy(ECRPATH_UPDATESERVER . '/index.html', $base . '/index.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/template_extension.html', $base . '/template.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/updateserver.css', $base . '/updateserver.css');
         JFile::copy(ECRPATH_UPDATESERVER . '/favicon.ico', $base . '/favicon.ico');
         /* @var SimpleXMLElement $xml */
         $xml = EcrProjectHelper::getXML('<updates/>', false);
         $xml->addChild('name', $this->project->name);
         $buffer = $xml->asFormattedXML();
         //-- @todo: The file name "extension.xml" is the J! default - customize.
         JFile::write($base . '/extension.xml', $buffer);
         JFile::write($base . '/development.xml', $buffer);
         $feed = new EcrProjectFeed();
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Release Feed';
         $feed->link = $this->releaseUrl . '/release-feed.xml';
         $feed->id = $feed->link;
         $feed->author = 'XX-Author';
         $feed->updated = date(DATE_ATOM);
         $buffer = $feed->printPretty();
         JFile::write($base . '/release-feed.xml', $buffer);
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Development Feed';
         $feed->link = $this->developmentUrl . '/development-feed.xml';
         $feed->id = $feed->link;
         $buffer = $feed->printPretty();
         JFile::write($base . '/development-feed.xml', $buffer);
         //-- Copy the Joomla! manifest
         JFile::copy($this->project->getJoomlaManifestPath() . '/' . $this->project->getJoomlaManifestName(), $base . '/manifest.xml');
         $this->update();
     }
 }
Exemple #2
0
 /**
  * Installs an extension with the standard Joomla! installer.
  *
  * @throws EcrExceptionBuilder
  * @return EcrProjectBuilder
  */
 private function install()
 {
     if ($this->testMode) {
         //-- Exiting in test mode
         $this->logger->log('TEST MODE - not installing');
         return $this;
     }
     if ('cliapp' == $this->project->type || 'webapp' == $this->project->type) {
         $src = $this->buildDir . '/site';
         $dest = $this->project->getExtensionPath();
         if (false == JFolder::copy($src, $dest)) {
             throw new EcrExceptionBuilder(sprintf('Failed to copy the JApplication from %s to %s', $src, $dest));
         }
         $this->logger->log(sprintf('JApplication files copied from %s to %s', $src, $dest));
         $src = $this->buildDir . DS . $this->project->getJoomlaManifestName();
         $dest = $this->project->getJoomlaManifestPath() . DS . $this->project->getJoomlaManifestName();
         if (false == JFile::copy($src, $dest)) {
             throw new EcrExceptionBuilder(sprintf('Failed to copy package manifest xml from %s to %s', $src, $dest));
         }
         return $this;
     }
     if ('package' == $this->project->type) {
         //-- J! 1.6 package - only copy the manifest xml
         $src = $this->buildDir . DS . $this->project->getJoomlaManifestName();
         $dest = $this->project->getJoomlaManifestPath() . DS . $this->project->getJoomlaManifestName();
         if (false == JFile::copy($src, $dest)) {
             throw new EcrExceptionBuilder(sprintf('Failed to copy package manifest xml from %s to %s', $src, $dest));
         }
         $this->logger->log(sprintf('Package manifest xml has been copied from %s to %s', $src, $dest));
         return $this;
     }
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     $this->logger->log('Starting Install');
     //-- Did you give us a valid package ?
     $type = JInstallerHelper::detectType($this->buildDir);
     if (false == $type) {
         throw new EcrExceptionBuilder(jgettext('Path does not have a valid package'));
     }
     //-- Get an installer instance
     $installer = JInstaller::getInstance();
     //-- Install the package
     $result = $installer->install($this->buildDir);
     $this->logger->log('Installer Message: ' . $installer->message);
     $this->logger->log('Extension Message: ' . $installer->get('extension.message'));
     //-- Clean up the install directory. If we are not debugging.
     ECR_DEBUG ? null : JInstallerHelper::cleanupInstall('', $this->buildDir);
     //-- There was an error installing the package
     if (false == $result) {
         throw new EcrExceptionBuilder(sprintf(jgettext('An error happened while installing your %s'), jgettext($type)));
     }
     return $this;
 }
Exemple #3
0
 /**
  * Findes the Joomla! install xml file for a given extension.
  *
  * @param EcrProjectBase $project The project
  *
  * @return mixed [boolean false on error | string path on success]
  */
 public static function findManifest(EcrProjectBase $project)
 {
     $path = $project->getJoomlaManifestPath();
     if (!JFolder::exists($path)) {
         return false;
     }
     //-- @Joomla!-version-check
     switch (ECR_JVERSION) {
         case '2.5':
         case '3.0':
         case '3.1':
         case '3.2':
         case '3.3':
         case '3.4':
             if ('library' == $project->type || 'package' == $project->type) {
                 $xmlFiles = array($path . DS . $project->getJoomlaManifestName());
             }
             break;
         default:
             EcrHtml::message(__METHOD__ . ' - Unknown JVersion', 'error');
             return false;
             break;
     }
     if (empty($xmlFiles)) {
         $xmlFiles = JFolder::files($path, '.xml$', false, true);
     }
     if (empty($xmlFiles)) {
         return false;
     }
     //-- If at least one xml file exists
     foreach ($xmlFiles as $fileName) {
         if (!JFile::exists($fileName)) {
             /*
              JXXError::raiseWarning(100, 'File not found '.$fileName);
             EcrHtml::displayMessage('Unable to load XML file '.$fileName, 'error');
             */
             return false;
         }
         $xml = self::getXML($fileName);
         //-- Invalid XML file
         if (!$xml) {
             return false;
         }
         if ($xml->getName() == 'extension') {
             //-- Valid xml manifest found
             return str_replace(JPATH_ROOT . DS, '', JPath::clean($fileName));
         }
     }
     //foreach
     //-- None of the xml files found were valid install files
     EcrHtml::message(sprintf(jgettext('Manifest not found for type: %s - name: %s'), $project->type, $fileName), 'error');
     return false;
 }