Compare commits

...

5 Commits
v1.5 ... master

Author SHA1 Message Date
9e1c801a66
code review 2023-10-24 21:27:03 +02:00
3f3f0c0521
oups 2023-10-24 00:11:17 +02:00
c403444100
fix repo URL 2023-10-24 00:08:13 +02:00
cb9d370ed4
fix maxlength typo 2023-10-24 00:07:48 +02:00
8da1d0fbc6
oups 2023-10-16 23:12:29 +02:00
9 changed files with 88 additions and 81 deletions

View File

@ -1,3 +1,9 @@
fac 1.5.1 - 2023.10.24
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1+
* Code review
fac 1.5 - 2023.10.16
===========================================================
* Require Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README
[![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/fac/releases)
![Date](https://img.shields.io/badge/date-2023.10.16-c44d58.svg)
[![Release](https://img.shields.io/badge/release-1.5.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/fac/releases)
![Date](https://img.shields.io/badge/date-2023.10.24-c44d58.svg)
[![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/fac)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/fac/src/branch/master/LICENSE)

View File

@ -17,7 +17,7 @@ $this->registerModule(
'Feed after content',
'Add RSS/Atom feeds after entries content',
'Jean-Christian Denis and Contributors',
'1.5',
'1.5.1',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="fac">
<name>Feed after content</name>
<version>1.4</version>
<version>1.5.1</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Add RSS/Atom feeds after entries content</desc>
<file>https://github.com/JcDenis/fac/releases/download/v1.4/plugin-fac.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/fac/releases/download/v1.5.1/plugin-fac.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/fac/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/fac/issues</da:support>
</module>

View File

@ -23,10 +23,7 @@ class Backend extends Process
public static function process(): bool
{
if (!self::status()) {
return false;
}
if (self::status()) {
App::behavior()->addBehaviors([
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
@ -37,7 +34,8 @@ class Backend extends Process
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
]);
}
return true;
return self::status();
}
}

View File

@ -42,9 +42,9 @@ use Exception;
class BackendBehaviors
{
/**
* Get combos of types of supported public pages
* Get combos of types of supported public pages.
*
* @return array List of post type and name
* @return array<string, string> List of post type and name
*/
public static function getPostsTypes(): array
{
@ -61,7 +61,7 @@ class BackendBehaviors
$types[sprintf(
__('"%s" pages from extension muppet'),
$v['name']
)] = $k;
)] = (string) $k;
}
}
@ -69,9 +69,9 @@ class BackendBehaviors
}
/**
* Add settings to blog preference
* Add settings to blog preference.
*
* @param dcSettings $blog_settings dcSettings instance
* @param BlogSettingsInterface $blog_settings Blog settings instance
*/
public static function adminBlogPreferencesFormV2(BlogSettingsInterface $blog_settings): void
{
@ -114,7 +114,7 @@ class BackendBehaviors
// defaultfeedtitle
(new Para())->items([
(new Label(__('Default title')))->for('fac_defaultfeedtitle'),
(new Input('fac_defaultfeedtitle'))->size(70)->maxlenght(255)->value((string) $blog_settings->get(My::id())->get('defaultfeedtitle')),
(new Input('fac_defaultfeedtitle'))->size(70)->maxlength(255)->value((string) $blog_settings->get(My::id())->get('defaultfeedtitle')),
]),
(new Note())->text(__('Use %T to insert title of feed.'))->class('form-note'),
// showfeeddesc
@ -133,9 +133,9 @@ class BackendBehaviors
}
/**
* Save blog settings
* Save blog settings.
*
* @param dcSettings $blog_settings dcSettings instance
* @param BlogSettingsInterface $blog_settings Blog settings instance
*/
public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
{
@ -146,7 +146,7 @@ class BackendBehaviors
}
/**
* Add javascript (toggle)
* Add javascript (toggle).
*
* @return string HTML head
*/
@ -156,10 +156,10 @@ class BackendBehaviors
}
/**
* Add form to post sidebar
* Add form to post sidebar.
*
* @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items
* @param ArrayObject<string, string> $main_items Main items
* @param ArrayObject<string, array<string, mixed>> $sidebar_items Sidebar items
* @param null|MetaRecord $post Post record or null
*/
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
@ -191,10 +191,10 @@ class BackendBehaviors
}
/**
* Save linked feed
* Save linked feed.
*
* @param Cursor $cur Current post Cursor
* @param integer $post_id Post id
* @param int $post_id Post id
*/
public static function adminAfterPostSave(Cursor $cur, int $post_id): void
{
@ -211,9 +211,9 @@ class BackendBehaviors
}
/**
* Delete linked feed on post edition
* Delete linked feed on post edition.
*
* @param integer $post_id Post id
* @param int $post_id Post id
*/
public static function adminBeforePostDelete(int $post_id): void
{
@ -221,7 +221,7 @@ class BackendBehaviors
}
/**
* Add actions to posts page combo
* Add actions to posts page combo.
*
* @param ActionsPosts $pa ActionsPostsPage instance
*/
@ -249,10 +249,10 @@ class BackendBehaviors
}
/**
* Posts actions callback to remove linked feed
* Posts actions callback to remove linked feed.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
* @param ArrayObject<string, mixed> $post _POST actions
*/
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
{
@ -275,7 +275,7 @@ class BackendBehaviors
# Delete unused feed
foreach ($posts_ids as $post_id) {
self::delFeed($post_id);
self::delFeed((int) $post_id);
}
Notices::addSuccessNotice(__('Linked feed deleted.'));
@ -283,10 +283,10 @@ class BackendBehaviors
}
/**
* Posts actions callback to add linked feed
* Posts actions callback to add linked feed.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
* @param ArrayObject<string, mixed> $post _POST actions
*/
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
{
@ -303,8 +303,8 @@ class BackendBehaviors
if (!empty($post['fac_url'])
&& !empty($post['fac_format'])) {
foreach ($posts_ids as $post_id) {
self::delFeed($post_id);
self::addFeed($post_id, $post);
self::delFeed((int) $post_id);
self::addFeed((int) $post_id, $post);
}
Notices::addSuccessNotice(__('Linked feed added.'));
@ -325,7 +325,7 @@ class BackendBehaviors
(new Text('', $pa->getCheckboxes() . self::formFeed())),
(new Para())->items([
App::nonce()->formNonce(),
... $pa->giddenFields(),
... $pa->hiddenFields(),
(new Hidden(['action'], 'fac_add')),
(new Submit(['save']))->value(__('Save')),
]),
@ -336,10 +336,11 @@ class BackendBehaviors
}
/**
* Linked feed form field
* Linked feed form field.
*
* @param string $url Feed URL
* @param string $format Feed format
*
* @return string Feed form content
*/
protected static function formFeed(string $url = '', string $format = ''): string
@ -354,7 +355,7 @@ class BackendBehaviors
// fac_url
(new Para())->items([
(new Label(__('Feed URL:')))->for('fac_url')->class('required'),
(new Input('fac_url'))->size(60)->maxlenght(255)->value($url),
(new Input('fac_url'))->size(60)->maxlength(255)->value($url),
]),
// fac_format
(new Para())->items([
@ -366,9 +367,9 @@ class BackendBehaviors
}
/**
* List of fac formats
* List of fac formats.
*
* @return array List of fac formats
* @return array<string, string> List of fac formats
*/
protected static function comboFac(): array
{
@ -382,16 +383,16 @@ class BackendBehaviors
$res = [];
foreach ($formats as $uid => $f) {
$res[$f['name']] = $uid;
$res[(string) $f['name']] = (string) $uid;
}
return $res;
}
/**
* Delete linked feed
* Delete linked feed.
*
* @param integer $post_id Post id
* @param int $post_id Post id
*/
protected static function delFeed(int $post_id): void
{
@ -401,10 +402,10 @@ class BackendBehaviors
}
/**
* Add linked feed
* Add linked feed.
*
* @param integer $post_id Post id
* @param array|ArrayObject $options Feed options
* @param int $post_id Post id
* @param array<string, mixed>|ArrayObject<string, mixed> $options Feed options
*/
protected static function addFeed(int $post_id, $options): void
{

View File

@ -169,6 +169,9 @@ class Config extends Process
Page::helpBlock('fac');
}
/**
* @param array<string, string> $format
*/
private static function displayFacFormat(string $title, string $uid, array $format): void
{
echo
@ -182,7 +185,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name',
]))->value(empty($format['name']) ? '' : $format['name'])->size(20)->maxlenght(255)->class('maximal'),
]))->value(empty($format['name']) ? '' : $format['name'])->size(20)->maxlength(255)->class('maximal'),
]),
(new Note())->text(__('In order to remove a format, leave its name empty.'))->class('form-note'),
// dateformat
@ -191,7 +194,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat',
]))->value(empty($format['dateformat']) ? '' : $format['dateformat'])->size(20)->maxlenght(255)->class('maximal'),
]))->value(empty($format['dateformat']) ? '' : $format['dateformat'])->size(20)->maxlength(255)->class('maximal'),
]),
(new Note())->text(__('Use date format of Dotclear or leave empty to use default date format of blog.'))->class('form-note'),
// dateformat //todo: use Number
@ -200,7 +203,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit',
]))->value(empty($format['lineslimit']) ? '' : $format['lineslimit'])->size(4)->maxlenght(5),
]))->value(empty($format['lineslimit']) ? '' : $format['lineslimit'])->size(4)->maxlength(5),
]),
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
]),
@ -212,7 +215,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext',
]))->value(empty($format['linestitletext']) ? '' : $format['linestitletext'])->size(20)->maxlenght(255)->class('maximal'),
]))->value(empty($format['linestitletext']) ? '' : $format['linestitletext'])->size(20)->maxlength(255)->class('maximal'),
]),
(new Note())->text(
__('Format can be:') .
@ -228,7 +231,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover',
]))->value(empty($format['linestitleover']) ? '' : $format['linestitleover'])->size(20)->maxlenght(255)->class('maximal'),
]))->value(empty($format['linestitleover']) ? '' : $format['linestitleover'])->size(20)->maxlength(255)->class('maximal'),
]),
(new Note())->text(
__('Format can be:') .
@ -244,7 +247,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength',
]))->value(empty($format['linestitlelength']) ? '' : $format['linestitlelength'])->size(4)->maxlenght(5),
]))->value(empty($format['linestitlelength']) ? '' : $format['linestitlelength'])->size(4)->maxlength(5),
]),
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
]),
@ -272,7 +275,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength',
]))->value(empty($format['linesdescriptionlength']) ? '' : $format['linesdescriptionlength'])->size(4)->maxlenght(5),
]))->value(empty($format['linesdescriptionlength']) ? '' : $format['linesdescriptionlength'])->size(4)->maxlength(5),
]),
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
]),
@ -300,7 +303,7 @@ class Config extends Process
(new Input([
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength',
]))->value(empty($format['linescontentlength']) ? '' : $format['linescontentlength'])->size(4)->maxlenght(5),
]))->value(empty($format['linescontentlength']) ? '' : $format['linescontentlength'])->size(4)->maxlength(5),
]),
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
]),

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\fac;
use Dotclear\App;
use Dotclear\Core\Frontend\Ctx;
use Dotclear\Core\Process;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html;
@ -32,7 +31,7 @@ class Frontend extends Process
return false;
}
App::behavior()->addBehavior('publicEntryAfterContent', function ($___, Ctx $_ctx): void {
App::behavior()->addBehavior('publicEntryAfterContent', function ($___, $_____): void {
if (!App::blog()->isDefined()) {
return;
}
@ -133,7 +132,7 @@ class Frontend extends Process
$feeddesc = '';
if (My::settings()->get('showfeeddesc')
&& '' != $feed->description) {
$feeddesc = '<p>' . $_ctx::global_filters(
$feeddesc = '<p>' . App::frontend()->context()->global_filters(
$feed->description,
['encode_xml', 'remove_html']
) . '</p>';
@ -159,7 +158,7 @@ class Frontend extends Process
$date = Date::dt2str($dateformat, $item->pubdate);
// Entries title
$title = $_ctx::global_filters(
$title = App::frontend()->context()->global_filters(
str_replace(
[
'%D',
@ -175,13 +174,13 @@ class Frontend extends Process
$item->description,
$item->content,
],
$format['linestitletext']
(string) $format['linestitletext']
),
['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
);
// Entries over title
$overtitle = $_ctx::global_filters(
$overtitle = App::frontend()->context()->global_filters(
str_replace(
[
'%D',
@ -197,7 +196,7 @@ class Frontend extends Process
$item->description,
$item->content,
],
$format['linestitleover']
(string) $format['linestitleover']
),
['remove_html', 'cut_string' => 350],
);
@ -207,7 +206,7 @@ class Frontend extends Process
if ($format['showlinesdescription']
&& '' != $item->description) {
$description = '<dd>' .
$_ctx::global_filters(
App::frontend()->context()->global_filters(
$item->description,
['remove_html' => (int) $format['linesdescriptionnohtml'], 'cut_string' => abs((int) $format['linesdescriptionlength'])]
) . '</dd>';
@ -218,7 +217,7 @@ class Frontend extends Process
if ($format['showlinescontent']
&& '' != $item->content) {
$content = '<dd>' .
$_ctx::global_filters(
App::frontend()->context()->global_filters(
$item->content,
['remove_html' => (int) $format['linescontentnohtml'], 'cut_string' => abs((int) $format['linescontentlength'])]
) . '</dd>';

View File

@ -118,7 +118,7 @@ class Install extends Process
private static function growUp(): void
{
// version < 1.0 : upgrade settings id and ns and array
$current = App::version()()->getVersion(My::id());
$current = App::version()->getVersion(My::id());
if ($current && version_compare($current, '1.0', '<')) {
$record = App::con()->select(
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .