diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e1acc0..30028a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +# v1.1.0 +## 11/24/2015 + +1. [](#improved) + Use date instead of gmdate to respect the server local time (thanks @bovisp) +1. [](#improved) + Now works with multilang (thanks @bovisp) +1. [](#new) + Added french (@codebee-fr) and russian (@joomline) languages +1. [](#new) + Takes advantage of the new nonce support provided by the Form plugin + +# v1.0.2 +## 11/13/2015 + +1. [](#improved) + * Use nonce +1. [](#improved) + * Changed form action to work with multilang + +# v1.0.1 +## 11/11/2015 + +1. [](#bugfix) + * Fix error when user/data/comments does not exist +1. [](#improved) + * Use onAdminMenu instead of the deprecated onAdminTemplateNavPluginHook + # v1.0.0 ## 10/21/2015 diff --git a/blueprints.yaml b/blueprints.yaml index 4c49570..23c8197 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Comments -version: 1.0.0 +version: 1.1.0 description: Adds a commenting functionality to your site icon: comment author: diff --git a/comments.php b/comments.php index 7f3389f..1dda2ac 100644 --- a/comments.php +++ b/comments.php @@ -1,6 +1,7 @@ enable([ 'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0], - 'onAdminTemplateNavPluginHook' => ['onAdminTemplateNavPluginHook', 0], + 'onAdminMenu' => ['onAdminMenu', 0], + 'onAdminTemplateNavPluginHook' => ['onAdminMenu', 0], //DEPRECATED 'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0], ]); @@ -175,7 +177,7 @@ class CommentsPlugin extends Plugin $data['comments'][] = [ 'text' => $text, - 'date' => gmdate('D, d M Y H:i:s', time()), + 'date' => date('D, d M Y H:i:s', time()), 'author' => $name, 'email' => $email ]; @@ -185,7 +187,7 @@ class CommentsPlugin extends Plugin 'lang' => $lang, 'comments' => array([ 'text' => $text, - 'date' => gmdate('D, d M Y H:i:s', time()), + 'date' => date('D, d M Y H:i:s', time()), 'author' => $name, 'email' => $email ]) @@ -204,6 +206,10 @@ class CommentsPlugin extends Plugin $path = DATA_DIR . 'comments'; } + if (!file_exists($path)) { + Folder::mkdir($path); + } + $dirItr = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS); $filterItr = new RecursiveFolderFilterIterator($dirItr); $itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST); @@ -311,7 +317,7 @@ class CommentsPlugin extends Plugin $pages[] = [ 'title' => $file->data['title'], 'commentsCount' => count($file->data['comments']), - 'lastCommentDate' => gmdate('D, d M Y H:i:s', $file->modifiedDate) + 'lastCommentDate' => date('D, d M Y H:i:s', $file->modifiedDate) ]; } @@ -354,7 +360,7 @@ class CommentsPlugin extends Plugin /** * Add navigation item to the admin plugin */ - public function onAdminTemplateNavPluginHook() + public function onAdminMenu() { $this->grav['twig']->plugins_hooked_nav['PLUGIN_COMMENTS.COMMENTS'] = ['route' => $this->route, 'icon' => 'fa-file-text']; } diff --git a/languages.yaml b/languages.yaml index e4a65da..ae3212c 100644 --- a/languages.yaml +++ b/languages.yaml @@ -10,6 +10,18 @@ en: EMAIL: Email: WRITTEN_ON: Written on BY: by +fr: + PLUGIN_COMMENTS: + ADD_COMMENT: Ajouter un commentaire + COMMENTS: Commentaires + EMAIL_NOT_CONFIGURED: Email non configurée + NEW_COMMENT_EMAIL_SUBJECT: 'Nouveau commentaire sur %1$s' + NEW_COMMENT_EMAIL_BODY: '

Un nouveau commentaire a été posté sur %1$s par %3$s (%4$s).

Page: %2$s

Texte: %5$s

' + EMAIL_FOOTER: '' + NAME: Nom: + EMAIL: Email: + WRITTEN_ON: Ecrit le + BY: par it: PLUGIN_COMMENTS: ADD_COMMENT: Aggiungi un commento @@ -22,3 +34,15 @@ it: EMAIL: Email: WRITTEN_ON: Scritto il BY: da +ru: + PLUGIN_COMMENTS: + ADD_COMMENT: Добавить комментарий + 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

' + EMAIL_FOOTER: '' + NAME: Имя: + EMAIL: Email: + WRITTEN_ON: Написан в + BY: от diff --git a/templates/partials/comments.html.twig b/templates/partials/comments.html.twig index 3462a23..7a798e1 100644 --- a/templates/partials/comments.html.twig +++ b/templates/partials/comments.html.twig @@ -3,7 +3,7 @@

{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}

{% for field in grav.config.plugins.comments.form.fields %} @@ -21,6 +21,8 @@ {% endfor %} + + {{ nonce_field('form', 'form-nonce') }}
{{ form.message }}
@@ -41,4 +43,4 @@ {% endfor %} {% endif %} -{% endif %} \ No newline at end of file +{% endif %}