$step = $this->executePIP($nodeData);
break;
+ case 'optionalPackages':
+ $step = $this->selectOptionalPackages($nodeData);
+ break;
+
default:
die("Unknown node type: '".$data['nodeType']."'");
break;
return $installationStep;
}
+ protected function selectOptionalPackages(array $nodeData) {
+ $installationStep = new PackageInstallationStep();
+
+ $document = $this->promptOptionalPackages($nodeData);
+ if ($document !== null && $document instanceof form\FormDocument) {
+ $installationStep->setDocument($document);
+ }
+
+ $installationStep->setSplitNode();
+
+ return $installationStep;
+ }
+
/**
* Extracts files from .tar (or .tar.gz) archive and installs them
*
}
}
+ protected function promptOptionalPackages(array $packages) {
+ if (!PackageInstallationFormManager::findForm($this->queue, 'optionalPackages')) {
+ $container = new container\MultipleSelectionFormElementContainer();
+
+ foreach ($packages as $package) {
+ $optionalPackage = new element\MultipleSelectionFormElement($container);
+ $optionalPackage->setLabel($package['packageName']);
+ $optionalPackage->setValue($package['package']);
+
+ $container->appendChild($optionalPackage);
+ }
+
+ $document = new form\FormDocument('optionalPackages');
+ $document->appendContainer($container);
+
+ PackageInstallationFormManager::registerForm($this->queue, $document);
+ return $document;
+ }
+ else {
+ $document = PackageInstallationFormManager::getForm($this->queue, 'optionalPackages');
+ $document->handleRequest();
+
+ $packages = $document->getValue('optionalPackages');
+ die('<pre>'.print_r($packages, true));
+ }
+ }
+
/**
* Returns current package id.
*
* not really matter at this point).
*/
protected function buildOptionalNodes() {
- $packageNodes = array();
+ $packages = array();
$optionalPackages = $this->installation->getArchive()->getOptionals();
foreach ($optionalPackages as $package) {
- $packageNodes[] = array(
- 'data' => $package
- );
+ // extract package
+ $index = $this->installation->getArchive()->getTar()->getIndexByFilename($package['file']);
+ if ($index === false) {
+ throw new SystemException("Unable to find required package '".$package['file']."' within archive.");
+ }
+
+ $fileName = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($package['file'])));
+ $this->installation->getArchive()->getTar()->extract($index, $fileName);
+
+ // get archive data
+ $archive = new PackageArchive($fileName);
+ $archive->openArchive();
- $lastNode = $newNode;
+ $packages[] = array(
+ 'archive' => $fileName,
+ 'package' => $archive->getPackageInfo('name'),
+ 'packageName' => $archive->getPackageInfo('packageName'),
+ 'selected' => 0
+ );
}
- if (!empty($packageNodes)) {
+ if (!empty($packages)) {
$this->parentNode = $this->node;
$this->node = $this->getToken();
- $this->sequenceNo = -1;
+ $this->sequenceNo = 0;
$sql = "INSERT INTO wcf".WCF_N."_package_installation_node
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- foreach ($packageNodes as $nodeData) {
- $this->sequenceNo = 0;
-
- $statement->execute(array(
- $this->installation->queue->queueID,
- $this->installation->queue->processNo,
- $this->sequenceNo,
- $this->node,
- $this->parentNode,
- 'optionalPackage',
- serialize($nodeData['data'])
- ));
- }
+ $statement->execute(array(
+ $this->installation->queue->queueID,
+ $this->installation->queue->processNo,
+ $this->sequenceNo,
+ $this->node,
+ $this->parentNode,
+ 'optionalPackages',
+ serialize($packages)
+ ));
}
}