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
- 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)
[![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)
[![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)
[![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
* admin permissions to configure plugin
* usage,contentadmin permissions to link feeds
* Dotclear 2.19
* Dotclear 2.24
* A theme that contents behavior publicEntryAfterContent
## 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.
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)
* 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

@ -10,22 +10,21 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$core->blog->settings->addNamespace('fac');
dcCore::app()->blog->settings->addNamespace('fac');
# Admin behaviors
$core->addBehavior('adminBlogPreferencesForm', ['facAdmin', 'adminBlogPreferencesForm']);
$core->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']);
$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
$core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']);
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['facAdmin', 'adminBlogPreferencesForm']);
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']);
dcCore::app()->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
dcCore::app()->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
dcCore::app()->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
dcCore::app()->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
dcCore::app()->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
dcCore::app()->addBehavior('adminPostsActions', ['facAdmin', 'adminPostsActionsPage']);
/**
* @ingroup DC_PLUGIN_FAC
@ -37,10 +36,9 @@ class facAdmin
/**
* Get combos of types of supported public pages
*
* @param dcCore $core dcCore instance
* @return array List of post type and name
*/
public static function getPostsTypes(dcCore $core)
public static function getPostsTypes()
{
$types = [
__('home page') => 'default',
@ -48,9 +46,9 @@ class facAdmin
__('tags pages') => 'tag',
__('archives pages') => 'archive',
__('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) {
$types[sprintf(
__('"%s" pages from extension muppet'),
@ -58,27 +56,27 @@ class facAdmin
)] = $k;
}
}
return $types;
}
/**
* Add settings to blog preference
*
* @param dcCore $core dcCore instance
* @param dcSettings $blog_settings dcSettings instance
*/
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
public static function adminBlogPreferencesForm(dcSettings $blog_settings)
{
echo
'<div class="fieldset"><h4 id="fac_params">Feed after content</h4>' .
'<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.') .
'</p>';
if ($core->auth->isSuperAdmin()) {
echo '<p><a href="' . $core->adminurl->get('admin.plugins', [
if (dcCore::app()->auth->isSuperAdmin()) {
echo '<p><a href="' . dcCore::app()->adminurl->get('admin.plugins', [
'module' => 'fac',
'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>';
}
echo
@ -86,17 +84,17 @@ class facAdmin
'<div class="col">' .
'<h5>' . __('Activation') . '</h5>' .
'<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>' .
'<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>' .
'<h5>' . __('Feed') . '</h5>' .
'<p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' .
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><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>' .
'</div>' .
'<div class="col">' .
@ -106,7 +104,7 @@ class facAdmin
if (!is_array($fac_public_tpltypes)) {
$fac_public_tpltypes = [];
}
foreach(self::getPostsTypes($core) as $k => $v) {
foreach (self::getPostsTypes() as $k => $v) {
echo '
<p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox(
@ -155,34 +153,30 @@ class facAdmin
*/
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{
global $core;
if (!$core->blog->settings->fac->fac_active) {
if (!dcCore::app()->blog->settings->fac->fac_active) {
return null;
}
# Get existing linked feed
$fac_url = $fac_format = '';
if ($post) {
$rs = $core->meta->getMetadata([
$rs = dcCore::app()->meta->getMetadata([
'meta_type' => 'fac',
'post_id' => $post->post_id,
'limit' => 1
'limit' => 1,
]);
$fac_url = $rs->isEmpty() ? '' : $rs->meta_id;
$rs = $core->meta->getMetadata([
$rs = dcCore::app()->meta->getMetadata([
'meta_type' => 'facformat',
'post_id' => $post->post_id,
'limit' => 1
'limit' => 1,
]);
$fac_format = $rs->isEmpty() ? '' : $rs->meta_id;
}
# Set linked feed form items
$sidebar_items['options-box']['items']['fac'] =
self::formFeed($core, $fac_url, $fac_format);
$sidebar_items['options-box']['items']['fac'] = self::formFeed($fac_url, $fac_format);
}
/**
@ -193,18 +187,16 @@ class facAdmin
*/
public static function adminAfterPostSave(cursor $cur, $post_id)
{
global $core;
if (!isset($_POST['fac_url'])
|| !isset($_POST['fac_format'])) {
return null;
}
# Delete old linked feed
self::delFeed($core, $post_id);
self::delFeed($post_id);
# Add new linked feed
self::addFeed($core, $post_id, $_POST);
self::addFeed($post_id, $_POST);
}
/**
@ -214,18 +206,17 @@ class facAdmin
*/
public static function adminBeforePostDelete($post_id)
{
self::delFeed($GLOBALS['core'], $post_id);
self::delFeed($post_id);
}
/**
* Add actions to posts page combo
*
* @param dcCore $core dcCore instance
* @param dcPostsActionsPage $ap dcPostsActionsPage instance
* @param dcPostsActions $pa 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;
}
@ -234,7 +225,10 @@ class facAdmin
['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;
}
$pa->addAction(
@ -246,11 +240,10 @@ class facAdmin
/**
* Posts actions callback to remove linked feed
*
* @param dcCore $core dcCore instance
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
* @param dcPostsActions $pa dcPostsActions instance
* @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
$posts_ids = $pa->getIDs();
@ -259,13 +252,16 @@ class facAdmin
}
# 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'));
}
# Delete unused feed
foreach ($posts_ids as $post_id) {
self::delFeed($core, $post_id);
self::delFeed($post_id);
}
dcPage::addSuccessNotice(__('Linked feed deleted.'));
@ -275,11 +271,10 @@ class facAdmin
/**
* Posts actions callback to add linked feed
*
* @param dcCore $core dcCore instance
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
* @param dcPostsActions $pa dcPostsActions instance
* @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
$posts_ids = $pa->getIDs();
@ -291,8 +286,8 @@ class facAdmin
if (!empty($post['fac_url'])
&& !empty($post['fac_format'])) {
foreach ($posts_ids as $post_id) {
self::delFeed($core, $post_id);
self::addFeed($core, $post_id, $post);
self::delFeed($post_id);
self::addFeed($post_id, $post);
}
dcPage::addSuccessNotice(__('Linked feed added.'));
@ -302,9 +297,9 @@ class facAdmin
} else {
$pa->beginPage(
dcPage::breadcrumb([
html::escapeHTML($core->blog->name) => '',
html::escapeHTML(dcCore::app()->blog->name) => '',
$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">' .
$pa->getCheckboxes() .
self::formFeed($core) .
self::formFeed() .
'<p>' .
$core->formNonce() .
dcCore::app()->formNonce() .
$pa->getHiddenFields() .
form::hidden(['action'], 'fac_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' .
@ -328,14 +323,13 @@ class facAdmin
/**
* Linked feed form field
*
* @param dcCore $core dcCore instance
* @param string $url Feed URL
* @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;
}
@ -355,7 +349,7 @@ class facAdmin
__('Format:') . '</label>' .
form::combo(
'fac_format',
self::comboFac($core),
self::comboFac(),
$format,
'maximal'
) . '</p>' .
@ -366,12 +360,11 @@ class facAdmin
/**
* List of fac formats
*
* @param dcCore $core dcCore instance
* @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)) {
return [];
}
@ -387,38 +380,36 @@ class facAdmin
/**
* Delete linked feed
*
* @param dcCore $core dcCore instance
* @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;
$core->meta->delPostMeta($post_id, 'fac');
$core->meta->delPostMeta($post_id, 'facformat');
$post_id = (int) $post_id;
dcCore::app()->meta->delPostMeta($post_id, 'fac');
dcCore::app()->meta->delPostMeta($post_id, 'facformat');
}
/**
* Add linked feed
*
* @param dcCore $core dcCore instance
* @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'])
|| empty($options['fac_format'])) {
return null;
}
$post_id = (integer) $post_id;
$post_id = (int) $post_id;
$core->meta->setPostMeta(
dcCore::app()->meta->setPostMeta(
$post_id,
'fac',
$options['fac_url']
);
$core->meta->setPostMeta(
dcCore::app()->meta->setPostMeta(
$post_id,
'facformat',
$options['fac_format']

View File

@ -10,21 +10,20 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_MODULE')) {
return null;
}
if (!$core->auth->isSuperAdmin()) {
if (!dcCore::app()->auth->isSuperAdmin()) {
return null;
}
$redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir'];
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings --
$core->blog->settings->addNamespace('fac');
$s = $core->blog->settings->fac;
dcCore::app()->blog->settings->addNamespace('fac');
$s = dcCore::app()->blog->settings->fac;
$fac_formats = @unserialize($s->fac_formats);
@ -54,16 +53,16 @@ if (!empty($_POST['save'])) {
true
);
$core->blog->triggerBlog();
dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Configuration successfully updated.')
);
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) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -86,7 +85,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
'fac_formats_' . $uid . '_name',
],
20,
255,
@ -102,7 +101,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
'fac_formats_' . $uid . '_dateformat',
],
20,
255,
@ -118,7 +117,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
'fac_formats_' . $uid . '_lineslimit',
],
5,
4,
@ -136,7 +135,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
'fac_formats_' . $uid . '_linestitletext',
],
20,
255,
@ -157,7 +156,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
'fac_formats_' . $uid . '_linestitleover',
],
20,
255,
@ -178,7 +177,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
'fac_formats_' . $uid . '_linestitlelength',
],
5,
4,
@ -195,7 +194,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox(
[
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
'fac_formats_' . $uid . '_showlinesdescription',
],
1,
!empty($f['showlinesdescription'])
@ -206,7 +205,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox(
[
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
'fac_formats_' . $uid . '_linesdescriptionnohtml',
],
1,
!empty($f['linesdescriptionnohtml'])
@ -218,7 +217,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
'fac_formats_' . $uid . '_linesdescriptionlength',
],
5,
4,
@ -235,7 +234,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox(
[
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
'fac_formats_' . $uid . '_showlinescontent',
],
1,
!empty($f['showlinescontent'])
@ -246,7 +245,7 @@ foreach($fac_formats as $uid => $f) {
form::checkbox(
[
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
'fac_formats_' . $uid . '_linescontentnohtml',
],
1,
!empty($f['linescontentnohtml'])
@ -258,7 +257,7 @@ foreach($fac_formats as $uid => $f) {
form::field(
[
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
'fac_formats_' . $uid . '_linescontentlength',
],
5,
4,
@ -288,7 +287,7 @@ __('Name:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
'fac_formats_' . $uid . '_name',
],
20,
255,
@ -304,7 +303,7 @@ __('Date format:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
'fac_formats_' . $uid . '_dateformat',
],
20,
255,
@ -320,7 +319,7 @@ __('Entries limit:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
'fac_formats_' . $uid . '_lineslimit',
],
5,
4,
@ -338,7 +337,7 @@ __('Title format:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
'fac_formats_' . $uid . '_linestitletext',
],
20,
255,
@ -359,7 +358,7 @@ __('Over title format:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
'fac_formats_' . $uid . '_linestitleover',
],
20,
255,
@ -380,7 +379,7 @@ __('Maximum length of title:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
'fac_formats_' . $uid . '_linestitlelength',
],
5,
4,
@ -397,7 +396,7 @@ __('Leave lengh empty for no limit.') .
form::checkbox(
[
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
'fac_formats_' . $uid . '_showlinesdescription',
],
1,
0
@ -408,7 +407,7 @@ __('Show description of entries') . '</label></p>
form::checkbox(
[
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
'fac_formats_' . $uid . '_linesdescriptionnohtml',
],
1,
1
@ -420,7 +419,7 @@ __('Maximum length of description:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
'fac_formats_' . $uid . '_linesdescriptionlength',
],
5,
4,
@ -437,7 +436,7 @@ __('Leave lengh empty for no limit.') .
form::checkbox(
[
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
'fac_formats_' . $uid . '_showlinescontent',
],
1,
0
@ -448,7 +447,7 @@ __('Show content of entries') . '</label></p>
form::checkbox(
[
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
'fac_formats_' . $uid . '_linescontentnohtml',
],
1,
1
@ -460,7 +459,7 @@ __('Maximum length of content:') . '</label>' .
form::field(
[
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
'fac_formats_' . $uid . '_linescontentlength',
],
5,
4,

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -19,16 +18,19 @@ $this->registerModule(
'Feed after content',
'Add RSS/Atom feeds after entries content',
'Jean-Christian Denis and Contributors',
'0.9.3',
'0.10',
[
'requires' => [['core', '2.19']],
'permissions' => 'usage,contentadmin',
'requires' => [['core', '2.24']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'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',
'settings' => [
'blog' => '#params.fac_params'
]
'blog' => '#params.fac_params',
],
]
);

View File

@ -10,26 +10,25 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
# -- Module specs --
$dc_min = '2.19';
$dc_min = '2.24';
$mod_id = 'fac';
$mod_conf = [
[
'fac_active',
'Enabled fac plugin',
false,
'boolean'
'boolean',
],
[
'fac_public_tpltypes',
'List of templates types which used fac',
serialize(['post', 'tag', 'archive']),
'string'
'string',
],
[
'fac_formats',
@ -47,7 +46,7 @@ $mod_conf = [
'linesdescriptionnohtml' => '1',
'showlinescontent' => '0',
'linescontentlength' => '350',
'linescontentnohtml' => '1'
'linescontentnohtml' => '1',
],
uniqid() => [
'name' => 'full',
@ -61,57 +60,67 @@ $mod_conf = [
'linesdescriptionnohtml' => '1',
'showlinescontent' => '1',
'linescontentlength' => '',
'linescontentnohtml' => '1'
]
'linescontentnohtml' => '1',
],
]),
'string',
false,
true
true,
],
[
'fac_defaultfeedtitle',
'Default title of feed',
'%T',
'string'
'string',
],
[
'fac_showfeeddesc',
'Show description of feed',
1,
'boolean'
]
'boolean',
],
];
# -- Nothing to change below --
try {
# Check module version
if (version_compare(
$core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'),
'>=')) {
dcCore::app()->getVersion($mod_id),
dcCore::app()->plugins->moduleInfo($mod_id, 'version'),
'>='
)) {
return null;
}
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min
'%s requires Dotclear %s',
$mod_id,
$dc_min
));
}
# Set module settings
$core->blog->settings->addNamespace($mod_id);
dcCore::app()->blog->settings->addNamespace($mod_id);
foreach ($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put(
$v[0], $v[2], $v[3], $v[1], false, true
dcCore::app()->blog->settings->{$mod_id}->put(
$v[0],
$v[2],
$v[3],
$v[1],
false,
true
);
}
# Set module version
$core->setVersion(
dcCore::app()->setVersion(
$mod_id,
$core->plugins->moduleInfo($mod_id, 'version')
dcCore::app()->plugins->moduleInfo($mod_id, 'version')
);
return true;
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
return false;
}

View File

@ -10,14 +10,13 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$core->addBehavior(
dcCore::app()->addBehavior(
'publicEntryAfterContent',
array('facPublic', 'publicEntryAfterContent')
['facPublic', 'publicEntryAfterContent']
);
/**
@ -35,43 +34,43 @@ class facPublic
*/
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
if (!$core->blog->settings->fac->fac_active
|| !$_ctx->exists('posts')) {
if (!dcCore::app()->blog->settings->fac->fac_active
|| !dcCore::app()->ctx->exists('posts')) {
return null;
}
# 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)
|| !in_array($core->url->type,$types)) {
|| !in_array(dcCore::app()->url->type, $types)) {
return null;
}
# Get related feed
$fac_url = $core->meta->getMetadata([
$fac_url = dcCore::app()->meta->getMetadata([
'meta_type' => 'fac',
'post_id' => $_ctx->posts->post_id,
'limit' => 1
'post_id' => dcCore::app()->ctx->posts->post_id,
'limit' => 1,
]);
if ($fac_url->isEmpty()) {
return null;
}
# Get related format
$fac_format = $core->meta->getMetadata([
$fac_format = dcCore::app()->meta->getMetadata([
'meta_type' => 'facformat',
'post_id' => $_ctx->posts->post_id,
'limit' => 1
'post_id' => dcCore::app()->ctx->posts->post_id,
'limit' => 1,
]);
if ($fac_format->isEmpty()) {
return null;
}
# Get format info
$default_format = array(
$default_format = [
'name' => 'default',
'dateformat' => '',
'lineslimit' => '5',
@ -83,10 +82,10 @@ class facPublic
'linesdescriptionnohtml' => '1',
'showlinescontent' => '0',
'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)
|| !is_array($formats)
|| !isset($formats[$fac_format->meta_id])) {
@ -100,6 +99,7 @@ class facPublic
# Read feed url
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
try {
$feed = feedReader::quickParse($fac_url->meta_id, $cache);
} catch (Exception $e) {
@ -113,27 +113,27 @@ class facPublic
# Feed title
$feedtitle = '';
if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) {
$feedtitle = '<h3>' . html::escapeHTML(empty($feed->title) ?
if ('' != dcCore::app()->blog->settings->fac->fac_defaultfeedtitle) {
$feedtitle = '<h3>' . html::escapeHTML(
empty($feed->title) ?
str_replace(
'%T',
__('a related feed'),
$core->blog->settings->fac->fac_defaultfeedtitle
dcCore::app()->blog->settings->fac->fac_defaultfeedtitle
) :
str_replace(
'%T',
$feed->title,
$core->blog->settings->fac->fac_defaultfeedtitle
dcCore::app()->blog->settings->fac->fac_defaultfeedtitle
)
) . '</h3>';
}
# Feed desc
$feeddesc = '';
if ($core->blog->settings->fac->fac_showfeeddesc
if (dcCore::app()->blog->settings->fac->fac_showfeeddesc
&& '' != $feed->description) {
$feeddesc =
'<p>' . context::global_filters(
$feeddesc = '<p>' . context::global_filters(
$feed->description,
['encode_xml', 'remove_html']
) . '</p>';
@ -142,10 +142,10 @@ class facPublic
# Date 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
$entrieslimit = abs((integer) $format['lineslimit']);
$entrieslimit = abs((int) $format['lineslimit']);
$uselimit = $entrieslimit > 0 ? true : false;
echo
@ -155,49 +155,48 @@ class facPublic
$i = 0;
foreach ($feed->items as $item) {
# Format date
$date = dt::dt2str($dateformat, $item->pubdate);
# Entries title
$title = context::global_filters(
str_replace(
array(
[
'%D',
'%T',
'%A',
'%E',
'%C'
),
array(
'%C',
],
[
$date,
$item->title,
$item->creator,
$item->description,
$item->content
),
$item->content,
],
$format['linestitletext']
),
['remove_html', 'cut_string' => abs((integer) $format['linestitlelength'])],
['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
);
# Entries over title
$overtitle = context::global_filters(
str_replace(
array(
[
'%D',
'%T',
'%A',
'%E',
'%C'
),
array(
'%C',
],
[
$date,
$item->title,
$item->creator,
$item->description,
$item->content
),
$item->content,
],
$format['linestitleover']
),
['remove_html', 'cut_string' => 350],
@ -210,7 +209,7 @@ class facPublic
$description = '<dd>' .
context::global_filters(
$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>';
}
@ -221,7 +220,7 @@ class facPublic
$content = '<dd>' .
context::global_filters(
$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>';
}

View File

@ -1,11 +1,12 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/">
<module id="fac">
<name>Feed after content</name>
<version>0.9.2</version>
<version>0.10</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/v0.9.2/plugin-fac.zip</file>
<da:dcmin>2.19</da:dcmin>
<file>https://github.com/JcDenis/fac/releases/download/v0.10/plugin-fac.zip</file>
<da:dcmin>2.24</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/fac</da:details>
<da:support>https://github.com/JcDenis/fac</da:support>
</module>

View File

@ -1,4 +1,5 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of fac, a plugin for Dotclear 2.
@ -15,4 +16,4 @@ if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';

View File

@ -1,4 +1,5 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of fac, a plugin for Dotclear 2.
@ -15,4 +16,4 @@ if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';