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


PHP Varien_Io_File::checkandcreatefolder方法代码示例

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


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

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

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


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