当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_File_Csv::setDelimiter方法代码示例

本文整理汇总了PHP中Varien_File_Csv::setDelimiter方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_File_Csv::setDelimiter方法的具体用法?PHP Varien_File_Csv::setDelimiter怎么用?PHP Varien_File_Csv::setDelimiter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_File_Csv的用法示例。


在下文中一共展示了Varien_File_Csv::setDelimiter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getFileData

 /**
  * Retrieve data from file
  *
  * @param   string $file
  * @return  array
  */
 protected function _getFileData($file)
 {
     $data = array();
     if (file_exists($file)) {
         $parser = new Varien_File_Csv();
         $parser->setDelimiter(self::CSV_SEPARATOR);
         $data = $parser->getDataPairs($file);
     }
     return $data;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:16,代码来源:Translate.php

示例2: massPrintAction

 /**
  *
  */
 public function massPrintAction()
 {
     $prepareKey = $this->getRequest()->getParam('massaction_prepare_key');
     $ids = $this->getRequest()->getParam($prepareKey);
     $labelType = $this->getRequest()->getParam('labelType');
     $printMethod = $this->getRequest()->getParam('printMethod');
     $row_start = $this->getRequest()->getParam('row_start');
     $col_start = $this->getRequest()->getParam('col_start');
     $labelInfo = array('xmlData' => file_get_contents('js/itwebexperts_payperrentals/labelPrinter/dymo_labels/' . $labelType . '.label'), 'data' => array());
     foreach (explode(',', $ids) as $label) {
         $barcodeType = 'Code128Auto';
         if ($label > 0) {
             $sendReturnId = Mage::getModel('payperrentals/rentalqueue')->load($label);
             $resOrder = Mage::getModel('payperrentals/sendreturn')->load($sendReturnId->getSendreturnId());
             $snArr = explode(',', $resOrder->getSn());
             $customer = Mage::getModel('customer/customer')->load($resOrder->getCustomerId());
             /** @var $address Mage_Customer_Model_Address */
             $address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
             /** replace \n and blank space to avoid indenting in pdf */
             $addressFormated = str_replace("\n", "", $address->format('html_special'));
             $re = "/(<br\\s?\\/>)\\s*/";
             $addressFormated = preg_replace($re, '$1', $addressFormated);
             /** regex remove trailing <br/> */
             $re = "/<br\\/>\\z/";
             $addressFormated = preg_replace($re, '', $addressFormated);
             $product = Mage::getModel('catalog/product')->load($resOrder->getProductId());
             $productName = $product->getName();
             $productDescription = $product->getDescription();
             foreach ($snArr as $sn) {
                 $labelInfo['data'][] = array('ProductsName' => $productName, 'Barcode' => $sn, 'BarcodeType' => $barcodeType, 'ProductsDescription' => $productDescription, 'Address' => $sn . "\n\n" . $addressFormated, 'products_name' => $productName, 'barcode' => $sn, 'barcode_type' => $barcodeType, 'products_description' => $productDescription, 'customers_address' => $addressFormated);
             }
         }
     }
     if ($printMethod == 'dymo') {
         $html = array('labelInfo' => $labelInfo);
         $this->getResponse()->setBody(Zend_Json::encode($html));
     } else {
         if ($printMethod == 'pdf') {
             Mage::helper('payperrentals/labels')->setData($labelInfo['data']);
             Mage::helper('payperrentals/labels')->setLabelsType($labelType);
             Mage::helper('payperrentals/labels')->setStartLocation($row_start, $col_start);
             Mage::helper('payperrentals/labels')->buildPDF();
         } else {
             $csv = new Varien_File_Csv();
             $sepString = $this->getRequest()->getParam('field_separator');
             $sep = ';';
             switch ($sepString) {
                 case 'tab':
                     $sep = '	';
                     break;
                 case 'semicolon':
                     $sep = ';';
                     break;
                 case 'colon':
                     $sep = ':';
                     break;
                 case 'comma':
                     $sep = ',';
             }
             if ($sep) {
                 $csv->setDelimiter($sep);
             }
             $io = new Varien_Io_File();
             $path = Mage::getBaseDir('var') . DS . 'export' . DS;
             //best would be to add exported path through config
             $name = md5(microtime());
             $file = $path . DS . $name . '.csv';
             /**
              * It is possible that you have name collision (summer/winter time +1/-1)
              * Try to create unique name for exported .csv file
              */
             while (file_exists($file)) {
                 sleep(1);
                 $name = md5(microtime());
                 $file = $path . DS . $name . '.csv';
             }
             $io->setAllowCreateFolders(true);
             $io->open(array('path' => $path));
             $io->streamOpen($file, 'w+');
             $io->streamLock(true);
             $headers = array('ProductsName', 'Barcode', 'BarcodeType', 'ProductsDescription', 'Address', 'products_name', 'barcode', 'barcode_type', 'products_description', 'customers_address');
             $io->streamWriteCsv($headers, $sep);
             foreach ($labelInfo['data'] as $row) {
                 $io->streamWriteCsv($row, $sep);
             }
             $io->streamUnlock();
             $io->streamClose();
             //$csv->saveData($file, $labelInfo['data']);
             header("Pragma: public");
             header("Expires: 0");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Cache-Control: private", false);
             header("Content-Type: application/octet-stream");
             header("Content-Disposition: attachment; filename=\"labelSpreadsheet.csv\";");
             header("Content-Transfer-Encoding: binary");
             //echo $io->streamReadCsv($sep);
             echo file_get_contents($file);
//.........这里部分代码省略.........
开发者ID:hueyl77,项目名称:fourwindsgear,代码行数:101,代码来源:SendreturnqueuehistoryController.php

示例3: runUpdate

 protected function runUpdate()
 {
     $this->setData('script_started_at', Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale()));
     $this->setData('script_finished_at', Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale()));
     $messages = array();
     $this->setData('messages', $messages);
     $website = $this->getRequest()->getParam('website');
     $store = $this->getRequest()->getParam('store');
     $testmode = $this->getRequest()->getParam('testmode', 0);
     $sku = $this->getRequest()->getParam('sku');
     $limit = (int) $this->getRequest()->getParam('limit', 0);
     $offset = (int) $this->getRequest()->getParam('offset', 0);
     if ($limit > 100) {
         $limit = 100;
     }
     $store_code = Mage_Core_Model_Store::DEFAULT_CODE;
     if ($store != "") {
         $store_code = $store;
     }
     $this->setData('is_feed', false);
     try {
         $Generator = Mage::getModel('googlebasefeedgenerator/generator', array('store_code' => $store_code));
         $messages[] = array('msg' => 'Store ' . Mage::app()->getStore($store_code)->getName(), 'type' => 'info');
         /* @var $Generator RocketWeb_GoogleBaseFeedGenerator_Model_Generator*/
         if ($testmode) {
             if ($limit > $Generator->getConfigVar('button_max_products')) {
                 $limit = $Generator->getConfigVar('button_max_products');
             }
             $this->setTestMode(true);
             $Generator->setTestMode(true);
             if ($sku) {
                 $Generator->setTestSku($sku);
                 $this->setTestSku($sku);
             } elseif ($offset >= 0 && $limit > 0) {
                 $Generator->setTestOffset($offset);
                 $this->setTestOffset($offset);
                 $Generator->setTestLimit($limit);
                 $this->setTestLimit($limit);
             } else {
                 Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $sku, $offset, $limit));
             }
             $messages[] = array('msg' => 'Test mode.', 'type' => 'info');
         } else {
             $this->setTestMode(false);
         }
         if (!$Generator->getConfigVar('is_turned_on')) {
             $messages[] = array('msg' => 'Can\'t generate feed. It\'s disabled from config option: RocketWeb Extensions > Google Base Feed Generator > Settings > Enabled.', 'type' => 'error');
             $this->setData('messages', $messages);
             return;
         }
         if (!$this->getTestMode()) {
             $collection = Mage::getModel('catalog/product')->getCollection();
             $collection->setStoreId(Mage::app()->getStore($store_code)->getStoreId());
             $count = $collection->getSize();
             if ($count > $Generator->getConfigVar('button_max_products')) {
                 Mage::throwException(sprintf("Too many products. Detected %d products more than the limit allowed of %d.", $count, $Generator->getConfigVar('button_max_products')));
             }
         }
         // Generate feed - costly process.
         $Generator->run();
         if ($Generator->getCountProductsExported() > 0) {
             $this->setData('is_feed', true);
         }
     } catch (Exception $e) {
         $messages[] = array('msg' => 'Error:<br />' . $e->getMessage(), 'type' => 'error');
     }
     $count_products = 0;
     $count_skipped = 0;
     if (isset($Generator) && is_object($Generator) && $Generator instanceof RocketWeb_GoogleBaseFeedGenerator_Model_Generator) {
         $count_products = $Generator->getCountProductsExported();
         $count_skipped = $Generator->getCountProductsSkipped();
     }
     $feed_data = array();
     if ($this->getIsFeed() && $sku != "" && $count_products > 0 && file_exists($Generator->getFeedPath())) {
         /* tsv file */
         $csv = new Varien_File_Csv();
         $csv->setDelimiter("\t");
         $csv->setEnclosure('~');
         // dummy enclosure
         $rows = $csv->getData($Generator->getFeedPath());
         $i = 0;
         foreach ($rows as $row) {
             if ($i == 0) {
                 $i++;
                 continue;
             }
             $feed_data[] = array_combine($rows[0], $row);
             $i++;
         }
     }
     $this->setFeedData($feed_data);
     $messages[] = array('msg' => sprintf("The feed was generated.<br />%d items were added %d products were skipped.", $count_products, $count_skipped), 'type' => 'info');
     $this->setData('messages', $messages);
     $this->setData('script_finished_at', Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale()));
 }
