Merge branch 'release/1.1.0'
This commit is contained in:
commit
42ede280e9
28
CHANGELOG.md
28
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
|
# v1.0.0
|
||||||
## 10/21/2015
|
## 10/21/2015
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: Comments
|
name: Comments
|
||||||
version: 1.0.0
|
version: 1.1.0
|
||||||
description: Adds a commenting functionality to your site
|
description: Adds a commenting functionality to your site
|
||||||
icon: comment
|
icon: comment
|
||||||
author:
|
author:
|
||||||
|
|
16
comments.php
16
comments.php
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Grav\Plugin;
|
namespace Grav\Plugin;
|
||||||
|
|
||||||
|
use Grav\Common\Filesystem\Folder;
|
||||||
use Grav\Common\GPM\GPM;
|
use Grav\Common\GPM\GPM;
|
||||||
use Grav\Common\Grav;
|
use Grav\Common\Grav;
|
||||||
use Grav\Common\Page\Page;
|
use Grav\Common\Page\Page;
|
||||||
|
@ -114,7 +115,8 @@ class CommentsPlugin extends Plugin
|
||||||
//Admin
|
//Admin
|
||||||
$this->enable([
|
$this->enable([
|
||||||
'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0],
|
'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0],
|
||||||
'onAdminTemplateNavPluginHook' => ['onAdminTemplateNavPluginHook', 0],
|
'onAdminMenu' => ['onAdminMenu', 0],
|
||||||
|
'onAdminTemplateNavPluginHook' => ['onAdminMenu', 0], //DEPRECATED
|
||||||
'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0],
|
'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -175,7 +177,7 @@ class CommentsPlugin extends Plugin
|
||||||
|
|
||||||
$data['comments'][] = [
|
$data['comments'][] = [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'date' => gmdate('D, d M Y H:i:s', time()),
|
'date' => date('D, d M Y H:i:s', time()),
|
||||||
'author' => $name,
|
'author' => $name,
|
||||||
'email' => $email
|
'email' => $email
|
||||||
];
|
];
|
||||||
|
@ -185,7 +187,7 @@ class CommentsPlugin extends Plugin
|
||||||
'lang' => $lang,
|
'lang' => $lang,
|
||||||
'comments' => array([
|
'comments' => array([
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'date' => gmdate('D, d M Y H:i:s', time()),
|
'date' => date('D, d M Y H:i:s', time()),
|
||||||
'author' => $name,
|
'author' => $name,
|
||||||
'email' => $email
|
'email' => $email
|
||||||
])
|
])
|
||||||
|
@ -204,6 +206,10 @@ class CommentsPlugin extends Plugin
|
||||||
$path = DATA_DIR . 'comments';
|
$path = DATA_DIR . 'comments';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
Folder::mkdir($path);
|
||||||
|
}
|
||||||
|
|
||||||
$dirItr = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
|
$dirItr = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||||
$filterItr = new RecursiveFolderFilterIterator($dirItr);
|
$filterItr = new RecursiveFolderFilterIterator($dirItr);
|
||||||
$itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);
|
$itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
@ -311,7 +317,7 @@ class CommentsPlugin extends Plugin
|
||||||
$pages[] = [
|
$pages[] = [
|
||||||
'title' => $file->data['title'],
|
'title' => $file->data['title'],
|
||||||
'commentsCount' => count($file->data['comments']),
|
'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
|
* 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'];
|
$this->grav['twig']->plugins_hooked_nav['PLUGIN_COMMENTS.COMMENTS'] = ['route' => $this->route, 'icon' => 'fa-file-text'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,18 @@ en:
|
||||||
EMAIL: Email:
|
EMAIL: Email:
|
||||||
WRITTEN_ON: Written on
|
WRITTEN_ON: Written on
|
||||||
BY: by
|
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:
|
it:
|
||||||
PLUGIN_COMMENTS:
|
PLUGIN_COMMENTS:
|
||||||
ADD_COMMENT: Aggiungi un commento
|
ADD_COMMENT: Aggiungi un commento
|
||||||
|
@ -22,3 +34,15 @@ it:
|
||||||
EMAIL: Email:
|
EMAIL: Email:
|
||||||
WRITTEN_ON: Scritto il
|
WRITTEN_ON: Scritto il
|
||||||
BY: da
|
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: от
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
|
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
|
||||||
|
|
||||||
<form name="{{ grav.config.plugins.comments.form.name }}"
|
<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') }}">
|
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
|
||||||
{% for field in grav.config.plugins.comments.form.fields %}
|
{% 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>
|
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ nonce_field('form', 'form-nonce') }}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="alert">{{ form.message }}</div>
|
<div class="alert">{{ form.message }}</div>
|
||||||
|
@ -41,4 +43,4 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue