upgrade to Dotclear 2.28
This commit is contained in:
parent
a841033859
commit
f378ba1faa
8 changed files with 105 additions and 118 deletions
|
@ -1,3 +1,9 @@
|
|||
lastpostsExtend 2023.10.19
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
lastpostsExtend 2023.08.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
33
README.md
33
README.md
|
@ -1,25 +1,22 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-2023.10.19-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases)
|
||||
[![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/lastpostsExtend)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/lastpostsExtend)](https://git.dotclear.watch/JcDenis/lastpostsExtend/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS LASTPOSTSEXTEND ?
|
||||
## ABOUT
|
||||
|
||||
_lastpostsExtend_ "Last entries (Extended)" is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_lastpostsExtend_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
Like widget lastposts but with more options.
|
||||
> Same as widget lastposts but with more options.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_lastpostsExtend_ requires:
|
||||
|
||||
* permissions to manage widgets
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1
|
||||
* Dotclear permissions to manage widgets
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -30,13 +27,15 @@ Add and configure "Last entries (Extended)" from widgets manager.
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/lastpostsExtend) or [GitHub Page](https://github.com/JcDenis/lastpostsExtend)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastpostsExtend)
|
||||
* [License](https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lastpostsExtend))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/lastpostsExtend) (or on [GitHub](https://github.com/JcDenis/lastpostsExtend))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/lastpostsExtend/issues) (or on [GitHub](https://github.com/JcDenis/lastpostsExtend/issues))
|
||||
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Chirstian Denis
|
||||
* Jean-Chirstian Denis (author)
|
||||
* Pierre Van Glabeke
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
33
_define.php
33
_define.php
|
@ -1,32 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lastpostsExtend, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin lastpostsExtend definition
|
||||
* @ingroup lastpostsExtend
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup lastpostsExtend Plugin lastpostsExtend.
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
* Extended list of entries.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Last entries (Extended)',
|
||||
'Extended list of entries',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'2023.08.13',
|
||||
'2023.10.19',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'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',
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'type' => 'plugin',
|
||||
'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/">
|
||||
<module id="lastpostsExtend">
|
||||
<name>Last entries (Extended)</name>
|
||||
<version>2023.08.13</version>
|
||||
<version>2023.10.19</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<desc>Extended list of entries</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/lastpostsExtend/releases/download/v2023.08.13/plugin-lastpostsExtend.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/lastpostsExtend/releases/download/v2023.10.19/plugin-lastpostsExtend.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/lastpostsExtend/issues</da:support>
|
||||
</module>
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lastpostsExtend, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastpostsExtend;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief lastpostsExtend backend class.
|
||||
* @ingroup lastpostsExtend
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,9 +27,7 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lastpostsExtend, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastpostsExtend;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief lastpostsExtend frontend class.
|
||||
* @ingroup lastpostsExtend
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,9 +27,7 @@ class Frontend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
20
src/My.php
20
src/My.php
|
@ -1,21 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lastpostsExtend, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastpostsExtend;
|
||||
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief lastpostsExtend My helper.
|
||||
* @ingroup lastpostsExtend
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// Use default permissions
|
||||
}
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lastpostsExtend, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastpostsExtend;
|
||||
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcMeta;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Text;
|
||||
use Dotclear\Helper\File\Path;
|
||||
|
@ -24,12 +12,18 @@ use Dotclear\Helper\Html\Html;
|
|||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
/**
|
||||
* @brief lastpostsExtend widgets class.
|
||||
* @ingroup lastpostsExtend
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +31,7 @@ class Widgets
|
|||
$w->create(
|
||||
'lastpostsextend',
|
||||
__('Last entries (Extended)'),
|
||||
[self::class, 'parseWidget'],
|
||||
self::parseWidget(...),
|
||||
null,
|
||||
__('Extended list of entries')
|
||||
);
|
||||
|
@ -51,7 +45,7 @@ class Widgets
|
|||
__('Gallery') => 'galitem',
|
||||
];
|
||||
// plugin muppet types
|
||||
if (dcCore::app()->plugins->getDefine('muppet')->isDefined() && class_exists('\muppet')) {
|
||||
if (App::plugins()->getDefine('muppet')->isDefined() && class_exists('\muppet')) {
|
||||
$muppet_types = \muppet::getPostTypes();
|
||||
if (is_array($muppet_types) && !empty($muppet_types)) {
|
||||
foreach ($muppet_types as $k => $v) {
|
||||
|
@ -68,7 +62,7 @@ class Widgets
|
|||
);
|
||||
|
||||
// Category (post and page have same category)
|
||||
$rs = dcCore::app()->blog->getCategories([
|
||||
$rs = App::blog()->getCategories([
|
||||
'post_type' => 'post',
|
||||
]);
|
||||
$categories = [
|
||||
|
@ -135,7 +129,7 @@ class Widgets
|
|||
);
|
||||
|
||||
// Tag
|
||||
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||
if (App::plugins()->moduleExists('tags')) {
|
||||
$w->lastpostsextend->setting(
|
||||
'tag',
|
||||
__('Limit to tags:'),
|
||||
|
@ -234,7 +228,10 @@ class Widgets
|
|||
public static function parseWidget(WidgetsElement $w): string
|
||||
{
|
||||
// Widget is offline & Home page only
|
||||
if (is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
if (!App::blog()->isDefined()
|
||||
|| $w->offline
|
||||
|| !$w->checkHomeOnly(App::url()->type)
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -306,19 +303,19 @@ class Widgets
|
|||
}
|
||||
|
||||
// Tags
|
||||
if (dcCore::app()->plugins->moduleExists('tags') && $w->tag) {
|
||||
if (App::plugins()->moduleExists('tags') && $w->tag) {
|
||||
$tags = explode(',', $w->tag);
|
||||
foreach ($tags as $i => $tag) {
|
||||
$tags[$i] = trim($tag);
|
||||
}
|
||||
$params['from'] .= ', ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' META ';
|
||||
$params['from'] .= ', ' . App::con()->prefix() . App::meta()::META_TABLE_NAME . ' META ';
|
||||
$params['sql'] .= 'AND META.post_id = P.post_id ';
|
||||
$params['sql'] .= 'AND META.meta_id ' . dcCore::app()->con->in($tags) . ' ';
|
||||
$params['sql'] .= 'AND META.meta_id ' . App::con()->in($tags) . ' ';
|
||||
$params['sql'] .= "AND META.meta_type = 'tag' ";
|
||||
}
|
||||
|
||||
$rs = dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'getPosts'],
|
||||
$rs = App::auth()->sudo(
|
||||
App::blog()->getPosts(...),
|
||||
$params,
|
||||
false
|
||||
);
|
||||
|
@ -332,20 +329,20 @@ class Widgets
|
|||
$res = $w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '';
|
||||
|
||||
while ($rs->fetch()) {
|
||||
if (is_null(dcCore::app()->blog)) { // phpstan ignores previous check !?
|
||||
if (!App::blog()->isDefined()) { // phpstan ignores previous check !?
|
||||
break;
|
||||
}
|
||||
$published = ((int) $rs->f('post_status')) == dcBlog::POST_PUBLISHED;
|
||||
$published = ((int) $rs->f('post_status')) == App::blog()::POST_PUBLISHED;
|
||||
|
||||
$res .= '<li>' .
|
||||
'<' . ($published ? 'a href="' . $rs->getURL() . '"' : 'span') .
|
||||
' title="' .
|
||||
Date::dt2str(
|
||||
dcCore::app()->blog->settings->get('system')->get('date_format'),
|
||||
App::blog()->settings()->get('system')->get('date_format'),
|
||||
$rs->f('post_upddt')
|
||||
) . ', ' .
|
||||
Date::dt2str(
|
||||
dcCore::app()->blog->settings->get('system')->get('time_format'),
|
||||
App::blog()->settings()->get('system')->get('time_format'),
|
||||
$rs->f('post_upddt')
|
||||
) . '">' .
|
||||
Html::escapeHTML($rs->f('post_title')) .
|
||||
|
@ -369,9 +366,9 @@ class Widgets
|
|||
if ($w->excerpt) {
|
||||
$excerpt = $rs->f('post_excerpt');
|
||||
if ($rs->f('post_format') == 'wiki') {
|
||||
dcCore::app()->initWikiComment();
|
||||
$excerpt = dcCore::app()->wikiTransform($excerpt);
|
||||
$excerpt = dcCore::app()->HTMLfilter($excerpt);
|
||||
App::filter()->initWikiComment();
|
||||
$excerpt = App::filter()->wikiTransform($excerpt);
|
||||
$excerpt = App::filter()->HTMLfilter($excerpt);
|
||||
}
|
||||
if (strlen($excerpt) > 0) {
|
||||
$cut = Text::cutString(
|
||||
|
@ -396,12 +393,12 @@ class Widgets
|
|||
|
||||
private static function entryFirstImage(string $type, $id, string $size = 's'): string
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || !in_array($type, ['post', 'page', 'galitem'])) {
|
||||
if (!App::blog()->isDefined() || !in_array($type, ['post', 'page', 'galitem'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$rs = dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'getPosts'],
|
||||
$rs = App::auth()->sudo(
|
||||
App::blog()->getPosts(...),
|
||||
['post_id' => $id, 'post_type' => $type],
|
||||
false
|
||||
);
|
||||
|
@ -414,13 +411,13 @@ class Widgets
|
|||
$size = 's';
|
||||
}
|
||||
|
||||
$p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url');
|
||||
$p_url = (string) App::blog()->settings()->get('system')->get('public_url');
|
||||
$p_site = (string) preg_replace(
|
||||
'#^(.+?//.+?)/(.*)$#',
|
||||
'$1',
|
||||
dcCore::app()->blog->url
|
||||
App::blog()->url()
|
||||
);
|
||||
$p_root = dcCore::app()->blog->public_path;
|
||||
$p_root = App::blog()->publicPath();
|
||||
|
||||
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
|
||||
$pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu', $pattern);
|
||||
|
|
Loading…
Reference in a new issue