update to dotclear 2.24
This commit is contained in:
parent
e5b7fdb30e
commit
83ea869ba2
10 changed files with 543 additions and 642 deletions
64
_admin.php
64
_admin.php
|
@ -1,33 +1,39 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
#--- icon.png issue du pack mini_icons_2 offertes par Brandspankingnew
|
||||
#--- http://www.brandspankingnew.net
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
// 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)
|
||||
);
|
||||
|
||||
$_menu['Blog']->addItem(__('List of comments'),'plugin.php?p=comListe','index.php?pf=comListe/icon.png',
|
||||
preg_match('/plugin.php\?p=comListe(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||
$core->auth->check('admin',$core->blog->id));
|
||||
|
||||
$core->addBehavior('adminDashboardFavorites','comListeDashboardFavorites');
|
||||
|
||||
function comListeDashboardFavorites($core,$favs)
|
||||
{
|
||||
$favs->register('comListe', array(
|
||||
'title' => __('List of comments'),
|
||||
'url' => 'plugin.php?p=comListe',
|
||||
'small-icon' => 'index.php?pf=comListe/icon.png',
|
||||
'large-icon' => 'index.php?pf=comListe/icon-big.png',
|
||||
'permissions' => 'usage,contentadmin'
|
||||
));
|
||||
}
|
||||
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]),
|
||||
]);
|
||||
},
|
||||
]);
|
||||
|
|
54
_define.php
54
_define.php
|
@ -1,28 +1,32 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */ "ComListe",
|
||||
/* Description*/ "Display a list of all comments and trackbacks of a blog in a public page",
|
||||
/* Author */ "Benoit de Marne, Pierre Van Glabeke",
|
||||
/* Version */ '0.4.2',
|
||||
/* Properties */
|
||||
array(
|
||||
'permissions' => 'admin',
|
||||
'type' => 'plugin',
|
||||
'dc_min' => '2.8',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333985#p333985',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/comListe'
|
||||
)
|
||||
);
|
||||
'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.5-dev',
|
||||
[
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
36
_install.php
Normal file
36
_install.php
Normal file
|
@ -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;
|
63
_prepend.php
63
_prepend.php
|
@ -1,15 +1,54 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
dcCore::app()->url->register(
|
||||
'comListe',
|
||||
'comListe',
|
||||
'^comListe(?:/(.+))?$',
|
||||
['urlcomListe','comListe']
|
||||
);
|
||||
|
||||
require dirname(__FILE__).'/_widgets.php';
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
253
_public.php
253
_public.php
|
@ -1,28 +1,235 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('enable')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public');
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
require_once dirname(__FILE__).'/inc/class.dc.comListe.php';
|
||||
|
||||
$core->url->register('comListe','comListe','^comListe(?:/(.+))?$',array('urlcomListe','comListe'));
|
||||
dcCore::app()->tpl->addValue('ComListeURL', ['tplComListe','comListeURL']);
|
||||
dcCore::app()->tpl->addValue('ComListePageTitle', ['tplComListe','comListePageTitle']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbComments', ['tplComListe','comListeNbComments']);
|
||||
dcCore::app()->tpl->addValue('ComListeNbCommentsPerPage', ['tplComListe','comListeNbCommentsPerPage']);
|
||||
dcCore::app()->tpl->addBlock('ComListeCommentsEntries', ['tplComListe','comListeCommentsEntries']);
|
||||
dcCore::app()->tpl->addValue('ComListePaginationLinks', ['tplComListe','comListePaginationLinks']);
|
||||
dcCore::app()->tpl->addValue('ComListeOpenPostTitle', ['tplComListe','comListeOpenPostTitle']);
|
||||
|
||||
$core->tpl->addValue('ComListeURL',array('tplComListe','comListeURL'));
|
||||
$core->tpl->addValue('ComListePageTitle',array('tplComListe','comListePageTitle'));
|
||||
$core->tpl->addValue('ComListeNbComments',array('tplComListe','comListeNbComments'));
|
||||
$core->tpl->addValue('ComListeNbCommentsPerPage',array('tplComListe','comListeNbCommentsPerPage'));
|
||||
$core->tpl->addBlock('ComListeCommentsEntries',array('tplComListe','comListeCommentsEntries'));
|
||||
$core->tpl->addValue('ComListePaginationLinks',array('tplComListe','comListePaginationLinks'));
|
||||
$core->tpl->addValue('ComListeOpenPostTitle',array('tplComListe','comListeOpenPostTitle'));
|
||||
$core->addBehavior('publicBreadcrumb',array('extComListe','publicBreadcrumb'));
|
||||
dcCore::app()->addBehaviors([
|
||||
'publicBreadcrumb' => function ($context, $separator) {
|
||||
if ($context == 'comListe') {
|
||||
return __('Comments list');
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
class tplComListe
|
||||
{
|
||||
public $html_prev = '«prev.';
|
||||
public $html_next = 'next»';
|
||||
|
||||
/* ComListeURL --------------------------------------- */
|
||||
public static function comListeURL($attr)
|
||||
{
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
|
||||
return '<?php echo ' . sprintf($f, 'dcCore::app()->blog->url.dcCore::app()->url->getBase("comListe")') . '; ?>';
|
||||
}
|
||||
|
||||
/* ComListePageTitle --------------------------------------- */
|
||||
public static function comListePageTitle($attr)
|
||||
{
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
|
||||
return '<?php echo ' . sprintf($f, 'dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("page_title")') . '; ?>';
|
||||
}
|
||||
|
||||
/* ComListeNbCommentsPerPage --------------------------------------- */
|
||||
public static function comListeNbCommentsPerPage($attr)
|
||||
{
|
||||
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'));
|
||||
}
|
||||
|
||||
/* comListeNbComments --------------------------------------- */
|
||||
public static function comListeNbComments($attr)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/* ComListeCommentsEntries --------------------------------------- */
|
||||
public static function comListeCommentsEntries($attr, $content)
|
||||
{
|
||||
$p = 'if (dcCore::app()->ctx->posts !== null) { ' .
|
||||
"\$params['post_id'] = dcCore::app()->ctx->posts->post_id; " .
|
||||
"dcCore::app()->blog->withoutPassword(false);\n" .
|
||||
"}\n";
|
||||
|
||||
if (empty($attr['with_pings'])) {
|
||||
$p .= "\$params['comment_trackback'] = false;\n";
|
||||
}
|
||||
|
||||
$lastn = 0;
|
||||
if (isset($attr['lastn'])) {
|
||||
$lastn = abs((int) $attr['lastn']) + 0;
|
||||
}
|
||||
|
||||
if ($lastn > 0) {
|
||||
$p .= "\$params['limit'] = " . $lastn . ";\n";
|
||||
} else {
|
||||
$p .= "if (dcCore::app()->ctx->nb_comment_per_page !== null) { \$params['limit'] = dcCore::app()->ctx->nb_comment_per_page; }\n";
|
||||
}
|
||||
|
||||
$p .= "\$params['limit'] = array(((dcCore::app()->public->getPageNumber()-1)*\$params['limit']),\$params['limit']);\n";
|
||||
|
||||
if (empty($attr['no_context'])) {
|
||||
$p .= 'if (dcCore::app()->ctx->exists("categories")) { ' .
|
||||
"\$params['cat_id'] = dcCore::app()->ctx->categories->cat_id; " .
|
||||
"}\n";
|
||||
|
||||
$p .= 'if (dcCore::app()->ctx->exists("langs")) { ' .
|
||||
"\$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 = 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 . "';\n";
|
||||
|
||||
if (isset($attr['no_content']) && $attr['no_content']) {
|
||||
$p .= "\$params['no_content'] = true;\n";
|
||||
}
|
||||
|
||||
$res = "<?php\n";
|
||||
$res .= $p;
|
||||
$res .= 'dcCore::app()->ctx->comments = dcCore::app()->blog->getComments($params); unset($params);' . "\n";
|
||||
$res .= "if (dcCore::app()->ctx->posts !== null) { dcCore::app()->blog->withoutPassword(true);}\n";
|
||||
|
||||
if (!empty($attr['with_pings'])) {
|
||||
$res .= 'dcCore::app()->ctx->pings = dcCore::app()->ctx->comments;' . "\n";
|
||||
}
|
||||
|
||||
$res .= "?>\n";
|
||||
|
||||
$res .= '<?php while (dcCore::app()->ctx->comments->fetch()) : ?>' . $content . '<?php endwhile; dcCore::app()->ctx->pop("comments"); ?>';
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/* ComListePaginationLinks --------------------------------------- */
|
||||
/* Reprise et adaptation de la fonction PaginationLinks du plugin advancedPagination-1.9 */
|
||||
public static function comListePaginationLinks($attr)
|
||||
{
|
||||
$p = '<?php
|
||||
|
||||
function comListeMakePageLink($pageNumber, $linkText) {
|
||||
if ($pageNumber != dcCore::app()->public->getPageNumber()) {
|
||||
$args = $_SERVER["URL_REQUEST_PART"];
|
||||
$args = preg_replace("#(^|/)page/([0-9]+)$#","",$args);
|
||||
$url = dcCore::app()->blog->url.$args;
|
||||
|
||||
if ($pageNumber > 1) {
|
||||
$url = preg_replace("#/$#","",$url);
|
||||
$url .= "/page/".$pageNumber;
|
||||
}
|
||||
|
||||
if (!empty($_GET["q"])) {
|
||||
$s = strpos($url,"?") !== false ? "&" : "?";
|
||||
$url .= $s."q=".rawurlencode($_GET["q"]);
|
||||
}
|
||||
|
||||
return "<a href=\"".$url."\">".$linkText."</a> ";
|
||||
} else {
|
||||
return $linkText." ";
|
||||
}
|
||||
}
|
||||
|
||||
$current = dcCore::app()->public->getPageNumber();
|
||||
|
||||
if(empty($params)) {
|
||||
dcCore::app()->ctx->pagination = dcCore::app()->blog->getComments(null,true);
|
||||
} else {
|
||||
dcCore::app()->ctx->pagination = dcCore::app()->blog->getComments($params,true);
|
||||
unset($params);
|
||||
}
|
||||
|
||||
if (dcCore::app()->ctx->exists("pagination")) {
|
||||
$nb_comments = dcCore::app()->ctx->pagination->f(0);
|
||||
}
|
||||
|
||||
$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;
|
||||
$quick_distance = 10;
|
||||
|
||||
if($nb_pages <= $nb_max_pages) {
|
||||
/* less or equal than 10 pages, simple links */
|
||||
for ($i = 1; $i <= $nb_pages; $i++) {
|
||||
echo comListeMakePageLink($i,$i);
|
||||
}
|
||||
} else {
|
||||
/* more than 10 pages, smart links */
|
||||
echo comListeMakePageLink(1,1);
|
||||
$min_page = max($current - ($nb_sequence - 1) / 2, 2);
|
||||
$max_page = min($current + ($nb_sequence - 1) / 2, $nb_pages - 1);
|
||||
if ($min_page > 2) {
|
||||
echo "...";
|
||||
echo " ";
|
||||
}
|
||||
|
||||
for ($i = $min_page; $i <= $max_page ; $i++) {
|
||||
echo comListeMakePageLink($i,$i);
|
||||
}
|
||||
|
||||
if ($max_page < $nb_pages - 1) {
|
||||
echo "...";
|
||||
echo " ";
|
||||
}
|
||||
echo comListeMakePageLink($nb_pages,$nb_pages);
|
||||
|
||||
/* quick navigation links */
|
||||
if($current >= 1 + $quick_distance) {
|
||||
echo " ";
|
||||
echo comListeMakePageLink($current - $quick_distance, "<<");
|
||||
}
|
||||
|
||||
if($current <= $nb_pages - $quick_distance) {
|
||||
echo " ";
|
||||
echo comListeMakePageLink($current + $quick_distance, ">> ");
|
||||
}
|
||||
}
|
||||
?>';
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/* ComListeOpenPostTitle --------------------------------------- */
|
||||
public static function comListeOpenPostTitle($attr)
|
||||
{
|
||||
return __('open post');
|
||||
}
|
||||
}
|
||||
|
|
92
_widgets.php
92
_widgets.php
|
@ -1,37 +1,63 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
dcCore::app()->addBehavior('initWidgets', ['comListeWidget','initWidget']);
|
||||
|
||||
$core->addBehavior('initWidgets',array('comListeWidgets','initWidgets'));
|
||||
|
||||
class comListeWidgets
|
||||
class comListeWidget
|
||||
{
|
||||
public static function initWidgets($w)
|
||||
{
|
||||
$w->create('comListe',__('ComListe'),array('tplComListe','comListeWidget'),
|
||||
null,
|
||||
__('List of comments'));
|
||||
$w->comListe->setting('title',__('Title:'),__('ComListe'));
|
||||
$w->comListe->setting('link_title',__('Link title:'),__('List of comments'));
|
||||
$w->comListe->setting('homeonly',__('Display on:'),0,'combo',
|
||||
array(
|
||||
__('All pages') => 0,
|
||||
__('Home page only') => 1,
|
||||
__('Except on home page') => 2
|
||||
)
|
||||
);
|
||||
$w->comListe->setting('content_only',__('Content only'),0,'check');
|
||||
$w->comListe->setting('class',__('CSS class:'),'');
|
||||
$w->comListe->setting('offline',__('Offline'),0,'check');
|
||||
}
|
||||
}
|
||||
public static function initWidget($w)
|
||||
{
|
||||
$w->create(
|
||||
'comListe',
|
||||
__('Comments list'),
|
||||
['comListeWidget','publicWidget'],
|
||||
null,
|
||||
__('Comments list')
|
||||
)
|
||||
->addTitle(__('Comments list'))
|
||||
->setting(
|
||||
'link_title',
|
||||
__('Link 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) : __('Comments list')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,351 +0,0 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) {return;}
|
||||
|
||||
class urlcomListe extends dcUrlHandlers
|
||||
{
|
||||
/**
|
||||
* Traitement de l'URL
|
||||
* Open the template
|
||||
*/
|
||||
public static function comListe($args)
|
||||
{
|
||||
global $_ctx,$core;
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
$blog_settings =& $core->blog->settings->comListe;
|
||||
} else {
|
||||
$blog_settings =& $core->blog->settings;
|
||||
}
|
||||
|
||||
// definition de la page courante
|
||||
if ($args == '') {
|
||||
$GLOBALS['_page_number'] = (integer) 1;
|
||||
} else {
|
||||
$current = self::getPageNumber($args);
|
||||
if ($current) {
|
||||
$GLOBALS['_page_number'] = (integer) $current;
|
||||
}
|
||||
}
|
||||
// definition du nombre de commentaires par page
|
||||
$_ctx->nb_comment_per_page=$blog_settings->comliste_nb_comments_per_page;
|
||||
|
||||
// ouverture de la page html
|
||||
$tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset');
|
||||
if (!empty($tplset) && is_dir(dirname(__FILE__).'/../default-templates/'.$tplset)) {
|
||||
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/../default-templates/'.$tplset);
|
||||
} else {
|
||||
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/../default-templates/'.DC_DEFAULT_TPLSET);
|
||||
}
|
||||
self::serveDocument('comListe.html');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
class tplComListe
|
||||
{
|
||||
public $html_prev = '«prev.';
|
||||
public $html_next = 'next»';
|
||||
|
||||
/* ComListeURL --------------------------------------- */
|
||||
public static function comListeURL($attr)
|
||||
{
|
||||
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
||||
return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("comListe")').'; ?>';
|
||||
}
|
||||
|
||||
/* ComListePageTitle --------------------------------------- */
|
||||
public static function comListePageTitle($attr)
|
||||
{
|
||||
global $core;
|
||||
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
return '<?php echo '.sprintf($f,'$core->blog->settings->comListe->comliste_page_title').'; ?>';
|
||||
} else {
|
||||
return '<?php echo '.sprintf($f,'$core->blog->settings->comliste_page_title').'; ?>';
|
||||
}
|
||||
}
|
||||
|
||||
/* ComListeNbCommentsPerPage --------------------------------------- */
|
||||
public static function comListeNbCommentsPerPage($attr)
|
||||
{
|
||||
global $_ctx, $core;
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
$nb_comments_per_page = $_ctx->nb_comment_per_page=$core->blog->settings->comListe->comliste_nb_comments_per_page;
|
||||
} else {
|
||||
$nb_comments_per_page = $_ctx->nb_comment_per_page=$core->blog->settings->comliste_nb_comments_per_page;
|
||||
}
|
||||
return ''.html::escapeHTML($nb_comments_per_page).'';
|
||||
}
|
||||
|
||||
/* comListeNbComments --------------------------------------- */
|
||||
public static function comListeNbComments($attr)
|
||||
{
|
||||
// __('Number of comments')
|
||||
global $_ctx, $core;
|
||||
|
||||
if(empty($params)) {
|
||||
$_ctx->pagination = $core->blog->getComments(null,true);
|
||||
} else {
|
||||
$_ctx->pagination = $core->blog->getComments($params,true);
|
||||
unset($params);
|
||||
}
|
||||
|
||||
if ($_ctx->exists("pagination")) {
|
||||
$nb_comments = $_ctx->pagination->f(0);
|
||||
}
|
||||
return ''.html::escapeHTML($nb_comments).'';
|
||||
}
|
||||
|
||||
/* ComListeCommentsEntries --------------------------------------- */
|
||||
public static function comListeCommentsEntries($attr,$content)
|
||||
{
|
||||
global $_ctx, $core;
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
$blog_settings =& $core->blog->settings->comListe;
|
||||
} else {
|
||||
$blog_settings =& $core->blog->settings;
|
||||
}
|
||||
|
||||
$p =
|
||||
"if (\$_ctx->posts !== null) { ".
|
||||
"\$params['post_id'] = \$_ctx->posts->post_id; ".
|
||||
"\$core->blog->withoutPassword(false);\n".
|
||||
"}\n";
|
||||
|
||||
if (empty($attr['with_pings'])) {
|
||||
$p .= "\$params['comment_trackback'] = false;\n";
|
||||
}
|
||||
|
||||
$lastn = 0;
|
||||
if (isset($attr['lastn'])) {
|
||||
$lastn = abs((integer) $attr['lastn'])+0;
|
||||
}
|
||||
|
||||
if ($lastn > 0) {
|
||||
$p .= "\$params['limit'] = ".$lastn.";\n";
|
||||
} else {
|
||||
$p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n";
|
||||
}
|
||||
|
||||
if (isset($GLOBALS["_page_number"])) {
|
||||
$_page_number = $GLOBALS["_page_number"];
|
||||
$p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n";
|
||||
} else {
|
||||
$_page_number = 1;
|
||||
$p .= "\$params['limit'] = array(0, \$params['limit']);\n";
|
||||
}
|
||||
|
||||
if (empty($attr['no_context']))
|
||||
{
|
||||
$p .=
|
||||
'if ($_ctx->exists("categories")) { '.
|
||||
"\$params['cat_id'] = \$_ctx->categories->cat_id; ".
|
||||
"}\n";
|
||||
|
||||
$p .=
|
||||
'if ($_ctx->exists("langs")) { '.
|
||||
"\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ".
|
||||
"}\n";
|
||||
}
|
||||
|
||||
// Sens de tri issu des paramètres du plugin
|
||||
$order = $blog_settings->comliste_comments_order;
|
||||
if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) {
|
||||
$order = $attr['order'];
|
||||
}
|
||||
|
||||
$p .= "\$params['order'] = 'comment_dt ".$order."';\n";
|
||||
|
||||
if (isset($attr['no_content']) && $attr['no_content']) {
|
||||
$p .= "\$params['no_content'] = true;\n";
|
||||
}
|
||||
|
||||
$res = "<?php\n";
|
||||
$res .= $p;
|
||||
$res .= '$_ctx->comments = $core->blog->getComments($params); unset($params);'."\n";
|
||||
$res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n";
|
||||
|
||||
if (!empty($attr['with_pings'])) {
|
||||
$res .= '$_ctx->pings = $_ctx->comments;'."\n";
|
||||
}
|
||||
|
||||
$res .= "?>\n";
|
||||
|
||||
$res .=
|
||||
'<?php while ($_ctx->comments->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->comments = null; ?>';
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/* ComListePaginationLinks --------------------------------------- */
|
||||
/* Reprise et adaptation de la fonction PaginationLinks du plugin advancedPagination-1.9 */
|
||||
public static function comListePaginationLinks($attr)
|
||||
{
|
||||
global $_ctx, $core;
|
||||
|
||||
$p = '<?php
|
||||
|
||||
function comListeMakePageLink($pageNumber, $linkText) {
|
||||
if (isset($GLOBALS["_page_number"])) {
|
||||
$current = $GLOBALS["_page_number"];
|
||||
} else {
|
||||
$current = 0;
|
||||
}
|
||||
if ($pageNumber != $current) {
|
||||
$args = $_SERVER["URL_REQUEST_PART"];
|
||||
$args = preg_replace("#(^|/)page/([0-9]+)$#","",$args);
|
||||
$url = $GLOBALS["core"]->blog->url.$args;
|
||||
|
||||
if ($pageNumber > 1) {
|
||||
$url = preg_replace("#/$#","",$url);
|
||||
$url .= "/page/".$pageNumber;
|
||||
}
|
||||
|
||||
if (!empty($_GET["q"])) {
|
||||
$s = strpos($url,"?") !== false ? "&" : "?";
|
||||
$url .= $s."q=".rawurlencode($_GET["q"]);
|
||||
}
|
||||
|
||||
return "<a href=\"".$url."\">".$linkText."</a> ";
|
||||
} else {
|
||||
return $linkText." ";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($GLOBALS["_page_number"])) {
|
||||
$current = $GLOBALS["_page_number"];
|
||||
} else {
|
||||
$current = 1;
|
||||
}
|
||||
|
||||
if(empty($params)) {
|
||||
$_ctx->pagination = $core->blog->getComments(null,true);
|
||||
} else {
|
||||
$_ctx->pagination = $core->blog->getComments($params,true);
|
||||
unset($params);
|
||||
}
|
||||
|
||||
if ($_ctx->exists("pagination")) {
|
||||
$nb_comments = $_ctx->pagination->f(0);
|
||||
}
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,\'2.2-alpha\',\'>=\')) {
|
||||
$blog_settings =& $core->blog->settings->comListe;
|
||||
} else {
|
||||
$blog_settings =& $core->blog->settings;
|
||||
}
|
||||
|
||||
$nb_per_page = abs((integer) $blog_settings->comliste_nb_comments_per_page);
|
||||
$nb_pages = ceil($nb_comments/$nb_per_page);
|
||||
$nb_max_pages = 10;
|
||||
$nb_sequence = 2*3+1;
|
||||
$quick_distance = 10;
|
||||
|
||||
if($nb_pages <= $nb_max_pages) {
|
||||
/* less or equal than 10 pages, simple links */
|
||||
for ($i = 1; $i <= $nb_pages; $i++) {
|
||||
echo comListeMakePageLink($i,$i);
|
||||
}
|
||||
} else {
|
||||
/* more than 10 pages, smart links */
|
||||
echo comListeMakePageLink(1,1);
|
||||
$min_page = max($current - ($nb_sequence - 1) / 2, 2);
|
||||
$max_page = min($current + ($nb_sequence - 1) / 2, $nb_pages - 1);
|
||||
if ($min_page > 2) {
|
||||
echo "...";
|
||||
echo " ";
|
||||
}
|
||||
|
||||
for ($i = $min_page; $i <= $max_page ; $i++) {
|
||||
echo comListeMakePageLink($i,$i);
|
||||
}
|
||||
|
||||
if ($max_page < $nb_pages - 1) {
|
||||
echo "...";
|
||||
echo " ";
|
||||
}
|
||||
echo comListeMakePageLink($nb_pages,$nb_pages);
|
||||
|
||||
/* quick navigation links */
|
||||
if($current >= 1 + $quick_distance) {
|
||||
echo " ";
|
||||
echo comListeMakePageLink($current - $quick_distance, "<<");
|
||||
}
|
||||
|
||||
if($current <= $nb_pages - $quick_distance) {
|
||||
echo " ";
|
||||
echo comListeMakePageLink($current + $quick_distance, ">> ");
|
||||
}
|
||||
}
|
||||
?>';
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/* ComListeOpenPostTitle --------------------------------------- */
|
||||
public static function comListeOpenPostTitle($attr)
|
||||
{
|
||||
return __('open post');
|
||||
}
|
||||
|
||||
# Widget function
|
||||
public static function comListeWidget($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
$blog_settings =& $core->blog->settings->comListe;
|
||||
} else {
|
||||
$blog_settings =& $core->blog->settings;
|
||||
}
|
||||
|
||||
if ($w->offline)
|
||||
return;
|
||||
|
||||
if (($w->homeonly == 1 && $core->url->type != 'default') ||
|
||||
($w->homeonly == 2 && $core->url->type == 'default')) {
|
||||
return;
|
||||
}
|
||||
if (!$blog_settings->comliste_enable) {
|
||||
return;
|
||||
}
|
||||
|
||||
$res =
|
||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
|
||||
'<p><a href="'.$core->blog->url.$core->url->getBase('comListe').'">'.
|
||||
($w->link_title ? html::escapeHTML($w->link_title) : __('List of comments')).
|
||||
'</a></p>';
|
||||
|
||||
return $w->renderDiv($w->content_only,'comliste '.$w->class,'',$res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class extComListe
|
||||
{
|
||||
public static function publicBreadcrumb($context,$separator)
|
||||
{
|
||||
if ($context == 'comListe') {
|
||||
return __('List of comments');
|
||||
}
|
||||
}
|
||||
}
|
220
index.php
220
index.php
|
@ -1,158 +1,96 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { exit; }
|
||||
|
||||
$page_title = __('List of comments');
|
||||
|
||||
# Settings compatibility test
|
||||
if (version_compare(DC_VERSION,'2.2-alpha','>=')) {
|
||||
$core->blog->settings->addNamespace('comListe');
|
||||
$blog_settings =& $core->blog->settings->comListe;
|
||||
$system_settings = $core->blog->settings->system;
|
||||
} else {
|
||||
$core->blog->settings->setNamespace('comListe');
|
||||
$blog_settings =& $core->blog->settings;
|
||||
$system_settings =& $core->blog->settings;
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
// initilisation des variables
|
||||
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : null;
|
||||
dcPage::check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]));
|
||||
|
||||
// Setting default parameters if missing configuration
|
||||
if (is_null($blog_settings->comliste_enable)) {
|
||||
try {
|
||||
$blog_settings->put('comliste_enable',false,'boolean','Enable comListe');
|
||||
$core->blog->triggerBlog();
|
||||
http::redirect(http::getSelfURI());
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
$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('comliste_page_title', $_POST['comliste_page_title']);
|
||||
$s->put('comliste_nb_comments_per_page', $_POST['comliste_nb_comments_per_page'] ?? 10);
|
||||
$s->put('comliste_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());
|
||||
}
|
||||
}
|
||||
|
||||
// Getting current parameters
|
||||
$comliste_enable = (boolean)$blog_settings->comliste_enable;
|
||||
$comliste_page_title = $blog_settings->comliste_page_title;
|
||||
$comliste_nb_comments_per_page = $blog_settings->comliste_nb_comments_per_page;
|
||||
$comliste_comments_order = $blog_settings->comliste_comments_order;
|
||||
echo '
|
||||
<html><head><title>' . __('Comments list') . '</title></head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Comments list') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
if ($comliste_page_title === null) {
|
||||
$comliste_page_title = __('List of comments');
|
||||
}
|
||||
if ($comliste_nb_comments_per_page === null) {
|
||||
$comliste_nb_comments_per_page = 10;
|
||||
}
|
||||
if ($comliste_comments_order === null) {
|
||||
$comliste_comments_order = 'desc';
|
||||
}
|
||||
'<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">' .
|
||||
'<div class="fieldset"><h4>' . __('Plugin activation') . '</h4>' .
|
||||
|
||||
// Saving new configuration
|
||||
if ($action == 'saveconfig')
|
||||
{
|
||||
try {
|
||||
|
||||
// Enable plugin
|
||||
$comliste_enable = (empty($_POST['comliste_enable']))?false:true;
|
||||
|
||||
// Title page
|
||||
$comliste_page_title = $_POST['comliste_page_title'];
|
||||
if (empty($_POST['comliste_page_title'])) {
|
||||
throw new Exception(__('No page title.'));
|
||||
}
|
||||
'<p class="field"><label for="comliste_enable" class="classic">' .
|
||||
form::checkbox('comliste_enable', 1, (bool) $s->get('enable')) .
|
||||
__('Enable comListe') . '</label></p>' .
|
||||
|
||||
// Number of comments per page
|
||||
$comliste_nb_comments_per_page = !empty($_POST['comliste_nb_comments_per_page'])?$_POST['comliste_nb_comments_per_page']:$comliste_nb_comments_per_page;
|
||||
|
||||
// Order
|
||||
$comliste_comments_order = !empty($_POST['comliste_comments_order'])?$_POST['comliste_comments_order']:$comliste_comments_order;
|
||||
|
||||
// Insert settings values
|
||||
$blog_settings->put('comliste_enable',$comliste_enable,'boolean','Enable comListe');
|
||||
$blog_settings->put('comliste_page_title',$comliste_page_title,'string','Title page');
|
||||
$blog_settings->put('comliste_nb_comments_per_page',$comliste_nb_comments_per_page,'integer','Number of comments per page');
|
||||
$blog_settings->put('comliste_comments_order',$comliste_comments_order,'string','Comments order');
|
||||
|
||||
$core->blog->triggerBlog();
|
||||
'</div>' .
|
||||
'<div class="fieldset"><h4>' . __('General options') . '</h4>' .
|
||||
|
||||
http::redirect($p_url.'&saveconfig=1');
|
||||
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
'<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>' .
|
||||
|
||||
<!-- Creating HTML page -->
|
||||
<html>
|
||||
'<p><label for="comliste_comments_order">' . __('Comments order:') . '</label>' .
|
||||
form::combo('comliste_comments_order', $order_combo, $s->get('comments_order') == 'asc' ? 'asc' : 'desc') .
|
||||
'</p>' .
|
||||
|
||||
<!-- header -->
|
||||
<head>
|
||||
<title><?php echo $page_title; ?></title>
|
||||
</head>
|
||||
'</div>
|
||||
|
||||
<!-- body -->
|
||||
<body>
|
||||
<p class="clear">' .
|
||||
form::hidden(['action'], 'saveconfig') .
|
||||
dcCore::app()->formNonce() . '
|
||||
<input id="new-action" type="submit" name="save" value="' . __('Save') . '" />
|
||||
</p>
|
||||
|
||||
<?php
|
||||
echo dcPage::breadcrumb(
|
||||
array(
|
||||
html::escapeHTML($core->blog->name) => '',
|
||||
'<span class="page-title">'.$page_title.'</span>' => ''
|
||||
));
|
||||
</form>';
|
||||
|
||||
if (!empty($_GET['saveconfig'])) {
|
||||
dcPage::success(__('Settings have been successfully updated.'));
|
||||
}
|
||||
?>
|
||||
dcPage::helpBlock('comListe');
|
||||
|
||||
<?php
|
||||
|
||||
$order_combo = array(__('Ascending') => 'asc',
|
||||
__('Descending') => 'desc' );
|
||||
|
||||
// comListe plugin configuration
|
||||
if ($core->auth->check('admin',$core->blog->id))
|
||||
{
|
||||
echo
|
||||
'<form method="post" action="plugin.php">'.
|
||||
'<div class="fieldset"><h4>'. __('Plugin activation').'</h4>'.
|
||||
'<p class="field">'.
|
||||
'<label class="classic" for="comliste_enable">'.
|
||||
form::checkbox('comliste_enable', 1, $comliste_enable).
|
||||
__('Enable comListe').'</label></p>'.
|
||||
'</div>'.
|
||||
'<div class="fieldset"><h4>'. __('General options').'</h4>'.
|
||||
'<p><label class="classic">'. __('Title page').' : '.
|
||||
form::field('comliste_page_title', 30,256, $comliste_page_title).
|
||||
'</label></p>'.
|
||||
'<p><label class=" classic">'. __('Number of comments per page:').' '.
|
||||
form::field('comliste_nb_comments_per_page', 4, 4, $comliste_nb_comments_per_page).
|
||||
'</label></p>'.
|
||||
'<p><label class=" classic">'. __('Comments order').' : '.
|
||||
form::combo('comliste_comments_order', $order_combo, $comliste_comments_order).
|
||||
'</label></p>'.
|
||||
'</div>'.
|
||||
'<p><input type="submit" value="'.__('Save').'" onclick="affinfo(\''.__('Save').'\')" /> '.
|
||||
$core->formNonce().
|
||||
form::hidden(array('action'),'saveconfig').
|
||||
form::hidden(array('p'),'comListe').'</p>'.
|
||||
'</form>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php dcPage::helpBlock('comListe');?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
echo '</body></html>';
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!isset($__resources['help']['comListe'])) {
|
||||
$__resources['help']['comListe'] = dirname(__FILE__).'/help/comListe.html';
|
||||
}
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
dcCore::app()->resources['help']['comListe'] = __DIR__ . '/help/comListe.html';
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of comListe, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2008-2015 Benoit de Marne
|
||||
# benoit.de.marne@gmail.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!isset($__resources['help']['comListe'])) {
|
||||
$__resources['help']['comListe'] = dirname(__FILE__).'/help/comListe.html';
|
||||
}
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
dcCore::app()->resources['help']['comListe'] = __DIR__ . '/help/comListe.html';
|
||||
|
|
Loading…
Reference in a new issue