Browse Source

enhance eventregistration form

This add multiple features to the form:

- The description field does automatic HTML paragraphs and linebreaks,
  showing the text as the registrator intends
- The description field escapes HTML
- The form contains a field to select the event entry's language. This
  helps set an automatic filename
- The tag for the country contains the full country name as visible
- The country field is now inserted automatically without the need to
  translate it
- The country-list template can now be extended with a CSS class
Max Mehl 8 months ago
Signed by: max.mehl <> GPG Key ID: 2704E4AB371E2E92

+ 6
- 1
cgi-bin/registerevent.php View File

@@ -67,7 +67,8 @@ function send_registration_mail($from, $to) {
'city' => $_POST['city'],
'countrycode' => explode('|', $_POST['country'])[0],
'countryname' => explode('|', $_POST['country'])[1],
'tags' => $_POST['tags']
'tags' => $_POST['tags'],
'lang' => $_POST['lang']

$data['event'] = eval_template('registerevent/event.php', $data);
@@ -81,6 +82,10 @@ function send_registration_mail($from, $to) {
. "X-OTRS-Queue: Events\n"
. "Content-Type: multipart/mixed; boundary=boundary";

// uncomment for local debug
// print_r($message);
// exit(0);

mail($to, $subject, $message, $headers);

return $data['img_error'];

+ 59
- 34
community/tools/eventregistration.en.xhtml View File

@@ -16,6 +16,19 @@

<form action="/cgi-bin/registerevent.php" method="POST" class="register_event fsfe-form" enctype="multipart/form-data" role="form">
<!-- @TRANSLATORS: there is no need to translate the HTML
attributes of the elements in this form, just the text between
the '>' and '<'.

An example:

<label><input type="checkbox" name="tags[]" value="localgroup" />talk</label>

can be translated to Spanish

<label><input type="checkbox" name="tags[]" value="localgroup" />grupo local</label>

Thank you! -->
<input name="register_event" type="hidden" />

<!--<fieldset id="register_event">-->
@@ -28,6 +41,48 @@

<p class="help-block">Your personal information will never be shared nor sold. It is used only to get in contact with you if there are any call backs or problems.</p>

<div class="form-group">
<label for="lang">Language of this event registration<span class="star">*</span></label>
<!-- @Translators: There is no need to translate the list below -->
<select id="lang" name="lang" class="form-control" required="required">
<option value="ar">&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1617;&#1577;</option>
<option value="bg">Български</option>
<option value="bs">Bosanski</option>
<option value="ca">Català</option>
<option value="cs">Česky</option>
<option value="da">Dansk</option>
<option value="de">Deutsch</option>
<option value="el">Ελληνικά</option>
<option value="en">English</option>
<option value="es">Español</option>
<option value="et">Eesti</option>
<option value="fi">Suomi</option>
<option value="fr">Français</option>
<option value="hr">Hrvatski</option>
<option value="hu">Magyar</option>
<option value="it">Italiano</option>
<option value="mk">Mакедонски</option>
<option value="nb">Norsk (bokmål)</option>
<option value="nl">Nederlands</option>
<option value="nn">Norsk (nynorsk)</option>
<option value="pl">Polski</option>
<option value="pt">Português</option>
<option value="ro">Română</option>
<option value="ru">Русский</option>
<option value="sk">Slovenčina</option>
<option value="sl">Slovenščina</option>
<option value="sq">Shqip</option>
<option value="sr">Српски</option>
<option value="sv">Svenska</option>
<option value="tr">Türkçe</option>
<option value="uk">Українська</option>
<option value="zh">漢語</option>
<p class="help-block">Please indicate the language of the text you will insert in the title and description. This will help our team to upload your event quickly and flawlessly. If you would like to provide a translation of your event (that would be great!), please make a separate event registration. Thank you!</p>

<!--<label for="groupname">Group name</label>
<input name="groupname" value="" type="text" />-->

@@ -43,7 +98,7 @@
<input name="startdate" value="" required="required" type="date" placeholder="YYYY-MM-DD" />
<label for="enddate" >End date</label>*
<label for="enddate" >End date</label>
<input name="enddate" value="" type="date" placeholder="YYYY-MM-DD" />
@@ -77,39 +132,9 @@
<input name="city" value="" required="required" type="text" />

<div class="form-group">
<label for="country">Country<span class="star">*</span></label>
<select name="country" class="form-control">
<option value="at|Austria">Austria</option>
<option value="be|Belgium">Belgium</option>
<option value="bg|Bulgaria">Bulgaria</option>
<option value="hr|Croatia">Croatia</option>
<option value="dk|Denmark">Denmark</option>
<option value="ee|Estonia">Estonia</option>
<option value="fi|Finland">Finland</option>
<option value="fr|France">France</option>
<option value="de|Germany">Germany</option>
<option value="gr|Greece">Greece</option>
<option value="hu|Hungary">Hungary</option>
<option value="ie|Ireland">Ireland</option>
<option value="it|Italy">Italy</option>
<option value="lv|Latvia">Latvia</option>
<option value="lt|Lithuania">Lithuania</option>
<option value="lu|Luxembourg">Luxembourg</option>
<option value="mt|Malta">Malta</option>
<option value="nl|Netherlands">Netherlands</option>
<option value="pl|Poland">Poland</option>
<option value="pt|Portugal">Portugal</option>
<option value="ro|Romania">Romania</option>
<option value="sr|Serbia">Serbia</option>
<option value="sk|Slovakia">Slovakia</option>
<option value="si|Slovenia">Slovenia</option>
<option value="es|Spain">Spain</option>
<option value="se|Sweden">Sweden</option>
<option value="ch|Switzerland">Switzerland</option>
<option value="uk|United Kingdom">United Kingdom</option>
<option value="|outside of Europe">Other</option>
<label for="country">Country<span class="star">*</span></label>
<country-list />

<!-- Should help against spam -->

+ 1
- 0
community/tools/eventregistration.sources View File

@@ -0,0 +1 @@

+ 14
- 0
community/tools/eventregistration.xsl View File

@@ -0,0 +1,14 @@
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:import href="../../fsfe.xsl" />
<xsl:import href="../../tools/xsltsl/countries.xsl" />
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" />
<!-- Dropdown list of countries requiring a choice -->
<!-- when copying this, remember importing the xsl, and editing the .source file -->
<xsl:template match="country-list">
<xsl:call-template name="country-list">
<xsl:with-param name="required" select="'yes'"/>
<xsl:with-param name="class" select="'form-control'"/>

+ 2
- 2
templates/registerevent/event.php View File

@@ -6,13 +6,13 @@
<title><?php echo htmlspecialchars($title) . " in " . htmlspecialchars($city) . ", " . htmlspecialchars($countryname); ?></title>

<p><?php echo $description?></p>
<p><?php echo str_replace("</p><p>","</p>\n <p>",nl2br(preg_replace("/(\r?\n){2,}/", "</p><p>", htmlspecialchars($description)))); ?></p>

<?php if($url) { echo "<link>" . htmlspecialchars($url) . "</link>"; }?>

<tag content=""><?php echo htmlspecialchars($countrycode); ?></tag>
<tag content="<?php echo htmlspecialchars($countryname); ?>"><?php echo htmlspecialchars($countrycode); ?></tag>
foreach ($tags as $tag) {
echo sprintf('<tag content="">%s</tag>', htmlspecialchars($tag)) . "\n";

+ 1
- 1
templates/registerevent/mail.php View File

@@ -28,7 +28,7 @@ Content-Disposition: attachment; filename="wikievent.txt"
Content-Type: application/xml; charset=utf-8
Content-Disposition: attachment; filename="event.xml"
Content-Disposition: attachment; filename="event-<?php echo str_replace("-", "", $startdate) . "-01." . $lang; ?>.xml"


+ 7
- 0
tools/xsltsl/countries.xsl View File

@@ -201,9 +201,16 @@
<!-- showing a dropdown select menu with all countries in /tools/countries.**.xml -->
<xsl:template name="country-list">
<xsl:param name="required" select="'no'" />
<xsl:param name="class" select="''" />
<xsl:element name="select">
<xsl:attribute name="id">country</xsl:attribute>
<xsl:attribute name="name">country</xsl:attribute>
<!-- if called with a "class" value, set it as the CSS class -->
<xsl:when test="$class != ''">
<xsl:attribute name="class"><xsl:value-of select="$class" /></xsl:attribute>
<!-- when called with the required="yes" param, add the attribute
and an empty option -->