| 1 |
<?php |
| 2 |
|
| 3 |
class Red_FileIO |
| 4 |
{ |
| 5 |
var $items = array (); |
| 6 |
|
| 7 |
function export ($type) |
| 8 |
{ |
| 9 |
include (dirname (__FILE__).'/../models/pager.php'); |
| 10 |
|
| 11 |
$module = Red_Module::get (intval ($_GET['module'])); |
| 12 |
if ($module) |
| 13 |
{ |
| 14 |
include (dirname (__FILE__)."/../fileio/$type.php"); |
| 15 |
|
| 16 |
if ($type == 'rss') |
| 17 |
$exporter = new Red_Rss_File (); |
| 18 |
else if ($type == 'xml') |
| 19 |
$exporter = new Red_Xml_File (); |
| 20 |
else if ($type == 'csv') |
| 21 |
$exporter = new Red_Csv_File (); |
| 22 |
else if ($type == 'apache') |
| 23 |
$exporter = new Red_Apache_File (); |
| 24 |
|
| 25 |
$exporter->collect ($module); |
| 26 |
$exporter->feed (); |
| 27 |
return true; |
| 28 |
} |
| 29 |
|
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
function import( $group, $file ) { |
| 34 |
if ( is_uploaded_file( $file['tmp_name'] ) ) { |
| 35 |
$parts = pathinfo( $file['name'] ); |
| 36 |
|
| 37 |
if ( $parts['extension'] == 'xml') { |
| 38 |
include dirname( __FILE__ ).'/../fileio/xml.php'; |
| 39 |
$importer = new Red_Xml_File(); |
| 40 |
$data = @file_get_contents ($file['tmp_name']); |
| 41 |
} |
| 42 |
elseif ( $parts['extension'] == 'csv' ) { |
| 43 |
include dirname( __FILE__ ).'/../fileio/csv.php'; |
| 44 |
$importer = new Red_Csv_File(); |
| 45 |
$data = ''; |
| 46 |
} |
| 47 |
else { |
| 48 |
include dirname( __FILE__ ).'/../fileio/apache.php'; |
| 49 |
$importer = new Red_Apache_File(); |
| 50 |
$data = @file_get_contents ($file['tmp_name']); |
| 51 |
} |
| 52 |
|
| 53 |
return $importer->load( $group, $data, $file['tmp_name'] ); |
| 54 |
} |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |
| 58 |
|
| 59 |
function load ($group, $data) { } |
| 60 |
} |
| 61 |
|
| 62 |
?> |