Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1093 feedback form should have a headline or subject #1130

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,17 @@ public function invokeFeedbackForm($request)
}
$feedbackName = $request->getQueryParamPOST('name');
$feedbackEmail = $request->getQueryParamPOST('email');
$msgSubject = $this->model->getConfig()->getServiceName() . ": ";
miguelvaara marked this conversation as resolved.
Show resolved Hide resolved
$msgSubject .= $request->getQueryParamPOST('msgsubject');
$feedbackVocab = $request->getQueryParamPOST('vocab');

$feedbackVocabEmail = ($feedbackVocab !== null && $feedbackVocab !== '') ?
$this->model->getVocabulary($feedbackVocab)->getConfig()->getFeedbackRecipient() : null;

// if the hidden field has been set a value we have found a spam bot
// and we do not actually send the message.
if ($this->honeypot->validateHoneypot($request->getQueryParamPOST('item-description')) &&
$this->honeypot->validateHoneytime($request->getQueryParamPOST('user-captcha'), $this->model->getConfig()->getHoneypotTime())) {
$this->sendFeedback($request, $feedbackMsg, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
$this->sendFeedback($request, $feedbackMsg, $msgSubject, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
}

echo $template->render(
array(
'languages' => $this->languages,
Expand All @@ -245,46 +244,43 @@ private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
if (!empty($fromEmail)) {
$headers .= "Reply-To: $fromName <$fromEmail>\r\n";
}

$service = $this->model->getConfig()->getServiceName();
return $headers . "From: $fromName via $service <$sender>";
}

/**
* Sends the user entered message through the php's mailer.
* @param string $message only required parameter is the actual message.
miguelvaara marked this conversation as resolved.
Show resolved Hide resolved
* @param string $messageSubject from the sender.
miguelvaara marked this conversation as resolved.
Show resolved Hide resolved
* @param string $fromName senders own name.
* @param string $fromEmail senders email address.
* @param string $fromVocab which vocabulary is the feedback related to.
*/
public function sendFeedback($request, $message, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
{
$toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
if ($fromVocab !== null && $fromVocab !== '') {
$message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
}

Copy link
Contributor

@kouralex kouralex Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these lines may have been there for comprehensibility. It is not a good idea to remove them out of no reason. If one does want to do such operations, it is recommended to be done in a separate commit/branch in order to not confuse the PR.

Does not require further changes.

$envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender();
$subject = $this->model->getConfig()->getServiceName() . " feedback";
// determine the sender address of the message
$sender = $this->model->getConfig()->getFeedbackSender();
if (empty($sender)) $sender = $envelopeSender;
if (empty($sender)) $sender = $this->model->getConfig()->getFeedbackAddress();

// determine sender name - default to "anonymous user" if not given by user
if (empty($fromName)) $fromName = "anonymous user";

$headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender);
$params = empty($envelopeSender) ? '' : "-f $envelopeSender";

// adding some information about the user for debugging purposes.
$message = $message . "<br /><br /> Debugging information:"
. "<br />Timestamp: " . date(DATE_RFC2822)
. "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT')
. "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');

try {
mail($toAddress, $subject, $message, $headers, $params);
mail($toAddress, $messageSubject, $message, $headers, $params);
} catch (Exception $e) {
header("HTTP/1.0 404 Not Found");
$template = $this->twig->loadTemplate('error-page.twig');
Expand Down
18 changes: 11 additions & 7 deletions resource/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ li, td > a {
font-size: 14px;
}

label {
Copy link
Contributor

@kouralex kouralex Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global setting - this will affect all labels in all places which is not acceptable. See #799 for more information. Should be changed to be as specific as possible.

Requires further changes.

font-weight: normal;
}

h1, .prefLabel, .prefLabelLang, .notation {
font-family: 'Fira Sans', sans-serif;
font-size: 24px;
Expand Down Expand Up @@ -667,7 +671,7 @@ span.xl-pref-label > img {
.welcome-box, .right-box, #vocabulary-list {
vertical-align: top;
}

.welcome-box {
background-color: #ffffff;
display: inline-block;
Expand Down Expand Up @@ -2000,7 +2004,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
margin: 2px 0 0 0;
line-height: 30px;
}

.concept-main > .row > .property-label-pref {
margin-top: 10px;
line-height: 20px;
Expand All @@ -2022,7 +2026,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
margin: 0;
width: 100%;
}

.headerbar-coloured {
overflow: hidden;
}
Expand All @@ -2034,7 +2038,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
}

@media (max-width: 800px) {

.twitter-typeahead {
width: 100%;
}
Expand Down Expand Up @@ -2103,7 +2107,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
.right-box {
display: inline;
}

.voclist-wide > .right-box {
left: 0;
top: 425px;
Expand Down Expand Up @@ -2161,12 +2165,12 @@ body, .versal, h1, h2, h3, p, .versal-bold {
.frontpage > .welcome-box, .frontpage > .right-box {
width: 200px;
}

.voclist #vocabulary-list {
margin-left: 20px;
width: calc(100% - 225px);
}

.voclist-right #vocabulary-list {
margin-left: 20px;
width: auto;
Expand Down
Binary file modified resource/translations/en/LC_MESSAGES/skosmos.mo
Binary file not shown.
Binary file modified resource/translations/fi/LC_MESSAGES/skosmos.mo
Binary file not shown.
9 changes: 9 additions & 0 deletions resource/translations/skosmos_en.po
Original file line number Diff line number Diff line change
Expand Up @@ -839,3 +839,12 @@ msgstr "Search results"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sidebar listing: list and traverse vocabulary contents by a criterion"

msgid "Subject:"
msgstr "Subject:"

msgid "Write a subject"
msgstr "Write a subject"

msgid "Select a vocabulary"
msgstr "You can select a vocabulary"
9 changes: 9 additions & 0 deletions resource/translations/skosmos_fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -838,3 +838,12 @@ msgstr "Hakutulokset"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sivupalkin lista: listaa ja selaa käsitteitä eri kriteerien mukaan"

msgid "Subject:"
msgstr "Aihe:"

msgid "Write a subject"
msgstr "Kirjoita aihe"

msgid "Select a vocabulary"
msgstr "Voit valita halutessasi sanaston"
9 changes: 9 additions & 0 deletions resource/translations/skosmos_sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,12 @@ msgstr "Sökresultat"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sidofältlista: ordna och bläddra begrepp efter kriterier"

msgid "Subject:"
msgstr "Ämne:"

msgid "Write a subject"
msgstr "Skriv ett ämne"

msgid "Select a vocabulary"
msgstr "Du kan välja ett vokabulär"
miguelvaara marked this conversation as resolved.
Show resolved Hide resolved
Binary file modified resource/translations/sv/LC_MESSAGES/skosmos.mo
Binary file not shown.
3 changes: 1 addition & 2 deletions tests/testconfig-fordefaults.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
skos:prefLabel "Test ontology"@en ;
skosmos:arrayClass isothes:ThesaurusArray ;
skosmos:defaultLanguage "en";
skosmos:feedbackRecipient "developer@vocabulary.org";
skosmos:feedbackRecipient "developer@vocabulary.org";
skosmos:groupClass skos:Collection;
skosmos:language "en";
skosmos:showTopConcepts "true";
Expand All @@ -48,4 +48,3 @@ mdrtype:THESAURUS a skos:Concept ;

mdrtype:ONTOLOGY a skos:Concept ;
skos:prefLabel "Онтология"@bg, "Ontologie"@cs, "Ontologi"@da, "Ontologie"@de, "Οντολογία"@el, "Ontology"@en, "Ontoloogia"@et, "Ontologia"@fi, "Ontologie"@fr, "Ontologija"@hr, "Ontológia"@hu, "Ontologia"@it, "Ontoloģija"@lv, "Ontologija"@lt, "Ontoloġija"@mt, "Ontologie"@nl, "Ontologi"@no, "Struktura pojęciowa"@pl, "Ontologia"@pt, "Ontologie"@ro, "Ontológia"@sk, "Ontologija"@sl, "Ontología"@es, "Ontologi"@sv .

23 changes: 15 additions & 8 deletions view/feedback.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% if vocabList %}
<input id="feedback-vocid-input" name="vocab" type="hidden"{% if request.vocabid %} value="{{ request.vocabid }}"{% endif %}>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="feedback-vocid" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<button class="btn btn-default dropdown-toggle" type="button" id="feedback-vocid" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" aria-label="{% trans %}Select a vocabulary{% endtrans %}">
{% if request.vocabid %}{{ request.vocab.title }}{% else %}{% trans %}Not to a specific vocabulary{% endtrans %}{% endif %}
<span class="caret"></span>
</button>
Expand All @@ -30,15 +30,22 @@
</div>
{% endif %}
<p>{% trans "feedback_enter_name_email" %}</p>

<p>{% trans %}Name:{% endtrans %}</p>
<input id="name" class="form-control" type ="text" size="40" name="name" placeholder="{% trans %}Enter your name{% endtrans %}">
<p>{% trans %}E-mail:{% endtrans %}</p>
<input id="email" class="form-control" type ="text" size="40" name="email" placeholder="{% trans %}Enter your e-mail address{% endtrans %}">
<p>{% trans %}Message:{% endtrans %} *</p>
<p>
<label for="name">{% trans %}Name:{% endtrans %}</label>
<input id="name" class="form-control" type="text" size="40" name="name" placeholder="{% trans %}Enter your name{% endtrans %}">
</p>
<p>
<label for="email">{% trans %}E-mail:{% endtrans %}</label>
<input id="email" class="form-control" type="text" size="40" name="email" placeholder="{% trans %}Enter your e-mail address{% endtrans %}">
</p>
<p>
<label for="msgsubject">{% trans %}Subject:{% endtrans %}</label>
<input id="msgsubject" class="form-control" type="text" size="40" name="msgsubject" placeholder="{% trans %}Write a subject{% endtrans %}">
</p>
<label for="message">{% trans %}Message:{% endtrans %}</label>
<textarea id="message" class="form-control" name="message"></textarea>
{{ honeypot.generate('item-description', 'user-captcha')|raw }}
<button type="submit" class="btn btn-primary" id="send-feedback">{% trans %}Send feedback{% endtrans %}</button>
<button type="submit" class="btn btn-primary" id="send-feedback" aria-label="{% trans %}Send feedback{% endtrans %}">{% trans %}Send feedback{% endtrans %}</button>
miguelvaara marked this conversation as resolved.
Show resolved Hide resolved
</form>
{% endif %}
</div>
Expand Down