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


PHP Varien_Io_File类代码示例

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


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

示例1: getPatchefiles

 public function getPatchefiles()
 {
     /* Mage::getBaseDir('etc') . DS . 'applied.patches.list'; */
     $path = BP . DS . "app" . DS . "etc" . DS;
     $filename = 'applied.patches.list';
     $filepath = $path . $filename;
     if (!file_exists($filepath)) {
         return "No Patch file found.";
     }
     if (!is_readable($filepath)) {
         return "Patch file is not readable.";
     }
     $flocal = new Varien_Io_File();
     $flocal->open(array('path' => dirname($filepath)));
     $flocal->streamOpen($filepath, 'r');
     $patch_install_version = array();
     $patch_uninstall_version = array();
     $patch_version = array();
     while (false !== ($patchFileLines = $flocal->streamReadCsv())) {
         if (strpos($patchFileLines[0], 'SUPEE') !== false) {
             $patch_name = explode('|', $patchFileLines[0]);
             $patch_install_version[] = str_replace("SUPEE-", '', $patch_name[1]);
         }
         if (strpos($patchFileLines[0], 'REVERTED') !== false) {
             $patch_name = explode('|', $patchFileLines[0]);
             $patch_uninstall_version[] = str_replace("SUPEE-", '', $patch_name[1]);
         }
     }
     $patch_install_version = array_unique($patch_install_version);
     $patch_uninstall_version = array_unique($patch_uninstall_version);
     $patch_version = array_diff($patch_install_version, $patch_uninstall_version);
     return implode(",", $patch_version);
 }
开发者ID:vijays91,项目名称:Magento-Security-Patches,代码行数:33,代码来源:Data.php

示例2: regenerate

 /**
  * regenerate theme css based on appearance settings
  */
 public function regenerate()
 {
     $websites = Mage::app()->getWebsites();
     foreach ($websites as $_website) {
         $_website_code = $_website->getCode();
         foreach ($_website->getStores() as $_store) {
             if (!Mage::app()->getStore($_store)->getIsActive()) {
                 continue;
             }
             ob_start();
             require $this->_css_template_path;
             $css = ob_get_clean();
             $filename = str_replace(array('%WEBSITE%', '%STORE%'), array($_website_code, $_store->getCode()), $this->_css_file);
             try {
                 $file = new Varien_Io_File();
                 $file->setAllowCreateFolders(true)->open(array('path' => $this->_css_path));
                 $file->streamOpen($filename, 'w+');
                 $file->streamWrite($css);
                 $file->streamClose();
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('athlete')->__('Css generation error: %s', $this->_css_path . $filename) . '<br/>' . $e->getMessage());
                 Mage::logException($e);
             }
         }
     }
 }
开发者ID:bigtailbear14,项目名称:rosstheme,代码行数:29,代码来源:Css.php

示例3: uninstall

 final function uninstall(Varien_Event_Observer $observer)
 {
     $module = $observer->getEvent()->getModule();
     if (0 !== strpos(get_class($this), $module)) {
         return false;
     }
     $this->run();
     $manifestPath = str_replace('_', '/', $module) . '/etc/manifest.xml';
     foreach (explode(PS, get_include_path()) as $includePath) {
         if (file_exists($includePath . DS . $manifestPath)) {
             $manifestPath = $includePath . DS . $manifestPath;
             break;
         }
     }
     if (!file_exists($manifestPath)) {
         throw new Exception('Manifest path "' . $manifestPath . '" does not exist');
     }
     $manifestXml = new SimpleXMLElement($manifestPath, null, true);
     $paths = $manifestXml->xpath('/manifest/' . $module . '/paths/path');
     $file = new Varien_Io_File();
     foreach ($paths as $path) {
         $path = BP . DS . $path;
         if (file_exists($path)) {
             if (is_dir($path)) {
                 $file->rmdir($path, true);
             } else {
                 $file->rm($path);
             }
         }
     }
     $this->_removeResources($module);
 }
开发者ID:Jonathonbyrd,项目名称:Optimized-Magento-1.9.x,代码行数:32,代码来源:Abstract.php

