Compare commits
No commits in common. "d00cca50a9115fe7872e784fad61c8177ed3ebb0" and "f03178f65f6f5da9c1d2238f7c2baa3213c4c817" have entirely different histories.
d00cca50a9
...
f03178f65f
|
@ -1,12 +1,3 @@
|
|||
0.7 - 2023.05.13
|
||||
* require dotclear 2.26
|
||||
* add plugin Uninstaller features
|
||||
* release for dotclear 2.26 stable
|
||||
|
||||
0.6 - 2023.04.26
|
||||
* require dotclear 2.26
|
||||
* use namespace
|
||||
|
||||
0.5 - 2023.01.05
|
||||
* update to dotclear 2.24
|
||||
* use anonymous functions
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[![Release](https://img.shields.io/github/v/release/JcDenis/comListe)](https://github.com/JcDenis/comListe/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/comListe)](https://github.com/JcDenis/comListe/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/comListe)](https://github.com/JcDenis/comListe/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/comListe)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/comListe)](https://github.com/JcDenis/comListe/blob/master/LICENSE)
|
||||
|
||||
|
@ -19,7 +19,7 @@ It adds public page of all comments and trackbacks.
|
|||
_comListe_ requires:
|
||||
|
||||
* admin perms for configuration
|
||||
* Dotclear 2.26
|
||||
* Dotclear 2.24
|
||||
|
||||
## USAGE
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
// Admin menu
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Comments list'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||
urldecode(dcPage::getPF(basename(__DIR__) . '/icon.png')),
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)
|
||||
);
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
// Dashboard favorites
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs) {
|
||||
$favs->register(basename(__DIR__), [
|
||||
'title' => __('Comments list'),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||
'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.png')),
|
||||
'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon-big.png')),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]),
|
||||
]);
|
||||
},
|
||||
'adminSimpleMenuAddType' => function (ArrayObject $items) {
|
||||
$items[basename(__DIR__)] = new ArrayObject([__('Comments list'), false]);
|
||||
},
|
||||
'adminSimpleMenuBeforeEdit' => function ($type, $select, &$item) {
|
||||
if (basename(__DIR__) == $type) {
|
||||
$item[0] = __('Comments list');
|
||||
$item[1] = dcCore::app()->blog->settings->get(basename(__DIR__))->get('page_title') ?? __('Comments list');
|
||||
$item[2] = dcCore::app()->admin->__get('blog_url') . dcCore::app()->url->getURLFor(basename(__DIR__));
|
||||
}
|
||||
},
|
||||
]);
|
19
_define.php
19
_define.php
|
@ -10,7 +10,7 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,15 @@ $this->registerModule(
|
|||
'Comments list',
|
||||
'Display a list of all comments and trackbacks of a blog in a public page',
|
||||
'Benoit de Marne, Pierre Van Glabeke and contributors',
|
||||
'0.7',
|
||||
'0.5',
|
||||
[
|
||||
'requires' => [['core', '2.26']],
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'settings' => [
|
||||
'self' => '',
|
||||
],
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333985',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||
'type' => 'plugin',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333985',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!dcCore::app()->newVersion(
|
||||
basename(__DIR__),
|
||||
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(basename(__DIR__));
|
||||
$s->put('enable', false, 'boolean', 'Enable comListe', false, true);
|
||||
$s->put('page_title', 'Comments list', 'string', 'Public page title', false, true);
|
||||
$s->put('nb_comments_per_page', 10, 'integer', 'Number of comments per page', false, true);
|
||||
$s->put('comments_order', 'desc', 'string', 'Comments order', false, true);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->url->register(
|
||||
'comListe',
|
||||
'comListe',
|
||||
'^comListe(?:/(.+))?$',
|
||||
[urlcomListe::class,'comListe']
|
||||
);
|
||||
|
||||
class urlcomListe extends dcUrlHandlers
|
||||
{
|
||||
public static function comListe($args)
|
||||
{
|
||||
$args = (string) $args;
|
||||
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('enable')) {
|
||||
self::p404();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$n = self::getPageNumber($args);
|
||||
if (!$n) {
|
||||
$n = 1;
|
||||
}
|
||||
|
||||
dcCore::app()->public->setPageNumber($n);
|
||||
dcCore::app()->ctx->__set('nb_comment_per_page', (int) dcCore::app()->blog->settings->get(basename(__DIR__))->get('nb_comments_per_page'));
|
||||
|
||||
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset');
|
||||
if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', $tplset]))) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', $tplset]));
|
||||
} else {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', DC_DEFAULT_TPLSET]));
|
||||
}
|
||||
|
||||
self::serveDocument('comListe.html');
|
||||
exit;
|
||||
}
|
||||
}
|
|
@ -10,58 +10,77 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('enable')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
class Template
|
||||
dcCore::app()->tpl->addValue('ComListeURL', [tplComListe::class,'comListeURL']);
|
||||
dcCore::app()->tpl->addValue('ComListePageTitle', [tplComListe::class,'comListePageTitle']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbComments', [tplComListe::class,'comListeNbComments']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbCommentsPerPage', [tplComListe::class,'comListeNbCommentsPerPage']);
|
||||
dcCore::app()->tpl->addBlock('ComListeCommentsEntries', [tplComListe::class,'comListeCommentsEntries']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationLinks', [tplComListe::class,'comListePaginationLinks']);
|
||||
dcCore::app()->tpl->addValue('ComListeOpenPostTitle', [tplComListe::class,'comListeOpenPostTitle']);
|
||||
dcCore::app()->tpl->addValue('ComListeCommentOrderNumber', [tplComListe::class,'comListeCommentOrderNumber']);
|
||||
|
||||
dcCore::app()->tpl->addBlock('ComListePagination', [tplComListe::class,'comListePagination']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationCounter', [tplComListe::class,'comListePaginationCounter']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationCurrent', [tplComListe::class,'comListePaginationCurrent']);
|
||||
dcCore::app()->tpl->addBlock('ComListePaginationIf', [tplComListe::class,'comListePaginationIf']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationURL', [tplComListe::class,'comListePaginationURL']);
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'publicBreadcrumb' => function ($context, $separator) {
|
||||
if ($context == 'comListe') {
|
||||
return __('Comments list');
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
class tplComListe
|
||||
{
|
||||
public string $html_prev = '«prev.';
|
||||
public string $html_next = 'next»';
|
||||
public $html_prev = '«prev.';
|
||||
public $html_next = 'next»';
|
||||
|
||||
/* ComListeURL --------------------------------------- */
|
||||
public static function comListeURL(ArrayObject $attr): string
|
||||
public static function comListeURL($attr)
|
||||
{
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("comListe")') . '; ?>';
|
||||
}
|
||||
|
||||
/* ComListePageTitle --------------------------------------- */
|
||||
public static function comListePageTitle(ArrayObject $attr): string
|
||||
public static function comListePageTitle($attr)
|
||||
{
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("page_title")') . '; ?>';
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("page_title")') . '; ?>';
|
||||
}
|
||||
|
||||
/* ComListeNbCommentsPerPage --------------------------------------- */
|
||||
public static function comListeNbCommentsPerPage(ArrayObject $attr): string
|
||||
public static function comListeNbCommentsPerPage($attr)
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
|
||||
return '10';
|
||||
}
|
||||
dcCore::app()->ctx->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page'));
|
||||
dcCore::app()->ctx->__set('nb_comment_per_page', (int) dcCore::app()->blog->settings->get(basename(__DIR__))->get('nb_comments_per_page'));
|
||||
|
||||
return Html::escapeHTML((string) dcCore::app()->ctx->__get('nb_comment_per_page'));
|
||||
return html::escapeHTML((string) dcCore::app()->ctx->__get('nb_comment_per_page'));
|
||||
}
|
||||
|
||||
/* comListeNbComments --------------------------------------- */
|
||||
public static function comListeNbComments(ArrayObject$attr): string
|
||||
public static function comListeNbComments($attr)
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
|
||||
return '0';
|
||||
}
|
||||
if (!dcCore::app()->ctx->exists('pagination')) {
|
||||
dcCore::app()->ctx->__set('pagination', dcCore::app()->blog->getComments([], true));
|
||||
}
|
||||
$nb_comments = dcCore::app()->ctx->__get('pagination')->f(0);
|
||||
|
||||
return Html::escapeHTML((string) $nb_comments);
|
||||
return html::escapeHTML((string) $nb_comments);
|
||||
}
|
||||
|
||||
/* ComListeCommentsEntries --------------------------------------- */
|
||||
public static function comListeCommentsEntries(ArrayObject $attr, string $content): string
|
||||
public static function comListeCommentsEntries($attr, $content)
|
||||
{
|
||||
$p = 'if (dcCore::app()->ctx->posts !== null) { ' .
|
||||
"\$params['post_id'] = dcCore::app()->ctx->posts->post_id; " .
|
||||
|
@ -91,17 +110,17 @@ class Template
|
|||
"}\n";
|
||||
|
||||
$p .= 'if (dcCore::app()->ctx->exists("langs")) { ' .
|
||||
"\$params['sql'] = \"AND P.post_lang = '\".dcCore::app()->blog->con->escapeStr((string) dcCore::app()->langs->post_lang).\"' \"; " .
|
||||
"\$params['sql'] = \"AND P.post_lang = '\".dcCore::app()->blog->con->escape(dcCore::app()->langs->post_lang).\"' \"; " .
|
||||
"}\n";
|
||||
}
|
||||
|
||||
// Sens de tri issu des paramètres du plugin
|
||||
$order = is_null(dcCore::app()->blog) ? 'desc' : My::settings()->get('comments_order');
|
||||
$order = dcCore::app()->blog->settings->get(basename(__DIR__))->get('comments_order');
|
||||
if (isset($attr['order']) && preg_match('/^(desc|asc)$/i', $attr['order'])) {
|
||||
$order = $attr['order'];
|
||||
}
|
||||
|
||||
$p .= "\$params['order'] = 'comment_dt " . ($order ?? 'desc') . "';\n";
|
||||
$p .= "\$params['order'] = 'comment_dt " . $order . "';\n";
|
||||
|
||||
if (isset($attr['no_content']) && $attr['no_content']) {
|
||||
$p .= "\$params['no_content'] = true;\n";
|
||||
|
@ -126,7 +145,7 @@ class Template
|
|||
|
||||
/* ComListePaginationLinks --------------------------------------- */
|
||||
/* Reprise et adaptation de la fonction PaginationLinks du plugin advancedPagination-1.9 */
|
||||
public static function comListePaginationLinks(ArrayObject $attr): string
|
||||
public static function comListePaginationLinks($attr)
|
||||
{
|
||||
$p = '<?php
|
||||
|
||||
|
@ -165,7 +184,7 @@ class Template
|
|||
$nb_comments = dcCore::app()->ctx->pagination->f(0);
|
||||
}
|
||||
|
||||
$nb_per_page = abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page"));
|
||||
$nb_per_page = abs((integer) dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("nb_comments_per_page"));
|
||||
$nb_pages = ceil($nb_comments/$nb_per_page);
|
||||
$nb_max_pages = 10;
|
||||
$nb_sequence = 2*3+1;
|
||||
|
@ -213,7 +232,7 @@ class Template
|
|||
}
|
||||
|
||||
/* ComListeOpenPostTitle --------------------------------------- */
|
||||
public static function comListeOpenPostTitle(ArrayObject $attr): string
|
||||
public static function comListeOpenPostTitle($attr)
|
||||
{
|
||||
return __('open post');
|
||||
}
|
||||
|
@ -224,7 +243,7 @@ class Template
|
|||
'<?php echo ' .
|
||||
'dcCore::app()->ctx->comments->index() + 1 +' .
|
||||
'(dcCore::app()->public->getPageNumber() - 1) * ' .
|
||||
'abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page"));' .
|
||||
'abs((integer) dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("nb_comments_per_page"));' .
|
||||
'?>';
|
||||
}
|
||||
|
||||
|
@ -251,7 +270,7 @@ class Template
|
|||
return
|
||||
"<?php\n" .
|
||||
'$bakcup_old_nbpp = dcCore::app()->ctx->nb_entry_per_page; ' . "\n" .
|
||||
'dcCore::app()->ctx->nb_entry_per_page = abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page"));' . "\n" .
|
||||
'dcCore::app()->ctx->nb_entry_per_page = abs((integer) dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("nb_comments_per_page"));' . "\n" .
|
||||
"?>\n" .
|
||||
$params .
|
||||
'<?php if (dcCore::app()->ctx->pagination->f(0) > dcCore::app()->ctx->comments->count()) : ?>' .
|
||||
|
@ -263,14 +282,14 @@ class Template
|
|||
|
||||
public static function comListePaginationCounter(ArrayObject $attr): string
|
||||
{
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationNbPages()') . '; ?>';
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'context::PaginationNbPages()') . '; ?>';
|
||||
}
|
||||
|
||||
public static function comListePaginationCurrent(ArrayObject $attr): string
|
||||
{
|
||||
$offset = isset($attr['offset']) ? (int) $attr['offset'] : 0;
|
||||
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationPosition(' . $offset . ')') . '; ?>';
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'context::PaginationPosition(' . $offset . ')') . '; ?>';
|
||||
}
|
||||
|
||||
public static function comListePaginationIf(ArrayObject $attr, string $content): string
|
||||
|
@ -279,12 +298,12 @@ class Template
|
|||
|
||||
if (isset($attr['start'])) {
|
||||
$sign = (bool) $attr['start'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx::PaginationStart()';
|
||||
$if[] = $sign . 'context::PaginationStart()';
|
||||
}
|
||||
|
||||
if (isset($attr['end'])) {
|
||||
$sign = (bool) $attr['end'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx::PaginationEnd()';
|
||||
$if[] = $sign . 'context::PaginationEnd()';
|
||||
}
|
||||
|
||||
if (count($if)) {
|
||||
|
@ -301,6 +320,6 @@ class Template
|
|||
$offset = (int) $attr['offset'];
|
||||
}
|
||||
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationURL(' . $offset . ')') . '; ?>';
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'context::PaginationURL(' . $offset . ')') . '; ?>';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('initWidgets', [comListeWidget::class,'initWidget']);
|
||||
|
||||
class comListeWidget
|
||||
{
|
||||
public static function initWidget($w)
|
||||
{
|
||||
$w->create(
|
||||
'comListe',
|
||||
__('Comments list'),
|
||||
['comListeWidget','publicWidget'],
|
||||
null,
|
||||
__('Link to comments list public page')
|
||||
)
|
||||
->addTitle(__('Comments list'))
|
||||
->setting(
|
||||
'link_title',
|
||||
__('Link title: (leave empty to use page title'),
|
||||
__('Comments list')
|
||||
)
|
||||
->addHomeOnly()
|
||||
->addContentOnly()
|
||||
->addClass()
|
||||
->addOffline();
|
||||
}
|
||||
|
||||
public static function publicWidget($w)
|
||||
{
|
||||
if ($w->offline
|
||||
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| !dcCore::app()->blog->settings->get(basename(__DIR__))->get('enable')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $w->renderDiv(
|
||||
$w->content_only,
|
||||
'comliste ' . $w->class,
|
||||
'',
|
||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||
sprintf(
|
||||
'<p><a href="%s">%s</a></p>',
|
||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('comListe'),
|
||||
$w->link_title ? html::escapeHTML($w->link_title) : (dcCore::app()->blog->settings->get(basename(__DIR__))->get('page_title') ?? __('Comments list'))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="comListe">
|
||||
<name>Comments list</name>
|
||||
<version>0.7</version>
|
||||
<version>0.5</version>
|
||||
<author>Benoit de Marne, Pierre Van Glabeke and contributors</author>
|
||||
<desc>Display a list of all comments and trackbacks of a blog in a public page</desc>
|
||||
<file>https://github.com/JcDenis/comListe/releases/download/v0.7/plugin-comListe.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<file>https://github.com/JcDenis/comListe/releases/download/v0.5/plugin-comListe.zip</file>
|
||||
<da:dcmin>2.24</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/comListe</da:details>
|
||||
<da:support>http://forum.dotclear.org/viewtopic.php?pid=333985</da:support>
|
||||
</module>
|
||||
|
|
|
@ -54,14 +54,14 @@
|
|||
<nav class="pagination" aria-label="{{tpl:lang Pagination}}" role="navigation">
|
||||
<tpl:Block name="_pagination-content-prev">
|
||||
<tpl:ComListePaginationIf end="0">
|
||||
<a href="{{tpl:ComListePaginationURL offset="+1"}}" class="prev"><span aria-hidden="true">« </span>{{tpl:lang previous entries}}</a>
|
||||
<a href="{{tpl:ComListePaginationURL offset="+1"}}" class="prev"><span aria-hidden="true">« </span>{{tpl:lang previous entries}}</a> -
|
||||
</tpl:ComListePaginationIf>
|
||||
</tpl:Block>
|
||||
<tpl:Block name="_pagination-content-current">
|
||||
<span class="visually-hidden">{{tpl:lang Active page}}</span>{{tpl:lang page}} {{tpl:ComListePaginationCurrent}} {{tpl:lang of}} {{tpl:ComListePaginationCounter}}
|
||||
</tpl:Block>
|
||||
<tpl:Block name="_pagination-content-next">
|
||||
<tpl:ComListePaginationIf start="0"> <a href="{{tpl:ComListePaginationURL offset="-1"}}" class="next">
|
||||
<tpl:ComListePaginationIf start="0"> - <a href="{{tpl:ComListePaginationURL offset="-1"}}" class="next">
|
||||
{{tpl:lang next entries}}<span aria-hidden="true"> »</span></a>
|
||||
</tpl:ComListePaginationIf>
|
||||
</tpl:Block>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
11
icon.svg
11
icon.svg
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg width="800px" height="800px" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_901_1004)">
|
||||
<path d="M23.875 25C23.875 25 27.937 29 28.937 30C30.547 31.609 31 31 31 30V8C31 7.447 30.553 7 30 7H8C7.447 7 7 7.447 7 8V26C7 26.553 7.447 27 8 27H22M13 15H25M13 19H18M25 4V2C25 1.437 24.604 1 24 1H2C1.447 1 1 1.447 1 2V20C1 20.553 1.447 21 2 21H7" stroke="#a2cbe9" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_901_1004">
|
||||
<rect width="32" height="32" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 635 B |
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcPage::check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]));
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(basename(__dir__));
|
||||
$action = $_REQUEST['action'] ?? null;
|
||||
$order_combo = [
|
||||
__('Ascending') => 'asc',
|
||||
__('Descending') => 'desc',
|
||||
];
|
||||
|
||||
if ($action == 'saveconfig') {
|
||||
try {
|
||||
if (empty($_POST['comliste_page_title'])) {
|
||||
throw new Exception(__('No page title.'));
|
||||
}
|
||||
|
||||
$s->put('enable', !empty($_POST['comliste_enable']));
|
||||
$s->put('page_title', $_POST['comliste_page_title']);
|
||||
$s->put('nb_comments_per_page', $_POST['comliste_nb_comments_per_page'] ?? 10);
|
||||
$s->put('comments_order', $_POST['comliste_comments_order'] == 'asc' ? 'asc' : 'desc');
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugin.' . basename(__DIR__)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
<html><head><title>' . __('Comments list') . '</title></head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Comments list') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">' .
|
||||
'<div class="fieldset"><h4>' . __('Plugin activation') . '</h4>' .
|
||||
|
||||
'<p class="field"><label for="comliste_enable" class="classic">' .
|
||||
form::checkbox('comliste_enable', 1, (bool) $s->get('enable')) .
|
||||
__('Enable comListe') . '</label></p>' .
|
||||
|
||||
'</div>' .
|
||||
'<div class="fieldset"><h4>' . __('General options') . '</h4>' .
|
||||
|
||||
'<p><label for="comliste_page_title">' . __('Public page title:') . ' </label>' .
|
||||
form::field('comliste_page_title', 30, 255, (string) $s->get('page_title')) .
|
||||
'</label></p>' .
|
||||
|
||||
'<p><label for="comliste_nb_comments_per_page">' .
|
||||
__('Number of comments per page:') . '</label>' .
|
||||
form::number('comliste_nb_comments_per_page', ['min' => 0, 'max' => 99, 'default' => (int) $s->get('nb_comments_per_page')]) .
|
||||
'</p>' .
|
||||
|
||||
'<p><label for="comliste_comments_order">' . __('Comments order:') . '</label>' .
|
||||
form::combo('comliste_comments_order', $order_combo, $s->get('comments_order') == 'asc' ? 'asc' : 'desc') .
|
||||
'</p>' .
|
||||
|
||||
'</div>
|
||||
|
||||
<p class="clear">' .
|
||||
form::hidden(['action'], 'saveconfig') .
|
||||
dcCore::app()->formNonce() . '
|
||||
<input id="new-action" type="submit" name="save" value="' . __('Save') . '" />
|
||||
</p>
|
||||
|
||||
</form>';
|
||||
|
||||
dcPage::helpBlock('comListe');
|
||||
|
||||
echo '</body></html>';
|
|
@ -9,18 +9,16 @@
|
|||
# DOT NOT MODIFY THIS FILE !
|
||||
#
|
||||
|
||||
use Dotclear\Helper\L10n;
|
||||
|
||||
L10n::$locales['Comments list'] = 'Liste de commentaires';
|
||||
L10n::$locales['open post'] = 'ouvrir le billet';
|
||||
L10n::$locales['Link to comments list public page'] = 'Lien vers la page public de la liste des commentaires';
|
||||
L10n::$locales['Pages:'] = 'Pages :';
|
||||
L10n::$locales['Number of comments per page:'] = 'Nombre de commentaires par page :';
|
||||
L10n::$locales['Total Comments:'] = 'Nombre total de commentaires :';
|
||||
L10n::$locales['Source:'] = 'Source :';
|
||||
L10n::$locales['No page title.'] = 'Pas de titre de page.';
|
||||
L10n::$locales['Enable comListe'] = 'Activer comListe';
|
||||
L10n::$locales['General options'] = 'Options générales';
|
||||
L10n::$locales['Public page title:'] = 'Titre de la page public :';
|
||||
L10n::$locales['Comments order:'] = 'Ordre des commentaires :';
|
||||
L10n::$locales['Display a list of all comments and trackbacks of a blog in a public page'] = 'Afficher la liste de tous les commentaires et rétroliens d\'un blog dans une page publique';
|
||||
l10n::$locales['Comments list'] = 'Liste de commentaires';
|
||||
l10n::$locales['open post'] = 'ouvrir le billet';
|
||||
l10n::$locales['Link to comments list public page'] = 'Lien vers la page public de la liste des commentaires';
|
||||
l10n::$locales['Pages:'] = 'Pages :';
|
||||
l10n::$locales['Number of comments per page:'] = 'Nombre de commentaires par page :';
|
||||
l10n::$locales['Total Comments:'] = 'Nombre total de commentaires :';
|
||||
l10n::$locales['Source:'] = 'Source :';
|
||||
l10n::$locales['No page title.'] = 'Pas de titre de page.';
|
||||
l10n::$locales['Enable comListe'] = 'Activer comListe';
|
||||
l10n::$locales['General options'] = 'Options générales';
|
||||
l10n::$locales['Public page title:'] = 'Titre de la page public :';
|
||||
l10n::$locales['Comments order:'] = 'Ordre des commentaires :';
|
||||
l10n::$locales['Display a list of all comments and trackbacks of a blog in a public page'] = 'Afficher la liste de tous les commentaires et rétroliens d\'un blog dans une page publique';
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Admin menu
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
// Dashboard favorites
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(My::id(), [
|
||||
'title' => My::name(),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]),
|
||||
]);
|
||||
},
|
||||
'adminSimpleMenuAddType' => function (ArrayObject $items): void {
|
||||
$items[My::id()] = new ArrayObject([My::name(), false]);
|
||||
},
|
||||
'adminSimpleMenuBeforeEdit' => function (string $type, string $select, array &$item): void {
|
||||
if (My::id() == $type) {
|
||||
$item[0] = My::name();
|
||||
$item[1] = My::settings()->get('page_title') ?? My::name();
|
||||
$item[2] = dcCore::app()->admin->__get('blog_url') . dcCore::app()->url->getURLFor(My::id());
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::FRONTEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!My::settings()->get('enable')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->addValue('ComListeURL', [Template::class,'comListeURL']);
|
||||
dcCore::app()->tpl->addValue('ComListePageTitle', [Template::class,'comListePageTitle']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbComments', [Template::class,'comListeNbComments']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbCommentsPerPage', [Template::class,'comListeNbCommentsPerPage']);
|
||||
dcCore::app()->tpl->addBlock('ComListeCommentsEntries', [Template::class,'comListeCommentsEntries']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationLinks', [Template::class,'comListePaginationLinks']);
|
||||
dcCore::app()->tpl->addValue('ComListeOpenPostTitle', [Template::class,'comListeOpenPostTitle']);
|
||||
dcCore::app()->tpl->addValue('ComListeCommentOrderNumber', [Template::class,'comListeCommentOrderNumber']);
|
||||
|
||||
dcCore::app()->tpl->addBlock('ComListePagination', [Template::class,'comListePagination']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationCounter', [Template::class,'comListePaginationCounter']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationCurrent', [Template::class,'comListePaginationCurrent']);
|
||||
dcCore::app()->tpl->addBlock('ComListePaginationIf', [Template::class,'comListePaginationIf']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationURL', [Template::class,'comListePaginationURL']);
|
||||
|
||||
dcCore::app()->addBehavior(
|
||||
'publicBreadcrumb',
|
||||
function (string $context, string $separator): ?string {
|
||||
if ($context == 'comListe') {
|
||||
return __('Comments list');
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$s = My::settings();
|
||||
$s->put('enable', false, 'boolean', 'Enable comListe', false, true);
|
||||
$s->put('page_title', 'Comments list', 'string', 'Public page title', false, true);
|
||||
$s->put('nb_comments_per_page', 10, 'integer', 'Number of comments per page', false, true);
|
||||
$s->put('comments_order', 'desc', 'string', 'Comments order', false, true);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
134
src/Manage.php
134
src/Manage.php
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
Form,
|
||||
Hidden,
|
||||
Input,
|
||||
Label,
|
||||
Number,
|
||||
Para,
|
||||
Select,
|
||||
Submit,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (($_REQUEST['action'] ?? null) != 'saveconfig') {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (empty($_POST['comliste_page_title'])) {
|
||||
throw new Exception(__('No page title.'));
|
||||
}
|
||||
$s = My::settings();
|
||||
$s->put('enable', !empty($_POST['comliste_enable']));
|
||||
$s->put('page_title', $_POST['comliste_page_title']);
|
||||
$s->put('nb_comments_per_page', $_POST['comliste_nb_comments_per_page'] ?? 10);
|
||||
$s->put('comments_order', $_POST['comliste_comments_order'] == 'asc' ? 'asc' : 'desc');
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
Notices::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$s = My::settings();
|
||||
|
||||
Page::openModule(My::name());
|
||||
|
||||
echo Page::breadcrumb([
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
Notices::getNotices() .
|
||||
|
||||
(new Form('setting_form'))->method('post')->action(My::manageUrl())->separator('')->fields([
|
||||
(new Div())->class('fieldset')->items([
|
||||
(new Text('h4', __('Plugin activation'))),
|
||||
(new Para())->items([
|
||||
(new Checkbox('comliste_enable', (bool) $s->get('enable')))->value(1),
|
||||
(new Label(__('Enable comListe'), Label::OUTSIDE_LABEL_AFTER))->for('comliste_enable')->class('classic'),
|
||||
]),
|
||||
]),
|
||||
(new Div())->class('fieldset')->items([
|
||||
(new Text('h4', __('General options'))),
|
||||
(new Para())->items([
|
||||
(new Label(__('Public page title:'), Label::OUTSIDE_LABEL_BEFORE))->for('comliste_page_title'),
|
||||
(new Input('comliste_page_title'))->size(30)->maxlenght(255)->value((string) $s->get('page_title')),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Label(__('Number of comments per page:'), Label::OUTSIDE_LABEL_BEFORE))->for('comliste_nb_comments_per_page'),
|
||||
(new Number('comliste_nb_comments_per_page'))->min(0)->max(99)->value((int) $s->get('nb_comments_per_page')),
|
||||
]),
|
||||
(new Label(__('Comments order:'), Label::OUTSIDE_LABEL_BEFORE))->for('comliste_comments_order'),
|
||||
(new Select('comliste_comments_order'))
|
||||
->items([__('Ascending') => 'asc', __('Descending') => 'desc'])
|
||||
->default($s->get('comments_order') == 'asc' ? 'asc' : 'desc'),
|
||||
]),
|
||||
(new Para())->class('clear')->items([
|
||||
(new Submit(['do']))->value(__('Save')),
|
||||
(new Hidden(['action'], 'saveconfig')),
|
||||
... My::hiddenFields(),
|
||||
]),
|
||||
])->render();
|
||||
|
||||
Page::helpBlock('comListe');
|
||||
|
||||
Page::closeModule();
|
||||
}
|
||||
}
|
24
src/My.php
24
src/My.php
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::PREPEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->url->register(
|
||||
'comListe',
|
||||
'comListe',
|
||||
'^comListe(?:/(.+))?$',
|
||||
[UrlHandler::class, 'comListe']
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Uninstaller::instance()
|
||||
->addUserAction(
|
||||
'settings',
|
||||
'delete_all',
|
||||
My::id()
|
||||
)
|
||||
->addUserAction(
|
||||
'plugins',
|
||||
'delete',
|
||||
My::id()
|
||||
)
|
||||
->addUserAction(
|
||||
'versions',
|
||||
'delete',
|
||||
My::id()
|
||||
)
|
||||
->addDirectAction(
|
||||
'settings',
|
||||
'delete_all',
|
||||
My::id()
|
||||
)
|
||||
->addDirectAction(
|
||||
'plugins',
|
||||
'delete',
|
||||
My::id()
|
||||
)
|
||||
->addDirectAction(
|
||||
'versions',
|
||||
'delete',
|
||||
My::id()
|
||||
)
|
||||
;
|
||||
|
||||
// no custom action
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use dcUrlHandlers;
|
||||
|
||||
class UrlHandler extends dcUrlHandlers
|
||||
{
|
||||
public static function comListe(?string $args): void
|
||||
{
|
||||
$args = (string) $args;
|
||||
|
||||
if (is_null(dcCore::app()->blog)
|
||||
|| is_null(dcCore::app()->ctx)
|
||||
|| !My::settings()->get('enable')
|
||||
) {
|
||||
self::p404();
|
||||
}
|
||||
|
||||
dcCore::app()->public->setPageNumber(self::getPageNumber($args) ?: 1);
|
||||
dcCore::app()->ctx->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page'));
|
||||
|
||||
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset');
|
||||
if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
|
||||
} else {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET]));
|
||||
}
|
||||
|
||||
self::serveDocument('comListe.html');
|
||||
exit;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief comListe, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Benoit de Marne, Pierre Van Glabeke and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\comListe;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
class Widgets
|
||||
{
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
{
|
||||
$w->create(
|
||||
My::id(),
|
||||
My::name(),
|
||||
[self::class, 'parseWidget'],
|
||||
null,
|
||||
__('Link to comments list public page')
|
||||
)
|
||||
->addTitle(My::name())
|
||||
->setting(
|
||||
'link_title',
|
||||
__('Link title: (leave empty to use page title'),
|
||||
My::name()
|
||||
)
|
||||
->addHomeOnly()
|
||||
->addContentOnly()
|
||||
->addClass()
|
||||
->addOffline();
|
||||
}
|
||||
|
||||
public static function parseWidget(WidgetsElement $w): string
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)
|
||||
|| $w->__get('offline')
|
||||
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| !My::settings()->get('enable')
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $w->renderDiv(
|
||||
(bool) $w->__get('content_only'),
|
||||
My::id() . ' ' . $w->__get('class'),
|
||||
'',
|
||||
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') .
|
||||
sprintf(
|
||||
'<p><a href="%s">%s</a></p>',
|
||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('comListe'),
|
||||
$w->__get('link_title') ? Html::escapeHTML($w->__get('link_title')) : (My::settings()->get('page_title') ?? My::name())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue