예제 #1
0
 function createPackage(&$package, $http, &$persistentData, &$cleanupFiles, $storePackage = true)
 {
     $createdPackage = false;
     if (!$package instanceof eZPackage) {
         $package = eZPackage::create($persistentData['name'], array('summary' => $persistentData['summary']));
         $createdPackage = true;
     } else {
         $package->setAttribute('summary', $persistentData['summary']);
     }
     $package->setAttribute('is_active', false);
     $package->setAttribute('type', $this->packageType($package, $persistentData));
     $package->setRelease($persistentData['version'], '1', false, $persistentData['licence'], $this->packageInitialState($package, $persistentData));
     $package->setAttribute('description', $persistentData['description']);
     $package->setAttribute('install_type', $this->packageInstallType($package, $persistentData));
     $package->setAttribute('packaging-host', $persistentData['host']);
     $package->setAttribute('packaging-packager', $persistentData['packager']);
     $changelogPerson = $persistentData['changelog_person'];
     $changelogEmail = $persistentData['changelog_email'];
     $changelogEntries = $persistentData['changelog_entries'];
     $maintainerPerson = $persistentData['maintainer_person'];
     $maintainerEmail = $persistentData['maintainer_email'];
     $maintainerRole = $persistentData['maintainer_role'];
     if ($maintainerPerson) {
         $package->appendMaintainer($maintainerPerson, $maintainerEmail, $maintainerRole);
     }
     if ($changelogPerson) {
         $package->appendChange($changelogPerson, $changelogEmail, $changelogEntries);
     }
     if ($persistentData['licence'] == 'GPL') {
         eZPackageCreationHandler::appendLicence($package);
     }
     $collections = array();
     $cleanupFiles = array();
     if (isset($persistentData['thumbnail']) and $persistentData['thumbnail']) {
         $thumbnail = $persistentData['thumbnail'];
         $fileItem = array('file' => $thumbnail['filename'], 'type' => 'thumbnail', 'role' => false, 'design' => false, 'path' => $thumbnail['url'], 'collection' => 'default', 'file-type' => false, 'role-value' => false, 'variable-name' => 'thumbnail');
         $package->appendFile($fileItem['file'], $fileItem['type'], $fileItem['role'], $fileItem['design'], $fileItem['path'], $fileItem['collection'], null, null, true, null, $fileItem['file-type'], $fileItem['role-value'], $fileItem['variable-name']);
         $cleanupFiles[] = $fileItem['path'];
         if (!in_array($fileItem['collection'], $collections)) {
             $collections[] = $fileItem['collection'];
         }
     }
     foreach ($collections as $collection) {
         $installItems = $package->installItemsList('ezfile', false, $collection, true);
         if (count($installItems) == 0) {
             $package->appendInstall('ezfile', false, false, true, false, false, array('collection' => $collection));
         }
         $dependencyItems = $package->dependencyItems('provides', array('type' => 'ezfile', 'name' => 'collection', 'valiue' => $collection));
         if (count($dependencyItems) == 0) {
             $package->appendDependency('provides', array('type' => 'ezfile', 'name' => 'collection', 'value' => $collection));
         }
         $installItems = $package->installItemsList('ezfile', false, $collection, false);
         if (count($installItems) == 0) {
             $package->appendInstall('ezfile', false, false, false, false, false, array('collection' => $collection));
         }
     }
     $package->setAttribute('is_active', true);
     if ($storePackage) {
         $package->store();
     }
     return $createdPackage;
 }
예제 #2
0
                 $package->exportToArchive($exportDirectory . eZSys::fileSeparator() . $package->exportName());
                 $cli->output("Package " . $cli->stylize('symbol', $package->attribute('name')) . " exported to directory " . $cli->stylize('dir', $exportDirectory));
             }
         } else {
             $exportPath = $package->exportToArchive($package->exportName());
             $cli->output("Package " . $cli->stylize('symbol', $package->attribute('name')) . " exported to file " . $cli->stylize('file', $exportPath));
         }
     } else {
         $cli->error("Could not locate package " . $cli->stylize('emphasize', $commandItem['name']));
     }
 } else {
     if ($command == 'create') {
         if ($alreadyCreated) {
             $cli->output();
         }
         $package = eZPackage::create($commandItem['name'], array('summary' => $commandItem['summary']), false, $repositoryID);
         $user = eZUser::currentUser();
         $userObject = $user->attribute('contentobject');
         $commandItem['licence'] = 'GPL';
         if (!in_array($commandItem['installtype'], array('install', 'import'))) {
             $commandItem['installtype'] = 'install';
         }
         if (!$commandItem['version']) {
             $commandItem['version'] = '1.0';
         }
         $package->setRelease($commandItem['version'], '1', false, $commandItem['licence'], 'alpha');
         $package->setAttribute('install_type', $commandItem['installtype']);
         if ($userObject) {
             $package->appendMaintainer($userObject->attribute('name'), $user->attribute('email'), 'lead');
         }
         eZPackageCreationHandler::appendLicence($package);