Created
March 27, 2016 12:29
-
-
Save av-jok/675ce225a125dd8f113b to your computer and use it in GitHub Desktop.
Translit non-latin (cyrillic etc.) names of uploadig files to latin with timestamp by modx cleanAlias()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Привязывать к событию OnFileManagerUpload. | |
$currentdoc = $modx->newObject('modResource'); | |
foreach($files as $file) | |
{ | |
if($file['error'] == 0) | |
{ | |
$pathInfo = pathinfo($file['name']); | |
$oldPath = $directory.$file['name']; | |
$newPath = date("Y-m-d-h-s-").$currentdoc->cleanAlias($pathInfo['filename']).'.'. $pathInfo['extension']; | |
$source->renameObject($oldPath, $newPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment