Skip to content

Commit

Permalink
#13325 fixing template picker
Browse files Browse the repository at this point in the history
  • Loading branch information
wezell committed Jan 17, 2018
1 parent df11585 commit 2f20b7d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static TemplateLayout themeLayout (final String themeInode,
throws DotDataException, DotSecurityException {
final String key = themeInode + isPreview;
if (!UtilMethods.isSet(themeInode)) {
throw new IllegalArgumentException("the themeInode is null");
return null;
}

TemplateLayout layout = layoutCache.getIfPresent(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ private Map<String, Object> buildTemplateMap(Template template) throws DotDataEx
if(parentHost != null) {
templateMap.put("hostName", parentHost.getHostname());
templateMap.put("hostId", parentHost.getIdentifier());
templateMap.put("fullTitle", parentHost.getHostname() + " " + templateMap.get("title"));
templateMap.put("fullTitle", templateMap.get("title") + " (" + parentHost.getHostname() + ")" );
templateMap.put("htmlTitle", "<div><div style='float:left'>" + templateMap.get("title") + "</div><div style='float:right'>" + parentHost.getHostname() + "</div></div>" );
} else {
templateMap.put("fullTitle", templateMap.get("title"));
templateMap.put("htmlTitle", templateMap.get("title"));
}
return templateMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,19 @@ public Template saveTemplate(Template template, Host destination, User user, boo
@Override
public List<Container> getContainersInTemplate(final Template template, final User user, final boolean respectFrontendRoles)
throws DotDataException, DotSecurityException {

final List<Container> containers = new ArrayList<>();
final TemplateLayout layout = DotTemplateTool.themeLayout(template.getInode());
final List<String> containersId = layout.getContainersId();

final List<Container> containers = new ArrayList<>();

for (final String cont : containersId) {
final Container container = APILocator.getContainerAPI().getWorkingContainerById(cont, user, false);

if(container==null) {
continue;
}

containers.add(container);
if(layout !=null) {
final List<String> containersId = layout.getContainersId();
for (final String cont : containersId) {
final Container container = APILocator.getContainerAPI().getWorkingContainerById(cont, user, false);

if(container==null) {
continue;
}

containers.add(container);
}
}

return containers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ dojo.ready(function(){
pageSize: 15,
autoComplete: false,
ignoreCase: true,
labelAttr: "fullTitle",
labelType:"html",
searchType:"html",
labelAttr: "htmlTitle",
searchAttr: "fullTitle",
value: dojo.byId("template").value,
invalidMessage: '$text.get("Invalid-option-selected")'
Expand Down
8 changes: 8 additions & 0 deletions dotCMS/src/main/webapp/html/ng-contentlet-selector.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

<%@page import="com.dotcms.contenttype.model.type.ContentType"%>
<%@page import="com.dotcms.contenttype.transform.contenttype.StructureTransformer"%>
<%@page import="com.dotcms.contenttype.model.type.BaseContentType"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.dotmarketing.business.APILocator"%>
<%@page import="com.liferay.portal.util.PortalUtil"%>
Expand All @@ -10,6 +13,11 @@
User user = PortalUtil.getUser(request);
Container container = (Container) APILocator.getVersionableAPI().findWorkingVersion(containerIdentifier, user, false);
List<Structure> structuresInContainer = APILocator.getContainerAPI().getStructuresInContainer(container);
List<ContentType> widgets = APILocator.getContentTypeAPI(user).findByBaseType(BaseContentType.WIDGET, "name", 15, 0);
structuresInContainer.addAll(new StructureTransformer(widgets).asStructureList());
%>
<!DOCTYPE html>
<html lang="en">
Expand Down

0 comments on commit 2f20b7d

Please sign in to comment.