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