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


PHP Varien_Io_File::read方法代码示例

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


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

示例1: rotateLogs

 /**
  * Rotate all files in var/log which ends with .log
  */
 public function rotateLogs()
 {
     $var = Mage::getBaseDir('log');
     $logDir = new Varien_Io_File();
     $logDir->cd($var);
     $logFiles = $logDir->ls(Varien_Io_File::GREP_FILES);
     foreach ($logFiles as $logFile) {
         if ($logFile['filetype'] == 'log') {
             $filename = $logFile['text'];
             if (extension_loaded('zlib')) {
                 $zipname = $var . DS . $this->getArchiveName($filename);
                 $zip = gzopen($zipname, 'wb9');
                 gzwrite($zip, $logDir->read($filename));
                 gzclose($zip);
             } else {
                 $logDir->cp($filename, $this->getArchiveName($filename));
             }
             foreach ($this->getFilesOlderThan(self::MAX_FILE_DAYS, $var, $filename) as $oldFile) {
                 $logDir->rm($oldFile['text']);
             }
             $logDir->rm($filename);
         }
     }
     $logDir->close();
 }
开发者ID:kirchbergerknorr,项目名称:firegento-logger,代码行数:28,代码来源:Observer.php

示例2: loadFile

 /**
  * @param $filename
  * @return bool|string
  */
 public function loadFile($filename)
 {
     $varienFile = new Varien_Io_File();
     $varienFile->open();
     $path = $this->getFilePath($filename);
     return $varienFile->read($path . DS . $filename);
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:11,代码来源:Pdf.php

示例3: getTemplateFile

 /**
  * Retrieve translated template file
  * Try current design package first
  *
  * @param string $file
  * @param string $type
  * @param string $localeCode
  * @return string
  */
 public function getTemplateFile($file, $type, $localeCode = null)
 {
     if (is_null($localeCode) || preg_match('/[^a-zA-Z_]/', $localeCode)) {
         $localeCode = $this->getLocale();
     }
     $filePath = $this->getLocaleOverrideFile($localeCode, 'template' . DS . $type . DS . $file);
     if (empty($filePath) || !file_exists($filePath)) {
         return parent::getTemplateFile($file, $type, $localeCode);
     }
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->open(array('path' => Mage::getBaseDir('locale')));
     return (string) $ioAdapter->read($filePath);
 }
开发者ID:Seb2nim,项目名称:Yireo_EmailOverride,代码行数:22,代码来源:Translate.php

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

示例5: saveFileContentToConfig

 public function saveFileContentToConfig($file, $field)
 {
     $adminsession = Mage::getSingleton('adminhtml/session');
     $io = new Varien_Io_File();
     $io->open(array('path' => Mage::getBaseDir()));
     if ($io->fileExists($file)) {
         try {
             $contents = $io->read($file);
             Mage::getModel('core/config')->saveConfig('creare' . $field . '/files/' . $field, $contents);
         } catch (Mage_Core_Exception $e) {
             $adminsession->addError($e->getMessage());
         }
     } else {
         $adminsession->addError($file . " does not exist. Please create this file on your domain root to use this feature.");
     }
     $io->streamClose();
 }
开发者ID:adampmoss,项目名称:CreareSEO,代码行数:17,代码来源:Data.php

示例6: validate

 /**
  * Validates the file supplied via the file param to ensure the hash values for each param match the current value of
  * the configuration variable in Magento.
  * This cron job will only output a message if there is a validation error or if debug mode is enabled
  */
 protected function validate()
 {
     $lockFileName = $this->getArg('file');
     $invalidKeys = array();
     if ($lockFileName) {
         $inFile = new Varien_Io_File();
         $inFile->open(array('path' => dirname($lockFileName)));
         $lockData = null;
         $lockData = $inFile->read(basename($lockFileName));
         if (!$lockData) {
             $this->fatal("Unable to read supplied file");
         }
         $lockData = json_decode($lockData, true);
         foreach ($lockData['hashes'] as $storeCode => $hashes) {
             $this->debug($storeCode);
             foreach ($hashes as $configKey => $configValueHash) {
                 $store = Mage::getModel("core/store")->load($storeCode, "code");
                 $configValue = Mage::getStoreConfig($configKey, $store);
                 if (password_verify($configValue, $configValueHash)) {
                     $this->debug($configKey . " is valid");
                 } else {
                     $this->error($configKey . " is NOT valid\n");
                     $invalidKeys[] = $configKey;
                 }
             }
         }
         if (count($invalidKeys) > 0) {
             /*
              * Check if the mandrill API key was encoded into the lock file. If found, use it to send emails in case
              *  it has been modified via the admin to prevent notifications
              */
             if (array_key_exists('mandrillApiKey', $lockData) && !empty($lockData['mandrillApiKey'])) {
                 Mage::app()->getStore()->setConfig("mandrill/general/apikey", Mage::helper('core')->decrypt($lockData['mandrillApiKey']));
                 Mage::app()->getStore()->setConfig("mandrill/general/active", 'true');
             }
             $this->notifyFailures($lockData['emails'], implode(",", $invalidKeys));
             die(1);
         }
     } else {
         $this->fatal('Must supply "file" argument to read lock file');
     }
 }
开发者ID:beejhuff,项目名称:config-lock,代码行数:47,代码来源:config_lock.php

示例7: getTemplateFile

 /**
  * Retrive translated template file
  *
  * @param string $file
  * @param string $type
  * @param string $localeCode
  * @return string
  */
 public function getTemplateFile($file, $type, $localeCode = null)
 {
     if (is_null($localeCode) || preg_match('/[^a-zA-Z_]/', $localeCode)) {
         $localeCode = $this->getLocale();
     }
     $filePath = Mage::getBaseDir('locale') . DS . $localeCode . DS . 'template' . DS . $type . DS . $file;
     if (!file_exists($filePath)) {
         // If no template specified for this locale, use store default
         $filePath = Mage::getBaseDir('locale') . DS . Mage::app()->getLocale()->getDefaultLocale() . DS . 'template' . DS . $type . DS . $file;
     }
     if (!file_exists($filePath)) {
         // If no template specified as  store default locale, use en_US
         $filePath = Mage::getBaseDir('locale') . DS . Mage_Core_Model_Locale::DEFAULT_LOCALE . DS . 'template' . DS . $type . DS . $file;
     }
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->open(array('path' => Mage::getBaseDir('locale')));
     return (string) $ioAdapter->read($filePath);
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:26,代码来源:Translate.php

示例8: _cacheImageData

 /**
  * Cache the widget images.
  *
  * @param string $type type
  * @param string $tsId Trusted Rating Id
  *
  * @return void
  */
 private function _cacheImageData($type, $tsId = null)
 {
     $ioObject = new Varien_Io_File();
     $ioObject->open();
     if ($type == 'emailWidget') {
         $emailWidgetName = $this->getRatingLinkData('emailratingimage');
         $readPath = self::EMAIL_WIDGET_LINK . $emailWidgetName;
         $writePath = self::IMAGE_LOCAL_PATH . $emailWidgetName;
         $cacheId = self::EMAIL_CACHEID;
     } else {
         $readPath = self::WIDGET_LINK . $tsId . self::WIDGET_FILE_SUFFIX;
         $writePath = self::IMAGE_LOCAL_PATH . $tsId . self::WIDGET_FILE_SUFFIX;
         $cacheId = self::CACHEID;
     }
     $result = $ioObject->read($readPath);
     $ioObject->write($writePath, $result);
     Mage::app()->saveCache($writePath, $cacheId, array(), 1);
     $ioObject->close();
 }
开发者ID:notimplementedyet,项目名称:trustedshops_trustedrating,代码行数:27,代码来源:Trustedrating.php

示例9: run

 /**
  * Run webservice
  *
  * @param Mage_Api_Controller_Action $controller
  * @return Mage_Api_Model_Server_Adapter_Soap
  */
 public function run()
 {
     $apiConfigCharset = Mage::getStoreConfig("api/config/charset");
     if ($this->getController()->getRequest()->getParam('wsdl') !== null) {
         // Generating wsdl content from template
         $io = new Varien_Io_File();
         $io->open(array('path' => Mage::getModuleDir('etc', 'Mage_Api')));
         $wsdlContent = $io->read('wsdl.xml');
         $template = Mage::getModel('core/email_template_filter');
         $wsdlConfig = new Varien_Object();
         $queryParams = $this->getController()->getRequest()->getQuery();
         if (isset($queryParams['wsdl'])) {
             unset($queryParams['wsdl']);
         }
         $wsdlConfig->setUrl(htmlspecialchars(Mage::getUrl('*/*/*', array('_query' => $queryParams))));
         $wsdlConfig->setName('Magento');
         $wsdlConfig->setHandler($this->getHandler());
         $template->setVariables(array('wsdl' => $wsdlConfig));
         $this->getController()->getResponse()->clearHeaders()->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)->setBody(preg_replace('/<\\?xml version="([^\\"]+)"([^\\>]+)>/i', '<?xml version="$1" encoding="' . $apiConfigCharset . '"?>', $template->filter($wsdlContent)));
     } else {
         try {
             $this->_instantiateServer();
             $this->getController()->getResponse()->clearHeaders()->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)->setBody(preg_replace('/<\\?xml version="([^\\"]+)"([^\\>]+)>/i', '<?xml version="$1" encoding="' . $apiConfigCharset . '"?>', $this->_soap->handle()));
         } catch (Zend_Soap_Server_Exception $e) {
             $this->fault($e->getCode(), $e->getMessage());
         } catch (Exception $e) {
             $this->fault($e->getCode(), $e->getMessage());
         }
     }
     return $this;
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:37,代码来源:Soap.php

示例10: run

 /**
  * Run webservice
  *
  * @param Mage_Api_Controller_Action $controller
  * @return Mage_Api_Model_Server_Adapter_Soap
  */
 public function run()
 {
     if ($this->getController()->getRequest()->getParam('wsdl')) {
         // Generating wsdl content from template
         $io = new Varien_Io_File();
         $io->open(array('path' => Mage::getModuleDir('etc', 'Mage_Api')));
         $wsdlContent = $io->read('wsdl.xml');
         $template = Mage::getModel('core/email_template_filter');
         $wsdlConfig = new Varien_Object();
         $wsdlConfig->setUrl(Mage::getUrl('*/*/*'));
         $wsdlConfig->setName('Magento');
         $wsdlConfig->setHandler($this->getHandler());
         $template->setVariables(array('wsdl' => $wsdlConfig));
         $this->getController()->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($template->filter($wsdlContent));
     } elseif ($this->_extensionLoaded()) {
         $this->_soap = new SoapServer(Mage::getUrl('*/*/*', array('wsdl' => 1)));
         use_soap_error_handler(false);
         $this->_soap->setClass($this->getHandler());
         $this->getController()->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->_soap->handle());
     } else {
         $this->fault('0', 'Unable to load Soap extension on the server');
     }
     return $this;
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:30,代码来源:Soap.php

示例11: _getFileContainerContent

 /**
  * Retrieve file content from file container array
  *
  * @param array $fileData
  * @return string
  */
 protected function _getFileContainerContent(array $fileData)
 {
     $io = new Varien_Io_File();
     $path = $io->dirname($fileData['value']);
     $io->open(array('path' => $path));
     return $io->read($fileData['value']);
 }
开发者ID:nja78,项目名称:Magento-Pre-Patched-Files,代码行数:13,代码来源:Grid.php

示例12: readSampleFile

 public function readSampleFile($folder, $filepath = "")
 {
     $result = "";
     if ($filepath) {
         $flocal = new Varien_Io_File();
         $flocal->open(array('path' => $folder));
         $result = $flocal->read($filepath);
     }
     return $result;
 }
开发者ID:booklein,项目名称:bookle,代码行数:10,代码来源:Data.php

示例13: getTemplateFile

 /**
  * Retrive translated template file
  * line 460 in Mage_Core_Model_Translate
  *
  * @modified_by MaWoScha <mawoscha@siempro.co>
  * @param string $file
  * @param string $type
  * @param string $localeCode
  * @return string
  */
 public function getTemplateFile($file, $type, $localeCode = null)
 {
     if (is_null($localeCode) || preg_match('/[^a-zA-Z_]/', $localeCode)) {
         $localeCode = $this->getLocale();
     }
     $filePath = Mage::getBaseDir('locale') . DS . $localeCode . DS . 'template' . DS . $type . DS . $file;
     /** START - MaWoScha */
     if (!file_exists($filePath)) {
         // If template doesn't exist for this locale, use fallback locale
         $filePath = Mage::getBaseDir('locale') . DS . Mage::getStoreConfig('general/locale/code_fallback') . DS . 'template' . DS . $type . DS . $file;
     }
     /** END - MaWoScha */
     if (!file_exists($filePath)) {
         // If template doesn't exist for fallback locale, use store default
         $filePath = Mage::getBaseDir('locale') . DS . Mage::app()->getLocale()->getDefaultLocale() . DS . 'template' . DS . $type . DS . $file;
     }
     if (!file_exists($filePath)) {
         // If template doesn't exist for store default, use en_US
         $filePath = Mage::getBaseDir('locale') . DS . Mage_Core_Model_Locale::DEFAULT_LOCALE . DS . 'template' . DS . $type . DS . $file;
     }
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->open(array('path' => Mage::getBaseDir('locale')));
     return (string) $ioAdapter->read($filePath);
 }
开发者ID:hhirsch,项目名称:LocaleFallback,代码行数:34,代码来源:Translate.php

示例14: getContentCustomCss

 public function getContentCustomCss()
 {
     $output = "";
     $theme = Mage::registry('theme_data')->get('group');
     $tmp_theme = explode("/", $theme);
     if (count($tmp_theme) == 1) {
         $theme = "default/" . $tmp_theme;
     }
     if ($theme) {
         $custom_css_path = Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/custom.css";
         if (is_file($custom_css_path) && file_exists($custom_css_path)) {
             $file = new Varien_Io_File();
             $file->open(array('path' => Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/"));
             //$flocal->streamOpen('customers.txt', 'r');
             $output = $file->read(Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/custom.css");
             $file->close();
         }
     }
     return $output;
 }
开发者ID:quanghuynt93,项目名称:VesSmartshop,代码行数:20,代码来源:Edit.php

示例15: buildFeeds

 public function buildFeeds($storeId, $type, $page)
 {
     $store = Mage::app()->getStore($storeId);
     if (Mage::getStoreConfig('clerk/settings/active', $store->getId())) {
         $feedData = array();
         if ($type == 'products') {
             $feedData[$type] = $this->__getFeedProductData($store->getId(), $page);
         }
         if ($type == 'categories') {
             $feedData[$type] = $this->__getFeedCategoryData($store->getId(), $page);
         }
         if ($type == 'sales') {
             $feedData[$type] = $this->__getFeedSalesData($store->getId(), $page);
         }
         if ($type != 'done') {
             $filename_tmp = Mage::helper('clerk')->getFileName($store, $tmp = true);
             $path = Mage::getBaseDir('media') . "/clerk/feeds/";
             $file = new Varien_Io_File();
             $file->checkAndCreateFolder($path);
             $file->open(array('path' => $path));
             if (file_exists($path . $filename_tmp)) {
                 $content = $file->read($filename_tmp);
                 $json = json_decode($content, true);
                 if (isset($json[$type])) {
                     if ($type == 'products') {
                         $add = true;
                         foreach ($json[$type] as $item_added) {
                             if ($item_added['id'] == $feedData[$type][0]['id']) {
                                 $add = false;
                                 break;
                             }
                         }
                         if ($add) {
                             $json[$type] = array_merge($json[$type], $feedData[$type]);
                         }
                     } else {
                         $json[$type] = array_merge($json[$type], $feedData[$type]);
                     }
                 } else {
                     $json[$type] = $feedData[$type];
                 }
                 $json['created'] = (int) time();
                 $file->write($filename_tmp, json_encode($json, JSON_HEX_QUOT));
             } else {
                 $feedData['created'] = (int) time();
                 $file->write($filename_tmp, json_encode($feedData, JSON_HEX_QUOT));
             }
         } else {
             $filename_tmp = Mage::helper('clerk')->getFileName($store, $tmp = true);
             $filename = Mage::helper('clerk')->getFileName($store, $tmp = false);
             $path = Mage::getBaseDir('media') . "/clerk/feeds/";
             $file = new Varien_Io_File();
             $file->checkAndCreateFolder($path);
             $file->open(array('path' => $path));
             $file->mv($filename_tmp, $filename);
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('clerk')->__("Done building feed. Data stored in %s", $filename));
             Mage::getModel('clerk/communicator')->startImportOfFeed($storeId);
         }
     }
     return true;
 }
开发者ID:KingIsulgard,项目名称:clerk-magento,代码行数:61,代码来源:FeedAjax.php


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