Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
7211542e
Commit
7211542e
authored
8 years ago
by
Laurent Destailleur
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #5569 from olsesacl/develop-show-preview-documents
NEW Preview documents
parents
c73f962b
5fe0d601
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/core/class/html.formfile.class.php
+33
-0
33 additions, 0 deletions
htdocs/core/class/html.formfile.class.php
htdocs/core/js/lib_head.js.php
+59
-0
59 additions, 0 deletions
htdocs/core/js/lib_head.js.php
with
92 additions
and
0 deletions
htdocs/core/class/html.formfile.class.php
+
33
−
0
View file @
7211542e
...
...
@@ -619,6 +619,9 @@ class FormFile
$out
.
=
' target="_blank">'
;
$out
.
=
img_mime
(
$file
[
"name"
],
$langs
->
trans
(
"File"
)
.
': '
.
$file
[
"name"
])
.
' '
.
dol_trunc
(
$file
[
"name"
],
$maxfilenamelength
);
$out
.
=
'</a>'
.
"
\n
"
;
$out
.
=
$this
->
showPreview
(
$file
,
$modulepart
,
$relativepath
);
$out
.
=
'</td>'
;
// Show file size
...
...
@@ -739,6 +742,8 @@ class FormFile
$out
.
=
img_mime
(
$relativepath
,
$file
[
"name"
]);
$out
.
=
'</a>'
.
"
\n
"
;
$out
.
=
$this
->
showPreview
(
$file
,
$modulepart
,
$relativepath
);
$this
->
infofiles
[
'nboffiles'
]
++
;
$this
->
infofiles
[
'files'
][]
=
$file
[
'fullname'
];
$ext
=
pathinfo
(
$file
[
"name"
],
PATHINFO_EXTENSION
);
...
...
@@ -859,6 +864,9 @@ class FormFile
//print dol_trunc($file['name'],$maxlength,'middle');
print
$file
[
'name'
];
print
'</a>'
;
print
$this
->
showPreview
(
$file
,
$modulepart
,
$filepath
);
print
"</td>
\n
"
;
print
'<td align="right" width="80px">'
.
dol_print_size
(
$file
[
'size'
],
1
,
1
)
.
'</td>'
;
print
'<td align="center" width="130px">'
.
dol_print_date
(
$file
[
'date'
],
"dayhour"
,
"tzuser"
)
.
'</td>'
;
...
...
@@ -1320,5 +1328,30 @@ class FormFile
return
$nboflinks
;
}
/**
* Show detail icon with link for preview
* @param array $file File
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs
* @return string $out Output string with HTML
*/
public
function
showPreview
(
$file
,
$modulepart
,
$relativepath
){
global
$langs
,
$conf
;
if
(
empty
(
$conf
->
use_javascript_ajax
))
return
''
;
$out
=
''
;
$mime_preview
=
array
(
'jpeg'
,
'png'
,
'gif'
,
'tiff'
,
'pdf'
,
'plain'
,
'css'
);
$num_mime
=
array_search
(
dol_mimetype
(
$file
[
'name'
],
''
,
1
),
$mime_preview
);
if
(
$num_mime
!==
false
){
$out
.
=
' <a href="javascript:document_preview(\''
.
DOL_URL_ROOT
.
'/document.php?modulepart='
.
$modulepart
.
'&attachment=0&file='
.
urlencode
(
$relativepath
)
.
'\',\''
.
dol_mimetype
(
$file
[
'name'
])
.
'\', \''
.
$file
[
'name'
]
.
'\')">'
;
$out
.
=
img_picto
(
$langs
->
trans
(
'Preview'
),
'detail'
)
.
'</a>'
;
return
$out
;
}
}
}
This diff is collapsed.
Click to expand it.
htdocs/core/js/lib_head.js.php
+
59
−
0
View file @
7211542e
...
...
@@ -948,6 +948,65 @@ function copyToClipboard(text,text2)
return false;
}
/*
* Function show document preview
* @params string file File path
* @params string type mime file
* @params string title
*/
function document_preview(file, type, title){
var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"];
if ($.inArray(type, ValidImageTypes)
<
0)
{
var
width=
'85%'
;
var
object_width=
'100%'
;
var
height =
$(
window
).
height
()
*0.90
;
var
object_height=
'98%'
;
show_preview
();
}
else
{
var
object_width=
0;
var
object_height=
0;
var
img =
new
Image
();
img.onload =
function()
{
object_width =
this.width;
object_height =
this.height;
width =
$(
window
).
width
()
*0.90
;
if
(
object_width
<
width
){
width =
object_width
+
30
}
height =
$(
window
).
height
()
*0.85
;
if
(
object_height
<
height
){
height =
object_height
+
80
}
show_preview
();
};
img.src =
file;
}
function
show_preview
(){
var
newElem =
'<object data="'
+
file
+'"
type=
"'+type+'"
width=
"'+object_width+'"
height=
"'+object_height+'"
></object>
';
$("#dialogforpopup").html(newElem);
$("#dialogforpopup").dialog({
closeOnEscape: true,
resizable: true,
width: width,
height: height,
modal: true,
title: title
});
}
}
/*
* Provide a function to get an URL GET parameter in javascript
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment