mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
add function getFilenameByDocname()
This commit is contained in:
parent
769706fe9c
commit
56bbdefced
|
@ -367,6 +367,34 @@ function utf8_basename($path, $suffix='') { /* {{{ */
|
|||
return $file;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return a valid file name
|
||||
*
|
||||
* This function returns a valid file name for the given document content
|
||||
* or an arbitrary string. If a document content is given the name of
|
||||
* the document will be used. The extension of the file name will be
|
||||
* either taken from the document name or the original file. If the two
|
||||
* differ the extension from the original file name will be used.
|
||||
*
|
||||
* @param object|string $content document content or an arbitrary string
|
||||
* @return string valid file name
|
||||
*/
|
||||
function getFilenameByDocname($content) { /* {{{ */
|
||||
if(is_string) {
|
||||
$filename = $content;
|
||||
} else {
|
||||
$document = $content->getDocument();
|
||||
$ext = pathinfo($document->getName(), PATHINFO_EXTENSION);
|
||||
$oext = pathinfo($content->getOriginalFileName(), PATHINFO_EXTENSION);
|
||||
if($ext == $oext)
|
||||
$filename = $document->getName();
|
||||
else {
|
||||
$filename = $document->getName().'.'.$oext;
|
||||
}
|
||||
}
|
||||
return mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
|
||||
} /* }}} */
|
||||
|
||||
function getLogger($prefix='') { /* {{{ */
|
||||
global $settings;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user