Merge branch 'release/1.1.0'

This commit is contained in:
Flavio Copes 2015-11-24 15:30:21 +01:00
commit 42ede280e9
5 changed files with 68 additions and 8 deletions

View File

@ -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

View File

@ -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:

View File

@ -1,6 +1,7 @@
<?php
namespace Grav\Plugin;
use Grav\Common\Filesystem\Folder;
use Grav\Common\GPM\GPM;
use Grav\Common\Grav;
use Grav\Common\Page\Page;
@ -114,7 +115,8 @@ class CommentsPlugin extends Plugin
//Admin
$this->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'];
}

View File

@ -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: '<p>Un nouveau commentaire a été posté sur %1$s par %3$s (%4$s).</p><p>Page: %2$s</p><p>Texte: %5$s</p>'
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: '<p>Новый комментарий был сделан на %1$s by %3$s (%4$s).</p><p>Страница: %2$s</p><p>Текст: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Имя:
EMAIL: Email:
WRITTEN_ON: Написан в
BY: от

View File

@ -3,7 +3,7 @@
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
<form name="{{ grav.config.plugins.comments.form.name }}"
action="{{ uri.rootUrl ~ (grav.config.plugins.comments.form.action|default(page.route)) }}"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
{% for field in grav.config.plugins.comments.form.fields %}
@ -21,6 +21,8 @@
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button>
{% endfor %}
</div>
{{ nonce_field('form', 'form-nonce') }}
</form>
<div class="alert">{{ form.message }}</div>
@ -41,4 +43,4 @@
{% endfor %}
</table>
{% endif %}
{% endif %}
{% endif %}