<%--
/**
 * 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.
 *
 *
 *
 */
--%>

<%
String formattedContent = null;

try {
	formattedContent = WikiUtil.getFormattedContent(renderRequest, renderResponse, wikiPage, viewPageURL, editPageURL, title, preview);
%>

	<div class="wiki-body">
		<c:choose>
			<c:when test="<%= !followRedirect && (redirectPage != null) %>">
				<div class="alert alert-info">
					<%= LanguageUtil.format(pageContext, "this-page-is-currently-redirected-to-x", redirectPage.getTitle(), false) %>
				</div>

				<c:if test="<%= WikiPagePermission.contains(permissionChecker, wikiPage, ActionKeys.UPDATE) %>">
					<portlet:renderURL var="removeRedirectURL">
						<portlet:param name="struts_action" value="/wiki/edit_page" />
						<portlet:param name="nodeId" value="<%= String.valueOf(node.getNodeId()) %>" />
						<portlet:param name="title" value="<%= title %>" />
						<portlet:param name="removeRedirect" value="true" />
					</portlet:renderURL>

					<div class="btn-toolbar">

						<%
						String taglibRemoveRedirect = "location.href = '" + removeRedirectURL + "';";
						%>

						<aui:button onClick="<%= taglibRemoveRedirect %>" value="remove-redirect" />
					</div>
				</c:if>
			</c:when>
			<c:when test="<%= Validator.isNull(formattedContent) && WikiPagePermission.contains(permissionChecker, wikiPage, ActionKeys.UPDATE) %>">
				<div class="alert alert-info">
					<aui:a href="<%= editPageURL.toString() %>" label="this-page-is-empty-edit-it-to-add-some-text" />
				</div>
			</c:when>
			<c:otherwise>
				<%= formattedContent %>
			</c:otherwise>
		</c:choose>
	</div>

<%
}
catch (WikiFormatException wfe) {
%>

	<div class="alert alert-error">
		<liferay-ui:message key="the-format-of-this-page-is-not-supported-the-page-content-will-be-shown-unformatted" />
	</div>

	<div class="wiki-body">
		<pre>
<%= wikiPage.getContent() %>
		</pre>
	</div>

<%
}
catch (Exception e) {
	_log.error("Error formatting the wiki page " + wikiPage.getPageId() + " with the format " + wikiPage.getFormat(), e);
%>

	<div class="alert alert-error">
		<liferay-ui:message key="an-error-occurred-while-formatting-the-wiki-page" />
	</div>

<%
}
%>

<%!
private static Log _log = LogFactoryUtil.getLog("portal-web.docroot.html.wiki.view_page_content_jspf");
%>