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


PHP Mage_Core_Model_File_Uploader::getNewFileName方法代码示例

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


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

示例1: getNewFileName

 public static function getNewFileName($destFile, $file = null)
 {
     if (!Mage::getStoreConfigFlag('magefm_cdn/general/enabled')) {
         return parent::getNewFileName($destFile);
     }
     if (is_null($file)) {
         Mage::throwException('Can\'t convert filename.');
     }
     if (!Mage::helper('magefm_cdn/storage')->fileExists($destFile . '/' . $file)) {
         return $file;
     }
     $ext = null;
     $i = 0;
     if (preg_match('#(.*)\\.([a-z0-9_-]*)$#', $file, $matches)) {
         $name = $matches[1];
         $ext = $matches[2];
     } else {
         $name = $file;
     }
     do {
         $i++;
         $fileName = "{$name}_{$i}" . (is_null($ext) ? '' : '.' . $ext);
     } while (Mage::helper('magefm_cdn/storage')->fileExists($destFile . '/' . $fileName));
     return $fileName;
 }
开发者ID:carriercomm,项目名称:cdn-17,代码行数:25,代码来源:Uploader.php

示例2: prepareForSave

 public function prepareForSave($data)
 {
     $this->_deleteFile = (bool) $data['delete'];
     if ($this->_deleteFile) {
         return '';
     }
     $fileName = !empty($data['value']) ? $data['value'] : $data['existing'];
     return Mage_Core_Model_File_Uploader::getNewFileName(strtolower($fileName));
 }
开发者ID:riker09,项目名称:EasyTemplate,代码行数:9,代码来源:File.php

示例3: _getNotDuplicatedFilename

 /**
  * Get filename which is not duplicated with other files in media temporary and media directories
  *
  * @param String $fileName
  * @param String $dispretionPath
  * @return String
  */
 protected function _getNotDuplicatedFilename($fileName, $dispretionPath)
 {
     $fileMediaName = $dispretionPath . DS . Mage_Core_Model_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($fileName));
     $fileTmpMediaName = $dispretionPath . DS . Mage_Core_Model_File_Uploader::getNewFileName($this->_getConfig()->getTmpMediaPath($fileName));
     if ($fileMediaName != $fileTmpMediaName) {
         if ($fileMediaName != $fileName) {
             return $this->_getNotDuplicatedFileName($fileMediaName, $dispretionPath);
         } elseif ($fileTmpMediaName != $fileName) {
             return $this->_getNotDuplicatedFilename($fileTmpMediaName, $dispretionPath);
         }
     }
     return $fileMediaName;
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:20,代码来源:Media.php

示例4: _moveFileFromTmp

 /**
  * Move file from tmp path to base path
  *
  * @param string $baseTmpPath
  * @param string $basePath
  * @param string $file
  * @return string
  */
 protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->getFilePath($basePath, $file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = dirname($file) . $ioObject->dirsep() . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
     Mage::helper('Mage_Core_Helper_File_Storage_Database')->copyFile($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     $result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:26,代码来源:File.php

示例5: _getUniqueFileName

 /**
  * Check whether file to move exists. Getting unique name
  *
  * @param <type> $file
  * @param <type> $dirsep
  * @return string
  */
 protected function _getUniqueFileName($file, $dirsep)
 {
     if ($this->_checkDb()) {
         $destFile = Mage::helper('core/file_storage_database')->getUniqueFilename(Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrlAddition(), $file);
     } else {
         $destFile = dirname($file) . $dirsep;
         if (version_compare(Mage::getVersion(), '1.5') > 0) {
             $destFile .= Mage_Core_Model_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
         } else {
             $destFile .= Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
         }
     }
     return $destFile;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:21,代码来源:Copyimg.php

示例6: _getUniqueFileName

 /**
  * Check whether file to move exists. Getting unique name
  *
  * @param string  $file
  * @param  string $dirsep
  * @return string
  */
 protected function _getUniqueFileName($file, $dirsep)
 {
     if (Mage::helper('core/file_storage_database')->checkDbUsage()) {
         $destFile = Mage::helper('core/file_storage_database')->getUniqueFilename($this->_getConfig()->getBaseMediaUrlAddition(), $file);
     } else {
         $destFile = dirname($file) . $dirsep . Mage_Core_Model_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
     }
     return $destFile;
 }
开发者ID:kalburgimanjunath,项目名称:magento-dealers,代码行数:16,代码来源:Gallery.php


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