<jsp:root 
	version="2.0" 
	xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:portlet="http://java.sun.com/portlet"    
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"    
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"     
>
	<jsp:directive.page session="false"/>
	<jsp:directive.page isELIgnored="false"/>
	<fmt:setLocale value=""/>
	<fmt:setBundle basename="samples.webcenter.portlets.wiki.WikiPortlet"/>
	<portlet:defineObjects/>
	<portlet:actionURL var="actionURL"/>
	<c:choose>
		<c:when test="${(error_type == null || wiki_create == 'true') && wiki_settings != 'true'}">		
			<div class="wiki-header">
				<div class="wiki-title">
					<h2>
						${page_info.domain}
					</h2>
				</div>
				<div class="wiki-controls">
					<c:if test="${pageContext.request.userPrincipal != null}">
						<portlet:actionURL var="createwikiEntryLink">
							<portlet:param name="wiki_show" value="single"/>
							<portlet:param name="wiki_create" value="true"/>                                                        
						</portlet:actionURL>
						<a name="Create" href="${createwikiEntryLink}"><fmt:message key="wiki.create.label"/></a>
					</c:if>				
					<portlet:actionURL var="wikiSearchURL"/>
					<form name="Search" id="${uid}_wiki_search_form" method="POST" action="${wikiSearchURL}">
						<input id="wiki_search_text" name="wiki_search_text" type="text" value=""/>
						<fmt:message key='wiki.search.label' var="wiki_search_label"/>
						<input type="button" name="Search" onclick="wikiPortlet_doSearch('${uid}');" value="${wiki_search_label}"/>
						<input type="hidden" name="page_action" value="search"/>		
					</form>
					<portlet:actionURL var="settingsUrl"/>					
					<form name="Settings" id="${uid}_wiki_settings_form" method="POST" action="${settingsUrl}">
						<fmt:message key='wiki.settings.label' var="wiki_settings_label"/>
						<input type="button" name="Settings" onclick="this.form.submit();" value="${wiki_settings_label}"/>
						<input type="hidden" name="page_action" value="settings"/>		
					</form>							
				</div>				
			</div>
			<div class="wiki-container">
				<div id="${uid}_wiki_nav" class="wiki-nav wiki-nav-expanded" onmousedown="wikiPortlet_navClick('${uid}', event);">
					<div id="${uid}_wiki_page_list" class="wiki-list">
						<ul>
						<c:forEach items="${all_page_info}" var="info" varStatus="status" end="${(wiki_max_pages == null || wiki_max_pages == '' || wiki_max_pages == -1) ? 9999 : wiki_max_pages - 1}">
							<portlet:actionURL var="wikiPageLink">
								<portlet:param name="wiki_page" value="${info.name}"/>	
							</portlet:actionURL>
							<c:set var="dateTime" value="${fn:split(info.modified, ' ')}" scope="request"/>
							<fmt:message key="wiki.page.msg.info" var="info_msg">
								<fmt:param value="${info.author}"></fmt:param>
								<fmt:param value="${info.editor}"></fmt:param>
								<fmt:param value="${dateTime[0]}"></fmt:param>
								<fmt:param value="${dateTime[1]}"></fmt:param>
							</fmt:message>
							<li>
								<c:set var="linkClass" value="${info.name == page_info.name ? 'wiki-link-selected' : 'wiki-link'}" scope="request"/>
								<c:set var="selectedIndex" value="${info.name == page_info.name ? status.index : selectedIndex}" scope="request"/>
								<a id="${uid}_link_${status.index}" class="${linkClass}" onclick="wikiPortlet_select('${uid}', this);" href="${wikiPageLink}" title="${info_msg}">${info.name}</a>
							</li>
						</c:forEach>
						</ul>
					</div>
				</div>
				<div id="${uid}_wiki_main" class="wiki-main">
					<c:choose>
						<c:when test="${wiki_create == 'true'}">
							<c:set var="wiki_create_page" value="true" scope="request"/>
							<jsp:include page="page.jspx"/>
						</c:when>
						<c:when test="${search_results != null}">
							<jsp:include page="search_results.jspx"/>
						</c:when>						
						<c:otherwise>
							<jsp:include page="page.jspx"/>
						</c:otherwise>
					</c:choose>
				</div>
				<div class="wiki-footer">
				</div>
			</div>
		</c:when>
		<c:otherwise>
			<jsp:include page="../wikiEdit.jsp"/>
			<c:choose>
				<c:when test="${error_type == 'invalid_user'}">
					<fmt:message key='wiki.invalid.user.msg' var="wiki_invalid_user_msg"/>
					<script type="text/javascript">
					//<![CDATA[
						(typeof wikiPortlet_alert != "undefined") ? wikiPortlet_alert("${uid}", "${wiki_invalid_user_msg}") : void(0);
					//]]>
					</script>
				</c:when>
				<c:when test="${error_type == 'invalid_domain'}">
					<c:choose>
						<c:when test="${pageContext.request.userPrincipal != null && wiki_scope != null && wiki_scope != ''}">
							<portlet:actionURL var="createDomainURL"/>
							<form id="${uid}_create_domain_form" method="POST" action="${createDomainURL}" style="display: none">
								<input type="hidden" name="wiki_scope" id="${uid)_wiki_scope" value="${wiki_scope}"/>
								<input type="hidden" name="page_name" id="${uid)_wiki_page" value="${wiki_page}"/>
								<input id="${uid}_page_action" type="hidden" name="page_action" value="create_domain"/>		
							</form>
							<script type="text/javascript">
								if (typeof wikiPortlet_confirm != "undefined") {
									<fmt:message key='wiki.no.domain.create.msg' var="wiki_no_domain_msg">
										<fmt:param value="${wiki_scope}"/>
									</fmt:message>
									if (typeof wikiPortlet_confirm != "undefined") {
										if (wikiPortlet_confirm("${uid}", "${wiki_no_domain_msg}")) {
											var form = document.getElementById("${uid}_create_domain_form");
											form.submit();
										}
									}								
								}								
							</script>
						</c:when>
						<c:otherwise>
							<c:choose>
								<c:when test="${wiki_scope != null && wiki_scope != ''}">
									<fmt:message key='wiki.invalid.domain.msg' var="wiki_invalid_domain_msg">
										<fmt:param value="${wiki_scope}"/>
									</fmt:message>
								</c:when>
								<c:otherwise>
									<fmt:message key='wiki.no.domain.msg' var="wiki_invalid_domain_msg">
									</fmt:message>
								</c:otherwise>
							</c:choose>
							<script type="text/javascript">
								//<![CDATA[
									(typeof wikiPortlet_alert != "undefined") ? wikiPortlet_alert("${uid}", "${wiki_invalid_domain_msg}") : void(0);
								//]]>
							</script>						
						</c:otherwise>
					</c:choose>
				</c:when>
				<c:when test="${error_type == 'invalid_page'}">
					<c:choose>
						<c:when test="${pageContext.request.userPrincipal != null}">
							<portlet:actionURL var="createPageURL"/>
							<form id="${uid}_create_page_form" method="POST" action="${createPageURL}" style="display: none">
								<input type="hidden" name="wiki_scope" id="${uid)_wiki_scope" value="${wiki_scope}"/>
								<input type="hidden" name="page_name" id="${uid)_wiki_page" value="${wiki_page}"/>
								<input id="${uid}_page_action" type="hidden" name="page_action" value="create"/>		
							</form>
							<script type="text/javascript">
								<fmt:message key='wiki.not.exist.create.msg' var="wiki_not_exist_msg">
									<fmt:param value="${wiki_page}"/>
									<fmt:param value="${wiki_scope}"/>
								</fmt:message>
								if (typeof wikiPortlet_confirm != "undefined") {
									if (wikiPortlet_confirm("${uid}", "${wiki_not_exist_msg}")) {
										var form = document.getElementById("${uid}_create_page_form");
										form.submit();
									}
								}								
							</script>
						</c:when>
						<c:otherwise>
							<fmt:message key='wiki.not.exist.msg' var="wiki_not_exist_msg">
								<fmt:param value="${wiki_page}"/>
								<fmt:param value="${wiki_scope}"/>
							</fmt:message>
							<script type="text/javascript">
							//<![CDATA[
								(typeof wikiPortlet_alert != "undefined") ? wikiPortlet_alert("${uid}", "${wiki_not_exist_msg}") : void(0);
							//]]>
							</script>
						</c:otherwise>
					</c:choose>
				</c:when>
				<c:when test="${error_type == 'invalid_url'}">
					<fmt:message key='wiki.invalid.url.msg' var="wiki_invalid_url_msg">
						<fmt:param value="${wiki_url}"/>
					</fmt:message>
					<script type="text/javascript">
					//<![CDATA[
						(typeof wikiPortlet_alert != "undefined") ? wikiPortlet_alert("${uid}", "${wiki_invalid_url_msg}") : void(0);
					//]]>
					</script>
				</c:when>
				<c:when test="${error_type == 'invalid_service'}">
					<fmt:message key='wiki.invalid.service.msg' var="wiki_invalid_service_msg">
						<fmt:param value="${wiki_url}"/>
					</fmt:message>
					<script type="text/javascript">
					//<![CDATA[
						(typeof wikiPortlet_alert != "undefined") ? wikiPortlet_alert("${uid}", "${wiki_invalid_service_msg}") : void(0);
					//]]>
					</script>
				</c:when>
			</c:choose>				
		</c:otherwise>
	</c:choose>	
</jsp:root>