upgrade to dotclear 2.28
This commit is contained in:
parent
111d495155
commit
c950b1236e
10 changed files with 144 additions and 172 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
topWriter 1.4 - 2023.10.20
|
||||||
|
===========================================================
|
||||||
|
* Require Dotclear 2.28
|
||||||
|
* Require PHP 8.1
|
||||||
|
* Upgrade to Dotclear 2.28
|
||||||
|
|
||||||
topWriter 1.3 - 2023.08.13
|
topWriter 1.3 - 2023.08.13
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
|
32
README.md
32
README.md
|
@ -1,25 +1,22 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases)
|
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases)
|
||||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases)
|
![Date](https://img.shields.io/badge/date-2023.10.20-c44d58.svg)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/topWriter)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/topWriter)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/topWriter)](https://git.dotclear.watch/JcDenis/topWriter/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/LICENSE)
|
||||||
|
|
||||||
## WHAT IS TOPWRITER ?
|
## ABOUT
|
||||||
|
|
||||||
_Top writer_ is a plugin for the open-source
|
_topWriter_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||||
web publishing software called Dotclear.
|
|
||||||
|
|
||||||
Show most active contributor on a widget.
|
> Show most active contributor on a widget.
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_topWriter_ requires:
|
* Dotclear 2.28
|
||||||
|
* PHP 8.1
|
||||||
* permissions to manage widgets
|
* Dotclear permissions to manage widgets
|
||||||
* Dotclear 2.27
|
|
||||||
* PHP 7.4
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -32,10 +29,11 @@ Or add contents to the backend dashboard from your preferences.
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* [License](https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/LICENSE)
|
||||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/topWriter) or [GitHub Page](https://github.com/JcDenis/topWriter)
|
* [Packages & details](https://git.dotclear.watch/JcDenis/topWriter/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/topWriter))
|
||||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/topWriter/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/topWriter)
|
* [Sources & contributions](https://git.dotclear.watch/JcDenis/topWriter) (or on [GitHub](https://github.com/JcDenis/topWriter))
|
||||||
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=333002#p333002)
|
* [Issues & security](https://git.dotclear.watch/JcDenis/topWriter/issues) (or on [GitHub](https://github.com/JcDenis/topWriter/issues))
|
||||||
|
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=333002#p333002)
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
|
|
23
_define.php
23
_define.php
|
@ -1,29 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin topWriter definition
|
||||||
|
* @ingroup topWriter
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @defgroup topWriter Plugin topWriter.
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
* Ranking of the most prolific writers and/or commentators.
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Top writer',
|
'Top writer',
|
||||||
'Ranking of the most prolific writers and/or commentators',
|
'Ranking of the most prolific writers and/or commentators',
|
||||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||||
'1.3',
|
'1.4',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.27']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => 'My',
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
|
||||||
]),
|
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="topWriter">
|
<module id="topWriter">
|
||||||
<name>Top writer</name>
|
<name>Top writer</name>
|
||||||
<version>1.3</version>
|
<version>1.4</version>
|
||||||
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
||||||
<desc>Ranking of the most prolific writers and/or commentators</desc>
|
<desc>Ranking of the most prolific writers and/or commentators</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/topWriter/releases/download/v1.3/plugin-topWriter.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/topWriter/releases/download/v1.4/plugin-topWriter.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/topWriter/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/topWriter/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief topWriter backend class.
|
||||||
|
* @ingroup topWriter
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Backend extends Process
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -30,11 +27,11 @@ class Backend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
'adminDashboardItemsV2' => [BackendBehaviors::class, 'adminDashboardItemsV2'],
|
'adminDashboardItemsV2' => BackendBehaviors::adminDashboardItemsV2(...),
|
||||||
'adminDashboardOptionsFormV2' => [BackendBehaviors::class, 'adminDashboardOptionsFormV2'],
|
'adminDashboardOptionsFormV2' => BackendBehaviors::adminDashboardOptionsFormV2(...),
|
||||||
'adminAfterDashboardOptionsUpdate' => [BackendBehaviors::class, 'adminAfterDashboardOptionsUpdate'],
|
'adminAfterDashboardOptionsUpdate' => BackendBehaviors::adminAfterDashboardOptionsUpdate(...),
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
|
@ -28,9 +18,11 @@ use Dotclear\Helper\Html\Form\{
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup DC_PLUGIN_TOPWRITER
|
* @brief topWriter backend behaviors class.
|
||||||
* @brief Display most active users - admin methods.
|
* @ingroup topWriter
|
||||||
* @since 2.6
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class BackendBehaviors
|
class BackendBehaviors
|
||||||
{
|
{
|
||||||
|
@ -114,33 +106,33 @@ class BackendBehaviors
|
||||||
|
|
||||||
public static function adminAfterDashboardOptionsUpdate(?string $user_id): void
|
public static function adminAfterDashboardOptionsUpdate(?string $user_id): void
|
||||||
{
|
{
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsItems',
|
'topWriterPostsItems',
|
||||||
!empty($_POST['topWriterPostsItems']),
|
!empty($_POST['topWriterPostsItems']),
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsPeriod',
|
'topWriterPostsPeriod',
|
||||||
(string) $_POST['topWriterPostsPeriod'],
|
(string) $_POST['topWriterPostsPeriod'],
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsLimit',
|
'topWriterPostsLimit',
|
||||||
(int) $_POST['topWriterPostsLimit'],
|
(int) $_POST['topWriterPostsLimit'],
|
||||||
'integer'
|
'integer'
|
||||||
);
|
);
|
||||||
|
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsItems',
|
'topWriterCommentsItems',
|
||||||
!empty($_POST['topWriterCommentsItems']),
|
!empty($_POST['topWriterCommentsItems']),
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsPeriod',
|
'topWriterCommentsPeriod',
|
||||||
(string) $_POST['topWriterCommentsPeriod'],
|
(string) $_POST['topWriterCommentsPeriod'],
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsLimit',
|
'topWriterCommentsLimit',
|
||||||
(int) $_POST['topWriterCommentsLimit'],
|
(int) $_POST['topWriterCommentsLimit'],
|
||||||
'integer'
|
'integer'
|
||||||
|
@ -149,43 +141,43 @@ class BackendBehaviors
|
||||||
|
|
||||||
private static function setDefaultPref(): array
|
private static function setDefaultPref(): array
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsItems')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsItems',
|
'topWriterPostsItems',
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsPeriod')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsPeriod')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsPeriod',
|
'topWriterPostsPeriod',
|
||||||
'month',
|
'month',
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsLimit')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsLimit')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterPostsLimit',
|
'topWriterPostsLimit',
|
||||||
10,
|
10,
|
||||||
'integer'
|
'integer'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsItems')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsItems')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsItems',
|
'topWriterCommentsItems',
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsPeriod')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsPeriod')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsPeriod',
|
'topWriterCommentsPeriod',
|
||||||
'month',
|
'month',
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsLimit')) {
|
if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsLimit')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
App::auth()->prefs()->get('dashboard')->put(
|
||||||
'topWriterCommentsLimit',
|
'topWriterCommentsLimit',
|
||||||
10,
|
10,
|
||||||
'integer'
|
'integer'
|
||||||
|
@ -193,12 +185,12 @@ class BackendBehaviors
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'topWriterPostsItems' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsItems'),
|
'topWriterPostsItems' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsItems'),
|
||||||
'topWriterPostsPeriod' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsPeriod'),
|
'topWriterPostsPeriod' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsPeriod'),
|
||||||
'topWriterPostsLimit' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsLimit') ?? 10,
|
'topWriterPostsLimit' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsLimit') ?? 10,
|
||||||
'topWriterCommentsItems' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsItems'),
|
'topWriterCommentsItems' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsItems'),
|
||||||
'topWriterCommentsPeriod' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsPeriod'),
|
'topWriterCommentsPeriod' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsPeriod'),
|
||||||
'topWriterCommentsLimit' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsLimit') ?? 10,
|
'topWriterCommentsLimit' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsLimit') ?? 10,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief topWriter frontend class.
|
||||||
|
* @ingroup topWriter
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Frontend extends Process
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -30,9 +27,7 @@ class Frontend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
20
src/My.php
20
src/My.php
|
@ -1,21 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief topWriter My helper.
|
||||||
|
* @ingroup topWriter
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
|
// Use default persmissions
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,34 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use dcAuth;
|
use Dotclear\App;
|
||||||
use dcBlog;
|
|
||||||
use dcCore;
|
|
||||||
use dcUtils;
|
|
||||||
use Dotclear\Database\Statement\{
|
use Dotclear\Database\Statement\{
|
||||||
JoinStatement,
|
JoinStatement,
|
||||||
SelectStatement
|
SelectStatement
|
||||||
};
|
};
|
||||||
use Dotclear\Helper\Date;
|
use Dotclear\Helper\Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief topWriter utils class.
|
||||||
|
* @ingroup topWriter
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public static function posts(string $period, int $limit, bool $sort_desc = true): array
|
public static function posts(string $period, int $limit, bool $sort_desc = true): array
|
||||||
{
|
{
|
||||||
// nullsafe
|
if (!App::blog()->isDefined()) {
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
$sql
|
$sql
|
||||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||||
->columns([
|
->columns([
|
||||||
$sql->count('*', 'count'),
|
$sql->count('*', 'count'),
|
||||||
'U.user_id',
|
'U.user_id',
|
||||||
|
@ -43,12 +36,12 @@ class Utils
|
||||||
->join(
|
->join(
|
||||||
(new JoinStatement())
|
(new JoinStatement())
|
||||||
->inner()
|
->inner()
|
||||||
->from($sql->as(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME, 'U'))
|
->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
|
||||||
->on('U.user_id = P.user_id')
|
->on('U.user_id = P.user_id')
|
||||||
->statement()
|
->statement()
|
||||||
)
|
)
|
||||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||||
->and('post_status = ' . dcBlog::POST_PUBLISHED)
|
->and('post_status = ' . App::blog()::POST_PUBLISHED)
|
||||||
->and('user_status = 1')
|
->and('user_status = 1')
|
||||||
->group('U.user_id')
|
->group('U.user_id')
|
||||||
->order('count ' . ($sort_desc ? 'DESC' : 'ASC') . ' , U.user_id ASC')
|
->order('count ' . ($sort_desc ? 'DESC' : 'ASC') . ' , U.user_id ASC')
|
||||||
|
@ -67,7 +60,7 @@ class Utils
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
$user = $sql
|
$user = $sql
|
||||||
->from(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME)
|
->from(App::con()->prefix() . App::auth()::USER_TABLE_NAME)
|
||||||
->column('*')
|
->column('*')
|
||||||
->where('user_id = ' . $sql->quote($rs->f('user_id')))
|
->where('user_id = ' . $sql->quote($rs->f('user_id')))
|
||||||
->select();
|
->select();
|
||||||
|
@ -76,7 +69,7 @@ class Utils
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$author = dcUtils::getUserCN(
|
$author = App::users()->getUserCN(
|
||||||
$user->f('user_id'),
|
$user->f('user_id'),
|
||||||
$user->f('user_name'),
|
$user->f('user_name'),
|
||||||
$user->f('user_firstname'),
|
$user->f('user_firstname'),
|
||||||
|
@ -87,9 +80,9 @@ class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
if (dcCore::app()->blog->settings->get('authormode')->get('authormode_active')) {
|
if (App::blog()->settings()->get('authormode')->get('authormode_active')) {
|
||||||
$res[$i]['author_link'] = '<a href="' .
|
$res[$i]['author_link'] = '<a href="' .
|
||||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('author') . '/' . $user->f('user_id') . '" ' .
|
App::blog()->url() . App::url()->getBase('author') . '/' . $user->f('user_id') . '" ' .
|
||||||
'title="' . __('Author posts') . '">' . $author . '</a>';
|
'title="' . __('Author posts') . '">' . $author . '</a>';
|
||||||
} elseif ($user->f('user_url')) {
|
} elseif ($user->f('user_url')) {
|
||||||
$res[$i]['author_link'] = '<a href="' . $user->f('user_url') . '" title="' .
|
$res[$i]['author_link'] = '<a href="' . $user->f('user_url') . '" title="' .
|
||||||
|
@ -109,23 +102,22 @@ class Utils
|
||||||
|
|
||||||
public static function comments(string $period, int $limit, bool $sort_desc = true, bool $exclude = false): array
|
public static function comments(string $period, int $limit, bool $sort_desc = true, bool $exclude = false): array
|
||||||
{
|
{
|
||||||
// nullsafe
|
if (!App::blog()->isDefined()) {
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
$sql
|
$sql
|
||||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||||
->from($sql->as(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME, 'C'))
|
->from($sql->as(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME, 'C'))
|
||||||
->columns([
|
->columns([
|
||||||
$sql->count('*', 'count'),
|
$sql->count('*', 'count'),
|
||||||
'comment_email',
|
'comment_email',
|
||||||
])
|
])
|
||||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||||
->and('P.post_id = C.post_id')
|
->and('P.post_id = C.post_id')
|
||||||
->and('post_status = ' . dcBlog::POST_PUBLISHED)
|
->and('post_status = ' . App::blog()::POST_PUBLISHED)
|
||||||
->and('comment_status = ' . dcBlog::COMMENT_PUBLISHED)
|
->and('comment_status = ' . App::blog()::COMMENT_PUBLISHED)
|
||||||
->group('comment_email')
|
->group('comment_email')
|
||||||
->order('count ' . ($sort_desc ? 'DESC' : 'ASC'))
|
->order('count ' . ($sort_desc ? 'DESC' : 'ASC'))
|
||||||
->limit(abs((int) $limit))
|
->limit(abs((int) $limit))
|
||||||
|
@ -136,16 +128,16 @@ class Utils
|
||||||
if ($exclude) {
|
if ($exclude) {
|
||||||
$sql->and('comment_email NOT IN (' .
|
$sql->and('comment_email NOT IN (' .
|
||||||
(new SelectStatement())
|
(new SelectStatement())
|
||||||
->from($sql->as(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME, 'U'))
|
->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
|
||||||
->column('U.user_email')
|
->column('U.user_email')
|
||||||
->join(
|
->join(
|
||||||
(new JoinStatement())
|
(new JoinStatement())
|
||||||
->inner()
|
->inner()
|
||||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||||
->on('P.user_id = U.user_id')
|
->on('P.user_id = U.user_id')
|
||||||
->statement()
|
->statement()
|
||||||
)
|
)
|
||||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||||
->group('U.user_email')
|
->group('U.user_email')
|
||||||
->statement() .
|
->statement() .
|
||||||
')');
|
')');
|
||||||
|
@ -161,7 +153,7 @@ class Utils
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
$user = $sql
|
$user = $sql
|
||||||
->from(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME)
|
->from(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME)
|
||||||
->column('*')
|
->column('*')
|
||||||
->where('comment_email = ' . $sql->quote($rs->f('comment_email')))
|
->where('comment_email = ' . $sql->quote($rs->f('comment_email')))
|
||||||
->order('comment_dt DESC')
|
->order('comment_dt DESC')
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief topWriter, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\topWriter;
|
namespace Dotclear\Plugin\topWriter;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief topWriter widgets class.
|
||||||
|
* @ingroup topWriter
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Widgets
|
class Widgets
|
||||||
{
|
{
|
||||||
public static function initWidgets(WidgetsStack $w): void
|
public static function initWidgets(WidgetsStack $w): void
|
||||||
|
@ -28,7 +25,7 @@ class Widgets
|
||||||
->create(
|
->create(
|
||||||
'topcom',
|
'topcom',
|
||||||
__('Top writer: comments'),
|
__('Top writer: comments'),
|
||||||
[self::class, 'topComWidget'],
|
self::topComWidget(...),
|
||||||
null,
|
null,
|
||||||
__('List users who write more comments')
|
__('List users who write more comments')
|
||||||
)
|
)
|
||||||
|
@ -78,7 +75,7 @@ class Widgets
|
||||||
->create(
|
->create(
|
||||||
'toppost',
|
'toppost',
|
||||||
__('Top writer: entries'),
|
__('Top writer: entries'),
|
||||||
[self::class, 'topPostWidget'],
|
self::topPostWidget(...),
|
||||||
null,
|
null,
|
||||||
__('List users who write more posts')
|
__('List users who write more posts')
|
||||||
)
|
)
|
||||||
|
@ -120,7 +117,7 @@ class Widgets
|
||||||
|
|
||||||
public static function topComWidget(WidgetsElement $w): string
|
public static function topComWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
if ($w->offline || !$w->checkHomeOnly(App::url()->type)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +137,7 @@ class Widgets
|
||||||
|
|
||||||
public static function topPostWidget(WidgetsElement $w): string
|
public static function topPostWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
if ($w->offline || !$w->checkHomeOnly(App::url()->type)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue