masterpages.jsp
3.28 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<%--
ADOBE CONFIDENTIAL
Copyright 2015 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: All information contained herein is, and remains
the property of Adobe Systems Incorporated and its suppliers,
if any. The intellectual and technical concepts contained
herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents,
patents in process, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe Systems Incorporated.
--%><%
%><%@include file="/libs/granite/ui/global.jsp" %><%
%><%@page session="false"
import="java.util.Map,
java.util.Map.Entry,
java.util.HashMap,
java.util.Iterator,
java.util.Locale,
org.apache.commons.collections.Transformer,
org.apache.commons.collections.iterators.TransformIterator,
org.apache.jackrabbit.util.Text,
org.apache.sling.api.resource.ResourceMetadata,
org.apache.sling.api.resource.ResourceResolver,
org.apache.sling.api.wrappers.ValueMapDecorator,
com.adobe.granite.ui.components.Config,
com.adobe.granite.ui.components.ds.DataSource,
com.adobe.granite.ui.components.ds.SimpleDataSource,
com.adobe.granite.ui.components.ds.ValueMapResource,
com.day.cq.commons.Language,
com.day.cq.commons.LanguageUtil,
com.day.cq.wcm.api.LanguageManager,
com.day.cq.wcm.api.Page,
com.day.cq.wcm.msm.api.Blueprint,
com.day.cq.wcm.msm.api.BlueprintManager" %><%
// This is the same implementation as com.day.cq.wcm.core.impl.servlets.ContentLanguageServlet.
final ResourceResolver resolver = resourceResolver;
final Config cfg = new Config(resource.getChild(Config.DATASOURCE));
final BlueprintManager bpm = resolver.adaptTo(BlueprintManager.class);
if (bpm == null) {
return;
}
final String blueprintPath = cmp.getExpressionHelper().getString(cfg.get("blueprint", String.class));
if (blueprintPath == null) {
return;
}
final Blueprint blueprint = bpm.getBlueprint(blueprintPath);
final Resource site = resolver.getResource(blueprint.getSitePath());
if (site == null) {
return;
}
final Page rootPage = site.adaptTo(Page.class);
if (rootPage == null) {
return;
}
@SuppressWarnings("unchecked")
final Iterator<Resource> it = new TransformIterator(rootPage.listChildren(), new Transformer() {
public Object transform(Object o) {
Page masterPage = (Page) o;
String pageTitle = masterPage.getPageTitle();
if (pageTitle == null || pageTitle.isEmpty()) {
pageTitle = masterPage.getTitle();
}
ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>());
vm.put("value", masterPage.getPath());
vm.put("text", pageTitle);
vm.put("selected", true);
return new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm);
}
});
request.setAttribute(DataSource.class.getName(), new SimpleDataSource(it));
%>