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


PHP Varien_Io_File::write方法代码示例

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


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

示例1: _loadFiles

 protected function _loadFiles()
 {
     if (!$this->_isLoaded) {
         $readPath = Mage::getBaseDir("var") . DS . "backups";
         $ioProxy = new Varien_Io_File();
         try {
             $ioProxy->open(array('path' => $readPath));
         } catch (Exception $e) {
             $ioProxy->mkdir($readPath, 0755);
             $ioProxy->chmod($readPath, 0755);
             $ioProxy->open(array('path' => $readPath));
         }
         if (!is_file($readPath . DS . ".htaccess")) {
             // Deny from reading in browser
             $ioProxy->write(".htaccess", "deny from all", 0644);
         }
         $list = $ioProxy->ls(Varien_Io_File::GREP_FILES);
         $fileExtension = constant($this->_itemObjectClass . "::BACKUP_EXTENSION");
         foreach ($list as $entry) {
             if ($entry['filetype'] == $fileExtension) {
                 $item = new $this->_itemObjectClass();
                 $item->load($entry['text'], $readPath);
                 if ($this->_checkCondition($item)) {
                     $this->addItem($item);
                 }
             }
         }
         $this->_totalRecords = count($this->_items);
         if ($this->_totalRecords > 1) {
             usort($this->_items, array(&$this, 'compareByTypeOrDate'));
         }
         $this->_isLoaded = true;
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:35,代码来源:Collection.php

示例2: writeSampleDataFile

 /**
  * Write Sample Data to File. Store in folder: "skin/frontend/default/ves theme name/import/"
  */
 public function writeSampleDataFile($importDir, $file_name, $content = "")
 {
     $file = new Varien_Io_File();
     //Create import_ready folder
     $error = false;
     if (!file_exists($importDir)) {
         $importReadyDirResult = $file->mkdir($importDir);
         $error = false;
         if (!$importReadyDirResult) {
             //Handle error
             $error = true;
             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('Can not create folder "%s".', $importDir));
         }
     } else {
         $file->open(array('path' => $importDir));
     }
     if (!$file->write($importDir . $file_name, $content)) {
         //Handle error
         $error = true;
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('Can not save import sample file "%s".', $file_name));
     }
     if (!$error) {
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('Successfully, Stored sample data file "%s".', $file_name));
     }
     return !$error;
 }
开发者ID:quanghuynt93,项目名称:VesSmartshop,代码行数:29,代码来源:ExportSample.php

示例3: _saveFile

 /**
  * Create/update file in file system
  *
  * @return bool|int
  */
 protected function _saveFile()
 {
     $filePath = $this->getFilePath(true);
     $this->_ioFile->checkAndCreateFolder(dirname($filePath));
     $result = $this->_ioFile->write($filePath, $this->getContent());
     $this->_design->cleanMergedJsCss();
     return $result;
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例4: write

 /**
  * Write xml nfe in folder
  *
  * @return true
  */
 public function write()
 {
     // load template array, fill data and convert to XML
     $this->_init()->_addCustomer()->_addItens()->_addOtherInfo()->_toXML();
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $io->createDestinationDir($this->_path);
     $return = $io->write($this->_path . $this->_getFileName(), $this->_stringFinalXML);
     return true;
 }
开发者ID:robsonximenes,项目名称:magento-nfe-bling,代码行数:15,代码来源:TransformToXML.php

示例5: finaliseStoreData

 protected function finaliseStoreData()
 {
     // Write DOM to file
     $filename = $this->info("clean_store_name") . '-products.xml';
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $this->getPath()));
     $io->write($filename, $this->_dom->saveXML());
     $io->close();
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:10,代码来源:Xml.php

