本文整理汇总了PHP中CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension方法的典型用法代码示例。如果您正苦于以下问题:PHP CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension方法的具体用法?PHP CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension怎么用?PHP CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKFinder_Connector_Utils_FileSystem
的用法示例。
在下文中一共展示了CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoRename
/**
* Autorename file if previous name is already taken
*
* @param string $filePath
* @param string $fileName
* @param string $sFileNameOrginal
*/
public static function autoRename($filePath, $fileName)
{
$sFileNameOrginal = $fileName;
$iCounter = 0;
while (true) {
$sFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($filePath, $fileName);
if (file_exists($sFilePath)) {
$iCounter++;
$fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension($sFileNameOrginal, false) . "(" . $iCounter . ")" . "." . CKFinder_Connector_Utils_FileSystem::getextension($sFileNameOrginal, false);
} else {
break;
}
}
return $fileName;
}
示例2: buildXml
/**
* handle request and build XML
* @access protected
*
*/
function buildXml()
{
if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$this->checkConnector();
$this->checkRequest();
//resizing to 1x1 is almost equal to deleting a file, that's why FILE_DELETE permissions are required
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE) || !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$_config =& CKFinder_Connector_core_Factory::getInstance("core_config");
$resourceTypeInfo = $this->_currentFolder->getResourceTypeconfig();
if (!isset($_POST["fileName"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if (!$resourceTypeInfo->checkextension($fileName, false)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
if (!file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
$newWidth = trim($_POST['width']);
$newHeight = trim($_POST['height']);
$quality = 80;
$resizeOriginal = !empty($_POST['width']) && !empty($_POST['height']);
if ($resizeOriginal) {
if (!preg_match("/^\\d+\$/", $newWidth) || !preg_match("/^\\d+\$/", $newHeight) || !preg_match("/^\\d+\$/", $newWidth)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if (!isset($_POST["newFileName"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["newFileName"]);
if (!$resourceTypeInfo->checkextension($newFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
if (!is_writable(dirname($newFilePath))) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
if ($_POST['overwrite'] != "1" && file_exists($newFilePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
}
$_imagesconfig = $_config->getImagesconfig();
$maxWidth = $_imagesconfig->getMaxWidth();
$maxHeight = $_imagesconfig->getMaxHeight();
// Shouldn't happen as the JavaScript validation should not allow this.
if ($maxWidth > 0 && $newWidth > $maxWidth || $maxHeight > 0 && $newHeight > $maxHeight) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
}
require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
if ($resizeOriginal) {
$result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false);
if (!$result) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
}
$config = $this->getconfig();
$nameWithoutExt = preg_replace("/^(.+)\\_\\d+x\\d+\$/", "\$1", CKFinder_Connector_Utils_FileSystem::getFileNameWithoutextension($fileName));
$extension = CKFinder_Connector_Utils_FileSystem::getextension($fileName);
foreach (array('small', 'medium', 'large') as $size) {
if (!empty($_POST[$size]) && $_POST[$size] == '1') {
$thumbName = $nameWithoutExt . "_" . $size . "." . $extension;
$newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $thumbName);
if (!empty($config[$size . 'Thumb'])) {
if (preg_match("/^(\\d+)x(\\d+)\$/", $config[$size . 'Thumb'], $matches)) {
CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true);
}
}
}
}
}