parent
6eac8b1853
commit
ed0ca29b7c
|
@ -1,3 +1,9 @@
|
|||
fac 1.5 - 2023.10.16
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1+
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
fac 1.4 - 2023.08.12
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
37
README.md
37
README.md
|
@ -1,29 +1,25 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/fac/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/fac/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/fac/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.16-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/fac)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/fac)](https://git.dotclear.watch/JcDenis/fac/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/fac/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS FAC ?
|
||||
## ABOUT
|
||||
|
||||
_fac_ "Feed After Content" is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_fac_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
It add options to the sidebar of post edition page
|
||||
to link en extenal feed to the bottom of an entry.
|
||||
> Add options to the sidebar of post edition page to link en extenal feed to the bottom of an entry.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_fac_ requires:
|
||||
|
||||
* superadmin to configure feeds formats
|
||||
* admin permissions to configure plugin
|
||||
* usage,contentadmin permissions to link feeds
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* A theme that contents behavior publicEntryAfterContent
|
||||
* Dotclear superadmin to configure feeds formats
|
||||
* Dotclear admin permissions to configure plugin
|
||||
* Dotclear usage or contentadmin permissions to link feeds
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -41,12 +37,13 @@ This plugins also supports pages from plugin "muppet".
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/fac) or [GitHub Page](https://github.com/JcDenis/fac)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/fac/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/fac)
|
||||
* [License](https://git.dotclear.watch/JcDenis/fac/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/fac/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/fac))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/fac) (or on [GitHub](https://github.com/JcDenis/fac))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/fac/issues) (or on [GitHub](https://github.com/JcDenis/fac/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (author)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
38
_define.php
38
_define.php
|
@ -1,36 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin fac definition
|
||||
* @ingroup fac
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup fac Plugin fac.
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
* Add RSS/Atom feeds after entries content.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Feed after content',
|
||||
'Add RSS/Atom feeds after entries content',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'1.4',
|
||||
'1.5',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'settings' => [
|
||||
'blog' => '#params.' . basename(__DIR__) . '_params',
|
||||
],
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<version>1.4</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Add RSS/Atom feeds after entries content</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/fac/releases/download/v1.4/plugin-fac.zip</file>
|
||||
<file>https://github.com/JcDenis/fac/releases/download/v1.4/plugin-fac.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/fac/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/fac/issues</da:support>
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin fac resources
|
||||
* @ingroup fac
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'fac', __DIR__ . '/help/fac.html');
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin fac resources
|
||||
* @ingroup fac
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['fac'] = __DIR__ . '/help/fac.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'fac', __DIR__ . '/help/fac.html');
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief fac backend class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,15 +27,15 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
|
||||
'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
|
||||
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
|
||||
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
|
||||
'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostSave'],
|
||||
'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'],
|
||||
'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
|
||||
'adminPostsActions' => [BackendBehaviors::class, 'adminPostsActions'],
|
||||
App::behavior()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
|
||||
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
|
||||
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,22 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcSettings;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
|
@ -40,12 +29,15 @@ use Dotclear\Helper\Html\Form\{
|
|||
Submit,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Interface\Core\BlogSettingsInterface;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_FAC
|
||||
* @brief Linked feed to entries - admin methods.
|
||||
* @since 2.6
|
||||
* @brief fac backend behaviors class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class BackendBehaviors
|
||||
{
|
||||
|
@ -64,7 +56,7 @@ class BackendBehaviors
|
|||
__('category pages') => 'category',
|
||||
__('entries feed') => 'feed',
|
||||
];
|
||||
if (dcCore::app()->plugins->getDefine('muppet')->isDefined() && class_exists('\muppet')) {
|
||||
if (App::plugins()->getDefine('muppet')->isDefined() && class_exists('\muppet')) {
|
||||
foreach (\muppet::getPostTypes() as $k => $v) {
|
||||
$types[sprintf(
|
||||
__('"%s" pages from extension muppet'),
|
||||
|
@ -81,7 +73,7 @@ class BackendBehaviors
|
|||
*
|
||||
* @param dcSettings $blog_settings dcSettings instance
|
||||
*/
|
||||
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
|
||||
public static function adminBlogPreferencesFormV2(BlogSettingsInterface $blog_settings): void
|
||||
{
|
||||
$lines = '';
|
||||
$fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true);
|
||||
|
@ -100,11 +92,11 @@ class BackendBehaviors
|
|||
'<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 (dcCore::app()->auth->isSuperAdmin()) {
|
||||
echo '<p><a href="' . dcCore::app()->admin->url->get('admin.plugins', [
|
||||
if (App::auth()->isSuperAdmin()) {
|
||||
echo '<p><a href="' . App::backend()->url()->get('admin.plugins', [
|
||||
'module' => My::id(),
|
||||
'conf' => 1,
|
||||
'redir' => dcCore::app()->admin->url->get('admin.blog.pref') . '#params.' . My::id() . '_params',
|
||||
'redir' => App::backend()->url()->get('admin.blog.pref') . '#params.' . My::id() . '_params',
|
||||
]) . '">' . __('Configure formats') . '</a></p>';
|
||||
}
|
||||
|
||||
|
@ -145,7 +137,7 @@ class BackendBehaviors
|
|||
*
|
||||
* @param dcSettings $blog_settings dcSettings instance
|
||||
*/
|
||||
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings): void
|
||||
public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
|
||||
{
|
||||
$blog_settings->get(My::id())->put('active', !empty($_POST['fac_active']));
|
||||
$blog_settings->get(My::id())->put('public_tpltypes', json_encode($_POST['fac_public_tpltypes']));
|
||||
|
@ -172,21 +164,21 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
|
||||
if (!App::blog()->isDefined() || !My::settings()->get('active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Get existing linked feed
|
||||
$fac_url = $fac_format = '';
|
||||
if ($post) {
|
||||
$rs = dcCore::app()->meta->getMetadata([
|
||||
$rs = App::meta()->getMetadata([
|
||||
'meta_type' => 'fac',
|
||||
'post_id' => $post->f('post_id'),
|
||||
'limit' => 1,
|
||||
]);
|
||||
$fac_url = $rs->isEmpty() ? '' : $rs->f('meta_id');
|
||||
|
||||
$rs = dcCore::app()->meta->getMetadata([
|
||||
$rs = App::meta()->getMetadata([
|
||||
'meta_type' => 'facformat',
|
||||
'post_id' => $post->f('post_id'),
|
||||
'limit' => 1,
|
||||
|
@ -235,24 +227,24 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function adminPostsActions(ActionsPosts $pa): void
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
|
||||
if (!App::blog()->isDefined() || !My::settings()->get('active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pa->addAction(
|
||||
[__('Linked feed') => [__('Add feed') => 'fac_add']],
|
||||
[self::class, 'callbackAdd']
|
||||
self::callbackAdd(...)
|
||||
);
|
||||
|
||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_DELETE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
if (!App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_DELETE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id())) {
|
||||
return;
|
||||
}
|
||||
$pa->addAction(
|
||||
[__('Linked feed') => [__('Remove feed') => 'fac_remove']],
|
||||
[self::class, 'callbackRemove']
|
||||
self::callbackRemove(...)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -264,7 +256,7 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
# No entry
|
||||
|
@ -274,10 +266,10 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# No right
|
||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_DELETE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
if (!App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_DELETE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id())) {
|
||||
throw new Exception(__('No enough right'));
|
||||
}
|
||||
|
||||
|
@ -298,7 +290,7 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
# No entry
|
||||
|
@ -322,9 +314,9 @@ class BackendBehaviors
|
|||
} else {
|
||||
$pa->beginPage(
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Linked feed to this selection') => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Linked feed to this selection') => '',
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -332,7 +324,8 @@ class BackendBehaviors
|
|||
(new Form('fac_form'))->action($pa->getURI())->method('post')->fields([
|
||||
(new Text('', $pa->getCheckboxes() . self::formFeed())),
|
||||
(new Para())->items([
|
||||
(new Text('', dcCore::app()->formNonce() . $pa->getHiddenFields())),
|
||||
App::nonce()->formNonce(),
|
||||
... $pa->giddenFields(),
|
||||
(new Hidden(['action'], 'fac_add')),
|
||||
(new Submit(['save']))->value(__('Save')),
|
||||
]),
|
||||
|
@ -351,7 +344,7 @@ class BackendBehaviors
|
|||
*/
|
||||
protected static function formFeed(string $url = '', string $format = ''): string
|
||||
{
|
||||
if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
|
||||
if (!App::blog()->isDefined() || !My::settings()->get('active')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -379,7 +372,7 @@ class BackendBehaviors
|
|||
*/
|
||||
protected static function comboFac(): array
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return [];
|
||||
}
|
||||
$formats = json_decode((string) My::settings()->get('formats'), true);
|
||||
|
@ -403,8 +396,8 @@ class BackendBehaviors
|
|||
protected static function delFeed(int $post_id): void
|
||||
{
|
||||
$post_id = (int) $post_id;
|
||||
dcCore::app()->meta->delPostMeta($post_id, 'fac');
|
||||
dcCore::app()->meta->delPostMeta($post_id, 'facformat');
|
||||
App::meta()->delPostMeta($post_id, 'fac');
|
||||
App::meta()->delPostMeta($post_id, 'facformat');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,12 +415,12 @@ class BackendBehaviors
|
|||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
dcCore::app()->meta->setPostMeta(
|
||||
App::meta()->setPostMeta(
|
||||
$post_id,
|
||||
'fac',
|
||||
$options['fac_url']
|
||||
);
|
||||
dcCore::app()->meta->setPostMeta(
|
||||
App::meta()->setPostMeta(
|
||||
$post_id,
|
||||
'facformat',
|
||||
$options['fac_format']
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
|
@ -33,6 +23,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief fac configuration class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Config extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -46,13 +43,12 @@ class Config extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$redir = empty($_REQUEST['redir']) ?
|
||||
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
App::backend()->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
|
||||
# -- Get settings --
|
||||
$s = My::settings();
|
||||
|
@ -85,17 +81,17 @@ class Config extends Process
|
|||
true
|
||||
);
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
dcCore::app()->admin->url->redirect(
|
||||
App::backend()->url()->redirect(
|
||||
'admin.plugins',
|
||||
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||
['module' => My::id(), 'conf' => 1, 'redir' => App::backend()->__get('list')->getRedir()]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use context;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Ctx;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Network\Feed\Reader;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief fac frontend class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -31,32 +28,31 @@ class Frontend extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
|
||||
if (!self::status() || !App::blog()->isDefined() || !My::settings()->get('active')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('publicEntryAfterContent', function (dcCore $core, context $_ctx): void {
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
|
||||
App::behavior()->addBehavior('publicEntryAfterContent', function ($___, Ctx $_ctx): void {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not a post
|
||||
if (!dcCore::app()->ctx->exists('posts')) {
|
||||
if (!App::frontend()->context()->exists('posts')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not in page to show
|
||||
$types = json_decode((string) My::settings()->get('public_tpltypes'), true);
|
||||
if (!is_array($types)
|
||||
|| !in_array(dcCore::app()->url->type, $types)) {
|
||||
|| !in_array(App::url()->type, $types)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get related feed
|
||||
$fac_url = dcCore::app()->meta->getMetadata([
|
||||
$fac_url = App::meta()->getMetadata([
|
||||
'meta_type' => 'fac',
|
||||
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||
'post_id' => App::frontend()->context()->__get('posts')->f('post_id'),
|
||||
'limit' => 1,
|
||||
]);
|
||||
if ($fac_url->isEmpty()) {
|
||||
|
@ -64,9 +60,9 @@ class Frontend extends Process
|
|||
}
|
||||
|
||||
// Get related format
|
||||
$fac_format = dcCore::app()->meta->getMetadata([
|
||||
$fac_format = App::meta()->getMetadata([
|
||||
'meta_type' => 'facformat',
|
||||
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||
'post_id' => App::frontend()->context()->__get('posts')->f('post_id'),
|
||||
'limit' => 1,
|
||||
]);
|
||||
if ($fac_format->isEmpty()) {
|
||||
|
@ -102,7 +98,7 @@ class Frontend extends Process
|
|||
}
|
||||
|
||||
// Read feed url
|
||||
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
|
||||
$cache = is_dir(App::config()->cacheRoot() . '/fac') ? App::config()->cacheRoot() . '/fac' : null;
|
||||
|
||||
try {
|
||||
$feed = Reader::quickParse($fac_url->f('meta_id'), $cache);
|
||||
|
@ -137,7 +133,7 @@ class Frontend extends Process
|
|||
$feeddesc = '';
|
||||
if (My::settings()->get('showfeeddesc')
|
||||
&& '' != $feed->description) {
|
||||
$feeddesc = '<p>' . context::global_filters(
|
||||
$feeddesc = '<p>' . $_ctx::global_filters(
|
||||
$feed->description,
|
||||
['encode_xml', 'remove_html']
|
||||
) . '</p>';
|
||||
|
@ -146,7 +142,7 @@ class Frontend extends Process
|
|||
// Date format
|
||||
$dateformat = '' != $format['dateformat'] ?
|
||||
$format['dateformat'] :
|
||||
dcCore::app()->blog->settings->get('system')->get('date_format') . ',' . dcCore::app()->blog->settings->get('system')->get('time_format');
|
||||
App::blog()->settings()->get('system')->get('date_format') . ',' . App::blog()->settings()->get('system')->get('time_format');
|
||||
|
||||
// Enrties limit
|
||||
$entrieslimit = abs((int) $format['lineslimit']);
|
||||
|
@ -163,7 +159,7 @@ class Frontend extends Process
|
|||
$date = Date::dt2str($dateformat, $item->pubdate);
|
||||
|
||||
// Entries title
|
||||
$title = context::global_filters(
|
||||
$title = $_ctx::global_filters(
|
||||
str_replace(
|
||||
[
|
||||
'%D',
|
||||
|
@ -185,7 +181,7 @@ class Frontend extends Process
|
|||
);
|
||||
|
||||
// Entries over title
|
||||
$overtitle = context::global_filters(
|
||||
$overtitle = $_ctx::global_filters(
|
||||
str_replace(
|
||||
[
|
||||
'%D',
|
||||
|
@ -211,7 +207,7 @@ class Frontend extends Process
|
|||
if ($format['showlinesdescription']
|
||||
&& '' != $item->description) {
|
||||
$description = '<dd>' .
|
||||
context::global_filters(
|
||||
$_ctx::global_filters(
|
||||
$item->description,
|
||||
['remove_html' => (int) $format['linesdescriptionnohtml'], 'cut_string' => abs((int) $format['linesdescriptionlength'])]
|
||||
) . '</dd>';
|
||||
|
@ -222,7 +218,7 @@ class Frontend extends Process
|
|||
if ($format['showlinescontent']
|
||||
&& '' != $item->content) {
|
||||
$content = '<dd>' .
|
||||
context::global_filters(
|
||||
$_ctx::global_filters(
|
||||
$item->content,
|
||||
['remove_html' => (int) $format['linescontentnohtml'], 'cut_string' => abs((int) $format['linescontentlength'])]
|
||||
) . '</dd>';
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief fac installation class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -113,7 +109,7 @@ class Install extends Process
|
|||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -122,15 +118,15 @@ class Install extends Process
|
|||
private static function growUp(): void
|
||||
{
|
||||
// version < 1.0 : upgrade settings id and ns and array
|
||||
$current = dcCore::app()->getVersion(My::id());
|
||||
$current = App::version()()->getVersion(My::id());
|
||||
if ($current && version_compare($current, '1.0', '<')) {
|
||||
$record = dcCore::app()->con->select(
|
||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||
$record = App::con()->select(
|
||||
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = 'fac' "
|
||||
);
|
||||
while ($record->fetch()) {
|
||||
if (preg_match('/^fac_(.*?)$/', $record->f('setting_id'), $match)) {
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||
if (in_array($record->f('setting_id'), ['fac_public_tpltypes', 'fac_formats'])) {
|
||||
$cur->setField('setting_value', json_encode(@unserialize($record->f('setting_value'))));
|
||||
}
|
||||
|
@ -138,7 +134,7 @@ class Install extends Process
|
|||
$cur->SetField('setting_ns', My::id());
|
||||
$cur->update(
|
||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = 'fac' " .
|
||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr($record->f('blog_id')) . "' "))
|
||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr($record->f('blog_id')) . "' "))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
19
src/My.php
19
src/My.php
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
@ -17,8 +7,13 @@ namespace Dotclear\Plugin\fac;
|
|||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief fac My helper.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// Use default permissions
|
||||
}
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief fac, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief fac uninstall class.
|
||||
* @ingroup fac
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -27,7 +23,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue