示例#1
0
文件: list.php 项目: nxc/nxc_import
<?php

/**
 * @package nxcImport
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    18 Jun 2013
 **/
$http = eZHTTPTool::instance();
if ($http->hasVariable('NewButton')) {
    return $Params['Module']->redirectTo('csv_import/add_config');
}
if ($http->hasVariable('RemoveButton')) {
    $IDs = (array) $http->variable('ConfigIDs');
    foreach ($IDs as $id) {
        if (($config = nxcCSVImportDBConfig::fetch($id)) instanceof nxcCSVImportDBConfig) {
            $config->remove();
        }
    }
}
$configs = nxcCSVImportDBConfig::fetchList();
$tpl = eZTemplate::factory();
$tpl->setVariable('configs', $configs);
$Result = array();
$Result['content'] = $tpl->fetch('design:csv_import/config/list.tpl');
$Result['left_menu'] = 'design:csv_import/menu.tpl';
$Result['path'] = array(array('text' => ezpI18n::tr('extension/nxc_import', 'CSV Import'), 'url' => false));
示例#2
0
<?php

/**
 * @package nxcImport
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    18 Jun 2013
 **/
$class = eZContentClass::fetch((int) $Params['ClassID']);
$classAttributes = $class instanceof eZContentClass ? $class->attribute('data_map') : array();
$config = nxcCSVImportDBConfig::fetch((int) $Params['ConfigID']);
$tpl = eZTemplate::factory();
$tpl->setVariable('class_attributes', $classAttributes);
$tpl->setVariable('config', $config);
echo $tpl->fetch('design:csv_import/config/attributes_mapping.tpl');
eZExecution::cleanExit();
示例#3
0
文件: import.php 项目: nxc/nxc_import
<?php

/**
 * @package nxcImport
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    18 Jun 2013
 **/
$http = eZHTTPTool::instance();
$configs = nxcCSVImportDBConfig::fetchList();
$config = null;
$errors = array();
$counter = array();
if ($http->hasVariable('ImportButton')) {
    $config = nxcCSVImportDBConfig::fetch((int) $http->variable('config_id'));
    if ($config instanceof nxcCSVImportDBConfig === false) {
        $errors[] = ezpI18n::tr('extension/nxc_import', 'Please select Import Configuration');
    }
    $allowedMimeTypes = array('text/csv', 'text/plain', 'application/csv', 'text/comma-separated-values', 'application/excel', 'application/vnd.ms-excel', 'application/vnd.msexcel', 'text/anytext', 'application/octet-stream', 'application/txt');
    $file = $_FILES['file'];
    if (empty($file['name']) || in_array($file['type'], $allowedMimeTypes) === false) {
        $errors[] = ezpI18n::tr('extension/nxc_import', 'Please upload valid CSV file');
    }
    if (count($errors) === 0) {
        $importConfig = new nxcImportDatabaseCSVConfig();
        $importConfig->setConfig($config);
        $importConfig->setSource($file['tmp_name']);
        $controller = new nxcImportController($importConfig, false, false);
        $controller->run(false, false, true, true);
        $counter = $controller->counter;
    }
}