]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ux/src/org/argeo/cms/ux/CmsUxUtils.java
Merge tag 'v2.3.27' into testing
[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.cms.util.CurrentSubject;
9
10 /** Utilities around UX. */
11 public class CmsUxUtils {
12 public static ContentSession getContentSession(ContentRepository contentRepository, CmsView cmsView) {
13 return CurrentSubject.callAs(cmsView.getCmsSession().getSubject(), () -> contentRepository.get());
14 }
15
16 public static String getTitle(Content content) {
17 return content.getName().getLocalPart();
18 }
19
20 public static StringBuilder imgBuilder(String src, String width, String height) {
21 return new StringBuilder(64).append("<img width='").append(width).append("' height='").append(height)
22 .append("' src='").append(src).append("'");
23 }
24
25 public static String img(String src, String width, String height) {
26 return imgBuilder(src, width, height).append("/>").toString();
27 }
28
29 public static String img(String src, Cms2DSize size) {
30 return img(src, Integer.toString(size.width()), Integer.toString(size.height()));
31 }
32
33 /** singleton */
34 private CmsUxUtils() {
35
36 }
37
38 }