<%@ taglib uri="infoglue-page" prefix="page" %>
<%@ taglib uri="infoglue-common" prefix="common" %>
<%@ taglib uri="infoglue-content" prefix="content" %>
<%@ taglib uri="infoglue-structure" prefix="structure" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/mailer-1.1" prefix="mt" %>
<%!
String getSecurityCode( HttpSession session)
{
String securityCode = (String)session.getAttribute("securityCode");
if(securityCode == null)
{
java.security.SecureRandom random = new java.security.SecureRandom();
securityCode = new java.math.BigInteger(130, random).toString(32);
session.setAttribute("securityCode", securityCode);
}
return securityCode;
}
%>
<%
String securityCode = getSecurityCode(session);
pageContext.setAttribute("securityCode", securityCode);
%>
<page:pageContext id="pc"/>
<page:deliveryContext id="dc" useFullUrl="true" disableNiceUri="false" disablePageCache="true"/>
<common:urlBuilder id="currentUrl"/>
<c:choose>
<c:when test="${param.saveContent == true && param.igSecurityCode != securityCode}">
Operation failed - mail us your details instead
</c:when>
<c:when test="${param.saveContent == true && param.igSecurityCode == securityCode && param.siteName != && param.url != && param.shortDescription != && param.implementingCompany != && param.contactInfoImplementor != && param.contactInfoCustomer != }">
<!-- Save the content remote and send email -->
<content:content id="parentContent" propertyName="ParentContent" useInheritance="false"/>
<content:contentTypeDefinition id="ctd" contentTypeDefinitionName="Reference"/>
<content:remoteContentService id="rcs" operationName="createContents">
<content:contentParameter name="${param.siteName}" parentContentId="${parentContent.id}" contentTypeDefinitionId="${ctd.id}" repositoryId="${parentContent.repositoryId}">
<content:contentVersionParameter languageId="${dc.languageId}">
<content:contentVersionAttributeParameter name="Title" value="${param.siteName}"/>
<content:contentVersionAttributeParameter name="NavigationTitle" value="${param.siteName}"/>
<content:contentVersionAttributeParameter name="SiteAddress" value="${param.url}"/>
<content:contentVersionAttributeParameter name="ContactName" value="${param.contactInfoImplementor}"/>
<content:contentVersionAttributeParameter name="ContactEmail" value="${param.contactInfoCustomer}"/>
<content:contentVersionAttributeParameter name="Description" value="${param.shortDescription}"/>
</content:contentVersionParameter>
</content:contentParameter>
</content:remoteContentService>
<structure:componentPropertyValue id="recipientEmail" propertyName="Recipient"/>
<!--Email: <c:out value="${recipientEmail}"/>-->
<c:set var="smtpServer" value="${pc.smtpServer}"/>
<mt:mail server="<%= (String)pageContext.getAttribute("smtpServer") %>" from="no-reply@infoglue.org">
<mt:setrecipient type="to"><c:out value="${recipientEmail}"/></mt:setrecipient>
<mt:subject>A reference was added</mt:subject>
<mt:message type="html" charset="utf-8">
<div>
SiteName: <c:out value="${param.siteName}"/><br/>
URL: <c:out value="${param.url}"/><br/>
Implementor: <c:out value="${param.contactInfoImplementor}"/><br/>
Customer: <c:out value="${param.contactInfoCustomer}"/><br/>
Description: <c:out value="${param.shortDescription}"/><br/>
IP-nummer: <%= request.getRemoteAddr() %><br/>
Webbläsare: <%= request.getHeader("User-Agent") %><br/>
</div>
</mt:message>
<mt:send/>
</mt:mail>
<h2>Thank you</h2>
<p>
The reference was added and will be published after review<br/>
</p>
<h3>Add another reference</h3>
<!-- End -->
</c:when>
</c:choose>
<!-- Input form -->
<style>
fieldset
{
border: 1px solid #cecbce;
width: 500px;
margin-top: 20px;
margin-bottom: 20px;
}
legend
{
color: #5a5d5a;
font-family: Arial, Verdana, San serif;
font-size:11px;
line-height: 14px;
background-color: #efefef;
border: 1px solid #cecbce;
padding: 2px 6px;
}
fieldset p
{
line-heigh: 12px;
margin: 0px;
padding-bottom: 4px;
clear: both;
}
fieldset label
{
width: 150px;
float: left;
text-align: left;
margin-right: 0.5em;
display: block;
}
fieldset select
{
background: white;
border: 1px solid #cccccc;
font-family: Verdana, Arial, San serif;
font-size: 8pt;
width: 300px;
}
fieldset input
{
background: white;
border: 1px solid #cccccc;
font-family: Verdana, Arial, San serif;
font-size: 8pt;
width: 300px;
}
fieldset textarea
{
background: white;
border: 1px solid #cccccc;
font-family: Verdana, Arial, San serif;
font-size: 8pt;
width: 300px;
height: 50px;
}
.submitButton
{
background: #efebef;
font-family: Arial, Helvetica, San serif;
font-size:11px;
line-height: 14px;
border: 1px solid #cecbce;
width: 100px;
}
</style>
<script type="text/javascript">
<!--
function submitCompany()
{
document.contentForm.igSecurityCode.value = "<c:out value="${securityCode}"/>";
document.contentForm.submit();
}
-->
</script>
<form name="contentForm" action="<c:out value="${currentUrl}"/>" method="POST" onsubmit="return false">
<input type="hidden" name="saveContent" value="true"/>
<input type="hidden" name="igSecurityCode" value=""/>
<fieldset>
<legend>Enter reference information</legend>
<p>
<label for="siteName">Site name <c:if test="${param.siteName == }"><span style="color:red;">*</span></c:if></label>
<input type="text" name="siteName"/>
</p>
<p>
<label for="url">Web address <c:if test="${param.url == }"><span style="color:red;">*</span></c:if></label>
<input type="text" name="url"/>
</p>
<p>
<label for="implementingCompany">Implementing company <c:if test="${param.implementingCompany == }"><span style="color:red;">*</span></c:if></label>
<input type="text" name="implementingCompany"/>
</p>
<p>
<label for="contactInfoImplementor">Contact impl. company <c:if test="${param.contactInfoImplementor == }"><span style="color:red;">*</span></c:if></label>
<input type="text" name="contactInfoImplementor"/>
</p>
<p>
<label for="contactInfoCustomer">Contact data customer <c:if test="${param.contactInfoCustomer == }"><span style="color:red;">*</span></c:if></label>
<input type="text" name="contactInfoCustomer"/>
</p>
<p>
<label for="shortDescription">Short description <c:if test="${param.shortDescription == }"><span style="color:red;">*</span></c:if></label>
<textarea name="shortDescription"></textarea>
</p>
<p>
<input class="submitButton" type="button" value="Submit" onclick="submitCompany();"/>
</p>
</fieldset>
</form>
<!-- End -->