本文整理汇总了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;
}
示例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;
}