-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlideShowCase.apxc
62 lines (54 loc) · 2.01 KB
/
SlideShowCase.apxc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* @Author: Durval Slompo Junior
* Controller to show SlideShow of images from Case object
*/
public class SlideShowCase {
public String tmp {get; set;}
private final Case caso;
private Integer posicao = 0;
private List<ContentVersion> idContentVersions;
public Integer getPosicao(){
return posicao + 1;
}
public Integer getSize(){
return idContentVersions.size();
}
public SlideShowCase(ApexPages.StandardController stdController) {
this.caso = (Case)stdController.getRecord();
init();
}
public void init(){
List<ContentDocumentLink> docs =
[SELECT Id, LinkedEntityId, ContentDocumentId, Visibility, IsDeleted, ShareType,
ContentDocument.Title, ContentDocument.createdDate, ContentDocument.FileType
FROM ContentDocumentLink WHERE LinkedEntityId = :caso.Id];
List<String> idContentDocuments = new List<String>();
for(ContentDocumentLink cdl : docs){
System.debug(cdl.ContentDocumentId);
idContentDocuments.add(cdl.ContentDocumentId);
}
idContentVersions = [select Id from ContentVersion where ContentDocumentId in :idContentDocuments
and FileExtension IN ('png', 'jpg', 'jpeg', 'bmp')];
if(idContentVersions.size()>0){
ContentVersion cv = idContentVersions.get(0);
tmp = '../sfc/servlet.shepherd/version/download/' + cv.Id;
}
}
public void prev()
{
if(posicao != 0){
posicao = posicao - 1;
ContentVersion cv = idContentVersions.get(posicao);
tmp = '../sfc/servlet.shepherd/version/download/' + cv.Id;
}
}
public void nxt()
{
if(posicao != (idContentVersions.size()-1))
{
posicao = posicao + 1;
ContentVersion cv = idContentVersions.get(posicao);
tmp = '../sfc/servlet.shepherd/version/download/' + cv.Id;
}
}
}