Compare commits
No commits in common. "master" and "v1.5" have entirely different histories.
@ -1,9 +1,3 @@
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
# README
|
||||
|
||||
[![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)
|
||||
[![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)
|
||||
[![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)
|
||||
|
@ -17,7 +17,7 @@ $this->registerModule(
|
||||
'Feed after content',
|
||||
'Add RSS/Atom feeds after entries content',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'1.5.1',
|
||||
'1.5',
|
||||
[
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="fac">
|
||||
<name>Feed after content</name>
|
||||
<version>1.5.1</version>
|
||||
<version>1.4</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Add RSS/Atom feeds after entries content</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/fac/releases/download/v1.5.1/plugin-fac.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<file>https://github.com/JcDenis/fac/releases/download/v1.4/plugin-fac.zip</file>
|
||||
<da:dcmin>2.27</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>
|
||||
|
@ -23,19 +23,21 @@ class Backend extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (self::status()) {
|
||||
App::behavior()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
|
||||
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
|
||||
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
|
||||
]);
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::status();
|
||||
App::behavior()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
|
||||
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
|
||||
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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<string, string> List of post type and name
|
||||
* @return array 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']
|
||||
)] = (string) $k;
|
||||
)] = $k;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,9 +69,9 @@ class BackendBehaviors
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings to blog preference.
|
||||
* Add settings to blog preference
|
||||
*
|
||||
* @param BlogSettingsInterface $blog_settings Blog settings instance
|
||||
* @param dcSettings $blog_settings dcSettings 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)->maxlength(255)->value((string) $blog_settings->get(My::id())->get('defaultfeedtitle')),
|
||||
(new Input('fac_defaultfeedtitle'))->size(70)->maxlenght(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 BlogSettingsInterface $blog_settings Blog settings instance
|
||||
* @param dcSettings $blog_settings dcSettings 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,11 +156,11 @@ class BackendBehaviors
|
||||
}
|
||||
|
||||
/**
|
||||
* Add form to post sidebar.
|
||||
* Add form to post sidebar
|
||||
*
|
||||
* @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
|
||||
* @param ArrayObject $main_items Main items
|
||||
* @param ArrayObject $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 int $post_id Post id
|
||||
* @param Cursor $cur Current post Cursor
|
||||
* @param integer $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 int $post_id Post id
|
||||
* @param integer $post_id Post id
|
||||
*/
|
||||
public static function adminBeforePostDelete(int $post_id): void
|
||||
{
|
||||
@ -221,9 +221,9 @@ class BackendBehaviors
|
||||
}
|
||||
|
||||
/**
|
||||
* Add actions to posts page combo.
|
||||
* Add actions to posts page combo
|
||||
*
|
||||
* @param ActionsPosts $pa ActionsPostsPage instance
|
||||
* @param ActionsPosts $pa ActionsPostsPage instance
|
||||
*/
|
||||
public static function adminPostsActions(ActionsPosts $pa): void
|
||||
{
|
||||
@ -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<string, mixed> $post _POST actions
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject $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((int) $post_id);
|
||||
self::delFeed($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<string, mixed> $post _POST actions
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject $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((int) $post_id);
|
||||
self::addFeed((int) $post_id, $post);
|
||||
self::delFeed($post_id);
|
||||
self::addFeed($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->hiddenFields(),
|
||||
... $pa->giddenFields(),
|
||||
(new Hidden(['action'], 'fac_add')),
|
||||
(new Submit(['save']))->value(__('Save')),
|
||||
]),
|
||||
@ -336,12 +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
|
||||
* @param string $url Feed URL
|
||||
* @param string $format Feed format
|
||||
* @return string Feed form content
|
||||
*/
|
||||
protected static function formFeed(string $url = '', string $format = ''): string
|
||||
{
|
||||
@ -355,7 +354,7 @@ class BackendBehaviors
|
||||
// fac_url
|
||||
(new Para())->items([
|
||||
(new Label(__('Feed URL:')))->for('fac_url')->class('required'),
|
||||
(new Input('fac_url'))->size(60)->maxlength(255)->value($url),
|
||||
(new Input('fac_url'))->size(60)->maxlenght(255)->value($url),
|
||||
]),
|
||||
// fac_format
|
||||
(new Para())->items([
|
||||
@ -367,9 +366,9 @@ class BackendBehaviors
|
||||
}
|
||||
|
||||
/**
|
||||
* List of fac formats.
|
||||
* List of fac formats
|
||||
*
|
||||
* @return array<string, string> List of fac formats
|
||||
* @return array List of fac formats
|
||||
*/
|
||||
protected static function comboFac(): array
|
||||
{
|
||||
@ -383,16 +382,16 @@ class BackendBehaviors
|
||||
|
||||
$res = [];
|
||||
foreach ($formats as $uid => $f) {
|
||||
$res[(string) $f['name']] = (string) $uid;
|
||||
$res[$f['name']] = $uid;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete linked feed.
|
||||
* Delete linked feed
|
||||
*
|
||||
* @param int $post_id Post id
|
||||
* @param integer $post_id Post id
|
||||
*/
|
||||
protected static function delFeed(int $post_id): void
|
||||
{
|
||||
@ -402,10 +401,10 @@ class BackendBehaviors
|
||||
}
|
||||
|
||||
/**
|
||||
* Add linked feed.
|
||||
* Add linked feed
|
||||
*
|
||||
* @param int $post_id Post id
|
||||
* @param array<string, mixed>|ArrayObject<string, mixed> $options Feed options
|
||||
* @param integer $post_id Post id
|
||||
* @param array|ArrayObject $options Feed options
|
||||
*/
|
||||
protected static function addFeed(int $post_id, $options): void
|
||||
{
|
||||
|
@ -169,9 +169,6 @@ class Config extends Process
|
||||
Page::helpBlock('fac');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $format
|
||||
*/
|
||||
private static function displayFacFormat(string $title, string $uid, array $format): void
|
||||
{
|
||||
echo
|
||||
@ -185,7 +182,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][name]',
|
||||
'fac_formats_' . $uid . '_name',
|
||||
]))->value(empty($format['name']) ? '' : $format['name'])->size(20)->maxlength(255)->class('maximal'),
|
||||
]))->value(empty($format['name']) ? '' : $format['name'])->size(20)->maxlenght(255)->class('maximal'),
|
||||
]),
|
||||
(new Note())->text(__('In order to remove a format, leave its name empty.'))->class('form-note'),
|
||||
// dateformat
|
||||
@ -194,7 +191,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][dateformat]',
|
||||
'fac_formats_' . $uid . '_dateformat',
|
||||
]))->value(empty($format['dateformat']) ? '' : $format['dateformat'])->size(20)->maxlength(255)->class('maximal'),
|
||||
]))->value(empty($format['dateformat']) ? '' : $format['dateformat'])->size(20)->maxlenght(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
|
||||
@ -203,7 +200,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][lineslimit]',
|
||||
'fac_formats_' . $uid . '_lineslimit',
|
||||
]))->value(empty($format['lineslimit']) ? '' : $format['lineslimit'])->size(4)->maxlength(5),
|
||||
]))->value(empty($format['lineslimit']) ? '' : $format['lineslimit'])->size(4)->maxlenght(5),
|
||||
]),
|
||||
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
|
||||
]),
|
||||
@ -215,7 +212,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][linestitletext]',
|
||||
'fac_formats_' . $uid . '_linestitletext',
|
||||
]))->value(empty($format['linestitletext']) ? '' : $format['linestitletext'])->size(20)->maxlength(255)->class('maximal'),
|
||||
]))->value(empty($format['linestitletext']) ? '' : $format['linestitletext'])->size(20)->maxlenght(255)->class('maximal'),
|
||||
]),
|
||||
(new Note())->text(
|
||||
__('Format can be:') .
|
||||
@ -231,7 +228,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][linestitleover]',
|
||||
'fac_formats_' . $uid . '_linestitleover',
|
||||
]))->value(empty($format['linestitleover']) ? '' : $format['linestitleover'])->size(20)->maxlength(255)->class('maximal'),
|
||||
]))->value(empty($format['linestitleover']) ? '' : $format['linestitleover'])->size(20)->maxlenght(255)->class('maximal'),
|
||||
]),
|
||||
(new Note())->text(
|
||||
__('Format can be:') .
|
||||
@ -247,7 +244,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][linestitlelength]',
|
||||
'fac_formats_' . $uid . '_linestitlelength',
|
||||
]))->value(empty($format['linestitlelength']) ? '' : $format['linestitlelength'])->size(4)->maxlength(5),
|
||||
]))->value(empty($format['linestitlelength']) ? '' : $format['linestitlelength'])->size(4)->maxlenght(5),
|
||||
]),
|
||||
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
|
||||
]),
|
||||
@ -275,7 +272,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][linesdescriptionlength]',
|
||||
'fac_formats_' . $uid . '_linesdescriptionlength',
|
||||
]))->value(empty($format['linesdescriptionlength']) ? '' : $format['linesdescriptionlength'])->size(4)->maxlength(5),
|
||||
]))->value(empty($format['linesdescriptionlength']) ? '' : $format['linesdescriptionlength'])->size(4)->maxlenght(5),
|
||||
]),
|
||||
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
|
||||
]),
|
||||
@ -303,7 +300,7 @@ class Config extends Process
|
||||
(new Input([
|
||||
'fac_formats[' . $uid . '][linescontentlength]',
|
||||
'fac_formats_' . $uid . '_linescontentlength',
|
||||
]))->value(empty($format['linescontentlength']) ? '' : $format['linescontentlength'])->size(4)->maxlength(5),
|
||||
]))->value(empty($format['linescontentlength']) ? '' : $format['linescontentlength'])->size(4)->maxlenght(5),
|
||||
]),
|
||||
(new Note())->text(__('Leave lengh empty for no limit.'))->class('form-note'),
|
||||
]),
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -31,7 +32,7 @@ class Frontend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
App::behavior()->addBehavior('publicEntryAfterContent', function ($___, $_____): void {
|
||||
App::behavior()->addBehavior('publicEntryAfterContent', function ($___, Ctx $_ctx): void {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
@ -132,7 +133,7 @@ class Frontend extends Process
|
||||
$feeddesc = '';
|
||||
if (My::settings()->get('showfeeddesc')
|
||||
&& '' != $feed->description) {
|
||||
$feeddesc = '<p>' . App::frontend()->context()->global_filters(
|
||||
$feeddesc = '<p>' . $_ctx::global_filters(
|
||||
$feed->description,
|
||||
['encode_xml', 'remove_html']
|
||||
) . '</p>';
|
||||
@ -158,7 +159,7 @@ class Frontend extends Process
|
||||
$date = Date::dt2str($dateformat, $item->pubdate);
|
||||
|
||||
// Entries title
|
||||
$title = App::frontend()->context()->global_filters(
|
||||
$title = $_ctx::global_filters(
|
||||
str_replace(
|
||||
[
|
||||
'%D',
|
||||
@ -174,13 +175,13 @@ class Frontend extends Process
|
||||
$item->description,
|
||||
$item->content,
|
||||
],
|
||||
(string) $format['linestitletext']
|
||||
$format['linestitletext']
|
||||
),
|
||||
['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
|
||||
);
|
||||
|
||||
// Entries over title
|
||||
$overtitle = App::frontend()->context()->global_filters(
|
||||
$overtitle = $_ctx::global_filters(
|
||||
str_replace(
|
||||
[
|
||||
'%D',
|
||||
@ -196,7 +197,7 @@ class Frontend extends Process
|
||||
$item->description,
|
||||
$item->content,
|
||||
],
|
||||
(string) $format['linestitleover']
|
||||
$format['linestitleover']
|
||||
),
|
||||
['remove_html', 'cut_string' => 350],
|
||||
);
|
||||
@ -206,7 +207,7 @@ class Frontend extends Process
|
||||
if ($format['showlinesdescription']
|
||||
&& '' != $item->description) {
|
||||
$description = '<dd>' .
|
||||
App::frontend()->context()->global_filters(
|
||||
$_ctx::global_filters(
|
||||
$item->description,
|
||||
['remove_html' => (int) $format['linesdescriptionnohtml'], 'cut_string' => abs((int) $format['linesdescriptionlength'])]
|
||||
) . '</dd>';
|
||||
@ -217,7 +218,7 @@ class Frontend extends Process
|
||||
if ($format['showlinescontent']
|
||||
&& '' != $item->content) {
|
||||
$content = '<dd>' .
|
||||
App::frontend()->context()->global_filters(
|
||||
$_ctx::global_filters(
|
||||
$item->content,
|
||||
['remove_html' => (int) $format['linescontentnohtml'], 'cut_string' => abs((int) $format['linescontentlength'])]
|
||||
) . '</dd>';
|
||||
|
@ -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 . ' ' .
|
||||
|
Loading…
Reference in New Issue
Block a user