/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); // get available exporters/importers $this->exporters = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.exporter'); // sort exporters by name uksort($this->exporters, function ($a, $b) { return strcasecmp(WCF::getLanguage()->get('wcf.acp.dataImport.exporter.' . $a), WCF::getLanguage()->get('wcf.acp.dataImport.exporter.' . $b)); }); $this->importers = array_keys(ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.importer')); if (isset($_REQUEST['exporterName'])) { $this->exporterName = $_REQUEST['exporterName']; if (!isset($this->exporters[$this->exporterName])) { throw new IllegalLinkException(); } $this->exporter = $this->exporters[$this->exporterName]->getProcessor(); $this->supportedData = $this->exporter->getSupportedData(); // remove unsupported data foreach ($this->supportedData as $key => $subData) { if (!in_array($key, $this->importers)) { unset($this->supportedData[$key]); continue; } foreach ($subData as $key2 => $value) { if (!in_array($value, $this->importers)) { unset($this->supportedData[$key][$key2]); } } } // get default database prefix if (!isset($_POST['dbPrefix'])) { $this->dbPrefix = $this->exporter->getDefaultDatabasePrefix(); } } }
/** * Reads the selected exporter. */ protected function readExporter() { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.selectExporter')); $exporterSelection = array(); $exporterIndex = 1; foreach ($this->exporters as $objectType) { CLIWCF::getReader()->println($exporterIndex . ') ' . WCF::getLanguage()->get('wcf.acp.dataImport.exporter.' . $objectType->objectType)); $exporterSelection[$exporterIndex++] = $objectType->objectType; } CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array('minSelection' => 1, 'maxSelection' => $exporterIndex - 1))); while (true) { $exporterIndex = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.exporter') . '> '); if ($exporterIndex === null) { exit; } if (isset($exporterSelection[$exporterIndex])) { $this->exporterName = $exporterSelection[$exporterIndex]; break; } CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.selectExporter.error.notValid')); } $this->exporter = $this->exporters[$this->exporterName]->getProcessor(); $this->supportedData = $this->exporter->getSupportedData(); // remove unsupported data foreach ($this->supportedData as $objectType => $subData) { if (!in_array($objectType, $this->importers)) { unset($this->supportedData[$objectType]); continue; } foreach ($subData as $key => $value) { if (!in_array($value, $this->importers)) { unset($this->supportedData[$objectType][$key]); } } } }