function definitionsexportAction()
 {
     $this->checkVersion();
     if (isset($_GET['go'])) {
         if ('CSV' == $_REQUEST['format']) {
             header(sprintf('Content-Disposition: attachment;filename="vaf-export-%s.csv"', time()));
             header('Content-Type: text/csv');
         } else {
             header(sprintf('Content-Disposition: attachment;filename="vaf-export-%s.xml"', time()));
             header('Content-Type: text/xml');
         }
         if ('CSV' == $_REQUEST['format']) {
             $stream = fopen("php://output", 'w');
             $exporter = new VF_Import_VehiclesList_CSV_Export();
             $exporter->export($stream);
         } else {
             $exporter = new VF_Import_VehiclesList_XML_Export();
             echo $exporter->export();
         }
         exit;
     }
     $this->loadLayout();
     $this->_setActiveMenu('vaf/export');
     $block = $this->getLayout()->createBlock('core/template', 'vafimporter/definitionsexport');
     $block->setTemplate('vf/vafimporter/definitions_export.phtml');
     $this->_addContent($block);
     $this->renderLayout();
 }
    protected function cols()
    {
	$return = $this->col('sku');
	$return .= $this->col('universal');
	$return .= parent::cols();
	$return .= $this->doCols();
	return $return;
    }
 function doIndexAction()
 {
     $config = $this->getConfig();
     $this->block->setTemplate('vf/vaf/vfdata.phtml');
     $form = $this->form();
     $this->block->form = $form;
     if ($this->getRequest()->getParam('download')) {
         $download_url = 'http://data.vehiclefits.com/api/download?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $download_stream = fopen($download_url, 'r');
         while (!feof($download_stream)) {
             $buffer = fread($download_stream, 512);
             // use a buffer of 512 bytes
             fwrite($local_stream, $buffer);
         }
         fclose($download_stream);
         fclose($local_stream);
         $importer = new VF_Import_VehiclesList_CSV_Import($local_file);
         $importer->import();
         $this->block->downloaded = true;
         return;
     }
     if ($this->getRequest()->getParam('upload')) {
         $upload_url = 'http://data.vehiclefits.com/api/upload?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $exporter = new VF_Import_VehiclesList_CSV_Export();
         $exporter->export($local_stream);
         $ch = curl_init($upload_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($local_file));
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $response = curl_exec($ch);
         $this->block->uploaded = $response;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
         $config->vfdata->api_token = $form->getValue('api_token');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Esempio n. 4
0
 function indexAction()
 {
     $schema = $this->schema();
     if (isset($_GET['go'])) {
         if ('CSV' == $_REQUEST['format']) {
             header(sprintf('Content-Disposition: attachment;filename="vaf-export-%s.csv"', time()));
             header('Content-Type: text/csv');
         } else {
             header(sprintf('Content-Disposition: attachment;filename="vaf-export-%s.xml"', time()));
             header('Content-Type: text/xml');
         }
         if ('CSV' == $_REQUEST['format']) {
             $stream = fopen("php://output", 'w');
             $exporter = new \VF_Import_VehiclesList_CSV_Export();
             $exporter->export($stream);
         } else {
             $exporter = new \VF_Import_VehiclesList_XML_Export();
             echo $exporter->export();
         }
         exit;
     }
     return array('schema' => $schema->getLevels());
 }
Esempio n. 5
0
 function main()
 {
     $stream = fopen("php://output", 'w');
     $exporter = new VF_Import_VehiclesList_CSV_Export();
     $exporter->export($stream);
 }
<?php

/**
 * Vehicle Fits
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to sales@vehiclefits.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Vehicle Fits to newer
 * versions in the future. If you wish to customize Vehicle Fits for your
 * needs please refer to http://www.vehiclefits.com for more information.
 * @copyright  Copyright (c) 2013 Vehicle Fits, llc
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require_once 'config.php';
$stream = $stream = fopen("php://output", 'w');
$exporter = new VF_Import_VehiclesList_CSV_Export();
$exporter->export($stream);