break; case 'import_manufacturers_images': $objectType = 'manufacturers_image'; $objectFolderName = 'manufacturers'; $objectFolders = $this->ms['image_paths']['manufacturers']; break; } $query = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_orphan_files', 'type=\'' . addslashes($objectType) . '\''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $content .= '<strong>Adding files for queue: ' . $objectFolderName . '</strong><br />'; $filesToInsert = array(); $tel = 0; foreach ($objectFolders as $key => $path) { $content .= 'Scanning: ' . $key . ' folder.<br/>'; $GLOBALS['TYPO3_DB']->connectDB(); $files = mslib_befe::listdir($this->DOCUMENT_ROOT . $path); $GLOBALS['TYPO3_DB']->connectDB(); sort($files, SORT_LOCALE_STRING); // we go to reconnect to the DB, because sometimes when scripts takes too long, the database connection is lost. $GLOBALS['TYPO3_DB']->connectDB(); foreach ($files as $f) { $path_parts = pathinfo($f); $path = str_replace('/images/' . $objectFolderName . '/' . $key . '/', '/images/' . $objectFolderName . '/original/', $path_parts['dirname']); if (!$filesToInsert[$path . '/' . $path_parts['basename']]) { $filesToInsert[$path . '/' . $path_parts['basename']] = 1; $insertArray = array('type' => $objectType, 'orphan' => 0, 'path' => $path, 'file' => $path_parts['basename'], 'crdate' => time()); $str2 = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_orphan_files', $insertArray); $res2 = $GLOBALS['TYPO3_DB']->sql_query($str2); $tel++; } }
$content .= $filename . '<br />'; foreach ($this->ms['image_paths']['products'] as $item) { $source = $this->DOCUMENT_ROOT . $item . '/' . $filename; $target = $this->DOCUMENT_ROOT . $item . '/' . $folder . '/' . $filename; if (!is_dir($this->DOCUMENT_ROOT . $item . '/' . $folder)) { \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $item . '/' . $folder); } exec("mv " . $source . ' ' . $target); $updated = 1; } } } } } // next the categories $files = mslib_befe::listdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['categories']['original']); sort($files, SORT_LOCALE_STRING); $tel = 0; $GLOBALS['TYPO3_DB']->connectDB(); if (count($files) > 0) { foreach ($files as $f) { $path_parts = pathinfo($f); $filename = $path_parts['basename']; if ($filename) { // first check if its already subdirectory based $folder = mslib_befe::getImagePrefixFolder($filename); if (!file_exists($this->DOCUMENT_ROOT . $this->ms['image_paths']['categories']['original'] . '/' . $folder . '/' . $filename)) { // we have to move this baby $content .= $filename . '<br />'; foreach ($this->ms['image_paths']['categories'] as $item) { $source = $this->DOCUMENT_ROOT . $item . '/' . $filename;