コード例 #1
0
ファイル: add.php プロジェクト: nxc/nxc_import
<?php

/**
 * @package nxcImport
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    18 Jun 2013
 **/
$http = eZHTTPTool::instance();
$config = new nxcCSVImportDBConfig(array());
if (($r = $config->proccessHTTPInput($Params['Module'], $http)) !== true) {
    return $r;
}
$errors = array();
if ($http->hasVariable('StoreButton')) {
    $errors = $config->validate();
    if (count($errors) === 0) {
        $config->store();
        $Params['Module']->redirectTo('csv_import/configs');
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('add', true);
$tpl->setVariable('config', $config);
$tpl->setVariable('classes', nxcCSVImportDBConfig::fetchContentClasses());
$tpl->setVariable('class_attributes', $config->attribute('class_attributes'));
$tpl->setVariable('errors', $errors);
$Result = array();
$Result['content'] = $tpl->fetch('design:csv_import/config/edit.tpl');
$Result['left_menu'] = 'design:csv_import/menu.tpl';
$Result['path'] = array(array('text' => ezpI18n::tr('extension/nxc_import', 'CSV Import'), 'url' => 'csv_import/configs'), array('text' => ezpI18n::tr('extension/nxc_import', 'New Configuration'), 'url' => false));
コード例 #2
0
ファイル: databasecsvconfig.php プロジェクト: nxc/nxc_import
 public function setConfig(nxcCSVImportDBConfig $config)
 {
     $this->DBConfig = $config;
     $this->contentClass = $config->attribute('class');
 }
コード例 #3
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));
コード例 #4
0
ファイル: attributes_mapping.php プロジェクト: nxc/nxc_import
<?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();
コード例 #5
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;
    }
}