1<#assign layoutSetLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.LayoutSetLocalService")>
2<#assign userLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.UserLocalService")>
3<#assign organizationLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.OrganizationLocalService")>
4
5<#function getNavigationString >
6 <#--LayoutConstants.DEFAULT_PARENT_LAYOUT_ID-->
7 <#assign defaultParentLayoutId = 0 />
8 <#assign outline = "<li class=\"navigation-outline\"></li>" />
9
10 <#local result = "" + outline />
11 <#assign rootOrder = 0 />
12 <#assign selLayout = themeDisplay.getLayout() />
13 <#assign layoutLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.LayoutLocalService")>
14 <#assign rootLayouts = layoutLocalService.getLayouts(selLayout.getGroupId(), selLayout.isPrivateLayout(), defaultParentLayoutId) />
15 <#local result += buildGroupsNavItems(selLayout.getLayoutSet()) />
16 <#local result = result + "<li class=\"navigation-spacer\"></li>" />
17 <#list rootLayouts as rootLayout>
18 <#if !rootLayout.isHidden()>
19 <#assign rootOrder = rootOrder + 1 />
20 <#local result = result + addNavigationItem(rootLayout, rootOrder) />
21 </#if>
22 </#list>
23 <#local result = result + outline />
24 <#return result />
25</#function>
26
27<#function buildGroupsNavItems layoutSet >
28 <#local result = "" />
29 <#local group = layoutSet.getGroup() />
30 <#if group.isControlPanel()>
31 <#return "" />
32 </#if>
33 <#local parentLayoutSet = getParentLayoutSet(layoutSet) />
34 <#if parentLayoutSet?has_content>
35 <#local result = result + buildGroupsNavItems(parentLayoutSet) />
36 </#if>
37 <#if group.isGuest() || !group.isActive()>
38 <#return "" />
39 </#if>
40 <#local layoutsPageCount = 0 />
41 <#if layoutSet.isPrivateLayout()>
42 <#local layoutsPageCount = group.getPrivateLayoutsPageCount() />
43 <#else>
44 <#local layoutsPageCount = group.getPublicLayoutsPageCount() />
45 </#if>
46 <#if layoutsPageCount gt 0 && !group.isGuest()>
47 <#local layoutSetFriendlyURL = portalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay) />
48 <#if themeDisplay.isAddSessionIdToURL()>
49 <#local layoutSetFriendlyURL = portalUtil.getURLWithSessionId(layoutSetFriendlyURL, themeDisplay.getSessionId()) />
50 </#if>
51 <#local result = result + "<li class=\"site-item\"><a href=\"" + layoutSetFriendlyURL + "\">" />
52 <#local result = result + htmlUtil.escape(group.getDescriptiveName()) + "</a></li>" />
53 </#if>
54 <#return result />
55</#function>
56
57<#function getParentLayoutSet layoutSet >
58 <#local group = layoutSet.getGroup() />
59 <#if group.isSite() >
60 <#if group.getParentGroup()?? && group.getParentGroup()?has_content>
61 <#return layoutSetLocalService.getLayoutSet(group.getParentGroup().getGroupId(), layoutSet.isPrivateLayout()) />
62 </#if>
63 <#elseif group.isUser()>
64 <#local user = userLocalService.getUser(group.getClassPK()) />
65 <#local organizations = organizationLocalService.getUserOrganizations(user.getUserId()) />
66 <#if organizations?has_content>
67 <#local organization = organizations[0] />
68 <#local parentGroup = organization.getGroup() />
69 <#return layoutSetLocalService.getLayoutSet(parentGroup.getGroupId(), layoutSet.isPrivateLayout()) />
70 </#if>
71 </#if>
72 <#return "" />
73
74</#function>
75
76<#function addNavigationItem layout rootOrder >
77 <#local itemClass = "" />
78 <#assign hasColoredMenu = themeDisplay.getThemeSetting("color-menu-items")?boolean />
79 <#assign colorSelector = "" />
80 <#if hasColoredMenu && rootOrder == 4>
81 <#assign colorSelector = "first-colored-item" />
82 </#if>
83 <#if hasColoredMenu && rootOrder == 5>
84 <#assign colorSelector = "second-colored-item" />
85 </#if>
86 <#if hasColoredMenu && rootOrder == 6>
87 <#assign colorSelector = "third-colored-item" />
88 </#if>
89
90 <#assign selected = themeDisplay.getLayout().getLayoutId() == layout.getLayoutId() />
91 <#assign children = layout.getChildren(themeDisplay.getPermissionChecker()) />
92 <#attempt>
93 <#if children?size gt 0>
94 <#local itemClass += "has-children ">
95 <#else>
96 <#local itemClass += "no-children " />
97 </#if>
98 <#if selected>
99 <#local itemClass += "selected " />
100 <#else>
101 <#local itemClass += "collapsed " />
102 </#if>
103 <#if hasColoredMenu>
104 <#local itemClass += colorSelector + " " />
105 </#if>
106
107 <#local content = "" />
108 <#if children?size gt 0>
109 <#local content += "<a href=\"javascript:void(0);\" class=\"nav-item-toggler\"><i class=\"icon-chevron-toggle\"></i></a>" />
110 </#if>
111
112 <#local content += "<div class=\"nav-item-text\"><a href=\"" + getFinalLayoutURL(layout) + "\">" />
113 <#local content += getFinalLayoutTitleHtmlChunk(layout) />
114 <#local content += "</a></div>" />
115 <#if children?size gt 0>
116 <#local content += getNextNavitationLevelHtml(children) />
117 </#if>
118 <#recover>
119 <#--log an error-->
120 </#attempt>
121
122 <#local result = "<li class=\""+itemClass+"\">"+content+"</li>"/>
123 <#return result />
124</#function>
125
126<#function getFinalLayoutTitleHtmlChunk layout >
127 <#local result = "<span>" />
128 <#local name = layout.getName(locale) />
129 <#local breakLineIndex = 0 />
130 <#attempt>
131 <#local breakLineIndex = layout.getExpandoBridge().getAttribute("breakLinePosition" + locale.getLanguage()?upper_case) />
132 <#recover>
133 <#--log an error-->
134 </#attempt>
135 <#if breakLineIndex != 0 && name?length gt breakLineIndex>
136 <#local result += name[0..<breakLineIndex] + "<br />" + name[breakLineIndex..] />
137 <#else>
138 <#local result += name />
139 </#if>
140 <#local result += "</span>" />
141 <#return result />
142</#function>
143
144<#function getFinalLayoutURL layout >
145 <#local finalURL = "" />
146 <#local redirectUrl = layout.getExpandoBridge().getAttribute("redirectUrl") />
147 <#local anchor = layout.getExpandoBridge().getAttribute("anchor") />
148 <#if redirectUrl?has_content>
149 <#local finalURL = redirectUrl />
150 <#else>
151 <#local finalURL = portalUtil.getLayoutFullURL(layout, themeDisplay) />
152 </#if>
153 <#if anchor?has_content>
154 <#local finalURL = finalURL + "#" + anchor />
155 </#if>
156 <#return finalURL />
157</#function>
158
159<#function getNextNavitationLevelHtml children >
160 <#local result = "<ul class=\"sub-menu\">" />
161 <#list children as navItem>
162 <#if navItem.isHidden()>
163 <#continue />
164 </#if>
165 <#local result += addNavigationItem(navItem, 0) />
166 </#list>
167 <#local result += "</ul>" />
168 <#return result />
169</#function>
170
171<#if !entries?has_content>
172 <#if themeDisplay.isSignedIn()>
173 <div class="alert alert-info">
174 <@liferay.language key="there-are-no-menu-items-to-display" />
175 </div>
176 </#if>
177<#else>
178 <div class="enw-navigation">
179 <div aria-label="<@liferay.language key="site-pages" />" class="navigation navigation--mobile list-menu">
180 <ul aria-label="<@liferay.language key="side-navigation" />" >
181 <#--publish HTML-->
182 ${getNavigationString()}
183 </ul>
184 </div>
185 </div>
186</#if>