开发者ID:xiaoguizhidao,项目名称:beut,代码行数:95,代码来源:Process.php

示例4: saveAction

 public function saveAction()
 {
     $x4c = "strtolower";
     $x4d = "array_pop";
     $x4e = "explode";
     $x4f = "in_array";
     $x50 = "implode";
     if ($this->getRequest()->getPost()) {
         $x36 = $this->getRequest()->getPost();
         if (isset($_FILES["file"]["name"]) && $_FILES["file"]["name"] != "") {
             $x39 = 1;
             if ($x4c($x4d($x4e(".", $_FILES["file"]["name"]))) != "csv") {
                 Mage::getSingleton("adminhtml/session")->addError(Mage::helper("pointofsale")->__("Wrong file type (" . $_FILES["file"]["type"] . ").<br>Choose a csv file."));
             } else {
                 $x3a = new Varien_File_Csv();
                 $x3a->setDelimiter("\t");
                 $x3b = $x3a->getData($_FILES["file"]["tmp_name"]);
                 $x35 = Mage::getModel("pointofsale/pointofsale");
                 $x3c = $x3b[0];
                 while (isset($x3b[$x39])) {
                     foreach ($x3b[$x39] as $x3d => $x3e) {
                         $x36[$x3c[$x3d]] = $x3e;
                     }
                     $x35->setData($x36)->save();
                     $x39++;
                 }
             }
             Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("pointofsale")->__($x39 - 1 . " places have been imported."));
             $this->_redirect("*/*/importCsv");
             return;
         }
         if (isset($x36["image"]["delete"]) && $x36["image"]["delete"] == 1) {
             $x36["image"] = "";
         } else {
             if (isset($_FILES["image"]["name"]) && $_FILES["image"]["name"] != "") {
                 try {
                     $x3f = new Varien_File_Uploader("image");
                     $x3f->setAllowedExtensions(array("jpg", "jpeg", "gif", "png"));
                     $x3f->setAllowRenameFiles(true);
                     $x3f->setFilesDispersion(false);
                     $x40 = Mage::getBaseDir("media") . DS;
                     $x3f->save($x40 . "stores", $_FILES["image"]["name"]);
                 } catch (Exception $x41) {
                 }
                 $x36["image"] = "stores/" . $_FILES["image"]["name"];
             } else {
                 unset($x36["image"]);
             }
         }
         $x35 = Mage::getModel("pointofsale/pointofsale");
         if ($x4f('-1', $x36["customer_group"])) {
             $x36["customer_group"] = array("-1");
         }
         $x36["customer_group"] = $x50(',', $x36["customer_group"]);
         if ($x4f('0', $x36["store_id"])) {
             $x36["store_id"] = array("0");
         }
         $x36["store_id"] = $x50(',', $x36["store_id"]);
         $x35->setData($x36)->setId($this->getRequest()->getParam("place_id"));
         $x35->save();
         try {
             Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("pointofsale")->__("Item was successfully saved"));
             Mage::getSingleton("adminhtml/session")->setFormData(false);
             if ($this->getRequest()->getParam("back")) {
                 $this->_redirect("*/*/edit", array("place_id" => $x35->getId()));
                 return;
             }
             $this->_redirect("*/*/");
             return;
         } catch (Exception $x41) {
             Mage::getSingleton("adminhtml/session")->addError($x41->getMessage());
             Mage::getSingleton("adminhtml/session")->setFormData($x36);
             $this->_redirect("*/*/edit", array("place_id" => $this->getRequest()->getParam("place_id")));
             return;
         }
     }
     Mage::getSingleton("adminhtml/session")->addError(Mage::helper("pointofsale")->__("Unable to find item to save"));
     $this->_redirect("*/*/");
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:79,代码来源:ManageController.php

示例5: runUpdate

 /**
  * Run the generators
  */
 protected function runUpdate()
 {
     $this->setData('script_started_at', Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale()));
     $this->setData('script_finished_at', Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale()));
     $messages = array();
     $this->setData('messages', $messages);
     $store = $this->getRequest()->getParam('store');
     $testmode = $this->getRequest()->getParam('testmode', 0);
     $sku = $this->getRequest()->getParam('sku');
     $limit = (int) $this->getRequest()->getParam('limit', 0);
     $offset = (int) $this->getRequest()->getParam('offset', 0);
     if ($limit > 100) {
         $limit = 100;
     }
     $store_code = Mage_Core_Model_Store::DEFAULT_CODE;
     if ($store != "") {
         $store_code = $store;
     }
     $this->setData('is_feed', false);
     $this->setData('log_messages', array());
     try {
         try {
             $store_id = Mage::app()->getStore($store_code)->getStoreId();
         } catch (Exception $e) {
             Mage::throwException(sprintf('Store with code \'%s\' doesn\'t exists.', $store_code));
         }
         $Generator = Mage::getSingleton('googlebasefeedgenerator/tools')->addData(array('store_code' => $store_code))->getGenerator($store_id);
         $messages[] = array('msg' => 'Store ' . Mage::app()->getStore($store_code)->getName(), 'type' => 'info');
         /**
          * @var $Generator RocketWeb_GoogleBaseFeedGenerator_Model_Generator
          */
         if ($testmode) {
             if ($limit > $Generator->getConfigVar('button_max_products', 'file')) {
                 $limit = $Generator->getConfigVar('button_max_products', 'file');
             }
             $this->setTestMode(true);
             $Generator->setTestMode(true);
             if ($sku) {
                 $Generator->setTestSku($sku);
                 $this->setTestSku($sku);
             } elseif ($offset >= 0 && $limit > 0) {
                 $Generator->setTestOffset($offset);
                 $this->setTestOffset($offset);
                 $Generator->setTestLimit($limit);
                 $this->setTestLimit($limit);
             } else {
                 Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $sku, $offset, $limit));
             }
             $messages[] = array('msg' => 'Test mode.', 'type' => 'info');
         } else {
             $this->setTestMode(false);
         }
         if (!$Generator->getConfig()->isEnabled($Generator->getStoreId())) {
             $messages[] = array('msg' => 'Extension is disabled, cannot generate feed.', 'type' => 'error');
             $this->setData('messages', $messages);
             return;
         }
         if (!$this->getTestMode()) {
             $collection = $Generator->getCollection();
             $count = $collection->getSize();
             if ($count > $Generator->getConfigVar('button_max_products', 'file')) {
                 Mage::throwException(sprintf("Too many products to generate a full feed through web server. Detected %d products more than the limit allowed of %d. <br />Magento Cron will generate the feed over night. If you need to generate the feed right now, run the shell script \"php shell/gsf_generate.php\" in a sever console.", $count, $Generator->getConfigVar('button_max_products', 'file')));
             }
         }
         // Generate feed - costly process.
         $Generator->run();
         if ($Generator->getCountProductsExported() > 0) {
             $this->setData('is_feed', true);
         }
     } catch (Exception $e) {
         $messages[] = array('msg' => 'Error:<br />' . $e->getMessage(), 'type' => 'error');
     }
     $count_products = 0;
     $count_skipped = 0;
     if (isset($Generator) && is_object($Generator) && $Generator instanceof RocketWeb_GoogleBaseFeedGenerator_Model_Generator) {
         $count_products = $Generator->getCountProductsExported();
         $count_skipped = $Generator->getCountProductsSkipped();
     }
     $feed_data = array();
     if ($this->getIsFeed() && $sku != "" && $count_products > 0 && file_exists($Generator->getFeedPath())) {
         /* tsv file */
         $csv = new Varien_File_Csv();
         $csv->setDelimiter("\t");
         $csv->setEnclosure('~');
         // dummy enclosure
         $rows = $csv->getData($Generator->getFeedPath());
         $i = 0;
         foreach ($rows as $row) {
             if ($i == 0) {
                 $i++;
                 continue;
             }
             $feed_data[] = array_combine($rows[0], $row);
             $i++;
         }
     }
     $this->setFeedData($feed_data);
