]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ux/src/org/argeo/cms/ux/CmsUxUtils.java
Move JNI from Argeo Commons to Argeo SLC
[lgpl/argeo-commons.git] / org.argeo.cms.ux / src / org / argeo / cms / ux / CmsUxUtils.java
1 package org.argeo.cms.ux;
2
3 import org.argeo.api.acr.Content;
4 import org.argeo.api.acr.ContentRepository;
5 import org.argeo.api.acr.ContentSession;
6 import org.argeo.api.cms.ux.Cms2DSize;
7 import org.argeo.api.cms.ux.CmsView;
8 import org.argeo.util.CurrentSubject;
9
10 public class CmsUxUtils {
11 public static ContentSession getContentSession(ContentRepository contentRepository, CmsView cmsView) {
12 return CurrentSubject.callAs(cmsView.getCmsSession().getSubject(), () -> contentRepository.get());
13 }
14
15 public static String getTitle(Content content) {
16 return content.getName().getLocalPart();
17 }
18
19 /** singleton */
20 private CmsUxUtils() {
21
22 }
23
24 public static StringBuilder imgBuilder(String src, String width, String height) {
25 return new StringBuilder(64).append("<img width='").append(width).append("' height='").append(height)
26 .append("' src='").append(src).append("'");
27 }
28
29 public static String img(String src, String width, String height) {
30 return imgBuilder(src, width, height).append("/>").toString();
31 }
32
33 public static String img(String src, Cms2DSize size) {
34 return img(src, Integer.toString(size.getWidth()), Integer.toString(size.getHeight()));
35 }
36 }