1<#assign displayDepth = 3 />
2
3<#assign portlet_namespace>
4 <@portlet.namespace />
5</#assign>
6
7<#assign assetCategoryPropertyLocalService = serviceLocator.findService("com.liferay.asset.category.property.service.AssetCategoryPropertyLocalService")/>
8<#assign assetCategoryService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryService") />
9<#assign systemParameterOrmLocalServiceUtil = serviceLocator.findService("pl.gov.mf.kud.seap.lf.sbl.seap.service.SystemParameterOrmLocalService") />
10<#assign aktualnosciOrmLocalService = serviceLocator.findService("pl.gov.mf.kud.seap.lf.sbl.seap.service.AktualnosciOrmLocalService") />
11
12<#assign selCategoryId = renderRequest.getParameter("categoryId")! />
13<#assign isUserCategoriesRequestParam = (request.getParameter("userCategory")?boolean)!false />
14
15<#assign customCategoriesId = systemParameterOrmLocalServiceUtil.getParamValue("newsletter.redirect.category.id", "0")?number />
16<#assign userCategories = aktualnosciOrmLocalService.getAktualnosciTreeByUser(themeDisplay.getUser().getUserUuid(), locale) />
17
18<#assign group = 0 />
19
20
21<#if !entries?has_content>
22 <#if themeDisplay.isSignedIn()>
23 <div class="alert alert-info"><@liferay.language key="there-are-no-menu-items-to-display" /></div>
24 </#if>
25<#else>
26 <div aria-label="<@liferay.language key="site-pages" />" id="sidebar" role="navigation">
27 <#list entries as entry>
28 <#assign categoryListId = entry.getPrimaryKey()?string />
29 <@buildNavigationSeap
30 navItemLevel=1 navItems=entry.getCategories() parentId="list-tab" isOpened=false categoryListId=categoryListId
31 addAll=entry?index name=entry.getName() />
32 <p></p>
33 </#list>
34 </div>
35</#if>
36
37<#function checkIfOpened category selCategoryId isUserCategories>
38 <#if isUserCategories && !isUserCategoriesRequestParam ||
39 !isUserCategories && isUserCategoriesRequestParam>
40 <#return false>
41 </#if>
42 <#local categoryId = category.categoryId?string/>
43 <#if categoryId == selCategoryId>
44 <#return true>
45 <#else>
46 <#if isUserCategories>
47 <#local childCategories = category.childs />
48 <#else>
49 <#if assetCategoryService??>
50 <#local childCategories = assetCategoryService.getChildCategories(category.getCategoryId()) />
51 </#if>
52 </#if>
53
54 <#if childCategories?has_content>
55 <#list childCategories as child>
56 <#if checkIfOpened(child, selCategoryId, isUserCategories)>
57 <#return true>
58 </#if>
59 </#list>
60 </#if>
61 </#if>
62 <#return false>
63</#function>
64
65<#macro buildNavigationSeap navItemLevel navItems parentId isOpened categoryListId addAll name>
66 <#-- ordering begin -->
67
68 <#local categoriesOrder = [] />
69 <#local categoriesOrdered = [] />
70 <#local av = [] />
71 <#list navItems as navItem>
72 <#local added = false />
73 <#if permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), "com.liferay.asset.kernel.model.AssetCategory", navItem.getCategoryId(), "VIEW")>
74 <#local categoryProperties = assetCategoryPropertyLocalService.getCategoryProperties(navItem.getCategoryId()) />
75 <#if categoryProperties?has_content>
76 <#list categoryProperties as categoryProperty>
77 <#if "order" == categoryProperty.getKey()>
78 <#local categoriesOrder += [{"category":navItem, "order":categoryProperty.getValue()?number}] />
79 <#local added = true />
80 </#if>
81
82 <#if "available" == categoryProperty.getKey()>
83 <#local av += [{"id": navItem.getCategoryId(), "av": categoryProperty.getValue()}] />
84 </#if>
85 </#list>
86 </#if>
87
88 <#if added == false>
89 <#local categoriesOrder += [{"category":navItem, "order":99999}] />
90 </#if>
91 </#if>
92 </#list>
93
94 <#list categoriesOrder?sort_by("order") as k>
95 <#local categoriesOrdered += [k.category] />
96 </#list>
97
98 <#-- ordering end -->
99
100 <#if navItems?has_content && ((displayDepth == 0) || (navItemLevel <= displayDepth))>
101 <#if navItemLevel == 1>
102 <#local seap_css_class = "list-group sidebar-menu" />
103 <#elseif navItemLevel == 2>
104 <#local seap_css_class = "nav" />
105 <#else>
106 <#local seap_css_class = "toggle-list-menu" />
107 </#if>
108
109 <#if navItemLevel != 1>
110 <div class="<#if isOpened>show<#else>collapse</#if>" id="${parentId}" role="list">
111 </#if>
112 <ul class="${seap_css_class}" <#if navItemLevel == 1>role="tablist"</#if>>
113 <#-- <#if navItemLevel == 1 && name != "Newsletter">
114 <#local categoryURL = renderResponse.createRenderURL() />
115 ${categoryURL.setParameter("resetCur", "true")}
116 ${categoryURL.setParameter("categoryId", categoryListId)}
117
118 <li class="nav-item">
119 <a class="nav-link <#if !(selCategoryId?has_content) || categoryListId == selCategoryId || selCategoryId=="0">selected active</#if>" href="${categoryURL}"
120 id="list-c-all" role="tab">
121 <@liferay.language key="newsletter" />
122 </a>
123 </li>
124 </#if> -->
125
126 <#if navItemLevel == 1 && name == "Newsletter">
127 <#local categoryURL = renderResponse.createRenderURL() />
128 ${categoryURL.setParameter("resetCur", "true")}
129 ${categoryURL.setParameter("categoryId", categoryListId)}
130
131 <li class="nav-item">
132 <a class="nav-link <#if !(selCategoryId?has_content) || categoryListId == selCategoryId || selCategoryId=="0">selected active</#if>" href="${categoryURL}?p_r_p_resetCur=true&p_r_p_categoryId=${categoryListId}"
133 id="list-c-all" role="tab">
134 <@liferay.language key="all" />
135 </a>
136 </li>
137 </#if>
138 <#list categoriesOrdered as navItem>
139 <#local childId = parentId + "-" + navItem?index />
140
141 <#if navItemLevel != 1 || navItem.isRootCategory()>
142 <#local categoryURL = renderResponse.createRenderURL() />
143 ${categoryURL.setParameter("resetCur", "true")}
144 ${categoryURL.setParameter("categoryId", navItem.getCategoryId()?string)}
145
146 <#local isUserCategories = customCategoriesId == navItem.getCategoryId() />
147 <#if isUserCategories>
148 <#local childCategories = userCategories />
149 <#local canShowSelection = isUserCategoriesRequestParam />
150 <#else>
151 <#if assetCategoryService??>
152 <#local
153 childCategories = assetCategoryService.getChildCategories(navItem.getCategoryId())
154 />
155 </#if>
156 <#local canShowSelection = !isUserCategoriesRequestParam />
157 </#if>
158
159 <#local isSubmenuItemExists = childCategories?has_content && (displayDepth == 0 || (navItemLevel < displayDepth))>
160 <#if isSubmenuItemExists>
161 <#local isOpened = checkIfOpened(navItem, selCategoryId, false) />
162 </#if>
163
164 <#local _av = 'true' />
165
166 <#list av as _a>
167 <#if _a.id == navItem.getCategoryId()>
168 <#local _av = _a.av />
169 </#if>
170 </#list>
171
172 <li class="nav-item">
173 <#if _av == 'false'>
174 <span class="nav-span">${navItem.getTitle(locale)}</span>
175 <#else>
176 <a class="nav-link <#if canShowSelection && navItem.getCategoryId()?string == selCategoryId>selected active</#if>" href="${categoryURL}?p_r_p_resetCur=true&p_r_p_categoryId=${navItem.getCategoryId()?string}<#if isUserCategories>&userCategory=true</#if>"
177 id="list-c-${childId}-child-${group}" role="tab" data-av="${_av}" <#if isSubmenuItemExists>aria-expanded="<#if !isOpened>false<#else>true</#if>"</#if>>
178 ${navItem.getTitle(locale)}
179 </a>
180 </#if>
181
182 <#if isSubmenuItemExists>
183 <i class="toggle fa fa-chevron-down <#if !isOpened>collapsed</#if>" data-toggle="collapse" data-target="#${childId}-child-${group}"></i>
184
185 <#if isUserCategories>
186 <@buildUserNavigationSeap listContent=childCategories level=(navItemLevel+1) parentId=childId+'-child-'+group isOpened=isUserCategoriesRequestParam />
187 <#else>
188 <@buildNavigationSeap
189 navItemLevel=(navItemLevel + 1)
190 navItems=childCategories parentId=childId+'-child-'+group isOpened=isOpened
191 categoryListId=categoryListId addAll=addAll name=name />
192 </#if>
193 </#if>
194 </li>
195 </#if>
196 <#assign group = group + 1 />
197 </#list>
198 </ul>
199 <#if navItemLevel != 1>
200 </div>
201 </#if>
202 </#if>
203</#macro>
204
205<#macro buildUserNavigationSeap listContent level parentId isOpened>
206 <#if listContent?has_content && ((displayDepth == 0) || (level <= displayDepth))>
207 <#if level == 1>
208 <#local seap_css_class = "list-group sidebar-menu" />
209 <#elseif level == 2>
210 <#local seap_css_class = "nav" />
211 <#else>
212 <#local seap_css_class = "toggle-list-menu" />
213 </#if>
214
215 <#if level != 1>
216 <div class="<#if isOpened>show<#else>collapse</#if>" id="${parentId}" role="list">
217 </#if>
218
219 <ul class="${seap_css_class}" <#if level == 1>role="tablist"</#if>>
220 <#list listContent as navItem>
221 <#local childId = parentId + "-" + navItem?index />
222
223 <#local categoryURL = renderResponse.createRenderURL() />
224 ${categoryURL.setParameter("resetCur", "true")}
225 ${categoryURL.setParameter("categoryId", navItem.categoryId?string)}
226
227 <#local childCategories = navItem.childs />
228
229 <#local isSubmenuItemExists = childCategories?has_content && (displayDepth == 0 || (level < displayDepth))>
230 <#if isSubmenuItemExists>
231 <#local isOpened = checkIfOpened(navItem, selCategoryId, true) />
232 </#if>
233
234 <li class="nav-item">
235 <a class="nav-link <#if navItem.categoryId?string == selCategoryId>selected active</#if>" href="${categoryURL}&userCategory=true&p_r_p_resetCur=true&p_r_p_categoryId=${navItem.categoryId?string}"
236 id="list-c-${childId}" role="tab">
237 ${navItem.name}
238 </a>
239
240 <#if isSubmenuItemExists>
241 <i class="toggle fa fa-chevron-down <#if !isOpened>collapsed</#if>" data-toggle="collapse" data-target="#${childId}"></i>
242
243 <@buildUserNavigationSeap listContent=childCategories level=(level+1) parentId=childId isOpened=isOpened />
244 </#if>
245 </li>
246 </#list>
247 </ul>
248 <#if level != 1>
249 </div>
250 </#if>
251 </#if>
252</#macro>
253<script>
254 Liferay.Portlet.ready(puescApp.initTabs);
255</script>