Compare commits
No commits in common. "f04b2b8330d8c2257dbd7da56b7aab9ce238fc58" and "11b700544a1eaf5855338959a9f38b77a4969bd6" have entirely different histories.
f04b2b8330
...
11b700544a
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,16 +1,3 @@
|
||||||
2023.06.17
|
|
||||||
- require dotclear 2.26
|
|
||||||
- fix php7.4 compatibility
|
|
||||||
|
|
||||||
2023.04.22
|
|
||||||
- require dotclear 2.26
|
|
||||||
- use latest helper namespace
|
|
||||||
- fix nullsafe warnings
|
|
||||||
|
|
||||||
2023.03.25
|
|
||||||
- require dotclear 2.26
|
|
||||||
- use namespace
|
|
||||||
|
|
||||||
2022.11.20
|
2022.11.20
|
||||||
- fix compatibility with Dotclear 2.24 (required)
|
- fix compatibility with Dotclear 2.24 (required)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/releases)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/issues)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/issues)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/lastpostsExtend)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/lastpostsExtend)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/lastpostsExtend)](https://github.com/JcDenis/lastpostsExtend/blob/master/LICENSE)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ Like widget lastposts but with more options.
|
||||||
lastpostsExtend requires:
|
lastpostsExtend requires:
|
||||||
|
|
||||||
* permissions to manage widgets
|
* permissions to manage widgets
|
||||||
* Dotclear 2.26
|
* Dotclear 2.24
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/_widgets.php';
|
14
_define.php
14
_define.php
|
@ -18,15 +18,13 @@ $this->registerModule(
|
||||||
'Last entries (Extended)',
|
'Last entries (Extended)',
|
||||||
'Extended list of entries',
|
'Extended list of entries',
|
||||||
'Jean-Christian Denis and contributors',
|
'Jean-Christian Denis and contributors',
|
||||||
'2023.06.17',
|
'2022.11.20',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.26']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcAuth::PERMISSION_ADMIN,
|
||||||
dcAuth::PERMISSION_ADMIN,
|
|
||||||
]),
|
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
'support' => 'https://github.com/JcDenis/lastpostsExtend',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
'details' => 'http://plugins.dotaddict.org/dc2/details/lastpostsExtend',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/repository.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/lastpostsExtend/master/repository.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/_widgets.php';
|
|
@ -10,49 +10,43 @@
|
||||||
* @copyright 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;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Dotclear\Plugin\lastpostsExtend;
|
dcCore::app()->addBehavior(
|
||||||
|
'initWidgets',
|
||||||
|
['lastpostsextendWidget', 'initWidget']
|
||||||
|
);
|
||||||
|
|
||||||
use dcBlog;
|
class lastpostsextendWidget
|
||||||
use dcCore;
|
|
||||||
use dcMeta;
|
|
||||||
use Dotclear\Helper\Date;
|
|
||||||
use Dotclear\Helper\Text;
|
|
||||||
use Dotclear\Helper\File\Path;
|
|
||||||
use Dotclear\Helper\Html\Html;
|
|
||||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
|
||||||
|
|
||||||
class Widgets
|
|
||||||
{
|
{
|
||||||
public static function initWidgets(WidgetsStack $w): void
|
public static function initWidget($w)
|
||||||
{
|
{
|
||||||
// nullsafe
|
# Create widget
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create widget
|
|
||||||
$w->create(
|
$w->create(
|
||||||
'lastpostsextend',
|
'lastpostsextend',
|
||||||
__('Last entries (Extended)'),
|
__('Last entries (Extended)'),
|
||||||
[self::class, 'parseWidget'],
|
['lastpostsextendWidget', 'parseWidget'],
|
||||||
null,
|
null,
|
||||||
__('Extended list of entries')
|
__('Extended list of entries')
|
||||||
);
|
);
|
||||||
// Title
|
# Title
|
||||||
$w->lastpostsextend->addTitle(__('Last entries'));
|
$w->lastpostsextend->setting(
|
||||||
|
'title',
|
||||||
// post type
|
__('Title:'),
|
||||||
|
__('Last entries'),
|
||||||
|
'text'
|
||||||
|
);
|
||||||
|
# type
|
||||||
$posttypes = [
|
$posttypes = [
|
||||||
__('Post') => 'post',
|
__('Post') => 'post',
|
||||||
__('Page') => 'page',
|
__('Page') => 'page',
|
||||||
__('Gallery') => 'galitem',
|
__('Gallery') => 'galitem',
|
||||||
];
|
];
|
||||||
// plugin muppet types
|
# plugin muppet types
|
||||||
if (dcCore::app()->plugins->moduleExists('muppet') && class_exists('\muppet')) {
|
if (dcCore::app()->plugins->moduleExists('muppet')) {
|
||||||
$muppet_types = \muppet::getPostTypes();
|
$muppet_types = muppet::getPostTypes();
|
||||||
if (is_array($muppet_types) && !empty($muppet_types)) {
|
if (is_array($muppet_types) && !empty($muppet_types)) {
|
||||||
foreach ($muppet_types as $k => $v) {
|
foreach ($muppet_types as $k => $v) {
|
||||||
$posttypes[$v['name']] = $k;
|
$posttypes[$v['name']] = $k;
|
||||||
|
@ -66,8 +60,7 @@ class Widgets
|
||||||
'combo',
|
'combo',
|
||||||
$posttypes
|
$posttypes
|
||||||
);
|
);
|
||||||
|
# Category (post and page have same category)
|
||||||
// Category (post and page have same category)
|
|
||||||
$rs = dcCore::app()->blog->getCategories([
|
$rs = dcCore::app()->blog->getCategories([
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
]);
|
]);
|
||||||
|
@ -78,8 +71,8 @@ class Widgets
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$categories[str_repeat(
|
$categories[str_repeat(
|
||||||
' ',
|
' ',
|
||||||
(int) $rs->f('level') - 1
|
$rs->level - 1
|
||||||
) . '• ' . Html::escapeHTML($rs->f('cat_title'))] = $rs->f('cat_id');
|
) . '• ' . html::escapeHTML($rs->cat_title)] = $rs->cat_id;
|
||||||
}
|
}
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'category',
|
'category',
|
||||||
|
@ -89,8 +82,7 @@ class Widgets
|
||||||
$categories
|
$categories
|
||||||
);
|
);
|
||||||
unset($rs, $categories);
|
unset($rs, $categories);
|
||||||
|
# Pasworded
|
||||||
// Passworded
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'passworded',
|
'passworded',
|
||||||
__('Protection:'),
|
__('Protection:'),
|
||||||
|
@ -102,8 +94,7 @@ class Widgets
|
||||||
__('only with password') => 'yes',
|
__('only with password') => 'yes',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
# Status
|
||||||
// Status
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'status',
|
'status',
|
||||||
__('Status:'),
|
__('Status:'),
|
||||||
|
@ -117,24 +108,21 @@ class Widgets
|
||||||
__('published') => '1',
|
__('published') => '1',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
# Selected entries only
|
||||||
// Selected entries only
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'selectedonly',
|
'selectedonly',
|
||||||
__('Selected entries only'),
|
__('Selected entries only'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
|
# Updated entries only
|
||||||
// Updated entries only
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'updatedonly',
|
'updatedonly',
|
||||||
__('Updated entries only'),
|
__('Updated entries only'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
|
# Tag
|
||||||
// Tag
|
|
||||||
if (dcCore::app()->plugins->moduleExists('tags')) {
|
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'tag',
|
'tag',
|
||||||
|
@ -143,24 +131,21 @@ class Widgets
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
# Search
|
||||||
// Search
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'search',
|
'search',
|
||||||
__('Limit to words:'),
|
__('Limit to words:'),
|
||||||
'',
|
'',
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
|
# Entries limit
|
||||||
// Entries limit
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'limit',
|
'limit',
|
||||||
__('Entries limit:'),
|
__('Entries limit:'),
|
||||||
10,
|
10,
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
|
# Sort type
|
||||||
// Sort
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'sortby',
|
'sortby',
|
||||||
__('Order by:'),
|
__('Order by:'),
|
||||||
|
@ -172,6 +157,7 @@ class Widgets
|
||||||
__('Comments') => 'nb_comment',
|
__('Comments') => 'nb_comment',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
# Sort order
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'sort',
|
'sort',
|
||||||
__('Sort:'),
|
__('Sort:'),
|
||||||
|
@ -182,8 +168,7 @@ class Widgets
|
||||||
__('Descending') => 'desc',
|
__('Descending') => 'desc',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
# First image
|
||||||
// First image
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'firstimage',
|
'firstimage',
|
||||||
__('Show entries first image:'),
|
__('Show entries first image:'),
|
||||||
|
@ -198,76 +183,103 @@ class Widgets
|
||||||
__('original') => 'o',
|
__('original') => 'o',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
# With excerpt
|
||||||
// With excerpt
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'excerpt',
|
'excerpt',
|
||||||
__('Show entries excerpt'),
|
__('Show entries excerpt'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
|
# Excerpt length
|
||||||
// Excerpt cut length
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'excerptlen',
|
'excerptlen',
|
||||||
__('Excerpt length:'),
|
__('Excerpt length:'),
|
||||||
100,
|
100,
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
|
# Comment count
|
||||||
// Comment count
|
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'commentscount',
|
'commentscount',
|
||||||
__('Show comments count'),
|
__('Show comments count'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
|
# Home only
|
||||||
// commons
|
$w->lastpostsextend->setting(
|
||||||
$w->lastpostsextend
|
'homeonly',
|
||||||
->addHomeOnly()
|
__('Display on:'),
|
||||||
->addContentOnly()
|
0,
|
||||||
->addClass()
|
'combo',
|
||||||
->addOffline();
|
[
|
||||||
|
__('All pages') => 0,
|
||||||
|
__('Home page only') => 1,
|
||||||
|
__('Except on home page') => 2,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
# widget option - content only
|
||||||
|
$w->lastpostsextend->setting(
|
||||||
|
'content_only',
|
||||||
|
__('Content only'),
|
||||||
|
0,
|
||||||
|
'check'
|
||||||
|
);
|
||||||
|
# widget option - additionnal CSS
|
||||||
|
$w->lastpostsextend->setting(
|
||||||
|
'class',
|
||||||
|
__('CSS class:'),
|
||||||
|
''
|
||||||
|
);
|
||||||
|
# widget option - put offline
|
||||||
|
$w->lastpostsextend->setting(
|
||||||
|
'offline',
|
||||||
|
__('Offline'),
|
||||||
|
0,
|
||||||
|
'check'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseWidget(WidgetsElement $w): string
|
public static function parseWidget($w)
|
||||||
{
|
{
|
||||||
// Widget is offline & Home page only
|
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Need posts excerpt
|
|
||||||
if ($w->excerpt) {
|
|
||||||
$params['columns'][] = 'post_excerpt';
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare request params
|
|
||||||
$params = [
|
$params = [
|
||||||
'sql' => '',
|
'sql' => '',
|
||||||
'columns' => [],
|
'columns' => [],
|
||||||
'from' => '',
|
'from' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Passworded
|
# Widget is offline
|
||||||
|
if ($w->offline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Home page only
|
||||||
|
if ($w->homeonly == 1 && dcCore::app()->url->type != 'default'
|
||||||
|
|| $w->homeonly == 2 && dcCore::app()->url->type == 'default') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Need posts excerpt
|
||||||
|
if ($w->excerpt) {
|
||||||
|
$params['columns'][] = 'post_excerpt';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Passworded
|
||||||
if ($w->passworded == 'yes') {
|
if ($w->passworded == 'yes') {
|
||||||
$params['sql'] .= 'AND post_password IS NOT NULL ';
|
$params['sql'] .= 'AND post_password IS NOT NULL ';
|
||||||
} elseif ($w->passworded == 'no') {
|
} elseif ($w->passworded == 'no') {
|
||||||
$params['sql'] .= 'AND post_password IS NULL ';
|
$params['sql'] .= 'AND post_password IS NULL ';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
# Status
|
||||||
if ($w->status != 'all') {
|
if ($w->status != 'all') {
|
||||||
$params['post_status'] = $w->status;
|
$params['post_status'] = $w->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search words
|
# Search words
|
||||||
if ('' != $w->search) {
|
if ('' != $w->search) {
|
||||||
$params['search'] = $w->search;
|
$params['search'] = $w->search;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated posts only
|
# Updated posts only
|
||||||
if ($w->updatedonly) {
|
if ($w->updatedonly) {
|
||||||
$params['sql'] .= 'AND post_creadt < post_upddt ' .
|
$params['sql'] .= 'AND post_creadt < post_upddt ' .
|
||||||
'AND post_dt < post_upddt ';
|
'AND post_dt < post_upddt ';
|
||||||
|
@ -286,15 +298,15 @@ class Widgets
|
||||||
$params['limit'] = abs((int) $w->limit);
|
$params['limit'] = abs((int) $w->limit);
|
||||||
$params['no_content'] = true;
|
$params['no_content'] = true;
|
||||||
|
|
||||||
// Selected posts only
|
# Selected posts only
|
||||||
if ($w->selectedonly) {
|
if ($w->selectedonly) {
|
||||||
$params['post_selected'] = 1;
|
$params['post_selected'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post type
|
# Type
|
||||||
$params['post_type'] = $w->posttype;
|
$params['post_type'] = $w->posttype;
|
||||||
|
|
||||||
// Category
|
# Category
|
||||||
if ($w->category) {
|
if ($w->category) {
|
||||||
if ($w->category == 'null') {
|
if ($w->category == 'null') {
|
||||||
$params['sql'] .= ' AND P.cat_id IS NULL ';
|
$params['sql'] .= ' AND P.cat_id IS NULL ';
|
||||||
|
@ -305,13 +317,13 @@ class Widgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tags
|
# Tags
|
||||||
if (dcCore::app()->plugins->moduleExists('tags') && $w->tag) {
|
if (dcCore::app()->plugins->moduleExists('tags') && $w->tag) {
|
||||||
$tags = explode(',', $w->tag);
|
$tags = explode(',', $w->tag);
|
||||||
foreach ($tags as $i => $tag) {
|
foreach ($tags as $i => $tag) {
|
||||||
$tags[$i] = trim($tag);
|
$tags[$i] = trim($tag);
|
||||||
}
|
}
|
||||||
$params['from'] .= ', ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' META ';
|
$params['from'] .= ', ' . dcCore::app()->prefix . 'meta META ';
|
||||||
$params['sql'] .= 'AND META.post_id = P.post_id ';
|
$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 ' . dcCore::app()->con->in($tags) . ' ';
|
||||||
$params['sql'] .= "AND META.meta_type = 'tag' ";
|
$params['sql'] .= "AND META.meta_type = 'tag' ";
|
||||||
|
@ -323,58 +335,53 @@ class Widgets
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// No result
|
# No result
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return '';
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse result
|
# Return
|
||||||
$res = $w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '';
|
$res = $w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '';
|
||||||
|
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
if (is_null(dcCore::app()->blog)) { // phpstan ignores previous check !?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$published = ((int) $rs->f('post_status')) == dcBlog::POST_PUBLISHED;
|
|
||||||
|
|
||||||
$res .= '<li>' .
|
$res .= '<li>' .
|
||||||
'<' . ($published ? 'a href="' . $rs->getURL() . '"' : 'span') .
|
'<' . ($rs->post_status == 1 ? 'a href="' . $rs->getURL() . '"' : 'span') .
|
||||||
' title="' .
|
' title="' .
|
||||||
Date::dt2str(
|
dt::dt2str(
|
||||||
dcCore::app()->blog->settings->get('system')->get('date_format'),
|
dcCore::app()->blog->settings->system->date_format,
|
||||||
$rs->f('post_upddt')
|
$rs->post_upddt
|
||||||
) . ', ' .
|
) . ', ' .
|
||||||
Date::dt2str(
|
dt::dt2str(
|
||||||
dcCore::app()->blog->settings->get('system')->get('time_format'),
|
dcCore::app()->blog->settings->system->time_format,
|
||||||
$rs->f('post_upddt')
|
$rs->post_upddt
|
||||||
) . '">' .
|
) . '">' .
|
||||||
Html::escapeHTML($rs->f('post_title')) .
|
html::escapeHTML($rs->post_title) .
|
||||||
'</' . ($published ? 'a' : 'span') . '>';
|
'</' . ($rs->post_status == 1 ? 'a' : 'span') . '>';
|
||||||
|
|
||||||
// Nb comments
|
# Nb comments
|
||||||
if ($w->commentscount && $published) {
|
if ($w->commentscount && $rs->post_status == 1) {
|
||||||
$res .= ' (' . $rs->nb_comment . ')';
|
$res .= ' (' . $rs->nb_comment . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
// First image
|
# First image
|
||||||
if ($w->firstimage != '') {
|
if ($w->firstimage != '') {
|
||||||
$res .= self::entryFirstImage(
|
$res .= self::entryFirstImage(
|
||||||
$rs->f('post_type'),
|
$rs->post_type,
|
||||||
$rs->f('post_id'),
|
$rs->post_id,
|
||||||
$w->firstimage
|
$w->firstimage
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Excerpt
|
# Excerpt
|
||||||
if ($w->excerpt) {
|
if ($w->excerpt) {
|
||||||
$excerpt = $rs->f('post_excerpt');
|
$excerpt = $rs->post_excerpt;
|
||||||
if ($rs->f('post_format') == 'wiki') {
|
if ($rs->post_format == 'wiki') {
|
||||||
dcCore::app()->initWikiComment();
|
dcCore::app()->initWikiComment();
|
||||||
$excerpt = dcCore::app()->wikiTransform($excerpt);
|
$excerpt = dcCore::app()->wikiTransform($excerpt);
|
||||||
$excerpt = dcCore::app()->HTMLfilter($excerpt);
|
$excerpt = dcCore::app()->HTMLfilter($excerpt);
|
||||||
}
|
}
|
||||||
if (strlen($excerpt) > 0) {
|
if (strlen($excerpt) > 0) {
|
||||||
$cut = Text::cutString(
|
$cut = text::cutString(
|
||||||
$excerpt,
|
$excerpt,
|
||||||
abs((int) $w->excerptlen)
|
abs((int) $w->excerptlen)
|
||||||
);
|
);
|
||||||
|
@ -387,16 +394,16 @@ class Widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $w->renderDiv(
|
||||||
(bool) $w->content_only,
|
$w->content_only,
|
||||||
'lastpostsextend ' . $w->class,
|
'lastpostsextend ' . $w->class,
|
||||||
'',
|
'',
|
||||||
'<ul>' . $res . '</ul>'
|
'<ul>' . $res . '</ul>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function entryFirstImage(string $type, $id, string $size = 's'): string
|
private static function entryFirstImage($type, $id, $size = 's')
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || !in_array($type, ['post', 'page', 'galitem'])) {
|
if (!in_array($type, ['post', 'page', 'galitem'])) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,8 +421,8 @@ class Widgets
|
||||||
$size = 's';
|
$size = 's';
|
||||||
}
|
}
|
||||||
|
|
||||||
$p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url');
|
$p_url = dcCore::app()->blog->settings->system->public_url;
|
||||||
$p_site = (string) preg_replace(
|
$p_site = preg_replace(
|
||||||
'#^(.+?//.+?)/(.*)$#',
|
'#^(.+?//.+?)/(.*)$#',
|
||||||
'$1',
|
'$1',
|
||||||
dcCore::app()->blog->url
|
dcCore::app()->blog->url
|
||||||
|
@ -428,10 +435,10 @@ class Widgets
|
||||||
$src = '';
|
$src = '';
|
||||||
$alt = '';
|
$alt = '';
|
||||||
|
|
||||||
$subject = $rs->f('post_excerpt_xhtml') . $rs->f('post_content_xhtml') . $rs->f('cat_desc');
|
$subject = $rs->post_excerpt_xhtml . $rs->post_content_xhtml . $rs->cat_desc;
|
||||||
if (preg_match_all($pattern, $subject, $m) > 0) {
|
if (preg_match_all($pattern, $subject, $m) > 0) {
|
||||||
foreach ($m[1] as $i => $img) {
|
foreach ($m[1] as $i => $img) {
|
||||||
if (($src = self::ContentFirstImageLookup($p_root, $img, $size)) != '') {
|
if (($src = self::ContentFirstImageLookup($p_root, $img, $size)) !== false) {
|
||||||
$src = $p_url . (dirname($img) != '/' ? dirname($img) : '') . '/' . $src;
|
$src = $p_url . (dirname($img) != '/' ? dirname($img) : '') . '/' . $src;
|
||||||
if (preg_match('/alt="([^"]+)"/', $m[0][$i], $malt)) {
|
if (preg_match('/alt="([^"]+)"/', $m[0][$i], $malt)) {
|
||||||
$alt = $malt[1];
|
$alt = $malt[1];
|
||||||
|
@ -449,24 +456,23 @@ class Widgets
|
||||||
return
|
return
|
||||||
'<div class="img-box">' .
|
'<div class="img-box">' .
|
||||||
'<div class="img-thumbnail">' .
|
'<div class="img-thumbnail">' .
|
||||||
'<a title="' . Html::escapeHTML($rs->f('post_title')) . '" href="' . $rs->getURL() . '">' .
|
'<a title="' . html::escapeHTML($rs->post_title) . '" href="' . $rs->getURL() . '">' .
|
||||||
'<img alt="' . $alt . '" src="' . stripslashes($src) . '" />' .
|
'<img alt="' . $alt . '" src="' . stripslashes($src) . '" />' .
|
||||||
'</a></div>' .
|
'</a></div>' .
|
||||||
"</div>\n";
|
"</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function ContentFirstImageLookup(string $root, string $img, string $size): string
|
private static function ContentFirstImageLookup($root, $img, $size)
|
||||||
{
|
{
|
||||||
$res = '';
|
|
||||||
|
|
||||||
# Get base name and extension
|
# Get base name and extension
|
||||||
$info = Path::info($img);
|
$info = path::info($img);
|
||||||
$base = $info['base'];
|
$base = $info['base'];
|
||||||
|
|
||||||
if (preg_match('/^\.(.+)_(sq|t|s|m)$/', $base, $m)) {
|
if (preg_match('/^\.(.+)_(sq|t|s|m)$/', $base, $m)) {
|
||||||
$base = $m[1];
|
$base = $m[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$res = false;
|
||||||
if ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.jpg')) {
|
if ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.jpg')) {
|
||||||
$res = '.' . $base . '_' . $size . '.jpg';
|
$res = '.' . $base . '_' . $size . '.jpg';
|
||||||
} else {
|
} else {
|
||||||
|
@ -482,6 +488,6 @@ class Widgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res ? $res : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="lastpostsExtend">
|
<module id="lastpostsExtend">
|
||||||
<name>Last entries (Extended)</name>
|
<name>Last entries (Extended)</name>
|
||||||
<version>2023.06.17</version>
|
<version>2022.11.20</version>
|
||||||
<author>Jean-Christian Denis and contributors</author>
|
<author>Jean-Christian Denis and contributors</author>
|
||||||
<desc>Extended list of entries</desc>
|
<desc>Extended list of entries</desc>
|
||||||
<file>https://github.com/JcDenis/lastpostsExtend/releases/download/v2023.06.17/plugin-lastpostsExtend.zip</file>
|
<file>https://github.com/JcDenis/lastpostsExtend/releases/download/v2022.11.20/plugin-lastpostsExtend.zip</file>
|
||||||
<da:dcmin>2.26</da:dcmin>
|
<da:dcmin>2.24</da:dcmin>
|
||||||
<da:details>http://plugins.dotaddict.org/dc2/details/lastpostsExtend</da:details>
|
<da:details>http://plugins.dotaddict.org/dc2/details/lastpostsExtend</da:details>
|
||||||
<da:support>https://github.com/JcDenis/lastpostsExtend</da:support>
|
<da:support>https://github.com/JcDenis/lastpostsExtend</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Dotclear
|
|
||||||
*
|
|
||||||
* @copyright Olivier Meunier & Association Dotclear
|
|
||||||
* @copyright GPL-2.0-only
|
|
||||||
*/
|
|
||||||
#
|
|
||||||
# DOT NOT MODIFY THIS FILE !
|
|
||||||
#
|
|
||||||
|
|
||||||
use Dotclear\Helper\L10n;
|
|
||||||
|
|
||||||
L10n::$locales['Last entries (Extended)'] = 'Derniers billets (étendu)';
|
|
||||||
L10n::$locales['Extended list of entries'] = 'Liste étendue de billets';
|
|
||||||
L10n::$locales['Post'] = 'Billet';
|
|
||||||
L10n::$locales['Gallery'] = 'Galerie';
|
|
||||||
L10n::$locales['Protection:'] = 'Protection :';
|
|
||||||
L10n::$locales['only without password'] = 'seulement sans mot de passe';
|
|
||||||
L10n::$locales['only with password'] = 'seulement avec mot de passe';
|
|
||||||
L10n::$locales['Selected entries only'] = 'Billets sélectionnés seulement';
|
|
||||||
L10n::$locales['Updated entries only'] = 'Billets mis à jour seulement';
|
|
||||||
L10n::$locales['Limit to tags:'] = 'Limiter aux mots-clés :';
|
|
||||||
L10n::$locales['Limit to words:'] = 'Limiter aux mots :';
|
|
||||||
L10n::$locales['Show entries first image:'] = 'Afficher la première image du billet :';
|
|
||||||
L10n::$locales['Show entries excerpt'] = 'Afficher l\'extrait';
|
|
||||||
L10n::$locales['Excerpt length:'] = 'Taille de l\'extrait :';
|
|
||||||
L10n::$locales['Show comments count'] = 'Afficher le nombre de commentaires';
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?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 dcNsProcess;
|
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
|
||||||
{
|
|
||||||
public static function init(): bool
|
|
||||||
{
|
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function process(): bool
|
|
||||||
{
|
|
||||||
if (!static::$init) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?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 dcNsProcess;
|
|
||||||
|
|
||||||
class Frontend extends dcNsProcess
|
|
||||||
{
|
|
||||||
public static function init(): bool
|
|
||||||
{
|
|
||||||
static::$init = true;
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function process(): bool
|
|
||||||
{
|
|
||||||
if (!static::$init) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue