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


PHP Varien_File_Csv::getDataPairs方法代码示例

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


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

 public function csvAction()
 {
     $dump = Mage::helper('pdfinvoiceplus/localization')->translate('Shipping & Handling');
     zend_debug::dump($dump);
     die;
     $p = 'magestore\\pdfinvoiceplus\\localization\\localization_england.csv';
     $path = str_replace(array('\\', '/'), DS, $p);
     $file = Mage::getBaseDir('media') . DS . $path;
     $csv = new Varien_File_Csv();
     $data = $csv->getDataPairs($file);
     zend_debug::dump($data);
     die;
     //        die($file);
     $csv = scandir($file);
     $data = array();
     foreach ($csv as $file) {
         if (preg_match('/^localization/', $file)) {
             $data[] = $file;
         }
     }
     zend_debug::dump($data);
     die;
     for ($i = 1; $i < count($data); $i++) {
         var_dump($data[$i]);
     }
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:26,代码来源:IndexController.php

示例3: getFileData

 /**
  * Get data from csv file
  *
  * @param string $file
  * @return array
  */
 protected function getFileData($file)
 {
     $parser = new Varien_File_Csv();
     return $parser->getDataPairs($file);
 }
开发者ID:flyw,项目名称:magento-cn,代码行数:11,代码来源:BaseTask.php

示例4: 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


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