// accept command line flag to actually change the database // accept filepath of the import file (xml) // accept semdom version number // accept language code $changeDatabase = false; // process xml into a php data structure, organized by language $xml = simplexml_load_file($xmlFilePath); $lang = $argv[2]; $version = $argv[3]; $projectCode = "semdom-{$lang}-{$semdomVersion}"; $projectName = "Semdom {$lang} Project"; $appName = LfProjectModel::SEMDOMTRANS_APP; $website = new Website($domain, Website::LANGUAGEFORGE); // if a previous project for that language and semantic domain version exists, DO NOT IMPORT $previousProject = new SemDomTransProjectModel(); $previousProject->readByProperties(array("languageIsoCode" => $lang, "semdomVersion" => $semdomVersion)); if ($previousProject->id->asString() == "") { $sourceProject = new SemDomTransProjectModel(); $sourceProject->readByCode("en"); $projectID = ProjectCommands::createProject($projectName, $projectCode, $appName, $userId, $website); $projectModel = new SemDomTransProjectModel($projectID); $newXmlFilePath = $projectModel->getAssetsFolderPath() . '/' . basename($xmlFilePath); FileUtilities::createAllFolders($projectModel->getAssetsFolderPath()); print "copying {$xmlFilePath} to {$newXmlFilePath}\n"; copy($xmlFilePath, $newXmlFilePath); $projectModel->xmlFilePath = $newXmlFilePath; $projectModel->languageIsoCode = $lang; $projectModel->semdomVersion = $semdomVersion; $projectModel->sourceLanguageProjectId = $sourceProject->id->asString(); $projectModel->write(); $importer = new SemDomXMLImporter($xmlFilePath, $projectModel, false, $isEnglish);
<?php require_once '../scriptsConfig.php'; use Api\Library\Languageforge\Semdomtrans; use Api\Library\Languageforge\Semdomtrans\SemDomXMLExporter; use Api\Model\Languageforge\Semdomtrans\SemDomTransProjectModel; $lang = $argv[1]; $version = SemDomTransProjectModel::SEMDOM_VERSION; $testMode = false; $projectModel = new SemDomTransProjectModel(); $projectModel->readByProperties(array("languageIsoCode" => $lang, "semdomVersion" => $version)); $xml = simplexml_load_file($projectModel->xmlFilePath); $exporter = new SemDomXMLExporter($projectModel, $testMode, $argv[2] == "1", $argv[3] == "1"); $exporter->run();