PSR2 and license

This commit is contained in:
Jean-Christian Paul Denis 2021-08-20 18:39:12 +02:00
parent b38ca38b09
commit a5d4f0d467
10 changed files with 1008 additions and 1069 deletions

View File

@ -1,41 +1,36 @@
fac 0.8 - 2021-08-19
* update license
* fixed PSR2 coding style
fac 0.7 - 2013-11-11 fac 0.7 - 2013-11-11
===========================================================
* Switch to Dotclear 2.6 * Switch to Dotclear 2.6
* Fix missing feed description * Fix missing feed description
fac 0.6.1 - 2010-11-12 fac 0.6.1 - 2010-11-12
===========================================================
* Fixed install on nightly build * Fixed install on nightly build
fac 0.6 - 2010-08-16 fac 0.6 - 2010-08-16
===========================================================
* Added compatibility with plugin muppet * Added compatibility with plugin muppet
fac 0.5 - 2010-06-05 fac 0.5 - 2010-06-05
===========================================================
* Switched to DC 2.2 * Switched to DC 2.2
* Added predefined format (thx to Jean-Michel) (closes #459) * Added predefined format (thx to Jean-Michel) (closes #459)
fac 0.4.1 - 2010-04-10 fac 0.4.1 - 2010-04-10
===========================================================
* Fixed typo (thx to Jean-Michel) (closes #458) * Fixed typo (thx to Jean-Michel) (closes #458)
fac 0.4 - 2010-05-25 fac 0.4 - 2010-05-25
===========================================================
* Fixed Timeout error * Fixed Timeout error
* Fixed DC 2.1.7 * Fixed DC 2.1.7
fac 0.3 - 2010-04-10 fac 0.3 - 2010-04-10
===========================================================
* Added options to format feed * Added options to format feed
* Added DC 2.2 compatibility * Added DC 2.2 compatibility
* Removed class and used metadata * Removed class and used metadata
* Changed admin page design * Changed admin page design
fac 0.2 - 2010-02-17 fac 0.2 - 2010-02-17
===========================================================
* Fixed some fields in admin * Fixed some fields in admin
fac 0.1 - 2010-02-16 fac 0.1 - 2010-02-16
===========================================================
* First lab release * First lab release

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -21,35 +19,16 @@ $core->blog->settings->addNamespace('fac');
# Not active # Not active
if (!$core->blog->settings->fac->fac_active) { if (!$core->blog->settings->fac->fac_active) {
return null; return null;
} }
# Admin behaviors # Admin behaviors
$core->addBehavior( $core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
'adminPostHeaders', $core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
array('facAdmin', 'adminPostHeaders') $core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
); $core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior( $core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
'adminPostFormItems', $core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']);
array('facAdmin', 'adminPostFormItems')
);
$core->addBehavior(
'adminAfterPostCreate',
array('facAdmin', 'adminAfterPostSave')
);
$core->addBehavior(
'adminAfterPostUpdate',
array('facAdmin', 'adminAfterPostSave')
);
$core->addBehavior(
'adminBeforePostDelete',
array('facAdmin', 'adminBeforePostDelete')
);
$core->addBehavior(
'adminPostsActionsPage',
array('facAdmin', 'adminPostsActionsPage')
);
/** /**
* @ingroup DC_PLUGIN_FAC * @ingroup DC_PLUGIN_FAC
@ -114,8 +93,7 @@ class facAdmin
global $core; global $core;
if (!isset($_POST['fac_url']) if (!isset($_POST['fac_url'])
|| !isset($_POST['fac_format']) || !isset($_POST['fac_format'])) {
) {
return null; return null;
} }
@ -154,7 +132,6 @@ class facAdmin
); );
if (!$core->auth->check('delete,contentadmin', $core->blog->id)) { if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
return null; return null;
} }
$pa->addAction( $pa->addAction(
@ -213,8 +190,7 @@ 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($core, $post_id);
self::addFeed($core, $post_id, $post); self::addFeed($core, $post_id, $post);
@ -222,10 +198,9 @@ class facAdmin
dcPage::addSuccessNotice(__('Linked feed added.')); dcPage::addSuccessNotice(__('Linked feed added.'));
$pa->redirect(true); $pa->redirect(true);
}
# Display form # Display form
else { } else {
$pa->beginPage( $pa->beginPage(
dcPage::breadcrumb(array( dcPage::breadcrumb(array(
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
@ -295,7 +270,6 @@ class facAdmin
{ {
$formats = @unserialize($core->blog->settings->fac->fac_formats); $formats = @unserialize($core->blog->settings->fac->fac_formats);
if (!is_array($formats) || empty($formats)) { if (!is_array($formats) || empty($formats)) {
return array(); return array();
} }
@ -330,8 +304,7 @@ class facAdmin
protected static function addFeed($core, $post_id, $options) protected static function addFeed($core, $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;
} }

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
@ -21,14 +19,14 @@ $redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir']; $list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Combos of types of supported public pages -- # -- Combos of types of supported public pages --
$types = array( $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 ($core->plugins->moduleExists('muppet')) {
foreach(muppet::getPostTypes() as $k => $v) { foreach(muppet::getPostTypes() as $k => $v) {
$types[sprintf( $types[sprintf(
@ -57,7 +55,6 @@ if (!is_array($fac_formats)) {
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
$fac_active = !empty($_POST['fac_active']); $fac_active = !empty($_POST['fac_active']);
$fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle']; $fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle'];
@ -83,8 +80,7 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( http::redirect(
$list->getURL('module=fac&conf=1&redir='. $list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
$list->getRedir())
); );
} }
catch (Exception $e) { catch (Exception $e) {
@ -94,7 +90,6 @@ if (!empty($_POST['save'])) {
# -- Display form -- # -- Display form --
echo ' echo '
<div class="fieldset"> <div class="fieldset">
<h4>' . __('Activation') . '</h4> <h4>' . __('Activation') . '</h4>
@ -114,7 +109,6 @@ foreach($types as $k => $v) {
) . __($k) . '</label></p>'; ) . __($k) . '</label></p>';
} }
echo ' echo '
</div> </div>
<div class="fieldset"> <div class="fieldset">
@ -132,7 +126,6 @@ __('Show description of feed').'</label></p>
$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;
} }

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -13,25 +12,19 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$this->registerModule( $this->registerModule(
/* Name */ 'fac',
"fac", 'Add RSS/Atom feeds after entries content',
/* Description*/ 'Jean-Christian Denis and Contributors',
"Add RSS/Atom feeds after entries content", '0.8',
/* Author */ [
"Jean-Christian Denis",
/* Version */
'0.7',
/* Properies */
array(
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.6', 'dc_min' => '2.18',
'support' => 'http://jcd.lv/q=fac', 'support' => 'https://github.com/JcDenis/fac',
'details' => 'http://plugins.dotaddict.org/dc2/details/fac' 'details' => 'https://plugins.dotaddict.org/dc2/details/fac'
) ]
); );

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -41,38 +39,34 @@ class facPublic
# Not active or not a post # Not active or not a post
if (!$core->blog->settings->fac->fac_active if (!$core->blog->settings->fac->fac_active
|| !$_ctx->exists('posts') || !$_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($core->blog->settings->fac->fac_public_tpltypes);
if (!is_array($types) if (!is_array($types)
|| !in_array($core->url->type,$types) || !in_array($core->url->type,$types)) {
) {
return null; return null;
} }
# Get related feed # Get related feed
$fac_url = $core->meta->getMetadata(array( $fac_url = $core->meta->getMetadata([
'meta_type' => 'fac', 'meta_type' => 'fac',
'post_id' => $_ctx->posts->post_id, 'post_id' => $_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(array( $fac_format = $core->meta->getMetadata([
'meta_type' => 'facformat', 'meta_type' => 'facformat',
'post_id' => $_ctx->posts->post_id, 'post_id' => $_ctx->posts->post_id,
'limit' => 1 'limit' => 1
)); ]);
if ($fac_format->isEmpty()) { if ($fac_format->isEmpty()) {
return null; return null;
} }
@ -95,11 +89,9 @@ class facPublic
$formats = @unserialize($core->blog->settings->fac->fac_formats); $formats = @unserialize($core->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])) {
) {
$format = $default_format; $format = $default_format;
} } else {
else {
$format = array_merge( $format = array_merge(
$default_format, $default_format,
$formats[$fac_format->meta_id] $formats[$fac_format->meta_id]
@ -110,14 +102,12 @@ class facPublic
$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) {
$feed = null; $feed = null;
} }
# No entries # No entries
if (!$feed) { if (!$feed) {
return null; return null;
} }
@ -141,8 +131,7 @@ class facPublic
# Feed desc # Feed desc
$feeddesc = ''; $feeddesc = '';
if ($core->blog->settings->fac->fac_showfeeddesc if ($core->blog->settings->fac->fac_showfeeddesc
&& '' != $feed->description && '' != $feed->description) {
) {
$feeddesc = $feeddesc =
'<p>' . context::global_filter($feed->description, 1, 1, 0, 0, 0) . '</p>'; '<p>' . context::global_filter($feed->description, 1, 1, 0, 0, 0) . '</p>';
} }
@ -222,8 +211,7 @@ class facPublic
# Entries description # Entries description
$description = ''; $description = '';
if ($format['showlinesdescription'] if ($format['showlinesdescription']
&& '' != $item->description && '' != $item->description) {
) {
$description = '<dd>' . $description = '<dd>' .
context::global_filter( context::global_filter(
$item->description, $item->description,
@ -237,8 +225,7 @@ class facPublic
# Entries content # Entries content
$content = ''; $content = '';
if ($format['showlinescontent'] if ($format['showlinescontent']
&& '' != $item->content && '' != $item->content) {
) {
$content = '<dd>'. $content = '<dd>'.
context::global_filter( context::global_filter(
$item->content, $item->content,

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -12,7 +11,8 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
?>

View File

@ -3,8 +3,7 @@
# #
# 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-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# 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
@ -12,7 +11,8 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
?>