本文整理汇总了PHP中Includes\Utils\FileManager::isCSV方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::isCSV方法的具体用法?PHP FileManager::isCSV怎么用?PHP FileManager::isCSV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Includes\Utils\FileManager
的用法示例。
在下文中一共展示了FileManager::isCSV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doActionImport
/**
* Import action
*
* @return void
*/
protected function doActionImport()
{
foreach (\XLite\Logic\Import\Importer::getImportOptionsList() as $key) {
\XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'Import', 'name' => $key, 'value' => isset(\XLite\Core\Request::getInstance()->options[$key]) ? \XLite\Core\Request::getInstance()->options[$key] : false));
}
\XLite\Core\Config::updateInstance();
$dirTo = LC_DIR_VAR . \XLite\Logic\Import\Importer::getImportDir();
if (!\Includes\Utils\FileManager::isExists($dirTo)) {
\Includes\Utils\FileManager::mkdirRecursive($dirTo);
}
$filesToImport = array();
if ($_FILES && isset($_FILES['files']) && $_FILES['files']['name'] && $_FILES['files']['name'][0] && \Includes\Utils\FileManager::isDirWriteable($dirTo)) {
$list = glob($dirTo . LC_DS . '*');
if ($list) {
foreach ($list as $path) {
if (is_file($path) && \Includes\Utils\FileManager::isCSV($path)) {
\Includes\Utils\FileManager::deleteFile($path);
}
}
}
$files = $_FILES['files'];
foreach ($files['name'] as $key => $name) {
$path = null;
if ($name && UPLOAD_ERR_OK === $files['error'][$key]) {
$path = \Includes\Utils\FileManager::getUniquePath($dirTo, $name ?: $files['name'][$key]);
if (move_uploaded_file($files['tmp_name'][$key], $path)) {
if (\XLite\Core\Archive::getInstance()->isArchive($path) || 'csv' == substr(strrchr($path, '.'), 1)) {
$filesToImport[] = $path;
} else {
\XLite\Core\TopMessage::addError('The "{{file}}" is not CSV or archive', array('file' => $name));
\Includes\Utils\FileManager::deleteFile($path);
}
} else {
$path = null;
}
}
if (!$path) {
\XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $name));
}
}
}
if ($filesToImport) {
\XLite\Logic\Import\Importer::run(\XLite\Logic\Import\Importer::assembleImportOptions() + array('files' => $filesToImport));
}
}