1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<?php
/**
*/
/* initialissation des variables */
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$tpl = eZTemplate::factory();
/* si l'admin clique sur importer fichier */
if($http->hasPostVariable('Upload')){
$csvFile = 'var/impact/exemple.csv';
$options = new SQLICSVOptions( array(
'csv_path' => $csvFile,
'enclosure' => '~'
) );
$csvDoc = new SQLICSVDoc( $options );
$csvDoc->parse();
foreach( $csvDoc->rows as $row ) // Iteration
{
$remode_id = (string)$row->titre;
$contentOptions = new SQLIContentOptions( array(
'class_identifier' => 'machin',
'remote_id' => hash('sha1',$remode_id)
) );
$content = SQLIContent::create( $contentOptions );
$content->fields->titre = (string)$row->titre;
$content->fields->description = (string)$row->description;
$content->addLocation(SQLILocation::fromNodeID(2));
$publisher = SQLIContentPublisher::getInstance();
$publisher->publish($content);
}
}
$Result = array();
$Result['content'] = $tpl->fetch("design:sqliimport/import.tpl");
$Result['path'] = array(array( 'url' => false,
'text' => 'Import sites'));
?> |
Partager