Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-03-16 06:13:33 +0300
committervipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-03-16 06:13:33 +0300
commita54f115c78fc5e0b78a70a67fbcff7dbca4aea8b (patch)
tree4ab24afa689a11ec30a1aa6690c94c3242fa3904 /plugins/Feedback
parent7f9abbb1c07044d00e13a00fbbf3f0c0e33f8a02 (diff)
fixes #1091 - update the Feedback plugin per ticket; also i18n-ize the remaining text strings, replace iframe with jquery-ui modal dialog, and add another example of using a nonce
Diffstat (limited to 'plugins/Feedback')
-rw-r--r--plugins/Feedback/Controller.php38
-rw-r--r--plugins/Feedback/Feedback.php12
-rw-r--r--plugins/Feedback/images/go-previous.pngbin0 -> 1200 bytes
-rw-r--r--plugins/Feedback/templates/feedback.js16
-rw-r--r--plugins/Feedback/templates/index.tpl78
-rw-r--r--plugins/Feedback/templates/sent.tpl41
6 files changed, 116 insertions, 69 deletions
diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php
index 7060f72816..9804ee55b8 100644
--- a/plugins/Feedback/Controller.php
+++ b/plugins/Feedback/Controller.php
@@ -1,11 +1,11 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Feedback
*/
@@ -15,10 +15,11 @@
* @package Piwik_Feedback
*/
class Piwik_Feedback_Controller extends Piwik_Controller
-{
+{
function index()
- {
+ {
$view = Piwik_View::factory('index');
+ $view->nonce = Piwik::getNonce('Piwik_Feedback.sendFeedback', 3600);
echo $view->render();
}
@@ -27,16 +28,18 @@ class Piwik_Feedback_Controller extends Piwik_Controller
*/
function sendFeedback()
{
- $body = Piwik_Common::getRequestVar('body', '', 'string');
$email = Piwik_Common::getRequestVar('email', '', 'string');
+ $body = Piwik_Common::getRequestVar('body', '', 'string');
+ $category = Piwik_Common::getRequestVar('category', '', 'string');
+ $nonce = Piwik_Common::getRequestVar('nonce', '', 'string');
$view = Piwik_View::factory('sent');
- try
+ try
{
$minimumBodyLength = 35;
if(strlen($body) < $minimumBodyLength)
{
- throw new Exception(sprintf("Message must be at least %s characters long.", $minimumBodyLength));
+ throw new Exception(Piwik_TranslateException('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
}
if(!Piwik::isValidEmailString($email))
{
@@ -44,14 +47,21 @@ class Piwik_Feedback_Controller extends Piwik_Controller
}
if(strpos($body, 'http://') !== false)
{
- throw new Exception("The message cannot contain a URL, to avoid spams messages.");
+ throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
}
-
+ if(!Piwik::verifyNonce('Piwik_Feedback.sendFeedback', $nonce))
+ {
+ throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
+ }
+
$mail = new Piwik_Mail();
- $mail->setFrom($email);
- $mail->addTo('hello@piwik.org','Piwik Team');
- $mail->setSubject('[ Feedback form - Piwik ]');
- $mail->setBodyText($body);
+ $mail->setFrom(Piwik_Common::unsanitizeInputValue($email));
+ $mail->addTo('hello@piwik.org', 'Piwik Team');
+ $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
+ $mail->setBodyText(Piwik_Common::unsanitizeInputValue($body) . "\n"
+ . 'Piwik ' . Piwik_Version::VERSION . "\n"
+ . 'IP: ' . Piwik_Common::getIpString() . "\n"
+ . 'URL: ' . Piwik_Url::getReferer() . "\n");
@$mail->send();
}
catch(Exception $e)
@@ -59,7 +69,7 @@ class Piwik_Feedback_Controller extends Piwik_Controller
$view->ErrorString = $e->getMessage();
$view->message = $body;
}
-
+
echo $view->render();
}
}
diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php
index b1fbb59b54..ef72872999 100644
--- a/plugins/Feedback/Feedback.php
+++ b/plugins/Feedback/Feedback.php
@@ -1,11 +1,11 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Feedback
*/
@@ -30,10 +30,16 @@ class Piwik_Feedback extends Piwik_Plugin
function getListHooksRegistered()
{
return array(
+ 'template_css_import' => 'css',
'template_js_import' => 'js',
);
}
-
+
+ function css()
+ {
+ echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/Feedback/templates/styles.css\" />\n";
+ }
+
function js()
{
echo "<script type=\"text/javascript\" src=\"plugins/Feedback/templates/feedback.js\"></script>\n";
diff --git a/plugins/Feedback/images/go-previous.png b/plugins/Feedback/images/go-previous.png
new file mode 100644
index 0000000000..c37bc0414c
--- /dev/null
+++ b/plugins/Feedback/images/go-previous.png
Binary files differ
diff --git a/plugins/Feedback/templates/feedback.js b/plugins/Feedback/templates/feedback.js
index 94aba1c2b0..814e095e0a 100644
--- a/plugins/Feedback/templates/feedback.js
+++ b/plugins/Feedback/templates/feedback.js
@@ -1,20 +1,26 @@
$(function() {
- // initialize
var feedback = $('a#topbar-feedback');
if (feedback.size()) {
- var iframe = $('<iframe src="' + feedback.attr('href') + '" style="width:450px !important;" width="450"></iframe>').appendTo('body');
- iframe.dialog({
+ var fbDiv = $('<div id="feedback-dialog"></div>').appendTo('body');
+
+ $.get(feedback.attr('href'), function(data) {
+ fbDiv.html(data);
+ });
+
+ fbDiv.dialog({
title: feedback.html(),
bgiframe: true,
modal: true,
height: 480,
- width: 450,
+ width: 460,
resizable: false,
autoOpen: false
});
$('#topbar-feedback').click(function() {
- iframe.dialog('open');
+ $('#feedback-faq').show();
+ $('#feedback-form').hide();
+ fbDiv.dialog('open');
return false;
});
}
diff --git a/plugins/Feedback/templates/index.tpl b/plugins/Feedback/templates/index.tpl
index aec45f58ce..992ba78a08 100644
--- a/plugins/Feedback/templates/index.tpl
+++ b/plugins/Feedback/templates/index.tpl
@@ -1,24 +1,62 @@
{literal}
-<style>
-input, textarea, p {
- font-family: Georgia,"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- font-size:0.9em;
- padding:0.2em;
-}
-input {
- margin-top:0.8em;
-}
-</style>
-{/literal}
+<script type="text/javascript">
+$(function() {
+ $('#feedback-contact').click(function() {
+ $('#feedback-faq').toggle();
+ $('#feedback-form').toggle();
+ return false;
+ });
-<form method="post" action="index.php?module=Feedback&action=sendFeedback">
+ $('#feedback-home').click(function() {
+ $('#feedback-form').hide();
+ $('#feedback-faq').show();
+ return false;
+ });
-<p><strong>your email :</strong>
-<br /><input type="text" name="email" size="40" /></p>
+ $('#feedback-form-submit').click(function() {
+ var feedback = $('#feedback-form form');
+ $('#feedback-form').hide();
+ $.post(feedback.attr('action'), feedback.serialize(), function (data) {
+ $('#feedback-sent').show().html(data);
+ });
+ return false;
+ });
+});
+</script>
+{/literal}
-<p><strong>your feedback:</strong><br/>
-<i>please be precise if you request for a feature or report a bug</i></p>
-<textarea name="body" cols="37" rows="10"></textarea>
-<br/>
-<input type="submit" value="Send feedback" />
-</form>
+ <div id="feedback-faq">
+ <p><strong>{'Feedback_PleaseUseForum'|translate}</strong></p>
+ <p>» {'Feedback_ViewAnswersTo'|translate} <a href="http://piwik.org/faq/">{'Feedback_FrequentlyAskedQuestions'|translate}</a>.</p>
+ <ul>
+ <li>{'Feedback_WhyAreMyVisitsNoTracked'|translate}</li>
+ <li>{'Feedback_WhyNoData'|translate}</li>
+ <li>{'Feedback_HowToExclude'|translate}</li>
+ <li>{'Feedback_WhyWrongCountry'|translate}</li>
+ <li>{'Feedback_HowToAnonymizeIP'|translate}</li>
+ </ul>
+ <p>» {'Feedback_VisitThe'|translate} <a href="http://forum.piwik.org/">{'Feedback_Forums'|translate}</a>.</p>
+ <p>» {'Feedback_LearnWaysTo'|translate} <a href="http://piwik.org/contribute/">{'Feedback_Participate'|translate}</a>.</p>
+ <p>» {'Feedback_SpecialRequest'|translate} <a href="#" id="feedback-contact">{'Feedback_ContactUs'|translate}</a>.</p>
+ </div>
+ <div id="feedback-form" style="display:none;">
+ <form method="post" action="index.php?module=Feedback&action=sendFeedback">
+ <p><strong>{'Feedback_IWantTo'|translate}</strong>
+ <select name="category">
+ <option value="share">{'Feedback_CategoryShareStory'|translate}</option>
+ <option value="sponsor">{'Feedback_CategorySponsor'|translate}</option>
+ <option value="hire">{'Feedback_CategoryHire'|translate}</option>
+ <option value="security">{'Feedback_CategorySecurity'|translate}</option>
+ </select>
+ </p>
+ <p><strong>{'Feedback_MyEmailAddress'|translate}</strong><br />
+ <input type="text" name="email" size="40" />
+ <input type="hidden" name="nonce" value="{$nonce}" /></p>
+ <p><strong>{'Feedback_MyMessage'|translate}</strong> {'Feedback_DetailsPlease'|translate}<br />
+ <textarea name="body" cols="37" rows="10"></textarea></p>
+ <p><input id="feedback-form-submit" type="submit" value="{'Feedback_SendFeedback'|translate}" /></p>
+ <p><a href="#" id="feedback-home"><img src="plugins/Feedback/images/go-previous.png" border="0" title="{'General_Previous'|translate}" alt="[{'General_Previous'|translate}]" /></a></p>
+ </form>
+ </div>
+ <div id="feedback-sent" style="display:none;">
+ </div>
diff --git a/plugins/Feedback/templates/sent.tpl b/plugins/Feedback/templates/sent.tpl
index e453a0d650..e64feef521 100644
--- a/plugins/Feedback/templates/sent.tpl
+++ b/plugins/Feedback/templates/sent.tpl
@@ -1,33 +1,20 @@
{literal}
-<style>
-body {
- font-family: Georgia,"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- font-size:0.9em;
- padding:0.2em;
-}
-#error {
- color: red;
- text-align: center;
- border: 2px solid red;
- background-color:#FFFBFB;
- margin: 10px;
- padding: 10px;
-}
-#success {
- color: #38D73B;
- text-align: center;
- border: 2px solid #38D73B;
- margin: 10px;
- padding: 10px;
-}
-</style>
+<script type="text/javascript">
+ $('#feedback-retry').click(function() {
+ $('#feedback-sent').hide().empty();
+ $('#feedback-form').show();
+ return false;
+ });
+</script>
{/literal}
{if isset($ErrorString)}
- <div id="error"><strong>{'General_Error'|translate}:</strong> {$ErrorString}</div>
- <p>Please manually send your message at <a href='mailto:hello@piwik.org'>hello@piwik.org</a></p>
- <p>{$message}</p>
+ <div id="feedback-error"><strong>{'General_Error'|translate}:</strong> {$ErrorString}</div>
+ <p>{'Feedback_ManuallySendEmailTo'|translate} <a href='mailto:hello@piwik.org?subject={'[Feedback form - Piwik]'|escape:"hex"}&body={$message|stripeol|escape:"hex"}'>hello@piwik.org</a></p>
+ <textarea cols="37" rows="10" readonly="readonly">{$message}</textarea>
+ <p><a href="#" id="feedback-retry"><img src="plugins/Feedback/images/go-previous.png" border="0" title="{'General_Previous'|translate}" alt="[{'General_Previous'|translate}]" /></a></p>
{else}
- <div id="success">Your message was sent to Piwik.</div>
- <p><strong>Thank you for your helping us making Piwik better!</strong><br /> The Piwik Team</p>
+ <div id="feedback-success">{'Feedback_MessageSent'|translate}</div>
+ <p><strong>{'Feedback_ThankYou'|translate}</strong></p>
+ <p>-- {'Feedback_ThePiwikTeam'|translate}</p>
{/if}