本文整理汇总了PHP中Varien_Io_File::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::close方法的具体用法?PHP Varien_Io_File::close怎么用?PHP Varien_Io_File::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::close方法的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();
}
示例2: export
/**
* Export function:
* - Returns false, if an error occured or if there are no orders to export
* - Returns array, containing the filename and the file contents
*
* @return bool|array
*/
public function export()
{
$collection = $this->_hasOrdersToExport();
if (!$collection) {
return false;
}
$fileName = $this->getFileName();
// Open file
$file = new Varien_Io_File();
$file->open(array('path' => Mage::getBaseDir('var')));
$file->streamOpen($fileName);
// Add headline
$row = array('Kundenname', 'BLZ', 'Kontonummer', 'BIC/Swift-Code', 'IBAN', 'Betrag', 'Verwendungszweck');
$file->streamWriteCsv($row);
// Add rows
foreach ($collection as $order) {
/* @var $orderModel Mage_Sales_Model_Order */
$orderModel = Mage::getModel('sales/order')->load($order->getData('entity_id'));
/* @var $paymentMethod Itabs_Debit_Model_Debit */
$paymentMethod = $orderModel->getPayment()->getMethodInstance();
// Format order amount
$amount = number_format($order->getData('grand_total'), 2, ',', '.');
$row = array('name' => $paymentMethod->getAccountName(), 'bank_code' => $paymentMethod->getAccountBLZ(), 'account_number' => $paymentMethod->getAccountNumber(), 'account_swift' => $paymentMethod->getAccountSwift(), 'account_iban' => $paymentMethod->getAccountIban(), 'amount' => $amount . ' ' . $order->getData('order_currency_code'), 'purpose' => 'Bestellung Nr. ' . $order->getData('increment_id'));
$file->streamWriteCsv($row);
$this->_getDebitHelper()->setStatusAsExported($order->getId());
}
// Close file, get file contents and delete temporary file
$file->close();
$filePath = Mage::getBaseDir('var') . DS . $fileName;
$fileContents = file_get_contents($filePath);
$file->rm($fileName);
$response = array('file_name' => $fileName, 'file_content' => $fileContents);
return $response;
}
示例3: 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();
}
示例4: checkFolderExists
/**
* @param $path
* @return bool
*/
private function checkFolderExists($path)
{
try {
$io_proxy = new Varien_Io_File();
$io_proxy->setAllowCreateFolders(true);
$io_proxy->open(array($path));
$io_proxy->close();
unset($io_proxy);
return true;
} catch (Exception $e) {
return false;
}
}
示例5: _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;
}
示例6: _generateCss
private function _generateCss($store)
{
$io = new Varien_Io_File();
$path = Mage::getBaseDir("skin") . DS . 'frontend' . DS . 'base' . DS . 'default' . DS . 'css' . DS . 'weltpixel' . DS;
$name = 'color_' . $store->getCode() . '.css';
$file = $path . DS . $name;
$io->setAllowCreateFolders(true);
$io->open(array('path' => $path));
$io->streamOpen($file, 'w+');
$io->streamLock(true);
$cssContent = Mage::helper('selector')->getDynamicCssContent($store->getId());
$io->streamWrite($cssContent);
$io->close();
}
示例7: _getRuleClasses
protected function _getRuleClasses()
{
$classes = array();
$rulesDir = Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Model' . DS . 'Rule' . DS . 'Condition';
$io = new Varien_Io_File();
$io->open();
$io->cd($rulesDir);
foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) {
if ($event['filetype'] != 'php') {
continue;
}
$info = pathinfo($event['text']);
$class = strtolower($info['filename']);
$classes[$class] = 'email/rule_condition_' . strtolower($class);
}
$io->close();
return $classes;
}
示例8: getVariablesHelpers
public function getVariablesHelpers()
{
$result = array();
$pathes = array('email' => Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Helper' . DS . 'Variables', 'emaildesign' => Mage::getModuleDir('', 'Mirasvit_EmailDesign') . DS . 'Helper' . DS . 'Variables');
$io = new Varien_Io_File();
$io->open();
foreach ($pathes as $pathKey => $path) {
$io->cd($path);
foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) {
if ($event['filetype'] != 'php') {
continue;
}
$info = pathinfo($event['text']);
$result[] = $pathKey . '/variables_' . strtolower($info['filename']);
}
}
$io->close();
return $result;
}
示例9: 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);
}
示例10: 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;
}
示例11: 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;
}
示例12: update
public static function update()
{
Mage::log('Fontis/Australia_Model_MyShopping_Cron: Entered update function');
if (Mage::getStoreConfig('fontis_feeds/myshoppingfeed/active')) {
$io = new Varien_Io_File();
$io->setAllowCreateFolders(true);
$io->open(array('path' => self::getPath()));
// Loop through all stores:
foreach (Mage::app()->getStores() as $store) {
Mage::log('Fontis/Australia_Model_MyShopping_Cron: Processing store: ' . $store->getName());
$clean_store_name = str_replace('+', '-', strtolower(urlencode($store->getName())));
Fontis_Australia_Model_MyShopping_Cron::$debugCount = 0;
// Write the entire products xml file:
Mage::log('Fontis/Australia_Model_MyShopping_Cron: Generating All Products XML File');
$products_result = self::getProductsXml($store);
$filename = $clean_store_name . '-products.xml';
$io->write($filename, $products_result['xml']);
Mage::log('Fontis/Australia_Model_MyShopping_Cron: Wrote ' . Fontis_Australia_Model_MyShopping_Cron::$debugCount . " records to " . self::getPath() . $filename);
}
$io->close();
} else {
Mage::log('Fontis/Australia_Model_MyShopping_Cron: Disabled');
}
}
示例13: getThemeCustomizePath
public function getThemeCustomizePath($theme = "")
{
$tmp_theme = explode("/", $theme);
if (count($tmp_theme) == 1) {
$theme = "default/" . $theme;
}
$customize_path = Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/customize/";
if (!file_exists($customize_path)) {
$file = new Varien_Io_File();
$file->mkdir($customize_path);
$file->close();
}
return $customize_path;
}
示例14: beforeSave
/**
*
* especially developed for copying when we get incoming data as an image collection
* instead of plain post...
*
*/
public function beforeSave($object)
{
$storeId = $object->getStoreId();
$attributeId = $this->getAttribute()->getId();
$entityId = $object->getId();
$entityIdField = $this->getEntityIdField();
$entityTypeId = $this->getAttribute()->getEntity()->getTypeId();
$connection = $this->getConnection('write');
$values = $object->getData($this->getAttribute()->getName());
if (!is_array($values) && is_object($values)) {
foreach ((array) $values->getItems() as $image) {
// TOFIX
$io = new Varien_Io_File();
$value = $image->getData();
$data = array();
$data[$entityIdField] = $entityId;
$data['attribute_id'] = $attributeId;
$data['position'] = $value['position'];
$data['entity_type_id'] = $entityTypeId;
$data['store_id'] = $storeId;
if ($entityId) {
$connection->insert($this->getTable(), $data);
$lastInsertId = $connection->lastInsertId();
} else {
continue;
}
unset($newFileName);
$types = $this->getImageTypes();
foreach ($types as $type) {
try {
$io->open();
$path = Mage::getStoreConfig('system/filesystem/upload', 0);
$io->cp($path . '/' . $type . '/' . 'image_' . $entityId . '_' . $value['value_id'] . '.' . 'jpg', $path . '/' . $type . '/' . 'image_' . $entityId . '_' . $lastInsertId . '.' . 'jpg');
$io->close();
} catch (Exception $e) {
continue;
}
$newFileName = 'image_' . $entityId . '_' . $lastInsertId . '.' . 'jpg';
}
$condition = array($connection->quoteInto('value_id = ?', $lastInsertId));
if (isset($newFileName)) {
$data = array();
$data['value'] = $newFileName;
$connection->update($this->getTable(), $data, $condition);
} else {
$connection->delete($this->getTable(), $condition);
}
}
$object->setData($this->getAttribute()->getName(), array());
}
return parent::beforeSave($object);
}
示例15: saveAction
public function saveAction()
{
$action = "";
if ($data = $this->getRequest()->getPost()) {
$action = $this->getRequest()->getParam('action');
$themecontrol = isset($data['themecontrol']) ? $data['themecontrol'] : '';
$internal_modules = isset($data['module']) ? $data['module'] : array();
if (isset($_FILES['bg_image']['name']) && $_FILES['bg_image']['name'] != '') {
try {
/* Starting upload */
$uploader = new Varien_File_Uploader('bg_image');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(false);
// Set the file upload mode
// false -> get the file directly in the specified folder
// true -> get the file in the product like folders
// (file.jpg will go in something like /media/f/i/file.jpg)
$uploader->setFilesDispersion(false);
// We set media as the upload dir
$path = Mage::getBaseDir('media') . '/ves_tempcp/upload/';
$uploader->save($path, $_FILES['bg_image']['name']);
} catch (Exception $e) {
}
//this way the name is saved in DB
$themecontrol['bg_image'] = 'ves_tempcp/upload/' . $_FILES['bg_image']['name'];
} elseif (isset($themecontrol['bg_image']) && strpos($themecontrol['bg_image'], "ves_tempcp/upload/") === false) {
$themecontrol['bg_image'] = "ves_tempcp/upload/" . $themecontrol['bg_image'];
} elseif (isset($data['delete_bg_image']) && $data['delete_bg_image']) {
if (file_exists(Mage::getBaseDir('media') . "/" . $themecontrol['bg_image'])) {
@unlink(Mage::getBaseDir('media') . "/" . $themecontrol['bg_image']);
}
$themecontrol['bg_image'] = "";
}
if (isset($themecontrol['custom_logo']) && strpos($themecontrol['custom_logo'], "images/") === false) {
$themecontrol['custom_logo'] = "images/" . $themecontrol['custom_logo'];
} elseif (isset($data['delete_custom_logo']) && $data['delete_custom_logo']) {
if (file_exists(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo'])) {
@unlink(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo']);
}
$themecontrol['custom_logo'] = "";
}
if (isset($themecontrol['custom_logo_small']) && strpos($themecontrol['custom_logo_small'], "images/") === false) {
$themecontrol['custom_logo_small'] = "images/" . $themecontrol['custom_logo_small'];
} elseif (isset($data['delete_custom_logo_small']) && $data['delete_custom_logo_small']) {
if (file_exists(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo_small'])) {
@unlink(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo_small']);
}
$themecontrol['custom_logo_small'] = "";
}
$data = array();
$custom_css = "";
if (isset($themecontrol['custom_css'])) {
$custom_css = trim($themecontrol['custom_css']);
unset($themecontrol['custom_css']);
}
$theme_id = $this->getRequest()->getParam('id');
$data['params'] = base64_encode(serialize($themecontrol));
$data['group'] = isset($themecontrol['default_theme']) ? $themecontrol['default_theme'] : 'ves default theme';
$data['is_default'] = 1;
$data['stores'] = $this->getRequest()->getParam('stores');
$_model = Mage::getModel('ves_tempcp/theme')->load($theme_id);
/*
if(empty($data['theme_id']) && $_model->checkExistsByGroup($data['group'])){
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('The Theme is exist, you can not create a same theme!'));
*/
// $this->_redirect('*/*/');
/* return;
}*/
$_model->setData($data);
if ($theme_id) {
$_model->setId($theme_id);
}
try {
$_model->save();
/*Save custom css*/
if (!empty($custom_css)) {
$theme_group = $_model->getGroup();
$tmp_theme = explode("/", $theme_group);
if (count($tmp_theme) == 1) {
$theme_group = "default/" . $theme_group;
}
$custom_css_path = Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/css/local/";
if (!file_exists($custom_css_path)) {
$file = new Varien_Io_File();
$file->mkdir($custom_css_path);
$file->close();
}
Mage::helper("ves_tempcp")->writeToCache($custom_css_path, "custom", $custom_css);
}
/*End save custom css*/
/*Save internal modules*/
$theme_id = $_model->getId();
Mage::getModel('ves_tempcp/module')->cleanModules($theme_id);
if (!empty($internal_modules)) {
foreach ($internal_modules as $position => $modules) {
if ($modules) {
foreach ($modules as $key => $module) {
//.........这里部分代码省略.........