Mage_Dataflow_Model_Convert_Adapter_Http Class Reference

Inheritance diagram for Mage_Dataflow_Model_Convert_Adapter_Http:

Mage_Dataflow_Model_Convert_Adapter_Abstract Mage_Dataflow_Model_Convert_Container_Abstract Mage_Dataflow_Model_Convert_Adapter_Interface Mage_Dataflow_Model_Convert_Container_Interface

List of all members.

Public Member Functions

 load ()
 save ()
 loadFile ()


Detailed Description

Definition at line 35 of file Http.php.


Member Function Documentation

load (  ) 

Implements Mage_Dataflow_Model_Convert_Adapter_Interface.

Definition at line 38 of file Http.php.

00039     {
00040         if (!$_FILES) {
00041 ?>
00042 <form method="POST" enctype="multipart/form-data">
00043 File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
00044 </form>
00045 <?php
00046             exit;
00047         }
00048         if (!empty($_FILES['io_file']['tmp_name'])) {
00049             $this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
00050         }
00051         return $this;
00052     }

loadFile (  ) 

Definition at line 66 of file Http.php.

00067     {
00068         if (!$_FILES) {
00069 ?>
00070 <form method="POST" enctype="multipart/form-data">
00071 File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
00072 </form>
00073 <?php
00074             exit;
00075         }
00076         if (!empty($_FILES['io_file']['tmp_name'])) {
00077             //$this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
00078             $uploader = new Varien_File_Uploader('io_file');
00079             $uploader->setAllowedExtensions(array('csv','xml'));
00080             $path = Mage::app()->getConfig()->getTempVarDir().'/import/';
00081             $uploader->save($path);
00082             if ($uploadFile = $uploader->getUploadedFileName()) {
00083                 $session = Mage::getModel('dataflow/session');
00084                 $session->setCreatedDate(date('Y-m-d H:i:s'));
00085                 $session->setDirection('import');
00086                 $session->setUserId(Mage::getSingleton('admin/session')->getUser()->getId());
00087                 $session->save();
00088                 $sessionId = $session->getId();
00089                 $newFilename = 'import_'.$sessionId.'_'.$uploadFile;
00090                 rename($path.$uploadFile, $path.$newFilename);
00091                 $session->setFile($newFilename);
00092                 $session->save();
00093                 $this->setData(file_get_contents($path.$newFilename));
00094                 Mage::register('current_dataflow_session_id', $sessionId);
00095             }
00096         }
00097         return $this;
00098     }

save (  ) 

Implements Mage_Dataflow_Model_Convert_Adapter_Interface.

Definition at line 54 of file Http.php.

00055     {
00056         if ($this->getVars()) {
00057             foreach ($this->getVars() as $key=>$value) {
00058                 header($key.': '.$value);
00059             }
00060         }
00061         echo $this->getData();
00062         return $this;
00063     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:05 2009 for Magento by  doxygen 1.5.8