/** * Parse */ public function parse() { if (empty($this->Filenames)) { return; } $Importer = new ImporterFactory($this->Filenames); $this->addErrors($Importer->getErrors()); foreach ($Importer->trainingObjects() as $object) { $this->addObject($object); } }
/** * Try to upload file */ private function tryToUploadFile() { $extension = Filesystem::extensionOfFile($_FILES['qqfile']['name']); if (!ImporterFactory::canImportExtension($extension)) { $this->throwUnknownExtension($extension); } elseif ($this->uploadErrorIsPresent()) { $this->throwUploadError(); } elseif ($this->uploadedFileWasTooBig()) { $this->throwTooBigFile(); } elseif ($this->tryToMoveFile()) { $this->setSucceeded(); } else { $this->throwUploadFailed(); } }
/** * Parse file * @param string $Filename relative path (from FRONTEND_PATH) to file */ public function parseFile($Filename) { $Archive = new ZipArchive(); if ($Archive->open(FRONTEND_PATH . $Filename) === true) { $Files = array(); for ($i = 0; $i < $Archive->numFiles; ++$i) { $file = $Archive->getNameIndex($i); $pathinfo = pathinfo($file); if (is_array($pathinfo) && isset($pathinfo['dirname']) && isset($pathinfo['extension']) && $pathinfo['dirname'] == '.' && substr($file, 0, 1) != '.' && ImporterFactory::canImportExtension($pathinfo['extension'])) { $Files[] = $file; } } $Archive->extractTo(FRONTEND_PATH . ImporterUpload::relativePath(''), $Files); $Archive->close(); $this->readFiles($Files); } }
/** * Import form garmin communicator */ private function importFromGarminCommunicator() { $Factory = new ImporterFactory(ImporterFactory::$FROM_COMMUNICATOR); $this->TrainingObjects = $Factory->trainingObjects(); $this->Errors = array_merge($this->Errors, $Factory->getErrors()); }
/** * CRON FOR EMAIL IMPORTER PROCESSOR. * * @return mixed */ public function emailImporter() { return $this->importerFactory->create()->processQueue(); }