<%--
/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<aui:fieldset>
	<aui:input name="preferences--enableRelatedAssets--" type="checkbox" value="<%= enableRelatedAssets %>" />

	<c:if test="<%= PropsValues.WIKI_PAGE_RATINGS_ENABLED || PropsValues.WIKI_PAGE_COMMENTS_ENABLED %>">
		<c:if test="<%= PropsValues.WIKI_PAGE_RATINGS_ENABLED %>">
			<aui:input name="preferences--enablePageRatings--" type="checkbox" value="<%= enablePageRatings %>" />
		</c:if>

		<c:if test="<%= PropsValues.WIKI_PAGE_COMMENTS_ENABLED %>">
			<aui:input name="preferences--enableComments--" type="checkbox" value="<%= enableComments %>" />

			<aui:input name="preferences--enableCommentRatings--" type="checkbox" value="<%= enableCommentRatings %>" />
		</c:if>
	</c:if>
</aui:fieldset>

<aui:fieldset>
	<div class="display-template">

		<%
		TemplateHandler templateHandler = TemplateHandlerRegistryUtil.getTemplateHandler(WikiPage.class.getName());
		%>

		<liferay-ui:ddm-template-selector
			classNameId="<%= PortalUtil.getClassNameId(templateHandler.getClassName()) %>"
			displayStyle="<%= displayStyle %>"
			displayStyleGroupId="<%= displayStyleGroupId %>"
			refreshURL="<%= configurationRenderURL %>"
			showEmptyOption="<%= true %>"
		/>
	</div>
</aui:fieldset>

<aui:fieldset label="visible-wikis">
	<aui:input name="preferences--visibleNodes--" type="hidden" />
	<aui:input name="preferences--hiddenNodes--" type="hidden" />

	<%
	Set<String> currentVisibleNodes = new HashSet<String>(allNodeNames);

	// Left list

	List<KeyValuePair> leftList = new ArrayList<KeyValuePair>();

	for (String folderColumn : visibleNodes) {
		if (currentVisibleNodes.contains(folderColumn)) {
			leftList.add(new KeyValuePair(folderColumn, HtmlUtil.escape(LanguageUtil.get(pageContext, folderColumn))));
		}
	}

	Arrays.sort(visibleNodes);
	Arrays.sort(hiddenNodes);

	for (String folderColumn : currentVisibleNodes) {
		if ((Arrays.binarySearch(hiddenNodes, folderColumn) < 0) && (Arrays.binarySearch(visibleNodes, folderColumn) < 0)) {
			leftList.add(new KeyValuePair(folderColumn, HtmlUtil.escape(LanguageUtil.get(pageContext, folderColumn))));
		}
	}

	// Right list

	List<KeyValuePair> rightList = new ArrayList<KeyValuePair>();

	for (String folderColumn : hiddenNodes) {
		if (currentVisibleNodes.contains(folderColumn)) {
			if (Arrays.binarySearch(visibleNodes, folderColumn) < 0) {
				rightList.add(new KeyValuePair(folderColumn, HtmlUtil.escape(LanguageUtil.get(pageContext, folderColumn))));
			}
		}
	}

	rightList = ListUtil.sort(rightList, new KeyValuePairComparator(false, true));
	%>

	<liferay-ui:input-move-boxes
		leftBoxName="currentVisibleNodes"
		leftList="<%= leftList %>"
		leftReorder="true"
		leftTitle="visible"
		rightBoxName="availableVisibleNodes"
		rightList="<%= rightList %>"
		rightTitle="hidden"
	/>
</aui:fieldset>