diff --git a/CHANGELOG.md b/CHANGELOG.md index f2d5015..ee6a5d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# v1.2.8 +## 09/10/2020 + +1. [](#improved) + * Improved some translations +1. [](#bugfix) + * Fix for PHP 7.4 [#81](https://github.com/getgrav/grav-plugin-comments/issues/81) + * Fix for allowing path in form submission [#86](https://github.com/getgrav/grav-plugin-comments/issues/86) [#80](https://github.com/getgrav/grav-plugin-comments/issues/80) + # v1.2.7 ## 05/12/2017 diff --git a/blueprints.yaml b/blueprints.yaml index 1daf30b..4b825e8 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,7 @@ name: Comments -version: 1.2.7 +type: plugin +slug: comments +version: 1.2.8 description: Adds a commenting functionality to your site icon: comment author: diff --git a/comments.php b/comments.php index 7a59543..f7f44eb 100644 --- a/comments.php +++ b/comments.php @@ -73,8 +73,17 @@ public function onFormPageHeaderProcessed(Event $event) } public function onTwigSiteVariables() { - $this->grav['twig']->enable_comments_plugin = $this->enable; - $this->grav['twig']->comments = $this->fetchComments(); + // Old way + $enabled = $this->enable; + $comments = $this->fetchComments(); + + $this->grav['twig']->enable_comments_plugin = $enabled; + $this->grav['twig']->comments = $comments; + + // New way + $this->grav['twig']->twig_vars['enable_comments_plugin'] = $enabled; + $this->grav['twig']->twig_vars['comments'] = $comments; + } /** @@ -189,8 +198,9 @@ public function onFormProcessed(Event $event) case 'addComment': $post = isset($_POST['data']) ? $_POST['data'] : []; + $path = $this->grav['uri']->path(); + $lang = filter_var(urldecode($post['lang']), FILTER_SANITIZE_STRING); - $path = filter_var(urldecode($post['path']), FILTER_SANITIZE_STRING); $text = filter_var(urldecode($post['text']), FILTER_SANITIZE_STRING); $name = filter_var(urldecode($post['name']), FILTER_SANITIZE_STRING); $email = filter_var(urldecode($post['email']), FILTER_SANITIZE_STRING); @@ -347,7 +357,8 @@ private function fetchComments() { $filename = $lang ? '/' . $lang : ''; $filename .= $this->grav['uri']->path() . '.yaml'; - $comments = $this->getDataFromFilename($filename)['comments']; + $data = $this->getDataFromFilename($filename); + $comments = isset($data['comments']) ? $data['comments'] : null; //save to cache if enabled $cache->save($this->comments_cache_id, $comments); return $comments; diff --git a/languages.yaml b/languages.yaml index 69533a1..3101de2 100644 --- a/languages.yaml +++ b/languages.yaml @@ -132,25 +132,25 @@ it: ja: PLUGIN_COMMENTS: - ADD_COMMENT: コメントを追加する + ADD_COMMENT: コメントする COMMENTS: コメント - EMAIL_NOT_CONFIGURED: メールアドレスは設定さていません - NEW_COMMENT_EMAIL_SUBJECT: '%1$sについて新しいコメント' - NEW_COMMENT_EMAIL_BODY: '
新しいコメントが%1$sについて%3$sから(%4$s)書かれた.
ページー : %2$s
文書 : %5$s
' + EMAIL_NOT_CONFIGURED: メールアドレスが設定さていません + NEW_COMMENT_EMAIL_SUBJECT: '%1$sの新しいコメント' + NEW_COMMENT_EMAIL_BODY: '%1$sに新しいコメントが%3$sから(%4$s)に書かれました。
ページ : %2$s
内容 : %5$s
' EMAIL_FOOTER: '' NAME: 名前 : EMAIL: メールアドレス : - WRITTEN_ON: に書かれた - BY: に + WRITTEN_ON: 投稿日時 + BY: By NAME_LABEL: "名前" - NAME_PLACEHOLDER: "お名前を" - EMAIL_LABEL: "メールアドレスを" - EMAIL_PLACEHOLDER: "ご自分のメールアドレスをここに..." + NAME_PLACEHOLDER: "名前を入力してください" + EMAIL_LABEL: "メールアドレス" + EMAIL_PLACEHOLDER: "メールアドレスを入力してください" MESSAGE_LABEL: "コメント" - MESSAGE_PLACEHOLDER: "コメントをここに" - SUBMIT_COMMENT_BUTTON_TEXT: "送信する" - EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント]、 {{ form.value.name|e }}から" - THANK_YOU_MESSAGE: "コメントを書いてくださいましてありがとうございました!" + MESSAGE_PLACEHOLDER: "コメントを入力してください" + SUBMIT_COMMENT_BUTTON_TEXT: "送信" + EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント] {{ form.value.name|e }}から" + THANK_YOU_MESSAGE: "コメントありがとうございます!" nl: PLUGIN_COMMENTS: @@ -193,12 +193,21 @@ ru: COMMENTS: Комментарии EMAIL_NOT_CONFIGURED: Email не настроен NEW_COMMENT_EMAIL_SUBJECT: 'Новый комментарий к %1$s' - NEW_COMMENT_EMAIL_BODY: 'Новый комментарий был сделан на %1$s by %3$s (%4$s).
Страница: %2$s
Текст: %5$s
' + NEW_COMMENT_EMAIL_BODY: 'Новый комментарий на %1$s от %3$s (%4$s).
Страница: %2$s
Текст: %5$s
' EMAIL_FOOTER: '' NAME: Имя: EMAIL: Email: WRITTEN_ON: Написан в BY: от + NAME_LABEL: "Имя" + NAME_PLACEHOLDER: "Введите свое имя" + EMAIL_LABEL: "Email" + EMAIL_PLACEHOLDER: "Введите свой email адрес" + MESSAGE_LABEL: "Комментарий" + MESSAGE_PLACEHOLDER: "Введите свой комментарий" + SUBMIT_COMMENT_BUTTON_TEXT: "Отправить" + EMAIL_NEW_COMMENT_SUBJECT: "[Новый комментарий] от {{ form.value.name|e }}" + THANK_YOU_MESSAGE: "Благодарим за ваш комментарий!" pt-br: PLUGIN_COMMENTS: diff --git a/templates/partials/comments.html.twig b/templates/partials/comments.html.twig index 29d79b9..b1ff904 100644 --- a/templates/partials/comments.html.twig +++ b/templates/partials/comments.html.twig @@ -1,4 +1,4 @@ -{% if grav.twig.enable_comments_plugin %} +{% if enable_comments_plugin %} {% set scope = scope ?: 'data.' %}{{comment.text}} |