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