mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 07:22:11 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
1667187613
|
@ -3729,6 +3729,9 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
function setMimeType($newMimetype) { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$newMimetype)
|
||||
return false;
|
||||
|
||||
$newMimetype = trim($newMimetype);
|
||||
|
||||
if(!$newMimetype)
|
||||
|
|
|
@ -395,6 +395,34 @@ function getFilenameByDocname($content) { /* {{{ */
|
|||
return mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return the mimetype of a given file
|
||||
*
|
||||
* This functions uses finfo but will correct some mimetypes which are
|
||||
* not propperly determined or could be more specific, e.g. text/plain
|
||||
* which is actually text/markdown. In thoses cases
|
||||
* the file extension will be taken into account.
|
||||
*
|
||||
* @param string $filename name of file on disc
|
||||
* @return string mimetype
|
||||
*/
|
||||
function getMimeType($filename) { /* {{{ */
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimetype = finfo_file($finfo, $filename);
|
||||
|
||||
switch($mimetype) {
|
||||
case 'application/octet-stream':
|
||||
case 'text/plain':
|
||||
$lastDotIndex = strrpos($filename, ".");
|
||||
if($lastDotIndex === false) $fileType = ".";
|
||||
else $fileType = substr($name, $lastDotIndex);
|
||||
if($fileType == '.md')
|
||||
$mimetype = 'text/markdown';
|
||||
break;
|
||||
}
|
||||
return $mimetype;
|
||||
} /* }}} */
|
||||
|
||||
function getLogger($prefix='', $mask=PEAR_LOG_INFO) { /* {{{ */
|
||||
global $settings;
|
||||
|
||||
|
|
|
@ -668,6 +668,37 @@ switch($command) {
|
|||
}
|
||||
break; /* }}} */
|
||||
|
||||
case 'setmimetype': /* {{{ */
|
||||
if($user && $user->isAdmin()) {
|
||||
if(checkFormKey('setmimetype', 'GET')) {
|
||||
$content = $dms->getDocumentContent($_REQUEST['contentid']);
|
||||
if($content) {
|
||||
$document = $content->getDocument();
|
||||
if ($document->getAccessMode($user) >= M_READWRITE) {
|
||||
$realmimetype = getMimeType($dms->contentDir . $content->getPath());
|
||||
if (!$content->setMimeType($realmimetype)) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>'Error setting mimetype', 'data'=>''));
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_mimetype_changed'), 'data'=>''));
|
||||
add_log_line();
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
||||
}
|
||||
}
|
||||
break; /* }}} */
|
||||
|
||||
case 'submittranslation': /* {{{ */
|
||||
if($settings->_showMissingTranslations) {
|
||||
if($user && !empty($_POST['phrase'])) {
|
||||
|
|
|
@ -358,9 +358,10 @@ $(document).ready( function() {
|
|||
print "<li>".htmlspecialchars($file->getName())."</li>\n";
|
||||
if($file->getName() != $file->getOriginalFileName())
|
||||
print "<li>".htmlspecialchars($file->getOriginalFileName())."</li>\n";
|
||||
if ($file_exists)
|
||||
if ($file_exists) {
|
||||
$realmimetype = getMimeType($dms->contentDir . $file->getPath());
|
||||
print "<li>".SeedDMS_Core_File::format_filesize(filesize($dms->contentDir . $file->getPath())) ." bytes, ".htmlspecialchars($file->getMimeType())."</li>";
|
||||
else print "<li>".htmlspecialchars($file->getMimeType())." - <span class=\"warning\">".getMLText("document_deleted")."</span></li>";
|
||||
} else print "<li>".htmlspecialchars($file->getMimeType())." - <span class=\"warning\">".getMLText("document_deleted")."</span></li>";
|
||||
|
||||
print "<li>".getMLText("uploaded_by")." <a href=\"mailto:".htmlspecialchars($responsibleUser->getEmail())."\">".htmlspecialchars($responsibleUser->getFullName())."</a></li>";
|
||||
print "<li>".getLongReadableDate($file->getDate())."</li>";
|
||||
|
@ -773,6 +774,11 @@ $(document).ready( function() {
|
|||
if ($file_exists) {
|
||||
print "<li>". SeedDMS_Core_File::format_filesize($latestContent->getFileSize()) .", ";
|
||||
print htmlspecialchars($latestContent->getMimeType());
|
||||
if($user->isAdmin()) {
|
||||
$realmimetype = getMimeType($dms->contentDir . $latestContent->getPath());
|
||||
if($realmimetype != $latestContent->getMimeType())
|
||||
echo " <i class=\"fa fa-exclamation-triangle ajax-click\" data-param1=\"command=setmimetype\" data-param2=\"contentid=".$latestContent->getId()."\" data-param3=\"formtoken=".createFormKey('setmimetype')."\" title=\"".htmlspecialchars($realmimetype)."\"></i> ";
|
||||
}
|
||||
if(in_array($latestContent->getMimeType(), ['image/jpeg', 'image/jpg', 'image/png', 'image/bmp'])) {
|
||||
$imsize = getimagesize($dms->contentDir . $latestContent->getPath(), $moreinfo);
|
||||
if(!empty($moreinfo['APP13'])) {
|
||||
|
|
|
@ -549,7 +549,13 @@ $(document).ready( function() {
|
|||
|
||||
$("body").on("click", ".ajax-click", function() { /* {{{ */
|
||||
var element = $(this);
|
||||
var url = element.data('href')+"?"+element.data('param1');
|
||||
var url = seeddms_webroot+"op/op.Ajax.php"+"?"+element.data('param1');
|
||||
var param2 = element.data('param2');
|
||||
var param3 = element.data('param3');
|
||||
if(typeof param2 !== 'undefined')
|
||||
url += "&"+param2;
|
||||
if(typeof param3 !== 'undefined')
|
||||
url += "&"+param3;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
|
|
|
@ -580,7 +580,13 @@ $(document).ready( function() {
|
|||
|
||||
$("body").on("click", ".ajax-click", function() { /* {{{ */
|
||||
var element = $(this);
|
||||
var url = element.data('href')+"?"+element.data('param1');
|
||||
var url = seeddms_webroot+"op/op.Ajax.php"+"?"+element.data('param1');
|
||||
var param2 = element.data('param2');
|
||||
var param3 = element.data('param3');
|
||||
if(typeof param2 !== 'undefined')
|
||||
url += "&"+param2;
|
||||
if(typeof param3 !== 'undefined')
|
||||
url += "&"+param3;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
|
|
|
@ -658,11 +658,9 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
|||
}
|
||||
fclose($fp);
|
||||
|
||||
$finfo = new finfo(FILEINFO_MIME);
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mimetype = $finfo->file($tmpFile);
|
||||
|
||||
$tmp = explode(';', $mimetype);
|
||||
$mimetype = $tmp[0];
|
||||
$lastDotIndex = strrpos($name, ".");
|
||||
if($lastDotIndex === false) $fileType = ".";
|
||||
else $fileType = substr($name, $lastDotIndex);
|
||||
|
|
Loading…
Reference in New Issue
Block a user