示例4: checkFolderPermissionsErrors

 /**
  * Check is folders exist and have writable permissions
  *
  * @return string Error message if exist
  */
 public function checkFolderPermissionsErrors()
 {
     $arrFolders = array('image_dir' => Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage::helper('nwdrevslider/images')->getImageDir(), 'thumb_dir' => Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage::helper('nwdrevslider/images')->getImageThumbDir(), 'admin_css_dir' => Mage::getBaseDir() . Mage::helper('nwdrevslider/css')->getAdminCssDir(), 'front_css_dir' => Mage::getBaseDir() . Mage::helper('nwdrevslider/css')->getFrontCssDir());
     $ioFile = new Varien_Io_File();
     $arrErrors = array();
     foreach ($arrFolders as $_folder) {
         try {
             if (!($ioFile->checkandcreatefolder($_folder) && $ioFile->isWriteable($_folder))) {
                 $arrErrors[] = $_folder;
             }
         } catch (Exception $e) {
             $arrErrors[] = $_folder;
             Mage::logException($e);
         }
     }
     if (!(in_array($arrFolders['admin_css_dir'], $arrErrors) || in_array($arrFolders['front_css_dir'], $arrErrors))) {
         if (!file_exists($arrFolders['admin_css_dir'] . 'statics.css')) {
             Mage::helper('nwdrevslider/css')->putStaticCss();
         }
         if (!file_exists($arrFolders['admin_css_dir'] . 'dynamic.css')) {
             Mage::helper('nwdrevslider/css')->putDynamicCss();
         }
     }
     $strError = $arrErrors ? Mage::helper('nwdrevslider')->__('Following directories not found or not writable, please change permissions to: ') . implode(' , ', $arrErrors) : '';
     return $strError;
 }
开发者ID:perseusl,项目名称:kingdavid,代码行数:31,代码来源:Masterview.php

示例5: __construct

 /**
  * Set base dir
  */
 public function __construct()
 {
     $this->_baseDir = Mage::getBaseDir('var') . DS . 'connect';
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true)->createDestinationDir($this->_baseDir);
     $this->addTargetDir($this->_baseDir);
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:10,代码来源:Collection.php

示例6: createModule

 public function createModule($data)
 {
     $namespace = $this->_cleanString($data['namespace']);
     $module = $this->_cleanString($data['module']);
     $pool = $data['pool'];
     $version = $this->_cleanString($data['version']);
     $dependencies = array();
     if (isset($data['depends'])) {
         foreach ($data['depends'] as $dependency) {
             $dependencies[] = sprintf('%s<%s />', str_repeat(' ', 4 * 4), $dependency);
         }
     }
     $replacements = array('{{Namespace}}' => $namespace, '{{namespace}}' => strtolower($namespace), '{{Module}}' => $module, '{{module}}' => strtolower($module), '{{pool}}' => $pool, '{{version}}' => $version, '{{depends}}' => implode(PHP_EOL, $dependencies));
     $io = new Varien_Io_File();
     $tplDir = $this->getTemplateDir();
     $tmpDir = $this->getTmpModuleDir($namespace . '_' . $module);
     $io->checkAndCreateFolder($tmpDir);
     if (!$io->isWriteable($tmpDir)) {
         Mage::throwException('Module temp dir is not writeable');
     }
     @shell_exec("cp -r {$tplDir} {$tmpDir}");
     $files = $this->_getTemplateFiles($tmpDir);
     if (empty($files)) {
         Mage::throwException('Could not copy templates files to module temp dir');
     }
     $this->_replaceVars($tmpDir, $replacements);
     $dest = Mage::getBaseDir();
     if (!$io->isWriteable($dest)) {
         Mage::throwException(sprintf('Could not move module files to Magento tree. However, module structure is available in %s', $tmpDir));
     }
     @shell_exec("cp -r {$tmpDir} {$dest}");
     return true;
 }
开发者ID:piotr0beschel,项目名称:magento-module-factory,代码行数:33,代码来源:Data.php

示例7: cleanImageCache

 /**
  * Flush the media/slider/resized folder, when the catalog image cache is flushed
  *
  * @param Varien_Event_Observer $observer
  * @return Soon_Image_Model_Observer
  */
 public function cleanImageCache(Varien_Event_Observer $observer)
 {
     $directory = Mage::getBaseDir('media') . DS . 'slider' . DS . 'resized' . DS;
     $io = new Varien_Io_File();
     $io->rmdir($directory, true);
     return $this;
 }
开发者ID:christinecardoso,项目名称:AntoineK_Slider,代码行数:13,代码来源:Observer.php

示例8: save

 public function save($destination = null, $newName = null)
 {
     $fileName = !isset($destination) ? $this->_fileName : $destination;
     if (isset($destination) && isset($newName)) {
         $fileName = $destination . "/" . $fileName;
     } elseif (isset($destination) && !isset($newName)) {
         $info = pathinfo($destination);
         $fileName = $destination;
         $destination = $info['dirname'];
     } elseif (!isset($destination) && isset($newName)) {
         $fileName = $this->_fileSrcPath . "/" . $newName;
     } else {
         $fileName = $this->_fileSrcPath . $this->_fileSrcName;
     }
     $destinationDir = isset($destination) ? $destination : $this->_fileSrcPath;
     if (!is_writable($destinationDir)) {
         try {
             $io = new Varien_Io_File();
             $io->mkdir($destination);
         } catch (Exception $e) {
             throw new Exception("Unable to write file into directory '{$destinationDir}'. Access forbidden.");
         }
     }
     // keep alpha transparency
     $isAlpha = false;
     $this->_getTransparency($this->_imageHandler, $this->_fileType, $isAlpha);
     if ($isAlpha) {
         $this->_fillBackgroundColor($this->_imageHandler);
     }
     call_user_func($this->_getCallback('output'), $this->_imageHandler, $fileName);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:31,代码来源:Gd2.php

示例9: getCSVFile

 public function getCSVFile()
 {
     $data = $this->dataExport;
     if ($this->isVersion13) {
         $content = '';
         foreach ($data as $val) {
             $content .= implode(',', $val) . "\r\n";
         }
         return $content;
     } else {
         $io = new Varien_Io_File();
         $path = Mage::getBaseDir('var') . DS . 'export' . DS;
         $name = md5(microtime());
         $file = $path . DS . $name . '.csv';
         $io->setAllowCreateFolders(true);
         $io->open(array('path' => $path));
         $io->streamOpen($file, 'w+');
         $io->streamLock(true);
         // $this->dataExport[0] == csvHeader
         $io->streamWriteCsv($data[0]);
         unset($data[0]);
         //$delimiter = Mage::getSingleton('core/session')->getExportSeperator();
         foreach ($data as $val) {
             $io->streamWriteCsv($val);
         }
         return array('type' => 'filename', 'value' => $file, 'rm' => false);
     }
 }
开发者ID:xiaoguizhidao,项目名称:storebaby.it,代码行数:28,代码来源:Export.php

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

示例11: save

 /**
  * Write file to file system.
  *
  * @param null $destination
  * @param null $newName
  * @throws Exception
  */
 public function save($destination = null, $newName = null)
 {
     Varien_Profiler::start(__METHOD__);
     if (isset($destination) && isset($newName)) {
         $fileName = $destination . "/" . $newName;
     } elseif (isset($destination) && !isset($newName)) {
         $info = pathinfo($destination);
         $fileName = $destination;
         $destination = $info['dirname'];
     } elseif (!isset($destination) && isset($newName)) {
         $fileName = $this->_fileSrcPath . "/" . $newName;
     } else {
         $fileName = $this->_fileSrcPath . $this->_fileSrcName;
     }
     $destinationDir = isset($destination) ? $destination : $this->_fileSrcPath;
     if (!is_writable($destinationDir)) {
         try {
             $io = new Varien_Io_File();
             $io->mkdir($destination);
         } catch (Exception $e) {
             Varien_Profiler::stop(__METHOD__);
             throw new Exception("Unable to write into directory '{$destinationDir}'.");
         }
     }
     //set compression quality
     $this->getImageMagick()->setImageCompressionQuality($this->getQuality());
     //remove all underlying information
     $this->getImageMagick()->stripImage();
     //write to file system
     $this->getImageMagick()->writeImage($fileName);
     //clear data and free resources
     $this->getImageMagick()->clear();
     $this->getImageMagick()->destroy();
     Varien_Profiler::stop(__METHOD__);
 }
开发者ID:erlisdhima,项目名称:Perfect_Watermarks,代码行数:42,代码来源:Imagemagic.php

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

示例13: resizeImg

 /**
  * Resize image
  *
  * @param string $fileName
  * @param int $width
  * @param int $height
  * @return string Resized image url
  */
 public function resizeImg($fileName, $width, $height = '')
 {
     if (!$height) {
         $height = $width;
     }
     $thumbDir = self::IMAGE_THUMB_DIR;
     $resizeDir = $thumbDir . "/resized_{$width}x{$height}";
     $ioFile = new Varien_Io_File();
     $ioFile->checkandcreatefolder(Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir);
     $imageParts = explode('/', $fileName);
     $imageFile = end($imageParts);
     $folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     $imageURL = $folderURL . $fileName;
     $basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $fileName;
     $newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir . DS . $imageFile;
     if ($width != '') {
         if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
             $imageObj = new Varien_Image($basePath);
             $imageObj->constrainOnly(TRUE);
             $imageObj->keepAspectRatio(TRUE);
             $imageObj->keepFrame(FALSE);
             $imageObj->keepTransparency(TRUE);
             //$imageObj->backgroundColor(array(255,255,255));
             $imageObj->resize($width, $height);
             $imageObj->save($newPath);
         }
         $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $resizeDir . '/' . $imageFile;
     } else {
         $resizedURL = $imageURL;
     }
     return $resizedURL;
 }
开发者ID:perseusl,项目名称:kingdavid,代码行数:40,代码来源:Images.php

示例14: import

 /**
  * @$forceCreation true overwrites existing entities with the new values
  */
 public function import($forceCreation = false)
 {
     if (is_null($this->_entity)) {
         throw Mage::exception('Please specify a valid entity.');
     }
     if (!file_exists($this->_importFile)) {
         throw Mage::exception('Please specify a valid csv file.');
     }
     if (is_null($this->_storeId)) {
         throw Mage::exception('Please specify a valid store.');
     }
     $io = new Varien_Io_File();
     $io->streamOpen($this->_importFile, 'r');
     $io->streamLock(true);
     $firstLine = true;
     while (false !== ($line = $io->streamReadCsv())) {
         if ($firstLine) {
             $firstLine = false;
             $this->_headerColumns = $line;
             continue;
         }
         $data = array();
         foreach ($this->_headerColumns as $key => $val) {
             $data[$val] = $line[$key];
         }
         $this->_importEntity($data, $forceCreation);
     }
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:31,代码来源:Import.php

示例15: fileUploadAction

 /**
  * @todo better subdirectories
  *       saves a file in the dir: media/wysiwyg/markdown/....
  *
  * @return $this
  */
 public function fileUploadAction()
 {
     $return = array('err' => TRUE, 'msg' => 'An error occurred.', 'fileUrl' => '');
     $binaryData = base64_decode($this->getRequest()->getParam('binaryData', ''));
     $file = json_decode($this->getRequest()->getParam('file', '[]'), TRUE);
     if (!(isset($file['extra']['nameNoExtension']) && isset($file['extra']['extension'])) || empty($binaryData)) {
         $return['msg'] = 'Either fileName or binaryData or file is empty ...';
         return $this->_setReturn($return, TRUE);
     }
     $fileName = $file['extra']['nameNoExtension'] . '.' . $file['extra']['extension'];
     if (strpos(strtolower($fileName), 'clipboard') !== FALSE) {
         $fileName = 'clipboard_' . date('Ymd-His') . '_' . str_replace('clipboard', '', strtolower($fileName));
     }
     $fileName = preg_replace('~[^\\w\\.]+~i', '_', $fileName);
     $savePath = $this->_getStorageRoot() . $this->_getStorageSubDirectory();
     $io = new Varien_Io_File();
     if ($io->checkAndCreateFolder($savePath)) {
         $result = (int) file_put_contents($savePath . $fileName, $binaryData);
         // io->write will not work :-(
         if ($result > 10) {
             $return['err'] = FALSE;
             $return['msg'] = '';
             $return['fileUrl'] = Mage::helper('markdown')->getTemplateMediaUrl($this->_getStorageSubDirectory() . $fileName);
         }
     }
     $this->_setReturn($return, TRUE);
 }
开发者ID:ho-nl-fork,项目名称:magento1-SchumacherFM_Markdown,代码行数:33,代码来源:MarkdownController.php


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