//.........这里部分代码省略.........
开发者ID:brandontamm,项目名称:api-merchant-center,代码行数:101,代码来源:Process.php

示例6: _importTopOSSczCPostFile

 /**
  * Importation logic
  * @param string $fileName
  * @param string $trackingTitle
  */
 protected function _importTopOSSczCPostFile($fileName, $trackingTitle)
 {
     /**
      * File handling
      **/
     ini_set('auto_detect_line_endings', true);
     $csvObject = new Varien_File_Csv();
     $csvObject->setDelimiter(';');
     $csvData = $csvObject->getData($fileName);
     /**
      * File expected fields
      */
     $expectedCsvFields = array(0 => $this->__('Order Id'), 1 => $this->__('Tracking Number'));
     /**
      * Get configuration
      */
     $sendEmail = Mage::helper('toposscz_cpost')->getConfigurationSendEmail();
     $commentDraft = Mage::helper('toposscz_cpost')->getConfigurationShippingComment();
     $includeComment = Mage::helper('toposscz_cpost')->getConfigurationIncludeComment();
     /* debug */
     //$this->_getSession()->addSuccess($this->__('%s - %s - %s - %s', $sendEmail, $comment, $includeComment, $trackingTitle));
     /**
      * $k is line number
      * $v is line content array
      */
     foreach ($csvData as $k => $v) {
         /**
          * End of file has more than one empty lines
          */
         if (count($v) <= 1 && !strlen($v[0])) {
             continue;
         }
         /**
          * Check that the number of fields is not lower than expected
          */
         if (count($v) < count($expectedCsvFields)) {
             $this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
             continue;
         }
         /**
          * Get fields content
          */
         //$orderId = $v[0];
         $invoiceId = $v[22];
         $trackingNumber = $v[0];
         $comment = $commentDraft . $trackingNumber;
         /* for debug */
         //$this->_getSession()->addSuccess($this->__('Lecture ligne %s: %s - %s', $k, $orderId, $trackingNumber));
         /**
          * Try to load the order
          */
         //$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
         $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
         if (!$invoice->getId()) {
             $this->_getSession()->addError($this->__('Invoice %s does not exist', $invoiceId));
             continue;
         }
         $order = $invoice->getOrder();
         //$orderId = $invoice->getOrderId();
         //$order = Mage::getModel('sales/order')->loadById($orderId);
         /**
          * Try to create a shipment
          */
         $shipmentId = $this->_createShipment($order, $invoice, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
         if ($shipmentId != 0) {
             $this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
         }
     }
     //foreach
 }
开发者ID:Zerocard,项目名称:free-magento-extensions,代码行数:75,代码来源:ImportController.php

示例7: exportAction

 /**
  * Do the export.
  */
 public function exportAction()
 {
     Mage::log("TranslationExporter: Export started");
     $translate = Mage::getSingleton('core/translate');
     $locale = $translate->getLocale();
     $baseFolder = $locale . '_base';
     $targetDir = Mage::getBaseDir('var') . DS . 'translations' . DS . $locale;
     $localeDir = Mage::getBaseDir('locale');
     Mage::log("TranslationExporter - target directory: {$targetDir}");
     $dbtrans = $translate->getResource()->getTranslationArray(null, $locale);
     Mage::log("TranslationExporter: " . count($dbtrans) . " translation rows from DB");
     // for each module:
     // - for each CSV file in that module:
     //   1. read it to memory
     //   2. modify it according to DB translation for that module
     //   3. write it back to dest dir
     $parser = new Varien_File_Csv();
     $parser->setDelimiter(Mage_Core_Model_Translate::CSV_SEPARATOR);
     foreach ($translate->getModulesConfig() as $moduleName => $info) {
         $info = $info->asArray();
         Mage::log("TranslationExporter: Exporting module {$moduleName}");
         foreach ($info['files'] as $file) {
             $enData = array();
             $enFilePath = $localeDir . DS . 'en_US' . DS . $file;
             if (file_exists($enFilePath)) {
                 $enData = $parser->getDataPairs($enFilePath);
             }
             $baseData = array();
             $baseFilePath = $localeDir . DS . $baseFolder . DS . $file;
             if (file_exists($baseFilePath)) {
                 $baseData = $parser->getDataPairs($baseFilePath);
             }
             foreach ($baseData as $key => $val) {
                 if (isset($enData[$key]) && $enData[$key] !== $val) {
                     $enData[$key] = $val;
                 }
             }
             $data = array();
             $filePath = $localeDir . DS . $locale . DS . $file;
             Mage::log("TranslationExporter: Reading {$filePath}");
             if (file_exists($filePath)) {
                 $data = $parser->getDataPairs($filePath);
             }
             foreach ($data as $key => $val) {
                 if (isset($enData[$key]) && $enData[$key] !== $val) {
                     $enData[$key] = $val;
                 }
             }
             // 2. MODIFY
             foreach ($enData as $key => $val) {
                 $fullKey = $moduleName . '::' . $key;
                 if (isset($dbtrans[$fullKey])) {
                     $stack[] = $fullKey;
                     Mage::log("TranslationExporter: Rewrite '{$fullKey}' from '{$val}' to '{$dbtrans[$fullKey]}'");
                     $enData[$key] = $dbtrans[$fullKey];
                 }
             }
             // 3. WRITE
             if (!file_exists($targetDir)) {
                 if (!mkdir($targetDir, 0777, true)) {
                     throw new Exception("Cannot create {$targetDir}");
                 }
             }
             $targetFile = $targetDir . '/' . $file;
             $parser = new Varien_File_Csv();
             $csvdata = array();
             foreach ($enData as $key => $val) {
                 $csvdata[] = array($key, $val);
             }
             $parser->saveData($targetFile, $csvdata);
             Mage::log("TranslationExporter: wrote {$targetFile}");
         }
         Mage::log("TranslationExporter: Done.");
     }
     Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('compiler')->__("Translations has been exported to '%s'.", $targetDir));
     $this->_redirect('*/*/');
 }
开发者ID:akits,项目名称:magento_zh_TW,代码行数:80,代码来源:IndexController.php

示例8: saveAction

 public function saveAction()
 {
     $x34 = "strtolower";
     $x35 = "array_pop";
     $x36 = "explode";
     $x37 = "in_array";
     $x38 = "implode";
     $x39 = "strlen";
     $x3a = "count";
     $x1f = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "pos", "ver" => "5.1.3");
     $x20 = array("activation_key" => Mage::getStoreConfig("pointofsale/license/activation_key"), "activation_code" => Mage::getStoreConfig("pointofsale/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url"));
     if ($x20[$x1f['ac']] != $x1f["md"]($x1f["md"]($x20[$x1f['ak']]) . $x1f["md"]($x20[$x1f['bu']]) . $x1f["md"]($x1f["ext"]) . $x1f["md"]($x1f["ver"]))) {
         ${$x1f["ext"]} = "valid";
         ${$x1f["th"]}->{$x1f["dm"]} = true;
     } else {
         ${$x1f["th"]}->{$x1f["dm"]} = false;
         ${$x1f["ext"]} = "valid";
     }
     if (!isset(${$x1f["ext"]}) || ${$x1f["th"]}->{$x1f["dm"]}) {
         ${$x1f["th"]}->{$x1f["dm"]} = true;
     }
     if (${$x1f["th"]}->{$x1f["dm"]}) {
         $this->_getSession()->addError(Mage::helper("pointofsale")->__("Invalid license."));
         Mage::getConfig()->saveConfig("pointofsale/license/activation_code", "", "default", "0");
         Mage::getConfig()->cleanCache();
         $this->_redirect("*/*/");
     }
     if (${$x1f["th"]}->{$x1f["dm"]}) {
         return ${$x1f["th"]};
     }
     if ($this->getRequest()->getPost()) {
         $x1e = $this->getRequest()->getPost();
         if (isset($_FILES["file"]["name"]) && $_FILES["file"]["name"] != "") {
             $x21 = 1;
             if ($x34($x35($x36(".", $_FILES["file"]["name"]))) != "csv") {
                 Mage::getSingleton("adminhtml/session")->addError(Mage::helper("pointofsale")->__("Wrong file type (" . $_FILES["file"]["type"] . ").<br>Choose a csv file."));
             } else {
                 $x22 = new Varien_File_Csv();
                 $x22->setDelimiter("\t");
                 $x23 = $x22->getData($_FILES["file"]["tmp_name"]);
                 $x1d = Mage::getModel("pointofsale/pointofsale");
                 $x24 = $x23[0];
                 while (isset($x23[$x21])) {
                     foreach ($x23[$x21] as $x25 => $x26) {
                         $x1e[$x24[$x25]] = $x26;
                     }
                     $x1d->setData($x1e)->save();
                     $x21++;
                 }
             }
             Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("pointofsale")->__($x21 - 1 . " places have been imported."));
             $this->_redirect("*/*/importCsv");
             return;
         }
         if (isset($x1e["image"]["delete"]) && $x1e["image"]["delete"] == 1) {
             $x1e["image"] = "";
         } else {
             if (isset($_FILES["image"]["name"]) && $_FILES["image"]["name"] != "") {
                 try {
                     $x27 = new Varien_File_Uploader("image");
                     $x27->setAllowedExtensions(array("jpg", "jpeg", "gif", "png"));
                     $x27->setAllowRenameFiles(true);
                     $x27->setFilesDispersion(false);
                     $x28 = Mage::getBaseDir("media") . DS;
                     $x27->save($x28 . "stores", $_FILES["image"]["name"]);
                 } catch (Exception $x29) {
                 }
                 $x1e["image"] = "stores/" . $_FILES["image"]["name"];
             } else {
                 unset($x1e["image"]);
             }
         }
         $x1d = Mage::getModel("pointofsale/pointofsale");
         if ($x37('-1', $x1e["customer_group"])) {
             $x1e["customer_group"] = array("-1");
         }
         $x1e["customer_group"] = $x38(',', $x1e["customer_group"]);
         if ($x37('0', $x1e["store_id"])) {
             $x1e["store_id"] = array("0");
         }
         $x1e["store_id"] = $x38(',', $x1e["store_id"]);
         $x1d->setData($x1e)->setId($this->getRequest()->getParam("place_id"));
         $x1d->save();
         try {
             Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("pointofsale")->__("Item was successfully saved"));
             Mage::getSingleton("adminhtml/session")->setFormData(false);
             if ($this->getRequest()->getParam("back")) {
                 $this->_redirect("*/*/edit", array("place_id" => $x1d->getId()));
                 return;
             }
             $this->_redirect("*/*/");
             return;
         } catch (Exception $x29) {
             Mage::getSingleton("adminhtml/session")->addError($x29->getMessage());
             Mage::getSingleton("adminhtml/session")->setFormData($x1e);
             $this->_redirect("*/*/edit", array("place_id" => $this->getRequest()->getParam("place_id")));
             return;
         }
     }
     Mage::getSingleton("adminhtml/session")->addError(Mage::helper("pointofsale")->__("Unable to find item to save"));
//.........这里部分代码省略.........
开发者ID:rcclaudrey,项目名称:dev,代码行数:101,代码来源:-ManageController.php


注:本文中的Varien_File_Csv::setDelimiter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。