示例6: saveFile

 /**
  * @param $file
  * @param $filename
  * @throws Exception
  */
 public function saveFile($file, $filename)
 {
     $varienFile = new Varien_Io_File();
     $varienFile->open();
     $path = $this->getFilePath($filename);
     $varienFile->checkAndCreateFolder($path);
     if ($varienFile->write($path . DS . $filename, $file) !== false) {
         return $path . DS . $filename;
     } else {
         throw new Exception('Could not save PDF file');
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:17,代码来源:Pdf.php

示例7: __construct

 public function __construct()
 {
     parent::__construct();
     $this->_baseDir = Mage::getBaseDir('export');
     // check for valid base dir
     $ioProxy = new Varien_Io_File();
     $ioProxy->mkdir($this->_baseDir);
     if (!is_file($this->_baseDir . DS . '.htaccess')) {
         $ioProxy->open(array('path' => $this->_baseDir));
         $ioProxy->write('.htaccess', 'deny from all', 0644);
     }
     $this->setOrder('file_created', self::SORT_ORDER_DESC)->addTargetDir($this->_baseDir)->setCollectRecursively(false);
 }
开发者ID:helirexi,项目名称:DataflowExportDownloads,代码行数:13,代码来源:Collection.php

示例8: _rewriteGrid

    protected function _rewriteGrid($blcgClass, $originalClass, $gridType)
    {
        $classParts = explode('_', str_replace($this->_getBlcgClassPrefix(), '', $blcgClass));
        $fileName = array_pop($classParts) . '.php';
        $rewriteDir = dirname(__FILE__) . '/../../../Block/Rewrite/' . implode('/', $classParts);
        $ioFile = new Varien_Io_File();
        $ioFile->setAllowCreateFolders(true);
        $ioFile->checkAndCreateFolder($rewriteDir);
        $ioFile->cd($rewriteDir);
        // Use open() to initialize Varien_Io_File::$_iwd
        // Prevents a warning when chdir() is used without error control in Varien_Io_File::read()
        if ($ioFile->fileExists($fileName, true) && $ioFile->open()) {
            if ($content = $ioFile->read($fileName)) {
                $lines = preg_split('#\\R#', $content, 3);
                $isUpToDate = false;
                if (isset($lines[0]) && isset($lines[1]) && $lines[0] == '<?php' && preg_match('#^// BLCG_REWRITE_CODE_VERSION\\=([0-9]+)$#', $lines[1], $matches)) {
                    if ($matches[1] === strval(self::REWRITE_CODE_VERSION)) {
                        $isUpToDate = true;
                    }
                }
            }
            $ioFile->close();
            if ($isUpToDate) {
                return $this;
            }
        }
        $content = '<?php
// BLCG_REWRITE_CODE_VERSION=' . self::REWRITE_CODE_VERSION . '
// This file was generated automatically. Do not alter its content.

/**
 * 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
 *
 * @category   BL
 * @package    BL_CustomGrid
 * @copyright  Copyright (c) ' . date('Y') . ' Benoît Leulliette <benoit.leulliette@gmail.com>
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

';
        $content .= $this->_getRewriteCode($blcgClass, $originalClass, $gridType);
        if (!$ioFile->write($fileName, $content)) {
            Mage::throwException();
        }
        return $this;
    }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:51,代码来源:File.php

示例9: __construct

 /**
  * Set collection specific parameters and make sure backups folder will exist
  */
 public function __construct()
 {
     parent::__construct();
     $this->_baseDir = Mage::getBaseDir('var') . DS . Ebizmarts_Mailchimp_Model_BulkSynchro::FLDR;
     // check for valid base dir
     $ioProxy = new Varien_Io_File();
     $ioProxy->mkdir($this->_baseDir);
     if (!is_file($this->_baseDir . DS . '.htaccess')) {
         $ioProxy->open(array('path' => $this->_baseDir));
         $ioProxy->write('.htaccess', 'deny from all', 0644);
     }
     // set collection specific params
     $this->setOrder('time', self::SORT_ORDER_DESC)->addTargetDir($this->_baseDir)->setFilesFilter('/^[a-z0-9\\-\\_]+\\.' . preg_quote(Ebizmarts_Mailchimp_Model_BulkSynchro::FILE_EXTENSION . "." . Ebizmarts_Mailchimp_Model_BulkSynchro::BULK_EXTENSION, '/') . '$/')->setCollectRecursively(false);
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:17,代码来源:Collection.php

示例10: _create

 /**
  * Product image add
  *
  * @throws Mage_Api2_Exception
  * @param array $data
  * @return string
  */
 protected function _create(array $data)
 {
     /* @var $validator Mage_Catalog_Model_Api2_Product_Image_Validator_Image */
     $validator = Mage::getModel('Mage_Catalog_Model_Api2_Product_Image_Validator_Image');
     if (!$validator->isValidData($data)) {
         foreach ($validator->getErrors() as $error) {
             $this->_error($error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
         }
         $this->_critical(self::RESOURCE_DATA_PRE_VALIDATION_ERROR);
     }
     $imageFileContent = @base64_decode($data['file_content'], true);
     if (!$imageFileContent) {
         $this->_critical('The image content must be valid base64 encoded data', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
     }
     unset($data['file_content']);
     $apiTempDir = Mage::getBaseDir('var') . DS . 'api' . DS . Mage::getSingleton('Mage_Api_Model_Session')->getSessionId();
     $imageFileName = $this->_getFileName($data);
     try {
         $ioAdapter = new Varien_Io_File();
         $ioAdapter->checkAndCreateFolder($apiTempDir);
         $ioAdapter->open(array('path' => $apiTempDir));
         $ioAdapter->write($imageFileName, $imageFileContent, 0666);
         unset($imageFileContent);
         // try to create Image object to check if image data is valid
         try {
             $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
             new Varien_Image($apiTempDir . DS . $imageFileName, $adapter);
         } catch (Exception $e) {
             $ioAdapter->rmdir($apiTempDir, true);
             $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
         }
         $product = $this->_getProduct();
         $imageFileUri = $this->_getMediaGallery()->addImage($product, $apiTempDir . DS . $imageFileName, null, false, false);
         $ioAdapter->rmdir($apiTempDir, true);
         // updateImage() must be called to add image data that is missing after addImage() call
         $this->_getMediaGallery()->updateImage($product, $imageFileUri, $data);
         if (isset($data['types'])) {
             $this->_getMediaGallery()->setMediaAttribute($product, $data['types'], $imageFileUri);
         }
         $product->save();
         return $this->_getImageLocation($this->_getCreatedImageId($imageFileUri));
     } catch (Mage_Core_Exception $e) {
         $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
     } catch (Exception $e) {
         $this->_critical(self::RESOURCE_UNKNOWN_ERROR);
     }
 }
开发者ID:nemphys,项目名称:magento2,代码行数:54,代码来源:V1.php

示例11: save

 /**
  * Save result to destination file from temporary
  *
  * @return Mage_Dataflow_Model_Convert_Adapter_Io
  */
 public function save()
 {
     if (!$this->getResource(true)) {
         return $this;
     }
     $batchModel = Mage::getSingleton('dataflow/batch');
     $dataFile = $batchModel->getIoAdapter()->getFile(true);
     $filename = $this->getVar('filename');
     /*         * Start Code For Vendor* */
     $isVendor = Mage::helper('marketplace')->isVendor();
     //current user is vendor or not
     if ($isVendor) {
         /*             * Fetch Current User Name* */
         $user = Mage::getSingleton('admin/session');
         $userName = $user->getUser()->getUsername();
         $filename = 'export_product_' . $userName . '.csv';
     }
     /*         * End Code For Vendor* */
     $result = $this->getResource()->write($filename, $dataFile, 0777);
     if (false === $result) {
         $message = Mage::helper('dataflow')->__('Could not save file: %s.', $filename);
         Mage::throwException($message);
     } else {
         /*             * Start Code For Vendor* */
         if ($isVendor) {
             $localpath = 'vendor/';
             //create path if not exist
             if (!file_exists($localpath)) {
                 mkdir($localpath, 0777, true);
             }
             $fileWithPath = $localpath . '/' . $filename;
             $localResource = new Varien_Io_File();
             $localResource->write($fileWithPath, $dataFile, 0777);
         }
         $message = Mage::helper('dataflow')->__('Saved successfully: "%s" [%d byte(s)].', $filename, $batchModel->getIoAdapter()->getFileSize());
         if ($batchModel->getIoAdapter()->getFileSize() == 0 && $isVendor) {
             $message = Mage::helper('dataflow')->__("You don't have any product to download");
             Mage::throwException($message);
         }
         if ($this->getVar('link')) {
             $message .= Mage::helper('dataflow')->__('<a href="%s" target="_blank">Link</a>', $this->getVar('link'));
         }
         $this->addException($message);
     }
     return $this;
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:51,代码来源:Io.php

示例12: writeRewriteFile

 function writeRewriteFile()
 {
     $adapter = Mage::getModel('freelunchlabs_cloudfront/refreshadapters_apache');
     $base_dir = Mage::getBaseDir() . DS;
     $file = new Varien_Io_File();
     try {
         if ($file->cd($base_dir) && $file->checkAndCreateFolder($this->cdn_rewrite_directory, 0755)) {
             if ($file->cd($base_dir . $this->cdn_rewrite_directory)) {
                 if (!$file->write($adapter->filename, $adapter->buildFileContents(), 0644)) {
                     throw new Exception("Could not write .htaccess to: " . $file->pwd());
                 }
             }
         }
     } catch (Exception $e) {
         Mage::getSingleton('core/session')->addWarning('Configuration saved but there was an error creating the .htaccess file: ' . $e->getMessage());
     }
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:17,代码来源:Refresh.php

示例13: __construct

 /**
  * Set collection specific parameters and make sure backups folder will exist
  */
 public function __construct()
 {
     parent::__construct();
     $this->_baseDir = Mage::getBaseDir('var') . DS . 'backups';
     // check for valid base dir
     $ioProxy = new Varien_Io_File();
     $ioProxy->mkdir($this->_baseDir);
     if (!is_file($this->_baseDir . DS . '.htaccess')) {
         $ioProxy->open(array('path' => $this->_baseDir));
         $ioProxy->write('.htaccess', 'deny from all', 0644);
     }
     // set collection specific params
     $extensions = Mage::helper('backup')->getExtensions();
     foreach ($extensions as $key => $value) {
         $extensions[] = '(' . preg_quote($value, '/') . ')';
     }
     $extensions = implode('|', $extensions);
     $this->setOrder('time', self::SORT_ORDER_DESC)->addTargetDir($this->_baseDir)->setFilesFilter('/^[a-z0-9\\-\\_]+\\.' . $extensions . '$/')->setCollectRecursively(false);
 }
开发者ID:usamatahir,项目名称:BulletProof,代码行数:22,代码来源:Collection.php

示例14: finaliseStoreData

 protected function finaliseStoreData()
 {
     // Write CSV data to temp file
     $memoryLimit = 16 * 1024 * 1024;
     $fp = fopen("php://temp/maxmemory:{$memoryLimit}", 'r+');
     foreach ($this->_rows as $row) {
         fputcsv($fp, $row, $this->_separator);
     }
     rewind($fp);
     // Write temp file data to file
     $cleanStoreName = str_replace('+', '-', strtolower(urlencode($this->_store->getName())));
     $filename = $cleanStoreName . '-products.csv';
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $this->getPath()));
     $io->write($filename, $fp);
     $io->close();
     fclose($fp);
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:19,代码来源:Csv.php

示例15: createConfigFile

 protected function createConfigFile()
 {
     $base_url = explode("/", Mage::getBaseUrl('js'));
     $base_url = explode($base_url[count($base_url) - 2], Mage::getBaseUrl('js'));
     $this->_base_url = $base_url[0];
     $base_URLs = preg_replace('/http:\\/\\//is', 'https://', $base_url[0]);
     /** Create file config for javascript */
     $js = "var mw_baseUrl = '{BASE_URL}';\n";
     $js = str_replace("{BASE_URL}", $base_url[0], $js);
     $js .= "var mw_baseUrls = '{$base_URLs}';\n";
     $js .= "var FACEBOOK_ID = '" . Mage::helper('mw_socialgift')->getFBID() . "';\n";
     $file = new Varien_Io_File();
     $file->checkAndCreateFolder($this->baseDir . "/media/mw_socialgift/js/");
     $file->checkAndCreateFolder($this->baseDir . "/media/mw_socialgift/css/");
     foreach ($this->_multi_path_js as $code => $path) {
         if (!file_exists($path) && Mage::app()->getStore()->getCode() == $code) {
             $file->write($path, $js);
             $file->close();
         }
     }
     return $js;
 }
开发者ID:GaynorH,项目名称:prestigedrinks,代码行数:22,代码来源:Layout.php


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