protected function _enableWebInstaller(InputInterface $input, OutputInterface $output) { if (Util::isPlatform($this->target_dir)) { return; } $version = Util::getJoomlaVersion($this->target_dir); if (version_compare($version, '3.2.0', '<')) { return; } $xml = simplexml_load_file('http://appscdn.joomla.org/webapps/jedapps/webinstaller.xml'); if (!$xml) { $output->writeln('<warning>Failed to install web installer</warning>'); return; } $url = ''; foreach ($xml->update->downloads->children() as $download) { $attributes = $download->attributes(); if ($attributes->type == 'full' && $attributes->format == 'zip') { $url = (string) $download; break; } } if (empty($url)) { return; } $filename = self::$files . '/cache/' . basename($url); if (!file_exists($filename)) { $bytes = file_put_contents($filename, fopen($url, 'r')); if ($bytes === false || $bytes == 0) { return; } } `mkdir -p {$this->target_dir}/plugins/installer`; `cd {$this->target_dir}/plugins/installer/ && unzip -o {$filename}`; $sql = "INSERT INTO `j_extensions` (`name`, `type`, `element`, `folder`, `enabled`, `access`, `manifest_cache`) VALUES ('plg_installer_webinstaller', 'plugin', 'webinstaller', 'installer', 1, 1, '{\"name\":\"plg_installer_webinstaller\",\"type\":\"plugin\",\"version\":\"" . $xml->update->version . "\",\"description\":\"Web Installer\"}');"; $sql = escapeshellarg($sql); $password = empty($this->mysql->password) ? '' : sprintf("-p'%s'", $this->mysql->password); exec(sprintf("mysql --host=%s -u'%s' %s %s -e %s", $this->mysql->host, $this->mysql->user, $password, $this->target_db, $sql)); }
protected function _getSQLFiles(InputInterface $input, OutputInterface $output) { $dumps = $input->getOption('sql-dumps'); if (count($dumps) > 0) { foreach ($dumps as $dump) { if (!file_exists($dump)) { throw new \RuntimeException(sprintf('Can not find SQL dump file %s', $dump)); } } return $dumps; } $version = Util::getJoomlaVersion($this->target_dir); $imports = $this->_getInstallFiles($input->getOption('sample-data')); if ($version !== false) { $users = 'joomla3.users.sql'; if (is_numeric(substr($version, 0, 1)) && version_compare($version, '3.0.0', '<')) { $users = 'joomla2.users.sql'; } $imports[] = self::$files . '/' . $users; } foreach ($imports as $import) { if (!file_exists($import)) { throw new \RuntimeException(sprintf('Can not find SQL dump file %s', $import)); } } return $imports; }