release 0.10

This commit is contained in:
Jean-Christian Paul Denis 2022-11-20 21:13:56 +01:00
parent b4485bebd0
commit 807214f658
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
10 changed files with 327 additions and 318 deletions

View File

@ -1,5 +1,5 @@
0.9.3 0.10 2022.11.20
- [ ] ? - fix compatibility with Dotclear 2.24 (required)
0.9.2 - 2021.09.02 0.9.2 - 2021.09.02
- update license bloc to phpdoc - update license bloc to phpdoc

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/fac)](https://github.com/JcDenis/fac/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/fac)](https://github.com/JcDenis/fac/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/fac)](https://github.com/JcDenis/fac/releases) [![Date](https://img.shields.io/github/release-date/JcDenis/fac)](https://github.com/JcDenis/fac/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/fac)](https://github.com/JcDenis/fac/issues) [![Issues](https://img.shields.io/github/issues/JcDenis/fac)](https://github.com/JcDenis/fac/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-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/fac) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/fac)
[![License](https://img.shields.io/github/license/JcDenis/fac)](https://github.com/JcDenis/fac/blob/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/fac)](https://github.com/JcDenis/fac/blob/master/LICENSE)
@ -22,7 +22,7 @@ to link en extenal feed to the bottom of an entry.
* superadmin to configure feeds formats * superadmin to configure feeds formats
* admin permissions to configure plugin * admin permissions to configure plugin
* usage,contentadmin permissions to link feeds * usage,contentadmin permissions to link feeds
* Dotclear 2.19 * Dotclear 2.24
* A theme that contents behavior publicEntryAfterContent * A theme that contents behavior publicEntryAfterContent
## USAGE ## USAGE
@ -39,8 +39,14 @@ to link a feed to this post.
You can also add or remove feed to multiple post from posts actions page. You can also add or remove feed to multiple post from posts actions page.
This plugins also supports pages from plugin "muppet". This plugins also supports pages from plugin "muppet".
## MORE ## LINKS
* License : GNU GPL v2 * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/fac) * Source & contribution : [GitHub Page](https://github.com/JcDenis/fac)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/fac) * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/fac)
## CONTRIBUTORS
* Jean-Christian Denis
You are welcome to contribute to this code.

View File

@ -1,31 +1,30 @@
<?php <?php
/** /**
* @brief fac, a plugin for Dotclear 2 * @brief fac, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * @author Jean-Christian Denis and Contributors
* *
* @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
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$core->blog->settings->addNamespace('fac'); dcCore::app()->blog->settings->addNamespace('fac');
# Admin behaviors # Admin behaviors
$core->addBehavior('adminBlogPreferencesForm', ['facAdmin', 'adminBlogPreferencesForm']); dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['facAdmin', 'adminBlogPreferencesForm']);
$core->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']); dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']);
$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']); dcCore::app()->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']); dcCore::app()->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']); dcCore::app()->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']); dcCore::app()->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']); dcCore::app()->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
$core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']); dcCore::app()->addBehavior('adminPostsActions', ['facAdmin', 'adminPostsActionsPage']);
/** /**
* @ingroup DC_PLUGIN_FAC * @ingroup DC_PLUGIN_FAC
@ -36,67 +35,66 @@ class facAdmin
{ {
/** /**
* Get combos of types of supported public pages * Get combos of types of supported public pages
* *
* @param dcCore $core dcCore instance
* @return array List of post type and name * @return array List of post type and name
*/ */
public static function getPostsTypes(dcCore $core) public static function getPostsTypes()
{ {
$types = [ $types = [
__('home page') => 'default', __('home page') => 'default',
__('post pages') => 'post', __('post pages') => 'post',
__('tags pages') => 'tag', __('tags pages') => 'tag',
__('archives pages') => 'archive', __('archives pages') => 'archive',
__('category pages') => 'category', __('category pages') => 'category',
__('entries feed') => 'feed' __('entries feed') => 'feed',
]; ];
if ($core->plugins->moduleExists('muppet')) { if (dcCore::app()->plugins->moduleExists('muppet')) {
foreach(muppet::getPostTypes() as $k => $v) { foreach (muppet::getPostTypes() as $k => $v) {
$types[sprintf( $types[sprintf(
__('"%s" pages from extension muppet'), __('"%s" pages from extension muppet'),
$v['name'] $v['name']
)] = $k; )] = $k;
} }
} }
return $types; return $types;
} }
/** /**
* Add settings to blog preference * Add settings to blog preference
* *
* @param dcCore $core dcCore instance
* @param dcSettings $blog_settings dcSettings instance * @param dcSettings $blog_settings dcSettings instance
*/ */
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings) public static function adminBlogPreferencesForm(dcSettings $blog_settings)
{ {
echo echo
'<div class="fieldset"><h4 id="fac_params">Feed after content</h4>' . '<div class="fieldset"><h4 id="fac_params">Feed after content</h4>' .
'<p class="form-note">' . '<p class="form-note">' .
__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') . __('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') .
'</p>'; '</p>';
if ($core->auth->isSuperAdmin()) { if (dcCore::app()->auth->isSuperAdmin()) {
echo '<p><a href="' . $core->adminurl->get('admin.plugins', [ echo '<p><a href="' . dcCore::app()->adminurl->get('admin.plugins', [
'module' => 'fac', 'module' => 'fac',
'conf' => 1, 'conf' => 1,
'redir' => $core->adminurl->get('admin.blog.pref') . '#fac_params' 'redir' => dcCore::app()->adminurl->get('admin.blog.pref') . '#fac_params',
]) . '">' . __('Configure formats') . '</a></p>'; ]) . '">' . __('Configure formats') . '</a></p>';
} }
echo echo
'<div class="two-cols">' . '<div class="two-cols">' .
'<div class="col">' . '<div class="col">' .
'<h5>' . __('Activation') . '</h5>' . '<h5>' . __('Activation') . '</h5>' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox('fac_active', '1', (boolean) $blog_settings->fac->fac_active) . form::checkbox('fac_active', '1', (bool) $blog_settings->fac->fac_active) .
__('Enable "fac" extension') . '</label></p>' . __('Enable "fac" extension') . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__("You can manage related feed to display for each post with a predefined format.") . __('You can manage related feed to display for each post with a predefined format.') .
'</p>' . '</p>' .
'<h5>' . __('Feed') . '</h5>' . '<h5>' . __('Feed') . '</h5>' .
'<p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' . '<p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' .
form::field('fac_defaultfeedtitle', 65, 255, (string) $blog_settings->fac->fac_defaultfeedtitle) . '</p>' . form::field('fac_defaultfeedtitle', 65, 255, (string) $blog_settings->fac->fac_defaultfeedtitle) . '</p>' .
'<p class="form-note">' . __('Use %T to insert title of feed.') . '</p>' . '<p class="form-note">' . __('Use %T to insert title of feed.') . '</p>' .
'<p><label class="classic" for="fac_showfeeddesc">' . '<p><label class="classic" for="fac_showfeeddesc">' .
form::checkbox('fac_showfeeddesc', 1, (boolean) $blog_settings->fac->fac_showfeeddesc) . form::checkbox('fac_showfeeddesc', 1, (bool) $blog_settings->fac->fac_showfeeddesc) .
__('Show description of feed') . '</label></p>' . __('Show description of feed') . '</label></p>' .
'</div>' . '</div>' .
'<div class="col">' . '<div class="col">' .
@ -106,7 +104,7 @@ class facAdmin
if (!is_array($fac_public_tpltypes)) { if (!is_array($fac_public_tpltypes)) {
$fac_public_tpltypes = []; $fac_public_tpltypes = [];
} }
foreach(self::getPostsTypes($core) as $k => $v) { foreach (self::getPostsTypes() as $k => $v) {
echo ' echo '
<p><label class="classic" for="fac_public_tpltypes' . $k . '">' . <p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox( form::checkbox(
@ -116,16 +114,16 @@ class facAdmin
) . __($k) . '</label></p>'; ) . __($k) . '</label></p>';
} }
echo echo
'</div>' . '</div>' .
'</div>' . '</div>' .
'<br class="clear" />' . '<br class="clear" />' .
'</div>'; '</div>';
} }
/** /**
* Save blog settings * Save blog settings
* *
* @param dcSettings $blog_settings dcSettings instance * @param dcSettings $blog_settings dcSettings instance
*/ */
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings) public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings)
@ -138,7 +136,7 @@ class facAdmin
/** /**
* Add javascript (toggle) * Add javascript (toggle)
* *
* @return string HTML head * @return string HTML head
*/ */
public static function adminPostHeaders() public static function adminPostHeaders()
@ -148,84 +146,77 @@ class facAdmin
/** /**
* Add form to post sidebar * Add form to post sidebar
* *
* @param ArrayObject $main_items Main items * @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items * @param ArrayObject $sidebar_items Sidebar items
* @param record $post Post record or null * @param record $post Post record or null
*/ */
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post) public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{ {
global $core; if (!dcCore::app()->blog->settings->fac->fac_active) {
if (!$core->blog->settings->fac->fac_active) {
return null; return null;
} }
# Get existing linked feed # Get existing linked feed
$fac_url = $fac_format = ''; $fac_url = $fac_format = '';
if ($post) { if ($post) {
$rs = dcCore::app()->meta->getMetadata([
$rs = $core->meta->getMetadata([
'meta_type' => 'fac', 'meta_type' => 'fac',
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'limit' => 1 'limit' => 1,
]); ]);
$fac_url = $rs->isEmpty() ? '' : $rs->meta_id; $fac_url = $rs->isEmpty() ? '' : $rs->meta_id;
$rs = $core->meta->getMetadata([ $rs = dcCore::app()->meta->getMetadata([
'meta_type' => 'facformat', 'meta_type' => 'facformat',
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'limit' => 1 'limit' => 1,
]); ]);
$fac_format = $rs->isEmpty() ? '' : $rs->meta_id; $fac_format = $rs->isEmpty() ? '' : $rs->meta_id;
} }
# Set linked feed form items # Set linked feed form items
$sidebar_items['options-box']['items']['fac'] = $sidebar_items['options-box']['items']['fac'] = self::formFeed($fac_url, $fac_format);
self::formFeed($core, $fac_url, $fac_format);
} }
/** /**
* Save linked feed * Save linked feed
* *
* @param cursor $cur Current post cursor * @param cursor $cur Current post cursor
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
public static function adminAfterPostSave(cursor $cur, $post_id) public static function adminAfterPostSave(cursor $cur, $post_id)
{ {
global $core; if (!isset($_POST['fac_url'])
if (!isset($_POST['fac_url'])
|| !isset($_POST['fac_format'])) { || !isset($_POST['fac_format'])) {
return null; return null;
} }
# Delete old linked feed # Delete old linked feed
self::delFeed($core, $post_id); self::delFeed($post_id);
# Add new linked feed # Add new linked feed
self::addFeed($core, $post_id, $_POST); self::addFeed($post_id, $_POST);
} }
/** /**
* Delete linked feed on post edition * Delete linked feed on post edition
* *
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
public static function adminBeforePostDelete($post_id) public static function adminBeforePostDelete($post_id)
{ {
self::delFeed($GLOBALS['core'], $post_id); self::delFeed($post_id);
} }
/** /**
* Add actions to posts page combo * Add actions to posts page combo
* *
* @param dcCore $core dcCore instance * @param dcPostsActions $pa dcPostsActionsPage instance
* @param dcPostsActionsPage $ap dcPostsActionsPage instance
*/ */
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) public static function adminPostsActionsPage(dcPostsActions $pa)
{ {
if (!$core->blog->settings->fac->fac_active) { if (!dcCore::app()->blog->settings->fac->fac_active) {
return null; return null;
} }
@ -234,7 +225,10 @@ class facAdmin
['facAdmin', 'callbackAdd'] ['facAdmin', 'callbackAdd']
); );
if (!$core->auth->check('delete,contentadmin', $core->blog->id)) { if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_DELETE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)) {
return null; return null;
} }
$pa->addAction( $pa->addAction(
@ -245,12 +239,11 @@ class facAdmin
/** /**
* Posts actions callback to remove linked feed * Posts actions callback to remove linked feed
* *
* @param dcCore $core dcCore instance * @param dcPostsActions $pa dcPostsActions instance
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
* @param ArrayObject $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) public static function callbackRemove(dcPostsActions $pa, ArrayObject $post)
{ {
# No entry # No entry
$posts_ids = $pa->getIDs(); $posts_ids = $pa->getIDs();
@ -259,13 +252,16 @@ class facAdmin
} }
# No right # No right
if (!$core->auth->check('delete,contentadmin',$core->blog->id)) { if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_DELETE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)) {
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
# Delete unused feed # Delete unused feed
foreach($posts_ids as $post_id) { foreach ($posts_ids as $post_id) {
self::delFeed($core, $post_id); self::delFeed($post_id);
} }
dcPage::addSuccessNotice(__('Linked feed deleted.')); dcPage::addSuccessNotice(__('Linked feed deleted.'));
@ -274,14 +270,13 @@ class facAdmin
/** /**
* Posts actions callback to add linked feed * Posts actions callback to add linked feed
* *
* @param dcCore $core dcCore instance * @param dcPostsActions $pa dcPostsActions instance
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
* @param ArrayObject $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) public static function callbackAdd(dcPostsActions $pa, ArrayObject $post)
{ {
# No entry # No entry
$posts_ids = $pa->getIDs(); $posts_ids = $pa->getIDs();
if (empty($posts_ids)) { if (empty($posts_ids)) {
throw new Exception(__('No entry selected')); throw new Exception(__('No entry selected'));
@ -290,9 +285,9 @@ class facAdmin
# Save action # Save action
if (!empty($post['fac_url']) if (!empty($post['fac_url'])
&& !empty($post['fac_format'])) { && !empty($post['fac_format'])) {
foreach($posts_ids as $post_id) { foreach ($posts_ids as $post_id) {
self::delFeed($core, $post_id); self::delFeed($post_id);
self::addFeed($core, $post_id, $post); self::addFeed($post_id, $post);
} }
dcPage::addSuccessNotice(__('Linked feed added.')); dcPage::addSuccessNotice(__('Linked feed added.'));
@ -302,9 +297,9 @@ class facAdmin
} else { } else {
$pa->beginPage( $pa->beginPage(
dcPage::breadcrumb([ dcPage::breadcrumb([
html::escapeHTML($core->blog->name) => '', html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true), $pa->getCallerTitle() => $pa->getRedirection(true),
__('Linked feed to this selection') => '' __('Linked feed to this selection') => '',
]) ])
); );
@ -312,10 +307,10 @@ class facAdmin
'<form action="' . $pa->getURI() . '" method="post">' . '<form action="' . $pa->getURI() . '" method="post">' .
$pa->getCheckboxes() . $pa->getCheckboxes() .
self::formFeed($core) . self::formFeed() .
'<p>' . '<p>' .
$core->formNonce() . dcCore::app()->formNonce() .
$pa->getHiddenFields() . $pa->getHiddenFields() .
form::hidden(['action'], 'fac_add') . form::hidden(['action'], 'fac_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' . '<input type="submit" value="' . __('Save') . '" /></p>' .
@ -327,20 +322,19 @@ class facAdmin
/** /**
* Linked feed form field * Linked feed form field
* *
* @param dcCore $core dcCore instance
* @param string $url Feed URL * @param string $url Feed URL
* @param string $format Feed format * @param string $format Feed format
* @return string Feed form content * @return null|string Feed form content
*/ */
protected static function formFeed(dcCore $core, $url = '', $format = '') protected static function formFeed($url = '', $format = '')
{ {
if (!$core->blog->settings->fac->fac_active) { if (!dcCore::app()->blog->settings->fac->fac_active) {
return null; return null;
} }
return return
'<div id="fac">' . '<div id="fac">' .
'<h5>' . __('Linked feed') . '</h5>' . '<h5>' . __('Linked feed') . '</h5>' .
'<p><label for="fac_url">' . '<p><label for="fac_url">' .
__('Feed URL:') . '</label>' . __('Feed URL:') . '</label>' .
@ -355,7 +349,7 @@ class facAdmin
__('Format:') . '</label>' . __('Format:') . '</label>' .
form::combo( form::combo(
'fac_format', 'fac_format',
self::comboFac($core), self::comboFac(),
$format, $format,
'maximal' 'maximal'
) . '</p>' . ) . '</p>' .
@ -365,19 +359,18 @@ class facAdmin
/** /**
* List of fac formats * List of fac formats
* *
* @param dcCore $core dcCore instance
* @return array List of fac formats * @return array List of fac formats
*/ */
protected static function comboFac(dcCore $core) protected static function comboFac()
{ {
$formats = @unserialize($core->blog->settings->fac->fac_formats); $formats = @unserialize(dcCore::app()->blog->settings->fac->fac_formats);
if (!is_array($formats) || empty($formats)) { if (!is_array($formats) || empty($formats)) {
return []; return [];
} }
$res = []; $res = [];
foreach($formats as $uid => $f) { foreach ($formats as $uid => $f) {
$res[$f['name']] = $uid; $res[$f['name']] = $uid;
} }
@ -386,42 +379,40 @@ class facAdmin
/** /**
* Delete linked feed * Delete linked feed
* *
* @param dcCore $core dcCore instance
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
protected static function delFeed(dcCore $core, $post_id) protected static function delFeed($post_id)
{ {
$post_id = (integer) $post_id; $post_id = (int) $post_id;
$core->meta->delPostMeta($post_id, 'fac'); dcCore::app()->meta->delPostMeta($post_id, 'fac');
$core->meta->delPostMeta($post_id, 'facformat'); dcCore::app()->meta->delPostMeta($post_id, 'facformat');
} }
/** /**
* Add linked feed * Add linked feed
* *
* @param dcCore $core dcCore instance
* @param integer $post_id Post id * @param integer $post_id Post id
* @param array $options Feed options * @param array|ArrayObject $options Feed options
*/ */
protected static function addFeed($core, $post_id, $options) protected static function addFeed($post_id, $options)
{ {
if (empty($options['fac_url']) if (empty($options['fac_url'])
|| empty($options['fac_format'])) { || empty($options['fac_format'])) {
return null; return null;
} }
$post_id = (integer) $post_id; $post_id = (int) $post_id;
$core->meta->setPostMeta( dcCore::app()->meta->setPostMeta(
$post_id, $post_id,
'fac', 'fac',
$options['fac_url'] $options['fac_url']
); );
$core->meta->setPostMeta( dcCore::app()->meta->setPostMeta(
$post_id, $post_id,
'facformat', 'facformat',
$options['fac_format'] $options['fac_format']
); );
} }
} }

View File

@ -1,30 +1,29 @@
<?php <?php
/** /**
* @brief fac, a plugin for Dotclear 2 * @brief fac, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * @author Jean-Christian Denis and Contributors
* *
* @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
*/ */
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
if (!$core->auth->isSuperAdmin()) { if (!dcCore::app()->auth->isSuperAdmin()) {
return null; return null;
} }
$redir = empty($_REQUEST['redir']) ? $redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir']; dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
$core->blog->settings->addNamespace('fac'); dcCore::app()->blog->settings->addNamespace('fac');
$s = $core->blog->settings->fac; $s = dcCore::app()->blog->settings->fac;
$fac_formats = @unserialize($s->fac_formats); $fac_formats = @unserialize($s->fac_formats);
@ -37,7 +36,7 @@ if (!empty($_POST['save'])) {
try { try {
$fac_formats = []; $fac_formats = [];
foreach($_POST['fac_formats'] as $uid => $f) { foreach ($_POST['fac_formats'] as $uid => $f) {
if (!empty($f['name'])) { if (!empty($f['name'])) {
$fac_formats[$uid] = $f; $fac_formats[$uid] = $f;
} }
@ -46,31 +45,31 @@ if (!empty($_POST['save'])) {
// fix 2021.08.21 : formats are now global // fix 2021.08.21 : formats are now global
$s->drop('fac_formats'); $s->drop('fac_formats');
$s->put( $s->put(
'fac_formats', 'fac_formats',
serialize($fac_formats), serialize($fac_formats),
'string', 'string',
'Formats of feeds contents', 'Formats of feeds contents',
true, true,
true true
); );
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice( dcAdminNotices::addSuccessNotice(
__('Configuration successfully updated.') __('Configuration successfully updated.')
); );
http::redirect( http::redirect(
$list->getURL('module=fac&conf=1&redir=' . $list->getRedir()) dcCore::app()->admin->list->getURL('module=fac&conf=1&redir=' . dcCore::app()->admin->list->getRedir())
); );
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
} }
# -- Display form -- # -- Display form --
$i = 1; $i = 1;
foreach($fac_formats as $uid => $f) { foreach ($fac_formats as $uid => $f) {
if (empty($f['name'])) { if (empty($f['name'])) {
continue; continue;
} }
@ -86,7 +85,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][name]', 'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name' 'fac_formats_' . $uid . '_name',
], ],
20, 20,
255, 255,
@ -102,7 +101,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][dateformat]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat' 'fac_formats_' . $uid . '_dateformat',
], ],
20, 20,
255, 255,
@ -118,7 +117,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][lineslimit]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit' 'fac_formats_' . $uid . '_lineslimit',
], ],
5, 5,
4, 4,
@ -136,7 +135,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitletext]', 'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext' 'fac_formats_' . $uid . '_linestitletext',
], ],
20, 20,
255, 255,
@ -157,7 +156,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitleover]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover' 'fac_formats_' . $uid . '_linestitleover',
], ],
20, 20,
255, 255,
@ -178,7 +177,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitlelength]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength' 'fac_formats_' . $uid . '_linestitlelength',
], ],
5, 5,
4, 4,
@ -195,7 +194,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][showlinesdescription]', 'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription' 'fac_formats_' . $uid . '_showlinesdescription',
], ],
1, 1,
!empty($f['showlinesdescription']) !empty($f['showlinesdescription'])
@ -206,11 +205,11 @@ foreach($fac_formats as $uid => $f) {
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][linesdescriptionnohtml]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml' 'fac_formats_' . $uid . '_linesdescriptionnohtml',
], ],
1, 1,
!empty($f['linesdescriptionnohtml']) !empty($f['linesdescriptionnohtml'])
). ) .
__('Remove html of description') . '</label></p> __('Remove html of description') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' . <p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
@ -218,7 +217,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linesdescriptionlength]', 'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength' 'fac_formats_' . $uid . '_linesdescriptionlength',
], ],
5, 5,
4, 4,
@ -235,7 +234,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][showlinescontent]', 'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent' 'fac_formats_' . $uid . '_showlinescontent',
], ],
1, 1,
!empty($f['showlinescontent']) !empty($f['showlinescontent'])
@ -246,7 +245,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][linescontentnohtml]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml' 'fac_formats_' . $uid . '_linescontentnohtml',
], ],
1, 1,
!empty($f['linescontentnohtml']) !empty($f['linescontentnohtml'])
@ -258,7 +257,7 @@ foreach($fac_formats as $uid => $f) {
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linescontentlength]', 'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength' 'fac_formats_' . $uid . '_linescontentlength',
], ],
5, 5,
4, 4,
@ -288,14 +287,14 @@ __('Name:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][name]', 'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name' 'fac_formats_' . $uid . '_name',
], ],
20, 20,
255, 255,
'', '',
'maximal' 'maximal'
) . '</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('In order to remove a format, leave its name empty.') . __('In order to remove a format, leave its name empty.') .
'</p> '</p>
@ -304,7 +303,7 @@ __('Date format:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][dateformat]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat' 'fac_formats_' . $uid . '_dateformat',
], ],
20, 20,
255, 255,
@ -320,7 +319,7 @@ __('Entries limit:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][lineslimit]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit' 'fac_formats_' . $uid . '_lineslimit',
], ],
5, 5,
4, 4,
@ -338,7 +337,7 @@ __('Title format:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitletext]', 'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext' 'fac_formats_' . $uid . '_linestitletext',
], ],
20, 20,
255, 255,
@ -355,11 +354,11 @@ __('Format can be:') .
'</p> '</p>
<p><label for="fac_formats_' . $uid . '_linestitleover">' . <p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:') . '</label>' . __('Over title format:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitleover]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover' 'fac_formats_' . $uid . '_linestitleover',
], ],
20, 20,
255, 255,
@ -380,14 +379,14 @@ __('Maximum length of title:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linestitlelength]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength' 'fac_formats_' . $uid . '_linestitlelength',
], ],
5, 5,
4, 4,
150, 150,
'maximal' 'maximal'
) . '</p> ) . '</p>
<p class="form-note">' . <p class="form-note">' .
__('Leave lengh empty for no limit.') . __('Leave lengh empty for no limit.') .
'</p> '</p>
@ -397,7 +396,7 @@ __('Leave lengh empty for no limit.') .
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][showlinesdescription]', 'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription' 'fac_formats_' . $uid . '_showlinesdescription',
], ],
1, 1,
0 0
@ -408,7 +407,7 @@ __('Show description of entries') . '</label></p>
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][linesdescriptionnohtml]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml' 'fac_formats_' . $uid . '_linesdescriptionnohtml',
], ],
1, 1,
1 1
@ -420,7 +419,7 @@ __('Maximum length of description:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linesdescriptionlength]', 'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength' 'fac_formats_' . $uid . '_linesdescriptionlength',
], ],
5, 5,
4, 4,
@ -437,7 +436,7 @@ __('Leave lengh empty for no limit.') .
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][showlinescontent]', 'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent' 'fac_formats_' . $uid . '_showlinescontent',
], ],
1, 1,
0 0
@ -448,7 +447,7 @@ __('Show content of entries') . '</label></p>
form::checkbox( form::checkbox(
[ [
'fac_formats[' . $uid . '][linescontentnohtml]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml' 'fac_formats_' . $uid . '_linescontentnohtml',
], ],
1, 1,
1 1
@ -460,7 +459,7 @@ __('Maximum length of content:') . '</label>' .
form::field( form::field(
[ [
'fac_formats[' . $uid . '][linescontentlength]', 'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength' 'fac_formats_' . $uid . '_linescontentlength',
], ],
5, 5,
4, 4,
@ -504,4 +503,4 @@ __('To add feed to an entry edit this entry and put in sidebar the url of the fe
</div>'; </div>';
dcPage::helpBlock('fac'); dcPage::helpBlock('fac');

View File

@ -1,16 +1,15 @@
<?php <?php
/** /**
* @brief fac, a plugin for Dotclear 2 * @brief fac, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * @author Jean-Christian Denis and Contributors
* *
* @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
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -19,16 +18,19 @@ $this->registerModule(
'Feed after content', 'Feed after content',
'Add RSS/Atom feeds after entries content', 'Add RSS/Atom feeds after entries content',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'0.9.3', '0.10',
[ [
'requires' => [['core', '2.19']], 'requires' => [['core', '2.24']],
'permissions' => 'usage,contentadmin', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcAuth::PERMISSION_USAGE,
'support' => 'https://github.com/JcDenis/fac', dcAuth::PERMISSION_CONTENT_ADMIN,
'details' => 'https://plugins.dotaddict.org/dc2/details/fac', ]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/fac',
'details' => 'https://plugins.dotaddict.org/dc2/details/fac',
'repository' => 'https://raw.githubusercontent.com/JcDenis/fac/master/repository.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/fac/master/repository.xml',
'settings' => [ 'settings' => [
'blog' => '#params.fac_params' 'blog' => '#params.fac_params',
] ],
] ]
); );

View File

@ -1,117 +1,126 @@
<?php <?php
/** /**
* @brief fac, a plugin for Dotclear 2 * @brief fac, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * @author Jean-Christian Denis and Contributors
* *
* @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
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
# -- Module specs -- # -- Module specs --
$dc_min = '2.19'; $dc_min = '2.24';
$mod_id = 'fac'; $mod_id = 'fac';
$mod_conf = [ $mod_conf = [
[ [
'fac_active', 'fac_active',
'Enabled fac plugin', 'Enabled fac plugin',
false, false,
'boolean' 'boolean',
], ],
[ [
'fac_public_tpltypes', 'fac_public_tpltypes',
'List of templates types which used fac', 'List of templates types which used fac',
serialize(['post', 'tag', 'archive']), serialize(['post', 'tag', 'archive']),
'string' 'string',
], ],
[ [
'fac_formats', 'fac_formats',
'Formats of feeds contents', 'Formats of feeds contents',
serialize([ serialize([
uniqid() => [ uniqid() => [
'name' => 'default', 'name' => 'default',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '5', 'lineslimit' => '5',
'linestitletext' => '%T', 'linestitletext' => '%T',
'linestitleover' => '%D', 'linestitleover' => '%D',
'linestitlelength' => '150', 'linestitlelength' => '150',
'showlinesdescription' => '0', 'showlinesdescription' => '0',
'linesdescriptionlength' => '350', 'linesdescriptionlength' => '350',
'linesdescriptionnohtml' => '1', 'linesdescriptionnohtml' => '1',
'showlinescontent' => '0', 'showlinescontent' => '0',
'linescontentlength' => '350', 'linescontentlength' => '350',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1',
], ],
uniqid() => [ uniqid() => [
'name' => 'full', 'name' => 'full',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '20', 'lineslimit' => '20',
'linestitletext' => '%T', 'linestitletext' => '%T',
'linestitleover' => '%D - %E', 'linestitleover' => '%D - %E',
'linestitlelength' => '', 'linestitlelength' => '',
'showlinesdescription' => '1', 'showlinesdescription' => '1',
'linesdescriptionlength' => '', 'linesdescriptionlength' => '',
'linesdescriptionnohtml' => '1', 'linesdescriptionnohtml' => '1',
'showlinescontent' => '1', 'showlinescontent' => '1',
'linescontentlength' => '', 'linescontentlength' => '',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1',
] ],
]), ]),
'string', 'string',
false, false,
true true,
], ],
[ [
'fac_defaultfeedtitle', 'fac_defaultfeedtitle',
'Default title of feed', 'Default title of feed',
'%T', '%T',
'string' 'string',
], ],
[ [
'fac_showfeeddesc', 'fac_showfeeddesc',
'Show description of feed', 'Show description of feed',
1, 1,
'boolean' 'boolean',
] ],
]; ];
# -- Nothing to change below -- # -- Nothing to change below --
try { try {
# Check module version # Check module version
if (version_compare( if (version_compare(
$core->getVersion($mod_id), dcCore::app()->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'), dcCore::app()->plugins->moduleInfo($mod_id, 'version'),
'>=')) { '>='
)) {
return null; return null;
} }
# Check Dotclear version # Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s',
$mod_id,
$dc_min
)); ));
} }
# Set module settings # Set module settings
$core->blog->settings->addNamespace($mod_id); dcCore::app()->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) { foreach ($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put( dcCore::app()->blog->settings->{$mod_id}->put(
$v[0], $v[2], $v[3], $v[1], false, true $v[0],
$v[2],
$v[3],
$v[1],
false,
true
); );
} }
# Set module version # Set module version
$core->setVersion( dcCore::app()->setVersion(
$mod_id, $mod_id,
$core->plugins->moduleInfo($mod_id, 'version') dcCore::app()->plugins->moduleInfo($mod_id, 'version')
); );
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
return false; return false;
} }

View File

@ -1,23 +1,22 @@
<?php <?php
/** /**
* @brief fac, a plugin for Dotclear 2 * @brief fac, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * @author Jean-Christian Denis and Contributors
* *
* @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
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$core->addBehavior( dcCore::app()->addBehavior(
'publicEntryAfterContent', 'publicEntryAfterContent',
array('facPublic', 'publicEntryAfterContent') ['facPublic', 'publicEntryAfterContent']
); );
/** /**
@ -29,64 +28,64 @@ class facPublic
{ {
/** /**
* Add feed after entry * Add feed after entry
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param context $_ctx context instance * @param context $_ctx context instance
*/ */
public static function publicEntryAfterContent(dcCore $core, context $_ctx) public static function publicEntryAfterContent(dcCore $core, context $_ctx)
{ {
$core->blog->settings->addNamespace('fac'); dcCore::app()->blog->settings->addNamespace('fac');
# Not active or not a post # Not active or not a post
if (!$core->blog->settings->fac->fac_active if (!dcCore::app()->blog->settings->fac->fac_active
|| !$_ctx->exists('posts')) { || !dcCore::app()->ctx->exists('posts')) {
return null; return null;
} }
# Not in page to show # Not in page to show
$types = @unserialize($core->blog->settings->fac->fac_public_tpltypes); $types = @unserialize((string) dcCore::app()->blog->settings->fac->fac_public_tpltypes);
if (!is_array($types) if (!is_array($types)
|| !in_array($core->url->type,$types)) { || !in_array(dcCore::app()->url->type, $types)) {
return null; return null;
} }
# Get related feed # Get related feed
$fac_url = $core->meta->getMetadata([ $fac_url = dcCore::app()->meta->getMetadata([
'meta_type' => 'fac', 'meta_type' => 'fac',
'post_id' => $_ctx->posts->post_id, 'post_id' => dcCore::app()->ctx->posts->post_id,
'limit' => 1 'limit' => 1,
]); ]);
if ($fac_url->isEmpty()) { if ($fac_url->isEmpty()) {
return null; return null;
} }
# Get related format # Get related format
$fac_format = $core->meta->getMetadata([ $fac_format = dcCore::app()->meta->getMetadata([
'meta_type' => 'facformat', 'meta_type' => 'facformat',
'post_id' => $_ctx->posts->post_id, 'post_id' => dcCore::app()->ctx->posts->post_id,
'limit' => 1 'limit' => 1,
]); ]);
if ($fac_format->isEmpty()) { if ($fac_format->isEmpty()) {
return null; return null;
} }
# Get format info # Get format info
$default_format = array( $default_format = [
'name' => 'default', 'name' => 'default',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '5', 'lineslimit' => '5',
'linestitletext' => '%T', 'linestitletext' => '%T',
'linestitleover' => '%D', 'linestitleover' => '%D',
'linestitlelength' => '150', 'linestitlelength' => '150',
'showlinesdescription' => '0', 'showlinesdescription' => '0',
'linesdescriptionlength' => '350', 'linesdescriptionlength' => '350',
'linesdescriptionnohtml' => '1', 'linesdescriptionnohtml' => '1',
'showlinescontent' => '0', 'showlinescontent' => '0',
'linescontentlength' => '350', 'linescontentlength' => '350',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1',
); ];
$formats = @unserialize($core->blog->settings->fac->fac_formats); $formats = @unserialize((string) dcCore::app()->blog->settings->fac->fac_formats);
if (empty($formats) if (empty($formats)
|| !is_array($formats) || !is_array($formats)
|| !isset($formats[$fac_format->meta_id])) { || !isset($formats[$fac_format->meta_id])) {
@ -100,6 +99,7 @@ class facPublic
# Read feed url # Read feed url
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null; $cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
try { try {
$feed = feedReader::quickParse($fac_url->meta_id, $cache); $feed = feedReader::quickParse($fac_url->meta_id, $cache);
} catch (Exception $e) { } catch (Exception $e) {
@ -113,91 +113,90 @@ class facPublic
# Feed title # Feed title
$feedtitle = ''; $feedtitle = '';
if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) { if ('' != dcCore::app()->blog->settings->fac->fac_defaultfeedtitle) {
$feedtitle = '<h3>' . html::escapeHTML(empty($feed->title) ? $feedtitle = '<h3>' . html::escapeHTML(
empty($feed->title) ?
str_replace( str_replace(
'%T', '%T',
__('a related feed'), __('a related feed'),
$core->blog->settings->fac->fac_defaultfeedtitle dcCore::app()->blog->settings->fac->fac_defaultfeedtitle
) : ) :
str_replace( str_replace(
'%T', '%T',
$feed->title, $feed->title,
$core->blog->settings->fac->fac_defaultfeedtitle dcCore::app()->blog->settings->fac->fac_defaultfeedtitle
) )
) . '</h3>'; ) . '</h3>';
} }
# Feed desc # Feed desc
$feeddesc = ''; $feeddesc = '';
if ($core->blog->settings->fac->fac_showfeeddesc if (dcCore::app()->blog->settings->fac->fac_showfeeddesc
&& '' != $feed->description) { && '' != $feed->description) {
$feeddesc = $feeddesc = '<p>' . context::global_filters(
'<p>' . context::global_filters( $feed->description,
$feed->description,
['encode_xml', 'remove_html'] ['encode_xml', 'remove_html']
) . '</p>'; ) . '</p>';
} }
# Date format # Date format
$dateformat = '' != $format['dateformat'] ? $dateformat = '' != $format['dateformat'] ?
$format['dateformat'] : $format['dateformat'] :
$core->blog->settings->system->date_format . ',' . $core->blog->settings->system->time_format; dcCore::app()->blog->settings->system->date_format . ',' . dcCore::app()->blog->settings->system->time_format;
# Enrties limit # Enrties limit
$entrieslimit = abs((integer) $format['lineslimit']); $entrieslimit = abs((int) $format['lineslimit']);
$uselimit = $entrieslimit > 0 ? true : false; $uselimit = $entrieslimit > 0 ? true : false;
echo echo
'<div class="post-fac">' . '<div class="post-fac">' .
$feedtitle . $feeddesc . $feedtitle . $feeddesc .
'<dl>'; '<dl>';
$i = 0; $i = 0;
foreach ($feed->items as $item) { foreach ($feed->items as $item) {
# Format date # Format date
$date = dt::dt2str($dateformat, $item->pubdate); $date = dt::dt2str($dateformat, $item->pubdate);
# Entries title # Entries title
$title = context::global_filters( $title = context::global_filters(
str_replace( str_replace(
array( [
'%D', '%D',
'%T', '%T',
'%A', '%A',
'%E', '%E',
'%C' '%C',
), ],
array( [
$date, $date,
$item->title, $item->title,
$item->creator, $item->creator,
$item->description, $item->description,
$item->content $item->content,
), ],
$format['linestitletext'] $format['linestitletext']
), ),
['remove_html', 'cut_string' => abs((integer) $format['linestitlelength'])], ['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
); );
# Entries over title # Entries over title
$overtitle = context::global_filters( $overtitle = context::global_filters(
str_replace( str_replace(
array( [
'%D', '%D',
'%T', '%T',
'%A', '%A',
'%E', '%E',
'%C' '%C',
), ],
array( [
$date, $date,
$item->title, $item->title,
$item->creator, $item->creator,
$item->description, $item->description,
$item->content $item->content,
), ],
$format['linestitleover'] $format['linestitleover']
), ),
['remove_html', 'cut_string' => 350], ['remove_html', 'cut_string' => 350],
@ -205,23 +204,23 @@ class facPublic
# Entries description # Entries description
$description = ''; $description = '';
if ($format['showlinesdescription'] if ($format['showlinesdescription']
&& '' != $item->description) { && '' != $item->description) {
$description = '<dd>' . $description = '<dd>' .
context::global_filters( context::global_filters(
$item->description, $item->description,
['remove_html' => (integer) $format['linesdescriptionnohtml'], 'cut_string' => abs((integer) $format['linesdescriptionlength'])] ['remove_html' => (int) $format['linesdescriptionnohtml'], 'cut_string' => abs((int) $format['linesdescriptionlength'])]
) . '</dd>'; ) . '</dd>';
} }
# Entries content # Entries content
$content = ''; $content = '';
if ($format['showlinescontent'] if ($format['showlinescontent']
&& '' != $item->content) { && '' != $item->content) {
$content = '<dd>'. $content = '<dd>' .
context::global_filters( context::global_filters(
$item->content, $item->content,
['remove_html' => (integer) $format['linescontentnohtml'], 'cut_string' => abs((integer) $format['linescontentlength'])] ['remove_html' => (int) $format['linescontentnohtml'], 'cut_string' => abs((int) $format['linescontentlength'])]
) . '</dd>'; ) . '</dd>';
} }
@ -237,4 +236,4 @@ class facPublic
} }
echo '</dl></div>'; echo '</dl></div>';
} }
} }

View File

@ -1,12 +1,13 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="fac"> <module id="fac">
<name>Feed after content</name> <name>Feed after content</name>
<version>0.9.2</version> <version>0.10</version>
<author>Jean-Christian Denis and Contributors</author> <author>Jean-Christian Denis and Contributors</author>
<desc>Add RSS/Atom feeds after entries content</desc> <desc>Add RSS/Atom feeds after entries content</desc>
<file>https://github.com/JcDenis/fac/releases/download/v0.9.2/plugin-fac.zip</file> <file>https://github.com/JcDenis/fac/releases/download/v0.10/plugin-fac.zip</file>
<da:dcmin>2.19</da:dcmin> <da:dcmin>2.24</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/fac</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/fac</da:details>
<da:support>https://github.com/JcDenis/fac</da:support> <da:support>https://github.com/JcDenis/fac</da:support>
</module> </module>
</modules> </modules>

View File

@ -1,10 +1,11 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- # -- BEGIN LICENSE BLOCK ----------------------------------
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -15,4 +16,4 @@ if (!defined('DC_RC_PATH')) {
return; return;
} }
$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html'; dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';

View File

@ -1,10 +1,11 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- # -- BEGIN LICENSE BLOCK ----------------------------------
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -15,4 +16,4 @@ if (!defined('DC_RC_PATH')) {
return; return;
} }
$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html'; dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';