- Don't try a CSV preview on non-csv files

- Skip plugin definition wizards
This commit is contained in:
Nathan Gray 2012-09-18 19:04:31 +00:00
parent c8eb6c5e24
commit 86f334bbf0
2 changed files with 9 additions and 1 deletions

View File

@ -394,7 +394,7 @@ class importexport_helper_functions {
$file = $appdir. '/'. $entry;
foreach ($types as $type) {
if( !is_file($file) || strpos($entry, $type) === false) continue;
if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
require_once($file);
$reflectionClass = new ReflectionClass($classname);
if($reflectionClass->IsInstantiable() &&

View File

@ -249,9 +249,13 @@
/**
* Display the contents of the file for dry runs
*
* CSV files only
*/
protected function preview(&$_stream, &$definition_obj)
{
if(!$definition_obj->plugin_options['csv_fields']) return;
$import_csv = new importexport_import_csv( $_stream, array(
'fieldsep' => $definition_obj->plugin_options['fieldsep'],
'charset' => $definition_obj->plugin_options['charset'],
@ -281,6 +285,10 @@
public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false)
{
$options =& $definition->plugin_options;
// Only CSV files
if(!$options['csv_fields']) return true;
$data = fgetcsv($file, 8000, $options['fieldsep']);
rewind($file);
$data = translation::convert($data,$options['charset']);