Compare commits
12 Commits
v2023.08.1
...
master
Author | SHA1 | Date | |
---|---|---|---|
ee39711e90 | |||
697027940b | |||
2b68c75c68 | |||
0d96001a25 | |||
f2a3977f2d | |||
17e98ca0f2 | |||
40fccc7434 | |||
2b6ee4cbba | |||
b25c9819c6 | |||
7f0cae3b8f | |||
0b0899fe7b | |||
c9b305aa8d |
26
CHANGELOG.md
26
CHANGELOG.md
@ -1,3 +1,29 @@
|
||||
zoneclearFeedServer 2023.11.04
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Code review (phpstan)
|
||||
|
||||
zoneclearFeedServer 2023.10.18
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade plugin activityReport
|
||||
|
||||
zoneclearFeedServer 2023.10.14
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
zoneclearFeedServer 2023.08.20
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
* Require PHP 8.1
|
||||
* Change settings to super admin only
|
||||
* Fix get feed tags
|
||||
* Fix per blog settings
|
||||
|
||||
zoneclearFeedServer 2023.08.16
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
36
README.md
36
README.md
@ -1,33 +1,30 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.16-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.16-c44d58.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.11.04-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/zoneclearFeedServer)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-676e78.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS ZONECLEARFEEDSERVER ?
|
||||
## ABOUT
|
||||
|
||||
"zoneclear Feeds server" is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_zoneclearFeedServer_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
It mix your blog with a feeds planet.
|
||||
> Mix your blog with a feeds planet
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_zoneclearFeedServer_ requires:
|
||||
|
||||
* super admin permission for plugin and services configuration
|
||||
* admin permission to manage feeds
|
||||
* Dotclear 2.27
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1
|
||||
* Dotclear super admin permissions for plugin and services configuration
|
||||
* Dotclear admin permissions to manage feeds
|
||||
|
||||
## USAGE
|
||||
|
||||
First install zoneclearFeedServer, manualy from a zip package or from
|
||||
First install _zoneclearFeedServer_, manualy from a zip package or from
|
||||
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||
|
||||
Go to ''plugins manager'', expand _zoneclearFeedServer_ information then
|
||||
Go to ''plugins manager'', expand ''Feed server'' information then
|
||||
go to ''configure plugin'', fill in form.
|
||||
|
||||
Once it's done you can manage your feeds from menu
|
||||
@ -35,10 +32,11 @@ Once it's done you can manage your feeds from menu
|
||||
|
||||
## 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/zoneclearFeedServer) or [GitHub Page](https://github.com/JcDenis/zoneclearFeedServer)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/zoneclearFeedServer)
|
||||
* Discussion & Help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=331158)
|
||||
* [License](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/zoneclearFeedServer))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/zoneclearFeedServer) (or on [GitHub](https://github.com/JcDenis/zoneclearFeedServer))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/issues) (or on [GitHub](https://github.com/JcDenis/zoneclearFeedServer/issues))
|
||||
* [Discussion & Help](http://forum.dotclear.org/viewtopic.php?pid=331158)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
|
38
_define.php
38
_define.php
@ -1,35 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin zoneclearFeedServer definition
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup zoneclearFeedServer Plugin zoneclearFeedServer.
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
* Mix your blog with a feeds planet.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @author Pierre Van Glabeke
|
||||
* @author BG
|
||||
* @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(
|
||||
'Feeds server',
|
||||
'Mix your blog with a feeds planet',
|
||||
'Jean-Christian Denis, BG, Pierre Van Glabeke',
|
||||
'2023.08.16',
|
||||
'2023.11.04',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'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',
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
20
_init.php
20
_init.php
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class initZoneclearFeedServer
|
||||
{
|
||||
public const TABLE_NAME = 'zc_feed';
|
||||
}
|
@ -5,6 +5,8 @@
|
||||
# By Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license
|
||||
|
||||
use Dotclear\App;
|
||||
|
||||
$opts = getopt('d:c:b:u:h');
|
||||
|
||||
function zchelp(string|int $status = 0): void
|
||||
@ -69,18 +71,18 @@ unset($blog_id);
|
||||
require $dc_root . '/inc/prepend.php';
|
||||
unset($dc_root);
|
||||
|
||||
dcCore::app()->setBlog(is_string(DC_BLOG_ID) ? DC_BLOG_ID : '');
|
||||
if (is_null(dcCore::app()->blog) || dcCore::app()->blog->id == null) {
|
||||
App::blog()->loadFromBlog(is_string(DC_BLOG_ID) ? DC_BLOG_ID : '');
|
||||
if (!App::blog()->isDefined() || '' == App::blog()->id()) {
|
||||
fwrite(STDERR, "Blog is not defined\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!isset($opts['u']) || !dcCore::app()->auth->checkUser(is_string($opts['u']) ? $opts['u'] : '')) {
|
||||
if (!isset($opts['u']) || !App::auth()->checkUser(is_string($opts['u']) ? $opts['u'] : '')) {
|
||||
fwrite(STDERR, "Unable to set user\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dcCore::app()->plugins->loadModules(DC_PLUGINS_ROOT);
|
||||
App::plugins()->loadModules(DC_PLUGINS_ROOT);
|
||||
|
||||
try {
|
||||
$zc = Dotclear\Plugin\zoneclearFeedServer\ZoneclearFeedServer::instance();
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="zoneclearFeedServer">
|
||||
<name>Feeds server</name>
|
||||
<version>2023.08.16</version>
|
||||
<version>2023.11.04</version>
|
||||
<author>Jean-Christian Denis, BG, Pierre Van Glabeke</author>
|
||||
<desc>Mix your blog with a feeds planet</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases/download/v2023.08.16/plugin-zoneclearFeedServer.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases/download/v2023.11.04/plugin-zoneclearFeedServer.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/zoneclearFeedServer/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/zoneclearFeedServer/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,20 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Cursor;
|
||||
use Dotclear\Plugin\activityReport\{
|
||||
Action,
|
||||
@ -23,12 +14,27 @@ use Dotclear\Plugin\activityReport\{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief zoneclearFeedServer plugin activityReport class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* Add feeds actions to the plugin activity report.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ActivityReportActions
|
||||
class ActivityReportAction extends Process
|
||||
{
|
||||
public static function init(): void
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(true);
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group = new Group(My::id(), My::name());
|
||||
|
||||
$group->add(new Action(
|
||||
@ -37,7 +43,7 @@ class ActivityReportActions
|
||||
__('Feed named "%s" point to "%s" has been updated by "%s"'),
|
||||
'zoneclearFeedServerAfterUpdateFeed',
|
||||
function (Cursor $cur, int $id): void {
|
||||
$user = dcCore::app()->auth->getInfo('user_cn');
|
||||
$user = App::auth()->getInfo('user_cn');
|
||||
if (!is_string($user)) {
|
||||
return;
|
||||
}
|
||||
@ -64,7 +70,7 @@ class ActivityReportActions
|
||||
__('A new feed named "%s" point to "%s" was added by "%s"'),
|
||||
'zoneclearFeedServerAfterAddFeed',
|
||||
function (Cursor $cur, int $id): void {
|
||||
$user = dcCore::app()->auth->getInfo('user_cn');
|
||||
$user = App::auth()->getInfo('user_cn');
|
||||
if (!is_string($user)
|
||||
|| !is_string($cur->getField('feed_name'))
|
||||
|| !is_string($cur->getField('feed_feed'))
|
||||
@ -115,7 +121,7 @@ class ActivityReportActions
|
||||
}
|
||||
$row = new FeedRow($rs);
|
||||
|
||||
$user = dcCore::app()->auth->getInfo('user_cn');
|
||||
$user = App::auth()->getInfo('user_cn');
|
||||
if (!is_string($user)) {
|
||||
return;
|
||||
}
|
||||
@ -145,5 +151,7 @@ class ActivityReportActions
|
||||
));
|
||||
|
||||
ActivityReport::instance()->groups->add($group);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Backend prepend.
|
||||
* @brief zoneclearFeedServer backend class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
@ -34,19 +28,17 @@ class Backend extends Process
|
||||
}
|
||||
|
||||
// behaviors that will be always loaded
|
||||
dcCore::app()->addBehaviors([
|
||||
App::behavior()->addBehaviors([
|
||||
// Allways take care to delete related info about feed post in meta table
|
||||
'adminBeforePostDelete' => function (int $post_id): void {
|
||||
ZoneclearFeedServer::instance()::deletePostsMeta($post_id);
|
||||
},
|
||||
// widgets registration
|
||||
'initWidgets' => [Widgets::class, 'init'],
|
||||
'initWidgets' => Widgets::init(...),
|
||||
// add Uninstaller cleaner for special direct action
|
||||
'UninstallerCleanersConstruct' => function ($uninstaller_stack) {
|
||||
UninstallCleaner::init($uninstaller_stack);
|
||||
},
|
||||
'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
|
||||
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
|
||||
]);
|
||||
|
||||
// not active
|
||||
@ -63,14 +55,14 @@ class Backend extends Process
|
||||
My::addBackendMenuItem();
|
||||
|
||||
// behaviors that require user perm
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'],
|
||||
'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
|
||||
'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
|
||||
'adminPostListHeaderV2' => [BackendBehaviors::class, 'adminPostListHeaderV2'],
|
||||
'adminPostListValueV2' => [BackendBehaviors::class, 'adminPostListValueV2'],
|
||||
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
|
||||
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
|
||||
App::behavior()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => BackendBehaviors::adminDashboardFavoritesV2(...),
|
||||
'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
|
||||
'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
|
||||
'adminPostListHeaderV2' => BackendBehaviors::adminPostListHeaderV2(...),
|
||||
'adminPostListValueV2' => BackendBehaviors::adminPostListValueV2(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
@ -1,232 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcSettings;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
Input,
|
||||
Label,
|
||||
Link,
|
||||
Number,
|
||||
Para,
|
||||
Select,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* Backend behaviors.
|
||||
* @brief zoneclearFeedServer backend behaviors class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class BackendBehaviors
|
||||
{
|
||||
/**
|
||||
* Module settings save.
|
||||
*
|
||||
* Used in blog settings and module config.
|
||||
*/
|
||||
public static function adminBeforeBlogSettingsUpdate(?dcSettings $blog_settings): void
|
||||
{
|
||||
// read settings
|
||||
$s = ZoneclearFeedServer::instance()->settings;
|
||||
|
||||
// write settings
|
||||
foreach ($s->dump() as $key => $value) {
|
||||
$s->set($key, $_POST[My::id() . $key] ?? $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module settings form.
|
||||
*
|
||||
* Used in blog settings and module config.
|
||||
*/
|
||||
public static function adminBlogPreferencesFormV2(?dcSettings $blog_settings): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$z = ZoneclearFeedServer::instance();
|
||||
$s = $z->settings;
|
||||
|
||||
$msg = [];
|
||||
if (!is_writable(DC_TPL_CACHE)) {
|
||||
$msg[] = (new Para())
|
||||
->class('error')
|
||||
->text(__('Dotclear cache is not writable or not well configured!'));
|
||||
}
|
||||
if ($s->pub_active) {
|
||||
$msg[] = (new Para())
|
||||
->items([
|
||||
(new Link())
|
||||
->class('onblog_link outgoing')
|
||||
->text(__('View the public list of feeds') . ' <img alt="" src="images/outgoing-link.svg">')
|
||||
->href(dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage')),
|
||||
]);
|
||||
}
|
||||
|
||||
$titles = [];
|
||||
foreach ($z->getPublicUrlTypes() as $k => $v) {
|
||||
$titles[] = (new Para(null, 'li'))
|
||||
->items([
|
||||
(new Checkbox([My::id() . 'post_title_redir[]', My::id() . 'post_title_redir_' . $v], in_array($v, $s->post_title_redir)))
|
||||
->value($v),
|
||||
(new Label(__($k), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'post_title_redir_' . $v),
|
||||
]);
|
||||
}
|
||||
|
||||
$contents = [];
|
||||
foreach ($z->getPublicUrlTypes() as $k => $v) {
|
||||
$contents[] = (new Para(null, 'li'))
|
||||
->items([
|
||||
(new Checkbox([My::id() . 'post_full_tpl_[]', My::id() . 'post_full_tpl_' . $v], in_array($v, $s->post_full_tpl)))
|
||||
->value($v),
|
||||
(new Label(__($k), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'post_full_tpl_' . $v),
|
||||
]);
|
||||
}
|
||||
|
||||
echo
|
||||
(new Div())->class('fieldset')
|
||||
->items([
|
||||
!is_null($blog_settings) ?
|
||||
(new Text('h4', My::name()))
|
||||
->id('disclaimerParam') :
|
||||
(new Text()),
|
||||
(new Div())
|
||||
->items($msg),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'active', $s->active))
|
||||
->value(1),
|
||||
(new Label(__('Enable plugin'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'active'),
|
||||
]),
|
||||
(new Div())
|
||||
->class('clear two-cols')
|
||||
->items([
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Status of new posts:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'post_status_new'),
|
||||
(new Select(My::id() . 'post_status_new'))
|
||||
->items(Combo::postsStatus())
|
||||
->default((string) $s->post_status_new),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Owner of entries created by the feed server:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'user'),
|
||||
(new Select(My::id() . 'user'))
|
||||
->items($z->getAllBlogAdmins())
|
||||
->default($s->user),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('How to transform imported tags:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'tag_case'),
|
||||
(new Select(My::id() . 'tag_case'))
|
||||
->items(Combo::tagCase())
|
||||
->default((string) $s->tag_case),
|
||||
]),
|
||||
]),
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Update feeds on public side:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'bhv_pub_upd'),
|
||||
(new Select(My::id() . 'bhv_pub_upd'))
|
||||
->items(Combo::pubUpdate())
|
||||
->default((string) $s->bhv_pub_upd),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Number of feeds to update at one time:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'update_limit'),
|
||||
(new Number(My::id() . 'update_limit'))
|
||||
->min(0)
|
||||
->max(20)
|
||||
->value($s->update_limit),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'keep_empty_feed', $s->keep_empty_feed))
|
||||
->value(1),
|
||||
(new Label(__('Keep active empty feeds'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'keep_empty_feed'),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'pub_active', $s->pub_active))
|
||||
->value(1),
|
||||
(new Label(__('Enable public page'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'pub_active'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
(new Div())
|
||||
->class('two-cols')
|
||||
->items([
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Text('p', __('Redirect to original post on:'))),
|
||||
(new Para(null, 'ul'))
|
||||
->items($titles),
|
||||
]),
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Text('p', __('Show full content on:'))),
|
||||
(new Para(null, 'ul'))
|
||||
->items($contents),
|
||||
]),
|
||||
]),
|
||||
(new Div())->class('clear')->items(
|
||||
!is_null($blog_settings) && $s->active ?
|
||||
[(new Para())
|
||||
->items([
|
||||
(new Link())
|
||||
->href(My::managerUrl())
|
||||
->text(__('Configure feeds')),
|
||||
])] :
|
||||
[],
|
||||
),
|
||||
(new Div())->class('clear'),
|
||||
])
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* User dashboard favorites icon.
|
||||
*/
|
||||
@ -237,9 +35,9 @@ class BackendBehaviors
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
'permissions' => App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_USAGE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
// update user dashboard favorites icon with nb of updated feeds
|
||||
'dashboard_cb' => function (ArrayObject $fav): void {
|
||||
@ -257,6 +55,8 @@ class BackendBehaviors
|
||||
|
||||
/**
|
||||
* Lists columns user preference.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $cols
|
||||
*/
|
||||
public static function adminColumnsListsV2(ArrayObject $cols): void
|
||||
{
|
||||
@ -285,6 +85,8 @@ class BackendBehaviors
|
||||
|
||||
/**
|
||||
* Lists filter.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $sorts
|
||||
*/
|
||||
public static function adminFiltersListsV2(ArrayObject $sorts): void
|
||||
{
|
||||
@ -308,18 +110,22 @@ class BackendBehaviors
|
||||
|
||||
/**
|
||||
* Add head column to posts list.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $cols
|
||||
*/
|
||||
public static function adminPostListHeaderV2(MetaRecord $rs, ArrayObject $cols): void
|
||||
{
|
||||
$cols['feed'] = (new Para(null, 'th'))->text(__('Feed'))->extra('scope="col"')->render();
|
||||
$cols['feed'] = (new Text('th', __('Feed')))->extra('scope="col"')->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add body column to posts list.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $cols
|
||||
*/
|
||||
public static function adminPostListValueV2(MetaRecord $rs, ArrayObject $cols): void
|
||||
{
|
||||
$rs_meta = dcCore::app()->meta->getMetadata(['post_id' => $rs->f('post_id'), 'meta_type' => My::META_PREFIX . 'id']);
|
||||
$rs_meta = App::meta()->getMetadata(['post_id' => $rs->f('post_id'), 'meta_type' => My::META_PREFIX . 'id']);
|
||||
if ($rs_meta->isEmpty()) {
|
||||
$item = (new Text('', '-'));
|
||||
} else {
|
||||
@ -342,11 +148,14 @@ class BackendBehaviors
|
||||
|
||||
/**
|
||||
* Add info about feed on post page sidebar.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $main_items
|
||||
* @param ArrayObject<string, mixed> $sidebar_items
|
||||
*/
|
||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -355,7 +164,7 @@ class BackendBehaviors
|
||||
return;
|
||||
}
|
||||
|
||||
$url = dcCore::app()->meta->getMetadata([
|
||||
$url = App::meta()->getMetadata([
|
||||
'post_id' => $post->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . 'url',
|
||||
'limit' => 1,
|
||||
@ -365,21 +174,21 @@ class BackendBehaviors
|
||||
return;
|
||||
}
|
||||
|
||||
$author = dcCore::app()->meta->getMetadata([
|
||||
$author = App::meta()->getMetadata([
|
||||
'post_id' => $post->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . 'author',
|
||||
'limit' => 1,
|
||||
]);
|
||||
$author = $author->isEmpty() ? '' : $author->f('meta_id');
|
||||
|
||||
$site = dcCore::app()->meta->getMetadata([
|
||||
$site = App::meta()->getMetadata([
|
||||
'post_id' => $post->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . 'site',
|
||||
'limit' => 1,
|
||||
]);
|
||||
$site = $site->isEmpty() ? '' : $site->f('meta_id');
|
||||
|
||||
$sitename = dcCore::app()->meta->getMetadata([
|
||||
$sitename = App::meta()->getMetadata([
|
||||
'post_id' => $post->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . 'sitename',
|
||||
'limit' => 1,
|
||||
@ -387,11 +196,11 @@ class BackendBehaviors
|
||||
$sitename = $sitename->isEmpty() ? '' : $sitename->f('meta_id');
|
||||
|
||||
$edit = (new Text('', ''));
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)
|
||||
if (App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id())
|
||||
) {
|
||||
$fid = dcCore::app()->meta->getMetadata([
|
||||
$fid = App::meta()->getMetadata([
|
||||
'post_id' => $post->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . 'id',
|
||||
'limit' => 1,
|
||||
|
@ -14,17 +14,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Various combo list.
|
||||
* @brief zoneclearFeedServer backend combo helper.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Combo
|
||||
{
|
||||
/**
|
||||
* @return array<string,string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function feedsSortby(): array
|
||||
{
|
||||
@ -38,7 +42,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function postsSortby(): array
|
||||
{
|
||||
@ -52,7 +56,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function feedsStatus(): array
|
||||
{
|
||||
@ -63,7 +67,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,int>
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function postsStatus(): array
|
||||
{
|
||||
@ -74,7 +78,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,int>
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function updateInterval(): array
|
||||
{
|
||||
@ -89,7 +93,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,int>
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function tagCase(): array
|
||||
{
|
||||
@ -102,7 +106,7 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,int>
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function pubUpdate(): array
|
||||
{
|
||||
@ -115,25 +119,24 @@ class Combo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function postCategories(): array
|
||||
{
|
||||
$combo = ['-' => ''];
|
||||
|
||||
try {
|
||||
$categories = dcCore::app()->blog?->getCategories(['post_type' => 'post']);
|
||||
if (!is_null($categories)) {
|
||||
while ($categories->fetch()) {
|
||||
$level = is_numeric($categories->f('level')) ? (int) $categories->f('level') : 1;
|
||||
$cat_title = is_string($categories->f('cat_title')) ? $categories->f('cat_title') : '';
|
||||
$cat_id = is_numeric($categories->f('cat_id')) ? (string) $categories->f('cat_id') : '';
|
||||
$categories = App::blog()->getCategories(['post_type' => 'post']);
|
||||
|
||||
$combo[
|
||||
str_repeat(' ', $level - 1) .
|
||||
'• ' . Html::escapeHTML($cat_title)
|
||||
] = $cat_id;
|
||||
}
|
||||
while ($categories->fetch()) {
|
||||
$level = is_numeric($categories->f('level')) ? (int) $categories->f('level') : 1;
|
||||
$cat_title = is_string($categories->f('cat_title')) ? $categories->f('cat_title') : '';
|
||||
$cat_id = is_numeric($categories->f('cat_id')) ? (string) $categories->f('cat_id') : '';
|
||||
|
||||
$combo[
|
||||
str_repeat(' ', $level - 1) .
|
||||
'• ' . Html::escapeHTML($cat_title)
|
||||
] = $cat_id;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
194
src/Config.php
194
src/Config.php
@ -14,17 +14,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
ModulesList,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
Label,
|
||||
Link,
|
||||
Number,
|
||||
Para,
|
||||
Select,
|
||||
Text
|
||||
};
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend module configuration.
|
||||
* @brief zoneclearFeedServer config class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Config extends Process
|
||||
{
|
||||
@ -45,18 +59,30 @@ class Config extends Process
|
||||
}
|
||||
|
||||
try {
|
||||
BackendBehaviors::adminBeforeBlogSettingsUpdate(null);
|
||||
// read settings
|
||||
$s = ZoneclearFeedServer::instance()->settings;
|
||||
|
||||
// write settings
|
||||
foreach ($s->dump() as $key => $value) {
|
||||
if (is_array($value) && empty($_POST[My::id() . $key])) {
|
||||
$s->set($key, []);
|
||||
} elseif (is_bool($value)) {
|
||||
$s->set($key, !empty($_POST[My::id() . $key]));
|
||||
} else {
|
||||
$s->set($key, $_POST[My::id() . $key] ?: $value);
|
||||
}
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
dcCore::app()->admin->url->redirect('admin.plugins', [
|
||||
App::backend()->url()->redirect('admin.plugins', [
|
||||
'module' => My::id(),
|
||||
'conf' => '1',
|
||||
'redir' => !(dcCore::app()->admin->__get('list') instanceof ModulesList) ? '' : dcCore::app()->admin->__get('list')->getRedir(),
|
||||
'redir' => !(App::backend()->__get('list') instanceof ModulesList) ? '' : App::backend()->__get('list')->getRedir(),
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -68,7 +94,161 @@ class Config extends Process
|
||||
return;
|
||||
}
|
||||
|
||||
BackendBehaviors::adminBlogPreferencesFormV2(null);
|
||||
$z = ZoneclearFeedServer::instance();
|
||||
$s = $z->settings;
|
||||
|
||||
$msg = [];
|
||||
if (!is_writable(App::config()->cacheRoot())) {
|
||||
$msg[] = (new Text('p', __('Dotclear cache is not writable or not well configured!')))
|
||||
->class('error');
|
||||
}
|
||||
if ($s->pub_active) {
|
||||
$msg[] = (new Para())
|
||||
->items([
|
||||
(new Link())
|
||||
->class('onblog_link outgoing')
|
||||
->text(__('View the public list of feeds') . ' <img alt="" src="images/outgoing-link.svg">')
|
||||
->href(App::blog()->url() . App::url()->getBase('zoneclearFeedsPage')),
|
||||
]);
|
||||
}
|
||||
|
||||
$titles = [];
|
||||
foreach ($z->getPublicUrlTypes() as $k => $v) {
|
||||
$titles[] = (new Para(null, 'li'))
|
||||
->items([
|
||||
(new Checkbox([My::id() . 'post_title_redir[]', My::id() . 'post_title_redir_' . $v], in_array($v, $s->post_title_redir)))
|
||||
->value($v),
|
||||
(new Label(__($k), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'post_title_redir_' . $v),
|
||||
]);
|
||||
}
|
||||
|
||||
$contents = [];
|
||||
foreach ($z->getPublicUrlTypes() as $k => $v) {
|
||||
$contents[] = (new Para(null, 'li'))
|
||||
->items([
|
||||
(new Checkbox([My::id() . 'post_full_tpl[]', My::id() . 'post_full_tpl_' . $v], in_array($v, $s->post_full_tpl)))
|
||||
->value($v),
|
||||
(new Label(__($k), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'post_full_tpl_' . $v),
|
||||
]);
|
||||
}
|
||||
|
||||
echo
|
||||
(new Div())
|
||||
->items([
|
||||
(new Div())
|
||||
->items($msg),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'active', $s->active))
|
||||
->value(1),
|
||||
(new Label(__('Enable plugin'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'active'),
|
||||
]),
|
||||
(new Div())
|
||||
->class('clear two-cols')
|
||||
->items([
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Status of new posts:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'post_status_new'),
|
||||
(new Select(My::id() . 'post_status_new'))
|
||||
->items(Combo::postsStatus())
|
||||
->default((string) $s->post_status_new),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Owner of entries created by the feed server:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'user'),
|
||||
(new Select(My::id() . 'user'))
|
||||
->items($z->getAllBlogAdmins())
|
||||
->default($s->user),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('How to transform imported tags:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'tag_case'),
|
||||
(new Select(My::id() . 'tag_case'))
|
||||
->items(Combo::tagCase())
|
||||
->default((string) $s->tag_case),
|
||||
]),
|
||||
]),
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Update feeds on public side:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'bhv_pub_upd'),
|
||||
(new Select(My::id() . 'bhv_pub_upd'))
|
||||
->items(Combo::pubUpdate())
|
||||
->default((string) $s->bhv_pub_upd),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Label(__('Number of feeds to update at one time:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for(My::id() . 'update_limit'),
|
||||
(new Number(My::id() . 'update_limit'))
|
||||
->min(0)
|
||||
->max(20)
|
||||
->value($s->update_limit),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'keep_empty_feed', $s->keep_empty_feed))
|
||||
->value(1),
|
||||
(new Label(__('Keep active empty feeds'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'keep_empty_feed'),
|
||||
]),
|
||||
(new Para())
|
||||
->items([
|
||||
(new Checkbox(My::id() . 'pub_active', $s->pub_active))
|
||||
->value(1),
|
||||
(new Label(__('Enable public page'), Label::OUTSIDE_LABEL_AFTER))
|
||||
->class('classic')
|
||||
->for(My::id() . 'pub_active'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
(new Div())
|
||||
->class('two-cols')
|
||||
->items([
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Text('p', __('Redirect to original post on:'))),
|
||||
(new Para(null, 'ul'))
|
||||
->items($titles),
|
||||
]),
|
||||
(new Div())
|
||||
->class('fieldset col')
|
||||
->items([
|
||||
(new Text('p', __('Show full content on:'))),
|
||||
(new Para(null, 'ul'))
|
||||
->items($contents),
|
||||
]),
|
||||
]),
|
||||
(new Div())->class('clear')->items(
|
||||
$s->active ?
|
||||
[(new Para())
|
||||
->items([
|
||||
(new Link())
|
||||
->href(My::manageUrl())
|
||||
->text(__('Configure feeds')),
|
||||
])] :
|
||||
[],
|
||||
),
|
||||
(new Div())->class('clear'),
|
||||
])
|
||||
->render();
|
||||
|
||||
Page::helpBlock('zoneclearFeedServer');
|
||||
}
|
||||
|
@ -17,7 +17,11 @@ namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
|
||||
/**
|
||||
* Feed meta record row type hinting.
|
||||
* @brief zoneclearFeedServer feed meta record row.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FeedRow
|
||||
{
|
||||
|
@ -1,21 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Action\Actions;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
@ -27,7 +17,11 @@ use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend feeds list actions handler.
|
||||
* @brief zoneclearFeedServer feeds list actions.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FeedsActions extends Actions
|
||||
{
|
||||
@ -56,7 +50,7 @@ class FeedsActions extends Actions
|
||||
FeedsDefaultActions::addDefaultFeedsActions($this);
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAddFeedsActions - FeedsActions
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAddFeedsActions', $this);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerAddFeedsActions', $this);
|
||||
}
|
||||
|
||||
public function beginPage(string $breadcrumb = '', string $head = ''): void
|
||||
@ -83,12 +77,12 @@ class FeedsActions extends Actions
|
||||
|
||||
public function error(Exception $e): void
|
||||
{
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
$this->beginPage(
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
||||
$this->getCallerTitle() => $this->getRedirection(true),
|
||||
__('Feeds actions') => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
$this->getCallerTitle() => $this->getRedirection(true),
|
||||
__('Feeds actions') => '',
|
||||
])
|
||||
);
|
||||
$this->endPage();
|
||||
@ -103,8 +97,8 @@ class FeedsActions extends Actions
|
||||
|
||||
$feeds = ZoneclearFeedServer::instance()->getFeeds($params);
|
||||
while ($feeds->fetch()) {
|
||||
$row = new FeedRow($feeds);
|
||||
$this->entries[$row->id] = $row->name;
|
||||
$row = new FeedRow($feeds);
|
||||
$this->entries[(string) $row->id] = $row->name;
|
||||
}
|
||||
$this->rs = $feeds;
|
||||
} else {
|
||||
|
@ -1,22 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcMeta;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
@ -35,7 +24,11 @@ use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend feeds list default actions.
|
||||
* @brief zoneclearFeedServer feeds list default actions.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FeedsDefaultActions
|
||||
{
|
||||
@ -46,40 +39,42 @@ class FeedsDefaultActions
|
||||
{
|
||||
$ap->addAction(
|
||||
[__('Change category') => 'changecat'],
|
||||
[self::class, 'doChangeCategory']
|
||||
self::doChangeCategory(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Change update interval') => 'changeint'],
|
||||
[self::class, 'doChangeInterval']
|
||||
self::doChangeInterval(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Disable feed update') => 'disablefeed'],
|
||||
[self::class, 'doEnableFeed']
|
||||
self::doEnableFeed(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Enable feed update') => 'enablefeed'],
|
||||
[self::class, 'doEnableFeed']
|
||||
self::doEnableFeed(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Reset last update') => 'resetupdlast'],
|
||||
[self::class, 'doResetUpdate']
|
||||
self::doResetUpdate(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Update (check) feed') => 'updatefeed'],
|
||||
[self::class, 'doUpdateFeed']
|
||||
self::doUpdateFeed(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Delete related posts') => 'deletepost'],
|
||||
[self::class, 'doDeletePost']
|
||||
self::doDeletePost(...)
|
||||
);
|
||||
$ap->addAction(
|
||||
[__('Delete feed (without related posts)') => 'deletefeed'],
|
||||
[self::class, 'doDeleteFeed']
|
||||
self::doDeleteFeed(...)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable / disable feeds.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doEnableFeed(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -93,7 +88,7 @@ class FeedsDefaultActions
|
||||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$ap->zcfs->enableFeed($id, $enable);
|
||||
$ap->zcfs->enableFeed((int) $id, $enable);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(sprintf(
|
||||
@ -116,6 +111,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Delete feeds posts.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doDeletePost(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -142,10 +139,10 @@ class FeedsDefaultActions
|
||||
|
||||
while ($posts->fetch()) {
|
||||
if (is_numeric($posts->f('post_id'))) {
|
||||
dcCore::app()->blog?->delPost((int) $posts->f('post_id'));
|
||||
App::blog()->delPost((int) $posts->f('post_id'));
|
||||
$sql = new DeleteStatement();
|
||||
$sql
|
||||
->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
->where('post_id = ' . $posts->f('post_id'))
|
||||
->and('meta_type ' . $sql->in($types))
|
||||
->delete();
|
||||
@ -161,6 +158,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Delete feeds.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doDeleteFeed(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -173,7 +172,7 @@ class FeedsDefaultActions
|
||||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$ap->zcfs->deleteFeed($id);
|
||||
$ap->zcfs->deleteFeed((int) $id);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(sprintf(
|
||||
@ -189,6 +188,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Update feeds properties.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doUpdateFeed(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -201,7 +202,7 @@ class FeedsDefaultActions
|
||||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$ap->zcfs->checkFeedsUpdate($id, true);
|
||||
$ap->zcfs->checkFeedsUpdate((int) $id, true);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(sprintf(
|
||||
@ -213,6 +214,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Reset feeds update timer.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doResetUpdate(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -228,7 +231,7 @@ class FeedsDefaultActions
|
||||
foreach ($ids as $id) {
|
||||
$cur->clean();
|
||||
$cur->setField('feed_upd_last', 0);
|
||||
$ap->zcfs->updateFeed($id, $cur);
|
||||
$ap->zcfs->updateFeed((int) $id, $cur);
|
||||
//$ap->zcfs->checkFeedsUpdate($id, true);
|
||||
}
|
||||
|
||||
@ -241,6 +244,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Change feeds categories.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doChangeCategory(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -259,7 +264,7 @@ class FeedsDefaultActions
|
||||
foreach ($ids as $id) {
|
||||
$cur->clean();
|
||||
$cur->setField('cat_id', $cat_id == 0 ? null : $cat_id);
|
||||
$ap->zcfs->updateFeed($id, $cur);
|
||||
$ap->zcfs->updateFeed((int) $id, $cur);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(sprintf(
|
||||
@ -270,10 +275,10 @@ class FeedsDefaultActions
|
||||
} else {
|
||||
$ap->beginPage(
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change category for this selection') => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change category for this selection') => '',
|
||||
])
|
||||
);
|
||||
|
||||
@ -294,7 +299,7 @@ class FeedsDefaultActions
|
||||
(new Submit('do-action'))
|
||||
->value(__('Save')),
|
||||
(new Hidden(['action'], 'changecat')),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]
|
||||
)),
|
||||
|
||||
@ -307,6 +312,8 @@ class FeedsDefaultActions
|
||||
|
||||
/**
|
||||
* Change feeds update interval.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $post
|
||||
*/
|
||||
public static function doChangeInterval(FeedsActions $ap, ArrayObject $post): void
|
||||
{
|
||||
@ -325,7 +332,7 @@ class FeedsDefaultActions
|
||||
foreach ($ids as $id) {
|
||||
$cur->clean();
|
||||
$cur->setField('feed_upd_int', $upd_int);
|
||||
$ap->zcfs->updateFeed($id, $cur);
|
||||
$ap->zcfs->updateFeed((int) $id, $cur);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(sprintf(
|
||||
@ -337,10 +344,10 @@ class FeedsDefaultActions
|
||||
$ap->beginPage(
|
||||
Page::breadcrumb(
|
||||
[
|
||||
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change update frequency for this selection') => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change update frequency for this selection') => '',
|
||||
]
|
||||
)
|
||||
);
|
||||
@ -362,7 +369,7 @@ class FeedsDefaultActions
|
||||
(new Submit('do-action'))
|
||||
->value(__('Save')),
|
||||
(new Hidden(['action'], 'changeint')),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]
|
||||
)),
|
||||
|
||||
|
@ -1,21 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Filter\Filters;
|
||||
use Dotclear\Core\Backend\Listing\{
|
||||
Listing,
|
||||
@ -32,7 +22,11 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* Backend feeds list.
|
||||
* @brief zoneclearFeedServer backend feeds list.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FeedsList extends Listing
|
||||
{
|
||||
@ -126,7 +120,7 @@ class FeedsList extends Listing
|
||||
if (!is_string($url)) {
|
||||
$url = '';
|
||||
}
|
||||
$tz = dcCore::app()->auth->getInfo('user_tz');
|
||||
$tz = App::auth()->getInfo('user_tz');
|
||||
if (!is_string($tz)) {
|
||||
$tz = 'UTC';
|
||||
}
|
||||
|
@ -1,28 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use dcUtils;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Frontend prepend.
|
||||
* @brief zoneclearFeedServer frontend class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
@ -39,7 +32,7 @@ class Frontend extends Process
|
||||
|
||||
$s = ZoneclearFeedServer::instance()->settings;
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
App::behavior()->addBehaviors([
|
||||
// posts record
|
||||
'coreBlogGetPosts' => function (MetaRecord $rs): void {
|
||||
RsExtPosts::$brother_extensions = $rs->extensions();
|
||||
@ -50,17 +43,17 @@ class Frontend extends Process
|
||||
return $context == 'zoneclearFeedsPage' ? __('List of feeds') : '';
|
||||
},
|
||||
// widgets registration
|
||||
'initWidgets' => [Widgets::class, 'init'],
|
||||
'initWidgets' => Widgets::init(...),
|
||||
]);
|
||||
|
||||
// Register template blocks
|
||||
foreach (My::TPL_BLOCKS as $block) {
|
||||
dcCore::app()->tpl->addBlock('zc' . $block, [Template::class, $block]);
|
||||
App::frontend()->template()->addBlock('zc' . $block, [Template::class, $block]);
|
||||
}
|
||||
|
||||
// Register template values
|
||||
foreach (My::TPL_VALUES as $value) {
|
||||
dcCore::app()->tpl->addValue('zc' . $value, [Template::class, $value]);
|
||||
App::frontend()->template()->addValue('zc' . $value, [Template::class, $value]);
|
||||
}
|
||||
|
||||
// module not active
|
||||
@ -70,8 +63,8 @@ class Frontend extends Process
|
||||
|
||||
// feeds update methods
|
||||
if (1 == $s->bhv_pub_upd) {
|
||||
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
|
||||
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
|
||||
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
|
||||
if (in_array(App::url()->type, ['default', 'feed'])) {
|
||||
try {
|
||||
ZoneclearFeedServer::instance()->checkFeedsUpdate();
|
||||
} catch (Exception $e) {
|
||||
@ -79,28 +72,28 @@ class Frontend extends Process
|
||||
};
|
||||
});
|
||||
} elseif (2 == $s->bhv_pub_upd) {
|
||||
dcCore::app()->addBehavior('publicAfterDocumentV2', function (): void {
|
||||
App::behavior()->addBehavior('publicAfterDocumentV2', function (): void {
|
||||
try {
|
||||
ZoneclearFeedServer::instance()->checkFeedsUpdate();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
});
|
||||
} elseif (3 == $s->bhv_pub_upd) {
|
||||
dcCore::app()->addBehavior('publicHeadContent', function (): void {
|
||||
if (is_null(dcCore::app()->blog) || dcCore::app()->url->type != 'default') {
|
||||
App::behavior()->addBehavior('publicHeadContent', function (): void {
|
||||
if (!App::blog()->isDefined() || App::url()->type != 'default') {
|
||||
return;
|
||||
}
|
||||
|
||||
$blog_url = Html::escapeJS(
|
||||
dcCore::app()->blog->url .
|
||||
dcCore::app()->url->getBase('zoneclearFeedsPage') .
|
||||
App::blog()->url() .
|
||||
App::url()->getBase('zoneclearFeedsPage') .
|
||||
'/zcfsupd'
|
||||
);
|
||||
$blog_id = Html::escapeJS(dcCore::app()->blog->id);
|
||||
$blog_id = Html::escapeJS(App::blog()->id());
|
||||
|
||||
echo
|
||||
"\n<!-- JS for zoneclearFeedServer --> \n" .
|
||||
dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
|
||||
App::plugins()->jsLoad(App::blog()->url() . App::url()->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
|
||||
"<script type=\"text/javascript\"> \n//<![CDATA[\n" .
|
||||
' $(function(){if(!document.getElementById){return;} ' .
|
||||
" $('body').zoneclearFeedServer({blog_url:'" .
|
||||
|
@ -1,26 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Module installation.
|
||||
* @brief zoneclearFeedServer install class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
@ -40,7 +34,7 @@ class Install extends Process
|
||||
Upgrade::preUpgrade();
|
||||
|
||||
// Tables
|
||||
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s = new Structure(App::con(), App::con()->prefix());
|
||||
$s->__get(My::TABLE_NAME)
|
||||
->field('feed_id', 'bigint', 0, false)
|
||||
->field('feed_creadt', 'timestamp', 0, false, 'now()')
|
||||
@ -67,7 +61,7 @@ class Install extends Process
|
||||
->index('idx_zcfs_type', 'btree', 'feed_type')
|
||||
->index('idx_zcfs_blog', 'btree', 'blog_id');
|
||||
|
||||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
(new Structure(App::con(), App::con()->prefix()))->synchronize($s);
|
||||
|
||||
// Settings
|
||||
$s = My::settings();
|
||||
@ -84,7 +78,7 @@ class Install extends Process
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1,20 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filters,
|
||||
FiltersLibrary
|
||||
@ -37,7 +27,11 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend feeds list manage page.
|
||||
* @brief zoneclearFeedServer backend feeds manage class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
@ -64,7 +58,7 @@ class Manage extends Process
|
||||
|
||||
// not configured
|
||||
if (!$s->active || !$s->user) {
|
||||
dcCore::app()->error->add(__('Module is not wel configured'));
|
||||
App::error()->add(__('Module is not wel configured'));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -131,13 +125,13 @@ class Manage extends Process
|
||||
$feeds_counter = $z->getFeeds($params, true)->f(0);
|
||||
$feeds_list = new FeedsList($feeds, $feeds_counter);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
Page::openModule(
|
||||
My::id(),
|
||||
(
|
||||
isset($feeds_list) && !dcCore::app()->error->flag() ?
|
||||
isset($feeds_list) && !App::error()->flag() ?
|
||||
$feeds_filter->js(My::manageUrl(['part' => 'feeds'], '&')) .
|
||||
My::jsLoad('feeds')
|
||||
: ''
|
||||
@ -188,7 +182,7 @@ class Manage extends Process
|
||||
(new Label(__('Selected feeds action:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for('action'),
|
||||
(new Select('action'))
|
||||
->items($feeds_actions_page->getCombo()),
|
||||
->items($feeds_actions_page->getCombo() ?? []),
|
||||
(new Submit('feeds-action'))
|
||||
->value(__('ok')),
|
||||
... My::hiddenFields($feeds_filter->values(true)),
|
||||
|
@ -1,20 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
@ -38,7 +28,11 @@ use Dotclear\Helper\L10n;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend feed and feed posts manage page.
|
||||
* @brief zoneclearFeedServer backend feeds posts manage class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ManageFeed extends Process
|
||||
{
|
||||
@ -70,26 +64,26 @@ class ManageFeed extends Process
|
||||
$testfeed_params['sql'] = 'AND feed_id <> ' . $v->id . ' ';
|
||||
}
|
||||
if ($z->getFeeds($testfeed_params, true)->f(0)) {
|
||||
dcCore::app()->error->add(__('Record with same feed URL already exists.'));
|
||||
App::error()->add(__('Record with same feed URL already exists.'));
|
||||
}
|
||||
if (empty($v->name)) {
|
||||
dcCore::app()->error->add(__('You must provide a name.'));
|
||||
App::error()->add(__('You must provide a name.'));
|
||||
}
|
||||
if (empty($v->owner)) {
|
||||
dcCore::app()->error->add(__('You must provide an owner.'));
|
||||
App::error()->add(__('You must provide an owner.'));
|
||||
}
|
||||
if (!$z::validateURL($v->url)) {
|
||||
dcCore::app()->error->add(__('You must provide valid site URL.'));
|
||||
App::error()->add(__('You must provide valid site URL.'));
|
||||
}
|
||||
if (!$z::validateURL($v->feed)) {
|
||||
dcCore::app()->error->add(__('You must provide valid feed URL.'));
|
||||
App::error()->add(__('You must provide valid feed URL.'));
|
||||
}
|
||||
if (null !== $v->cat_id && !dcCore::app()->blog?->getCategory($v->cat_id)) {
|
||||
dcCore::app()->error->add(__('You must provide valid category.'));
|
||||
if (null !== $v->cat_id && !App::blog()->getCategory($v->cat_id)) {
|
||||
App::error()->add(__('You must provide valid category.'));
|
||||
}
|
||||
|
||||
// check failed
|
||||
if (dcCore::app()->error->flag()) {
|
||||
if (App::error()->flag()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -103,7 +97,7 @@ class ManageFeed extends Process
|
||||
Notices::addSuccessNotice(__('Feed successfully created.'));
|
||||
My::redirect(['part' => 'feed', 'feed_id' => $id]);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -158,13 +152,13 @@ class ManageFeed extends Process
|
||||
'user_id' => 'P.user_id', ];
|
||||
|
||||
# --BEHAVIOR-- adminPostsSortbyLexCombo
|
||||
dcCore::app()->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]);
|
||||
App::behavior()->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]);
|
||||
|
||||
$params['no_content'] = true;
|
||||
$params['feed_id'] = $v->id;
|
||||
$params['order'] = (
|
||||
array_key_exists($sortby, $sortby_lex) ?
|
||||
dcCore::app()->con->lexFields($sortby_lex[$sortby]) :
|
||||
App::con()->lexFields($sortby_lex[$sortby]) :
|
||||
$sortby
|
||||
) . ' ' . $order;
|
||||
|
||||
@ -174,7 +168,7 @@ class ManageFeed extends Process
|
||||
$counter = $z->getPostsByFeed($params, true);
|
||||
$post_list = new PostsList($posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +176,7 @@ class ManageFeed extends Process
|
||||
Page::openModule(
|
||||
My::id(),
|
||||
(
|
||||
$v->id && isset($post_filter) && !dcCore::app()->error->flag() ?
|
||||
$v->id && isset($post_filter) && !App::error()->flag() ?
|
||||
$post_filter->js(My::manageUrl(['part' => 'feed', 'feed_id' => $v->id], '&') . '#entries') .
|
||||
My::jsLoad('feed')
|
||||
: ''
|
||||
@ -241,7 +235,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_name'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->name),
|
||||
]),
|
||||
// feed_owner
|
||||
@ -253,7 +247,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_owner'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->owner),
|
||||
]),
|
||||
// feed_url
|
||||
@ -265,7 +259,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_url'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->url),
|
||||
]),
|
||||
// feed_feed
|
||||
@ -277,7 +271,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_feed'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->feed),
|
||||
]),
|
||||
// feed_desc
|
||||
@ -288,7 +282,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_desc'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->desc),
|
||||
]),
|
||||
// feed_tags
|
||||
@ -299,7 +293,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_tags'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->tags),
|
||||
]),
|
||||
// feed_tweeter
|
||||
@ -310,7 +304,7 @@ class ManageFeed extends Process
|
||||
(new Input('feed_tweeter'))
|
||||
->class('maximal')
|
||||
->size(60)
|
||||
->maxlenght(255)
|
||||
->maxlength(255)
|
||||
->value($v->tweeter),
|
||||
]),
|
||||
]),
|
||||
@ -385,7 +379,7 @@ class ManageFeed extends Process
|
||||
->render();
|
||||
}
|
||||
|
||||
if ($v->id && $v->can_view_page && isset($post_filter) && isset($post_list) && isset($posts_actions_page) && !dcCore::app()->error->flag()) {
|
||||
if ($v->id && $v->can_view_page && isset($post_filter) && isset($post_list) && isset($posts_actions_page) && !App::error()->flag()) {
|
||||
echo '<div class="multi-part" title="' . __('Entries') . '" id="entries">';
|
||||
|
||||
# show posts filters
|
||||
@ -423,7 +417,7 @@ class ManageFeed extends Process
|
||||
(new Label(__('Selected entries action:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||
->for('action'),
|
||||
(new Select('action'))
|
||||
->items($posts_actions_page->getCombo()),
|
||||
->items($posts_actions_page->getCombo() ?? []),
|
||||
(new Submit('feed-action'))
|
||||
->value(__('ok')),
|
||||
... My::hiddenFields($post_filter->values()),
|
||||
|
@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* Backend feed manage page vars (type hinting).
|
||||
* @brief zoneclearFeedServer backend vars definition.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ManageFeedVars
|
||||
{
|
||||
@ -52,9 +46,9 @@ class ManageFeedVars
|
||||
{
|
||||
$z = ZoneclearFeedServer::instance();
|
||||
|
||||
$feed_headlink = '<link rel="%s" title="%s" href="' . dcCore::app()->admin->getPageURL() . '&part=feed&feed_id=%s" />';
|
||||
$feed_link = '<a href="' . dcCore::app()->admin->getPageURL() . '&part=feed&feed_id=%s" title="%s">%s</a>';
|
||||
$lang = dcCore::app()->auth->getInfo('user_lang');
|
||||
$feed_headlink = '<link rel="%s" title="%s" href="' . App::backend()->getPageURL() . '&part=feed&feed_id=%s" />';
|
||||
$feed_link = '<a href="' . App::backend()->getPageURL() . '&part=feed&feed_id=%s" title="%s">%s</a>';
|
||||
$lang = App::auth()->getInfo('user_lang');
|
||||
|
||||
// default values
|
||||
$feed_id = 0;
|
||||
@ -82,7 +76,7 @@ class ManageFeedVars
|
||||
$feed = $z->getFeeds(['feed_id' => $_REQUEST['feed_id']]);
|
||||
|
||||
if ($feed->isEmpty()) {
|
||||
dcCore::app()->error->add(__('This feed does not exist.'));
|
||||
App::error()->add(__('This feed does not exist.'));
|
||||
$can_view_page = false;
|
||||
} else {
|
||||
$row = new FeedRow($feed);
|
||||
@ -156,7 +150,7 @@ class ManageFeedVars
|
||||
$feed_feed = !empty($_POST['feed_feed']) && is_string($_POST['feed_feed']) ? $_POST['feed_feed'] : $feed_feed;
|
||||
$feed_lang = !empty($_POST['feed_lang']) && is_string($_POST['feed_lang']) ? $_POST['feed_lang'] : $feed_lang;
|
||||
$feed_tags = !empty($_POST['feed_tags']) && is_string($_POST['feed_tags']) ? $_POST['feed_tags'] : $feed_tags;
|
||||
$feed_get_tags = empty($_POST['feed_get_tags']) ? $feed_get_tags : true;
|
||||
$feed_get_tags = !empty($_POST['feed_get_tags']);
|
||||
$feed_cat_id = !empty($_POST['feed_cat_id']) && is_numeric($_POST['feed_cat_id']) ? (int) $_POST['feed_cat_id'] : $feed_cat_id;
|
||||
$feed_upd_int = !empty($_POST['feed_upd_int']) && is_numeric($_POST['feed_upd_int']) ? (int) $_POST['feed_upd_int'] : $feed_upd_int;
|
||||
$feed_status = empty($_POST['feed_status']) ? $feed_status : 1;
|
||||
@ -172,7 +166,7 @@ class ManageFeedVars
|
||||
$this->feed = $feed_feed;
|
||||
$this->lang = $feed_lang;
|
||||
$this->tags = $feed_tags;
|
||||
$this->get_tags = $feed_get_tags;
|
||||
$this->get_tags = (bool) $feed_get_tags;
|
||||
$this->cat_id = $feed_cat_id;
|
||||
$this->status = $feed_status;
|
||||
$this->upd_int = $feed_upd_int;
|
||||
@ -218,13 +212,13 @@ class ManageFeedVars
|
||||
$cur->setField('feed_feed', $this->feed);
|
||||
$cur->setField('feed_lang', $this->lang);
|
||||
$cur->setField('feed_tags', $this->tags);
|
||||
$cur->setField('feed_get_tags', $this->get_tags);
|
||||
$cur->setField('feed_get_tags', (int) $this->get_tags);
|
||||
$cur->setField('cat_id', $this->cat_id);
|
||||
$cur->setField('feed_status', $this->status);
|
||||
$cur->setField('feed_upd_int', $this->upd_int);
|
||||
|
||||
# --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedSave - Cursor, int
|
||||
dcCore::app()->callBehavior('adminBeforeZoneclearFeedServerFeedSave', $cur, $id);
|
||||
App::behavior()->callBehavior('adminBeforeZoneclearFeedServerFeedSave', $cur, $id);
|
||||
|
||||
if (!$id) {
|
||||
// create feed
|
||||
@ -235,7 +229,7 @@ class ManageFeedVars
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- adminAfterZoneclearFeedServerFeedSave - Cursor - int
|
||||
dcCore::app()->callBehavior('adminAfterZoneclearFeedServerFeedSave', $cur, $id);
|
||||
App::behavior()->callBehavior('adminAfterZoneclearFeedServerFeedSave', $cur, $id);
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
49
src/My.php
49
src/My.php
@ -1,15 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
@ -17,17 +7,33 @@ namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief zoneclearFeedServer My helper.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string This module database table name */
|
||||
public const TABLE_NAME = \initZoneclearFeedServer::TABLE_NAME;
|
||||
/**
|
||||
* This module database table name.
|
||||
*
|
||||
* @var string TABLE_NAME
|
||||
*/
|
||||
public const TABLE_NAME = 'zc_feed';
|
||||
|
||||
/** @var string This module meta prefix */
|
||||
/**
|
||||
* This module meta prefix.
|
||||
*
|
||||
* @var string META_PREFIX
|
||||
*/
|
||||
public const META_PREFIX = 'zoneclearfeed_';
|
||||
|
||||
/** @var array<int,string> This module template blocks */
|
||||
/**
|
||||
* This module template blocks.
|
||||
*
|
||||
* @var array<int,string> TPL_BLOCKS
|
||||
*/
|
||||
public const TPL_BLOCKS = [
|
||||
'Feeds',
|
||||
'FeedsFooter',
|
||||
@ -35,7 +41,11 @@ class My extends MyPlugin
|
||||
'FeedIf',
|
||||
];
|
||||
|
||||
/** @var array<int,string> This module template values */
|
||||
/**
|
||||
* This module template values.
|
||||
*
|
||||
* @var array<int,string> TPL_VALUES
|
||||
*/
|
||||
public const TPL_VALUES = [
|
||||
'FeedsCount',
|
||||
'FeedsEntriesCount',
|
||||
@ -55,8 +65,5 @@ class My extends MyPlugin
|
||||
'FeedFeedURL',
|
||||
];
|
||||
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return $context == My::BACKEND ? defined('DC_CONTEXT_ADMIN') : null;
|
||||
}
|
||||
// Use default permissions
|
||||
}
|
||||
|
@ -1,22 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcUtils;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Combos;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filter,
|
||||
@ -27,7 +16,11 @@ use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend feed posts list filters.
|
||||
* @brief zoneclearFeedServer backend feeds posts list filter.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class PostsFilter extends Filters
|
||||
{
|
||||
@ -45,7 +38,7 @@ class PostsFilter extends Filters
|
||||
]);
|
||||
|
||||
# --BEHAVIOR-- zcfsPostFilter
|
||||
dcCore::app()->callBehavior('zcfsPostFilter', $filters);
|
||||
App::behavior()->callBehavior('zcfsPostFilter', $filters);
|
||||
|
||||
$filters = $filters->getArrayCopy();
|
||||
|
||||
@ -62,18 +55,18 @@ class PostsFilter extends Filters
|
||||
$users = null;
|
||||
|
||||
try {
|
||||
$users = dcCore::app()->blog?->getPostsUsers();
|
||||
if (is_null($users) || $users->isEmpty()) {
|
||||
$users = App::blog()->getPostsUsers();
|
||||
if ($users->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$combo = Combos::getUsersCombo($users);
|
||||
dcUtils::lexicalKeySort($combo);
|
||||
App::lexical()->lexicalKeySort($combo);
|
||||
|
||||
return (new Filter('user_id'))
|
||||
->param()
|
||||
@ -95,12 +88,12 @@ class PostsFilter extends Filters
|
||||
$categories = null;
|
||||
|
||||
try {
|
||||
$categories = dcCore::app()->blog?->getCategories();
|
||||
if (is_null($categories) || $categories->isEmpty()) {
|
||||
$categories = App::blog()->getCategories();
|
||||
if ($categories->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -149,12 +142,12 @@ class PostsFilter extends Filters
|
||||
$dates = null;
|
||||
|
||||
try {
|
||||
$dates = dcCore::app()->blog?->getDates(['type' => 'month']);
|
||||
if (is_null($dates) || $dates->isEmpty()) {
|
||||
$dates = App::blog()->getDates(['type' => 'month']);
|
||||
if ($dates->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -1,21 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Listing\{
|
||||
Listing,
|
||||
Pager
|
||||
@ -31,7 +21,11 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* Backend feed posts lists.
|
||||
* @brief zoneclearFeedServer backend feed posts lists.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class PostsList extends Listing
|
||||
{
|
||||
@ -108,7 +102,7 @@ class PostsList extends Listing
|
||||
{
|
||||
$cat_title = (new Text('', __('None')));
|
||||
if ($this->rs->cat_title
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CATEGORIES]), dcCore::app()->blog?->id)
|
||||
&& App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_CATEGORIES]), App::blog()->id())
|
||||
) {
|
||||
$cat_title = (new Link())
|
||||
->href('category.php?id=' . $this->rs->cat_id)
|
||||
@ -155,7 +149,7 @@ class PostsList extends Listing
|
||||
->class('maximal')
|
||||
->items([
|
||||
(new Link())
|
||||
->href(dcCore::app()->getPostAdminURL($this->rs->post_type, $this->rs->post_id))
|
||||
->href(App::postTypes()->getPostAdminURL($this->rs->post_type, $this->rs->post_id))
|
||||
->title(Html::escapeHTML($this->rs->getURL()))
|
||||
->text(Html::escapeHTML(trim(Html::clean($this->rs->post_title)))),
|
||||
]),
|
||||
|
@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Module prepend.
|
||||
* @brief zoneclearFeedServer prepend class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
@ -34,18 +28,13 @@ class Prepend extends Process
|
||||
}
|
||||
|
||||
// public url for page of description of the flux
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
'zoneclearFeedsPage',
|
||||
'zcfeeds',
|
||||
'^zcfeeds(.*?)$',
|
||||
[UrlHandler::class, 'zoneclearFeedsPage']
|
||||
UrlHandler::zoneclearFeedsPage(...)
|
||||
);
|
||||
|
||||
// report zoneclearFeedServer activities
|
||||
if (defined('ACTIVITY_REPORT') && ACTIVITY_REPORT == 3) {
|
||||
ActivityReportActions::init();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use context;
|
||||
use dcCore;
|
||||
use rsExtPost;
|
||||
use rsExtPostPublic;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Ctx;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Schema\Extension\Post;
|
||||
use Dotclear\Schema\Extension\PostPublic;
|
||||
|
||||
/**
|
||||
* @brief zoneclearFeedServer posts record extension.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* Posts record extension to integrate feed info.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class RsExtPosts extends rsExtPost
|
||||
class RsExtPosts extends Post
|
||||
{
|
||||
/** @var array<string,mixed> $brother_extensions Stack posts record extensions */
|
||||
public static array $brother_extensions = [];
|
||||
@ -39,7 +35,7 @@ class RsExtPosts extends rsExtPost
|
||||
*/
|
||||
public static function zcFeed(MetaRecord $rs, string $info): ?string
|
||||
{
|
||||
$meta = dcCore::app()->meta->getMetadata([
|
||||
$meta = App::meta()->getMetadata([
|
||||
'post_id' => $rs->f('post_id'),
|
||||
'meta_type' => My::META_PREFIX . $info,
|
||||
'limit' => 1,
|
||||
@ -61,10 +57,10 @@ class RsExtPosts extends rsExtPost
|
||||
$ext = static::$brother_extensions;
|
||||
if (isset($ext[$type]) && is_callable($ext[$type])) {
|
||||
$func = $ext[$type];
|
||||
} elseif (is_callable([rsExtPostPublic::class, $type])) {
|
||||
$func = [rsExtPostPublic::class, $type];
|
||||
} elseif (is_callable([rsExtPost::class, $type])) {
|
||||
$func = [rsExtPost::class, $type];
|
||||
} elseif (is_callable([PostPublic::class, $type])) {
|
||||
$func = [PostPublic::class, $type];
|
||||
} elseif (is_callable([Post::class, $type])) {
|
||||
$func = [Post::class, $type];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -118,7 +114,7 @@ class RsExtPosts extends rsExtPost
|
||||
{
|
||||
$url = $rs->__call('zcFeed', ['url']);
|
||||
$site = $rs->__call('zcFeed', ['site']);
|
||||
$full = in_array(dcCore::app()->url->type, ZoneclearFeedServer::instance()->settings->post_title_redir);
|
||||
$full = in_array(App::url()->type, ZoneclearFeedServer::instance()->settings->post_title_redir);
|
||||
|
||||
return is_string($site) && is_string($url) && $full ?
|
||||
ZoneclearFeedServer::instance()::absoluteURL($site, $url) :
|
||||
@ -129,7 +125,7 @@ class RsExtPosts extends rsExtPost
|
||||
* Get post content from post to feed.
|
||||
*
|
||||
* @param MetaRecord $rs The record instance
|
||||
* @param mixed $absolute_urls Serve absolute URL (type "mixed" from rsExtPost)
|
||||
* @param mixed $absolute_urls Serve absolute URL (type "mixed" from Post)
|
||||
*
|
||||
* @return string The post content
|
||||
*/
|
||||
@ -140,14 +136,14 @@ class RsExtPosts extends rsExtPost
|
||||
$content = self::zcFeedBrother('getContent', [&$rs, $absolute_urls]);
|
||||
|
||||
if (is_string($url) && is_string($sitename) && $rs->f('post_type') == 'post') {
|
||||
if (in_array(dcCore::app()->url->type, ZoneclearFeedServer::instance()->settings->post_full_tpl)) {
|
||||
if (in_array(App::url()->type, ZoneclearFeedServer::instance()->settings->post_full_tpl)) {
|
||||
return $content . sprintf(
|
||||
'<p class="zoneclear-original"><em>%s</em></p>',
|
||||
sprintf(__('Original post on <a href="%s">%s</a>'), $url, $sitename)
|
||||
);
|
||||
}
|
||||
$content = context::remove_html($content);
|
||||
$content = context::cut_string($content, 350);
|
||||
$content = Ctx::remove_html($content);
|
||||
$content = Ctx::cut_string($content, 350);
|
||||
$content = Html::escapeHTML($content);
|
||||
|
||||
return sprintf(
|
||||
|
@ -1,21 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
/**
|
||||
* Module settings (type hinting).
|
||||
* @brief zoneclearFeedServer settings.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Settings
|
||||
{
|
||||
@ -36,10 +30,10 @@ class Settings
|
||||
|
||||
public readonly int $tag_case;
|
||||
|
||||
/** @var array<int,string> */
|
||||
/** @var array<int, string> */
|
||||
public readonly array $post_full_tpl;
|
||||
|
||||
/** @var array<int,string> */
|
||||
/** @var array<int, string> */
|
||||
public readonly array $post_title_redir;
|
||||
|
||||
public readonly string $user;
|
||||
@ -96,9 +90,8 @@ class Settings
|
||||
{
|
||||
$s = My::settings();
|
||||
|
||||
if (!is_null($s) && property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
||||
$s->drop($key);
|
||||
$s->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
||||
$s->put($key, $value, gettype($this->{$key}));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
159
src/Template.php
159
src/Template.php
@ -1,30 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcTemplate;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Tpl;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\L10n;
|
||||
|
||||
/**
|
||||
* Frontend template blocks and values.
|
||||
* @brief zoneclearFeedServer frontend tempalte class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Template
|
||||
{
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function Feeds(ArrayObject $a, string $c): string
|
||||
{
|
||||
$lastn = -1;
|
||||
@ -82,67 +79,70 @@ class Template
|
||||
|
||||
return
|
||||
'<?php ' . $p .
|
||||
'dcCore::app()->ctx->feeds_params = $zcfs_params;' . "\n" .
|
||||
'App::frontend()->context()->feeds_params = $zcfs_params;' . "\n" .
|
||||
'$zcfs = ' . ZoneclearFeedServer::class . '::instance();' . "\n" .
|
||||
'dcCore::app()->ctx->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);' . "\n" .
|
||||
'App::frontend()->context()->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);' . "\n" .
|
||||
"?>\n" .
|
||||
'<?php while (dcCore::app()->ctx->feeds->fetch()) : ?>' . $c . '<?php endwhile; ' .
|
||||
'dcCore::app()->ctx->feeds = null; dcCore::app()->ctx->feeds_params = null; ?>';
|
||||
'<?php while (App::frontend()->context()->feeds->fetch()) : ?>' . $c . '<?php endwhile; ' .
|
||||
'App::frontend()->context()->feeds = null; App::frontend()->context()->feeds_params = null; ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedIf(ArrayObject $a, string $c): string
|
||||
{
|
||||
$if = [];
|
||||
|
||||
$operator = isset($a['operator']) && is_string($a['operator']) ? dcTemplate::getOperator($a['operator']) : '&&';
|
||||
$operator = isset($a['operator']) && is_string($a['operator']) ? Tpl::getOperator($a['operator']) : '&&';
|
||||
|
||||
if (isset($a['type']) && is_string($a['type'])) {
|
||||
$type = trim($a['type']);
|
||||
$type = !empty($type) ? $type : 'feed';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_type == "' . addslashes($type) . '"';
|
||||
$if[] = 'App::frontend()->context()->feeds->feed_type == "' . addslashes($type) . '"';
|
||||
}
|
||||
if (isset($a['site_url']) && is_string($a['site_url'])) {
|
||||
$url = trim($a['site_url']);
|
||||
if (substr($url, 0, 1) == '!') {
|
||||
$url = substr($url, 1);
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_url != "' . addslashes($url) . '"';
|
||||
$if[] = 'App::frontend()->context()->feeds->feed_url != "' . addslashes($url) . '"';
|
||||
} else {
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_url == "' . addslashes($url) . '"';
|
||||
$if[] = 'App::frontend()->context()->feeds->feed_url == "' . addslashes($url) . '"';
|
||||
}
|
||||
}
|
||||
if (isset($a['feed_url']) && is_string($a['feed_url'])) {
|
||||
$url = trim($a['feed_url']);
|
||||
if (substr($url, 0, 1) == '!') {
|
||||
$url = substr($url, 1);
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_feed != "' . addslashes($url) . '"';
|
||||
$if[] = 'App::frontend()->context()->feeds->feed_feed != "' . addslashes($url) . '"';
|
||||
} else {
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_feed == "' . addslashes($url) . '"';
|
||||
$if[] = 'App::frontend()->context()->feeds->feed_feed == "' . addslashes($url) . '"';
|
||||
}
|
||||
}
|
||||
if (isset($a['category']) && is_string($a['category'])) {
|
||||
$category = addslashes(trim($a['category']));
|
||||
if (substr($category, 0, 1) == '!') {
|
||||
$category = substr($category, 1);
|
||||
$if[] = '(dcCore::app()->ctx->feeds->cat_url != "' . $category . '")';
|
||||
$if[] = '(App::frontend()->context()->feeds->cat_url != "' . $category . '")';
|
||||
} else {
|
||||
$if[] = '(dcCore::app()->ctx->feeds->cat_url == "' . $category . '")';
|
||||
$if[] = '(App::frontend()->context()->feeds->cat_url == "' . $category . '")';
|
||||
}
|
||||
}
|
||||
if (isset($a['first'])) {
|
||||
$sign = (bool) $a['first'] ? '=' : '!';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->index() ' . $sign . '= 0';
|
||||
$if[] = 'App::frontend()->context()->feeds->index() ' . $sign . '= 0';
|
||||
}
|
||||
if (isset($a['odd'])) {
|
||||
$sign = (bool) $a['odd'] ? '=' : '!';
|
||||
$if[] = '(dcCore::app()->ctx->feeds->index()+1)%2 ' . $sign . ' = 1';
|
||||
$if[] = '(App::frontend()->context()->feeds->index()+1)%2 ' . $sign . ' = 1';
|
||||
}
|
||||
if (isset($a['has_category'])) {
|
||||
$sign = (bool) $a['has_category'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->feeds->cat_id';
|
||||
$if[] = $sign . 'App::frontend()->context()->feeds->cat_id';
|
||||
}
|
||||
if (isset($a['has_description'])) {
|
||||
$sign = (bool) $a['has_description'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->feeds->feed_desc';
|
||||
$if[] = $sign . 'App::frontend()->context()->feeds->feed_desc';
|
||||
}
|
||||
|
||||
return empty($if) ?
|
||||
@ -150,95 +150,143 @@ class Template
|
||||
'<?php if(' . implode(' ' . $operator . ' ', $if) . ') : ?>' . $c . '<?php endif; ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedIfFirst(ArrayObject $a): string
|
||||
{
|
||||
$ret = Html::escapeHTML(isset($a['return']) && is_string($a['return']) ? $a['return'] : 'first');
|
||||
|
||||
return
|
||||
'<?php if (dcCore::app()->ctx->feeds->index() == 0) { ' .
|
||||
'<?php if (App::frontend()->context()->feeds->index() == 0) { ' .
|
||||
"echo '" . addslashes($ret) . "'; } ?>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedIfOdd(ArrayObject $a): string
|
||||
{
|
||||
$ret = Html::escapeHTML(isset($a['return']) && is_string($a['return']) ? $a['return'] : 'odd');
|
||||
|
||||
return
|
||||
'<?php if ((dcCore::app()->ctx->feeds->index()+1)%2 == 1) { ' .
|
||||
'<?php if ((App::frontend()->context()->feeds->index()+1)%2 == 1) { ' .
|
||||
"echo '" . addslashes($ret) . "'; } ?>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedDesc(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_desc');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedOwner(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_owner');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedCategory(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_title');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->cat_title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedCategoryID(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_id');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->cat_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedCategoryURL(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->blog->url.dcCore::app()->url->getBase(\'category\').\'/\'.Html::sanitizeURL(dcCore::app()->ctx->feeds->cat_url)');
|
||||
return self::getValue($a, 'App::blog()->url().App::url()->getBase(\'category\').\'/\'.Html::sanitizeURL(App::frontend()->context()->feeds->cat_url)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedCategoryShortURL(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_url');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->cat_url');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedID(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_id');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedLang(ArrayObject $a): string
|
||||
{
|
||||
return empty($a['full']) ?
|
||||
self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') :
|
||||
'<?php $langs = ' . L10n::class . '::getISOcodes(); if (isset($langs[dcCore::app()->ctx->feeds->feed_lang])) { ?>' .
|
||||
self::getValue($a, '$langs[dcCore::app()->ctx->feeds->feed_lang]') .
|
||||
self::getValue($a, 'App::frontend()->context()->feeds->feed_lang') :
|
||||
'<?php $langs = ' . L10n::class . '::getISOcodes(); if (isset($langs[App::frontend()->context()->feeds->feed_lang])) { ?>' .
|
||||
self::getValue($a, '$langs[App::frontend()->context()->feeds->feed_lang]') .
|
||||
'<?php } else { ?>' .
|
||||
self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') .
|
||||
self::getValue($a, 'App::frontend()->context()->feeds->feed_lang') .
|
||||
'<?php ; } unset($langs); ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedName(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_name');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedSiteURL(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_url');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_url');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedFeedURL(ArrayObject $a): string
|
||||
{
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_feed');
|
||||
return self::getValue($a, 'App::frontend()->context()->feeds->feed_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedsHeader(ArrayObject $a, string $c): string
|
||||
{
|
||||
return '<?php if (dcCore::app()->ctx->feeds->isStart()) : ?>' . $c . '<?php endif; ?>';
|
||||
return '<?php if (App::frontend()->context()->feeds->isStart()) : ?>' . $c . '<?php endif; ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedsFooter(ArrayObject $a, string $c): string
|
||||
{
|
||||
return '<?php if (dcCore::app()->ctx->feeds->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
||||
return '<?php if (App::frontend()->context()->feeds->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedsCount(ArrayObject $a): string
|
||||
{
|
||||
$none = isset($a['none']) && is_string($a['none']) ? addslashes($a['none']) : 'no sources';
|
||||
@ -246,7 +294,7 @@ class Template
|
||||
$more = isset($a['more']) && is_string($a['more']) ? addslashes($a['more']) : '%d sources';
|
||||
|
||||
return
|
||||
"<?php \$fcount = dcCore::app()->ctx->feeds->count(); \n" .
|
||||
"<?php \$fcount = App::frontend()->context()->feeds->count(); \n" .
|
||||
"if (\$fcount == 0) {\n" .
|
||||
" printf(__('" . $none . "'),\$fcount);\n" .
|
||||
"} elseif (\$fcount == 1) {\n" .
|
||||
@ -256,6 +304,9 @@ class Template
|
||||
'} unset($fcount); ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedsEntriesCount(ArrayObject $a): string
|
||||
{
|
||||
$none = isset($a['none']) && is_string($a['none']) ? addslashes($a['none']) : 'no entries';
|
||||
@ -280,6 +331,9 @@ class Template
|
||||
'} unset($allfeeds,$fcount); ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
public static function FeedEntriesCount(ArrayObject $a): string
|
||||
{
|
||||
$none = isset($a['none']) && is_string($a['none']) ? addslashes($a['none']) : 'no entries';
|
||||
@ -288,7 +342,7 @@ class Template
|
||||
|
||||
return
|
||||
'<?php $zcfs = ' . ZoneclearFeedServer::class . "::instance(); \n" .
|
||||
"\$fcount = \$zc->getPostsByFeed(array('feed_id'=>dcCore::app()->ctx->feeds->feed_id),true)->f(0); \n" .
|
||||
"\$fcount = \$zc->getPostsByFeed(array('feed_id'=>App::frontend()->context()->feeds->feed_id),true)->f(0); \n" .
|
||||
"if (\$fcount == 0) {\n" .
|
||||
" printf(__('" . $none . "'),\$fcount);\n" .
|
||||
"} elseif (\$fcount == 1) {\n" .
|
||||
@ -298,8 +352,11 @@ class Template
|
||||
'} unset($fcount); ?>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayObject<string, mixed> $a
|
||||
*/
|
||||
protected static function getValue(ArrayObject $a, string $v): string
|
||||
{
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), $v) . '; ?>';
|
||||
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), $v) . '; ?>';
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* Plugin Uninstaller actions.
|
||||
* @brief zoneclearFeedServer uninstall class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
@ -30,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;
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use dcMeta;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\Statement\{
|
||||
DeleteStatement,
|
||||
SelectStatement
|
||||
@ -29,9 +18,11 @@ use Dotclear\Plugin\Uninstaller\{
|
||||
};
|
||||
|
||||
/**
|
||||
* Plugin Uninstaller Cleaner object.
|
||||
* @brief zoneclearFeedServer uninstall cleaner.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* This add special action for feed posts metadata.
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class UninstallCleaner extends CleanerParent
|
||||
{
|
||||
@ -66,7 +57,7 @@ class UninstallCleaner extends CleanerParent
|
||||
public function values(): array
|
||||
{
|
||||
$sql = new SelectStatement();
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
->columns([
|
||||
$sql->as($sql->count('*'), 'counter'),
|
||||
])
|
||||
@ -92,7 +83,7 @@ class UninstallCleaner extends CleanerParent
|
||||
{
|
||||
if ($action == 'delete_all') {
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
->where($sql->like('meta_type', My::META_PREFIX . '%'))
|
||||
->delete();
|
||||
|
||||
|
@ -1,21 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\Statement\{
|
||||
SelectStatement,
|
||||
UpdateStatement
|
||||
@ -23,13 +12,17 @@ use Dotclear\Database\Statement\{
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Module versions upgrades.
|
||||
* @brief zoneclearFeedServer upgrade class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Upgrade
|
||||
{
|
||||
public static function preUpgrade(): void
|
||||
{
|
||||
$current = dcCore::app()->getVersion(My::id());
|
||||
$current = App::version()->getVersion(My::id());
|
||||
if (!is_string($current) || empty($current)) {
|
||||
return;
|
||||
}
|
||||
@ -59,7 +52,7 @@ class Upgrade
|
||||
'zoneclearFeedServer_post_title_redir' => 'post_title_redir',
|
||||
];
|
||||
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||
foreach ($setting_ids as $old => $new) {
|
||||
$cur->clean();
|
||||
$cur->setField('setting_id', $new);
|
||||
@ -69,13 +62,13 @@ class Upgrade
|
||||
$sql
|
||||
->where('setting_id = ' . $sql->quote($old))
|
||||
->and('setting_ns = ' . $sql->quote('zoneclearFeedServer'))
|
||||
->update();
|
||||
->update($cur);
|
||||
}
|
||||
|
||||
// use json rather than serialise for settings array
|
||||
$sql = new SelectStatement();
|
||||
$record = $sql
|
||||
->from(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME)
|
||||
->from(App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME)
|
||||
->where('setting_ns = ' . $sql->quote(My::id()))
|
||||
->select();
|
||||
|
||||
@ -88,7 +81,7 @@ class Upgrade
|
||||
'post_title_redir' => ['feed'],
|
||||
];
|
||||
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||
while ($record->fetch()) {
|
||||
foreach ($setting_values as $key => $default) {
|
||||
try {
|
||||
@ -105,7 +98,7 @@ class Upgrade
|
||||
->where('setting_id = ' . $sql->quote($key))
|
||||
->and('setting_ns = ' . $sql->quote($record->f('setting_ns')))
|
||||
->and('blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ('= ' . $sql->quote($record->f('blog_id')))))
|
||||
->update();
|
||||
->update($cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,7 +108,7 @@ class Upgrade
|
||||
// change settings type of json string to array
|
||||
$sql = new UpdateStatement();
|
||||
$sql
|
||||
->ref(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME)
|
||||
->ref(App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME)
|
||||
->column('setting_type')
|
||||
->value('array')
|
||||
->where('setting_id ' . $sql->in([
|
||||
|
@ -1,31 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Frontend URL handler.
|
||||
* @brief zoneclearFeedServer frontend URL handler.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* This adds public page that list feeds.
|
||||
* And serve an endpoint to update feeds through js.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class UrlHandler extends dcUrlHandlers
|
||||
class UrlHandler extends Url
|
||||
{
|
||||
/**
|
||||
* Feeds source page and update methods.
|
||||
@ -38,14 +32,14 @@ class UrlHandler extends dcUrlHandlers
|
||||
$s = $z->settings;
|
||||
|
||||
# Not active
|
||||
if (is_null(dcCore::app()->blog) || !$s->active) {
|
||||
if (!App::blog()->isDefined() || !$s->active) {
|
||||
self::p404();
|
||||
}
|
||||
|
||||
# Update feeds (from ajax or other post resquest)
|
||||
if ($args == '/zcfsupd' && 3 == $s->bhv_pub_upd) {
|
||||
$msg = '';
|
||||
if (!empty($_POST['blogId']) && Html::escapeJS(dcCore::app()->blog->id) == $_POST['blogId']) {
|
||||
if (!empty($_POST['blogId']) && Html::escapeJS(App::blog()->id()) == $_POST['blogId']) {
|
||||
try {
|
||||
if ($z->checkFeedsUpdate()) {
|
||||
$msg = sprintf(
|
||||
@ -76,7 +70,7 @@ class UrlHandler extends dcUrlHandlers
|
||||
|
||||
# Server js
|
||||
} elseif ($args == '/zcfsupd.js' && 3 == $s->bhv_pub_upd) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates');
|
||||
App::frontend()->template()->appendPath(My::path() . '/default-templates');
|
||||
self::serveDocument(
|
||||
'zcfsupd.js',
|
||||
'text/javascript',
|
||||
@ -86,17 +80,15 @@ class UrlHandler extends dcUrlHandlers
|
||||
|
||||
# Server feeds description page
|
||||
} elseif (in_array($args, ['', '/']) && $s->pub_active) {
|
||||
$theme = dcCore::app()->blog->settings->get('system')->get('theme');
|
||||
$theme = App::blog()->settings()->get('system')->get('theme');
|
||||
if (!is_string($theme)) {
|
||||
self::p404();
|
||||
}
|
||||
$tplset = dcCore::app()->themes->getDefine($theme)->get('tplset');
|
||||
$path = My::path() . '/default-templates/';
|
||||
if (!empty($tplset) && is_dir($path . $tplset)) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . $tplset);
|
||||
} else {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . DC_DEFAULT_TPLSET);
|
||||
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
|
||||
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
|
||||
$tplset = App::config()->defaultTplset();
|
||||
}
|
||||
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
|
||||
self::serveDocument('zcfeeds.html');
|
||||
}
|
||||
# Unknow
|
||||
|
@ -1,29 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
/**
|
||||
* Widgets.
|
||||
* @brief zoneclearFeedServer widgets.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* A widget to list feeds source.
|
||||
* A widget to list feeds statistics.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
@ -36,7 +30,7 @@ class Widgets
|
||||
->create(
|
||||
'zcfssource',
|
||||
__('Feeds server: sources'),
|
||||
[self::class, 'publicSource'],
|
||||
self::publicSource(...),
|
||||
null,
|
||||
__('List sources of feeds')
|
||||
)
|
||||
@ -85,7 +79,7 @@ class Widgets
|
||||
->create(
|
||||
'zcfsnumber',
|
||||
__('Feeds server: numbers'),
|
||||
[self::class, 'publicNumber'],
|
||||
self::publicNumber(...),
|
||||
null,
|
||||
__('Show some numbers about feeds')
|
||||
)
|
||||
@ -140,7 +134,7 @@ class Widgets
|
||||
|
||||
if ($w->__get('offline')
|
||||
|| !$s->active
|
||||
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| !$w->checkHomeOnly(App::url()->type)
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
@ -173,7 +167,7 @@ class Widgets
|
||||
if ($w->__get('pagelink') && $s->pub_active) {
|
||||
$pub = sprintf(
|
||||
'<p><strong><a href="%s">%s</a></strong></p>',
|
||||
dcCore::app()->blog?->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),
|
||||
App::blog()->url() . App::url()->getBase('zoneclearFeedsPage'),
|
||||
Html::escapeHTML(is_string($w->__get('pagelink')) ? $w->__get('pagelink') : '')
|
||||
);
|
||||
}
|
||||
@ -199,7 +193,7 @@ class Widgets
|
||||
|
||||
if ($w->__get('offline')
|
||||
|| !$s->active
|
||||
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| !$w->checkHomeOnly(App::url()->type)
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
@ -221,7 +215,7 @@ class Widgets
|
||||
if ($s->pub_active) {
|
||||
$text = sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
dcCore::app()->blog?->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),
|
||||
App::blog()->url() . App::url()->getBase('zoneclearFeedsPage'),
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
@ -1,26 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\zoneclearFeedServer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcAuth;
|
||||
use dcBlog;
|
||||
use dcCategories;
|
||||
use dcCore;
|
||||
use dcMeta;
|
||||
use dcUtils;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
@ -44,29 +29,61 @@ use Dotclear\Helper\Text;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Main module class.
|
||||
* @brief zoneclearFeedServer main class.
|
||||
* @ingroup zoneclearFeedServer
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ZoneclearFeedServer
|
||||
{
|
||||
/** @var int Net HTTP feed reader timeout */
|
||||
/**
|
||||
* Net HTTP timeout.
|
||||
*
|
||||
* @var int NET_HTTP_TIMEOUT
|
||||
*/
|
||||
public const NET_HTTP_TIMEOUT = 5;
|
||||
|
||||
/** @var string Net HTTP feed reader agent */
|
||||
/**
|
||||
* Net HTTP feed reader agent.
|
||||
*
|
||||
* @var string NET_HTTP_AGENT
|
||||
*/
|
||||
public const NET_HTTP_AGENT = 'zoneclearFeedServer - http://zoneclear.org';
|
||||
|
||||
/** @var int Net HTTP feed reader max redirect */
|
||||
/**
|
||||
* Net HTTP feed reader max redirect.
|
||||
*
|
||||
* @var int NET_HTTP_MAX_REDIRECT
|
||||
*/
|
||||
public const NET_HTTP_MAX_REDIRECT = 2;
|
||||
|
||||
/** @var ZoneclearFeedServer Self instance */
|
||||
/**
|
||||
* Self instance.
|
||||
*
|
||||
* @var ZoneclearFeedServer $instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/** @var Settings The settings instance */
|
||||
/**
|
||||
* Settings.
|
||||
*
|
||||
* @var Settings $settings
|
||||
*/
|
||||
public readonly Settings $settings;
|
||||
|
||||
/** @var null|string $lock File lock for update */
|
||||
/**
|
||||
* File lock for update.
|
||||
*
|
||||
* @var null|string $lock
|
||||
*/
|
||||
private static $lock = null;
|
||||
|
||||
/** @var null|string $user Affiliate user ID */
|
||||
/**
|
||||
* Affiliate user ID.
|
||||
*
|
||||
* @var null|string $user
|
||||
*/
|
||||
private $user = null;
|
||||
|
||||
/**
|
||||
@ -98,7 +115,7 @@ class ZoneclearFeedServer
|
||||
*/
|
||||
public function openCursor(): Cursor
|
||||
{
|
||||
return dcCore::app()->con->openCursor(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
return App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +126,7 @@ class ZoneclearFeedServer
|
||||
*/
|
||||
public function updateFeed(int $id, Cursor $cur): void
|
||||
{
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
|
||||
|
||||
try {
|
||||
if ($id < 1) {
|
||||
@ -121,18 +138,18 @@ class ZoneclearFeedServer
|
||||
$cur->update(sprintf(
|
||||
"WHERE feed_id = %s AND blog_id = '%s' ",
|
||||
$id,
|
||||
dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id)
|
||||
App::con()->escapeStr(App::blog()->id())
|
||||
));
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
$this->trigger();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterUpdateFeed -- Cursor, int
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterUpdateFeed', $cur, $id);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerAfterUpdateFeed', $cur, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,20 +161,20 @@ class ZoneclearFeedServer
|
||||
*/
|
||||
public function addFeed(Cursor $cur): int
|
||||
{
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
|
||||
|
||||
try {
|
||||
$cur->setField('feed_id', $this->getNextId());
|
||||
$cur->setField('blog_id', dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id));
|
||||
$cur->setField('blog_id', App::con()->escapeStr(App::blog()->id()));
|
||||
$cur->setField('feed_creadt', date('Y-m-d H:i:s'));
|
||||
|
||||
$this->getFeedCursor($cur);
|
||||
|
||||
$cur->insert();
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
$this->trigger();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
@ -165,7 +182,7 @@ class ZoneclearFeedServer
|
||||
$id = is_numeric($cur->getField('feed_id')) ? (int) $cur->getField('feed_id') : 0;
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterAddFeed -- Cursor, int
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterAddFeed', $cur, $id);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerAfterAddFeed', $cur, $id);
|
||||
|
||||
return $id;
|
||||
}
|
||||
@ -193,7 +210,7 @@ class ZoneclearFeedServer
|
||||
}
|
||||
|
||||
$cur = $this->openCursor();
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
|
||||
|
||||
$cur->setField('feed_upddt', date('Y-m-d H:i:s'));
|
||||
$cur->setField('feed_status', (int) $enable);
|
||||
@ -204,18 +221,18 @@ class ZoneclearFeedServer
|
||||
$cur->update(sprintf(
|
||||
"WHERE feed_id = %s AND blog_id = '%s' ",
|
||||
$id,
|
||||
dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id)
|
||||
App::con()->escapeStr(App::blog()->id())
|
||||
));
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
$this->trigger();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterEnableFeed -- int, bool, int
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterEnableFeed', $id, $enable, $time);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerAfterEnableFeed', $id, $enable, $time);
|
||||
}
|
||||
|
||||
#
|
||||
@ -231,12 +248,12 @@ class ZoneclearFeedServer
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerBeforeDeleteFeed -- int
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerBeforeDeleteFeed', $id);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerBeforeDeleteFeed', $id);
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::TABLE_NAME)
|
||||
$sql->from(App::con()->prefix() . My::TABLE_NAME)
|
||||
->where('feed_id ' . $sql->in($id))
|
||||
->and('blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->and('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->delete();
|
||||
|
||||
$this->trigger();
|
||||
@ -253,7 +270,7 @@ class ZoneclearFeedServer
|
||||
public static function deletePostsMeta(?int $id): void
|
||||
{
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
->where('meta_type ' . $sql->in([
|
||||
My::META_PREFIX . 'url',
|
||||
My::META_PREFIX . 'author',
|
||||
@ -272,8 +289,8 @@ class ZoneclearFeedServer
|
||||
/**
|
||||
* Get related posts.
|
||||
*
|
||||
* @param array<string,int|string|array> $params The query params
|
||||
* @param bool $count_only Return only result count
|
||||
* @param array<string, mixed> $params The query params
|
||||
* @param bool $count_only Return only result count
|
||||
*
|
||||
* @return MetaRecord The record instance
|
||||
*/
|
||||
@ -287,27 +304,25 @@ class ZoneclearFeedServer
|
||||
$sql->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' F')
|
||||
->from(App::con()->prefix() . App::meta()::META_TABLE_NAME . ' F')
|
||||
->on('P.post_id = F.post_id')
|
||||
->statement()
|
||||
);
|
||||
|
||||
$params['sql'] = "AND P.blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id) . "' " .
|
||||
$params['sql'] = "AND P.blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' " .
|
||||
"AND F.meta_type = '" . My::META_PREFIX . "id' " .
|
||||
"AND F.meta_id = '" . dcCore::app()->con->escapeStr((string) $params['feed_id']) . "' ";
|
||||
"AND F.meta_id = '" . App::con()->escapeStr((string) $params['feed_id']) . "' ";
|
||||
|
||||
unset($params['feed_id']);
|
||||
|
||||
$rs = dcCore::app()->blog?->getPosts($params, $count_only, $sql);
|
||||
|
||||
return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
|
||||
return App::blog()->getPosts($params, $count_only, $sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get feed record.
|
||||
*
|
||||
* @param array<string,int|string|array> $params The query params
|
||||
* @param bool $count_only Return only result count
|
||||
* @param array<string, mixed> $params The query params
|
||||
* @param bool $count_only Return only result count
|
||||
*
|
||||
* @return MetaRecord The record instance
|
||||
*/
|
||||
@ -332,17 +347,17 @@ class ZoneclearFeedServer
|
||||
'C.cat_title, C.cat_url, C.cat_desc ';
|
||||
}
|
||||
|
||||
$strReq .= 'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' Z ' .
|
||||
'LEFT OUTER JOIN ' . dcCore::app()->prefix . dcCategories::CATEGORY_TABLE_NAME . ' C ON Z.cat_id = C.cat_id ';
|
||||
$strReq .= 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' Z ' .
|
||||
'LEFT OUTER JOIN ' . App::con()->prefix() . App::categories()::CATEGORY_TABLE_NAME . ' C ON Z.cat_id = C.cat_id ';
|
||||
|
||||
if (!empty($params['from']) && is_string($params['from'])) {
|
||||
$strReq .= $params['from'] . ' ';
|
||||
}
|
||||
|
||||
$strReq .= "WHERE Z.blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id) . "' ";
|
||||
$strReq .= "WHERE Z.blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' ";
|
||||
|
||||
if (isset($params['feed_type']) && is_string($params['feed_type'])) {
|
||||
$strReq .= "AND Z.feed_type = '" . dcCore::app()->con->escapeStr((string) $params['feed_type']) . "' ";
|
||||
$strReq .= "AND Z.feed_type = '" . App::con()->escapeStr((string) $params['feed_type']) . "' ";
|
||||
} else {
|
||||
$strReq .= "AND Z.feed_type = 'feed' ";
|
||||
}
|
||||
@ -353,21 +368,21 @@ class ZoneclearFeedServer
|
||||
} elseif (is_numeric($params['feed_id'])) {
|
||||
$params['feed_id'] = [(int) $params['feed_id']];
|
||||
}
|
||||
$strReq .= 'AND Z.feed_id ' . dcCore::app()->con->in($params['feed_id']);
|
||||
$strReq .= 'AND Z.feed_id ' . App::con()->in($params['feed_id']);
|
||||
}
|
||||
|
||||
if (isset($params['feed_feed']) && is_string($params['feed_feed'])) {
|
||||
$strReq .= "AND Z.feed_feed = '" . dcCore::app()->con->escapeStr((string) $params['feed_feed']) . "' ";
|
||||
$strReq .= "AND Z.feed_feed = '" . App::con()->escapeStr((string) $params['feed_feed']) . "' ";
|
||||
}
|
||||
if (isset($params['feed_url']) && is_string($params['feed_url'])) {
|
||||
$strReq .= "AND Z.feed_url = '" . dcCore::app()->con->escapeStr((string) $params['feed_url']) . "' ";
|
||||
$strReq .= "AND Z.feed_url = '" . App::con()->escapeStr((string) $params['feed_url']) . "' ";
|
||||
}
|
||||
if (isset($params['feed_status'])) {
|
||||
$strReq .= 'AND Z.feed_status = ' . ((int) $params['feed_status']) . ' ';
|
||||
}
|
||||
|
||||
if (!empty($params['q']) && is_string($params['q'])) {
|
||||
$q = dcCore::app()->con->escapeStr((string) str_replace('*', '%', strtolower($params['q'])));
|
||||
$q = App::con()->escapeStr((string) str_replace('*', '%', strtolower($params['q'])));
|
||||
$strReq .= "AND LOWER(Z.feed_name) LIKE '" . $q . "' ";
|
||||
}
|
||||
|
||||
@ -377,7 +392,7 @@ class ZoneclearFeedServer
|
||||
|
||||
if (!$count_only) {
|
||||
if (!empty($params['order']) && is_string($params['order'])) {
|
||||
$strReq .= 'ORDER BY ' . dcCore::app()->con->escapeStr((string) $params['order']) . ' ';
|
||||
$strReq .= 'ORDER BY ' . App::con()->escapeStr((string) $params['order']) . ' ';
|
||||
} else {
|
||||
$strReq .= 'ORDER BY Z.feed_upddt DESC ';
|
||||
}
|
||||
@ -388,11 +403,11 @@ class ZoneclearFeedServer
|
||||
$params['limit'] = (int) $params['limit'];
|
||||
}
|
||||
if (is_int($params['limit']) || is_array($params['limit'])) {
|
||||
$strReq .= dcCore::app()->con->limit($params['limit']);
|
||||
$strReq .= App::con()->limit($params['limit']);
|
||||
}
|
||||
}
|
||||
|
||||
return new MetaRecord(dcCore::app()->con->select($strReq));
|
||||
return new MetaRecord(App::con()->select($strReq));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,7 +420,7 @@ class ZoneclearFeedServer
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql
|
||||
->column($sql->max('feed_id'))
|
||||
->from(dcCore::app()->prefix . My::TABLE_NAME)
|
||||
->from(App::con()->prefix() . My::TABLE_NAME)
|
||||
->select();
|
||||
|
||||
return (int) $rs?->f(0) + 1;
|
||||
@ -420,14 +435,14 @@ class ZoneclearFeedServer
|
||||
{
|
||||
try {
|
||||
# Cache writable ?
|
||||
if (!is_writable(DC_TPL_CACHE)) {
|
||||
if (!is_writable(App::config()->cacheRoot())) {
|
||||
throw new Exception("Can't write in cache fodler");
|
||||
}
|
||||
# Set file path
|
||||
$f_md5 = md5((string) dcCore::app()->blog?->id);
|
||||
$f_md5 = md5(App::blog()->id());
|
||||
$file = sprintf(
|
||||
'%s/%s/%s/%s/%s.txt',
|
||||
DC_TPL_CACHE,
|
||||
App::config()->cacheRoot(),
|
||||
My::id(),
|
||||
substr($f_md5, 0, 2),
|
||||
substr($f_md5, 2, 2),
|
||||
@ -480,7 +495,7 @@ class ZoneclearFeedServer
|
||||
return false;
|
||||
}
|
||||
|
||||
$tz = dcCore::app()->blog?->settings->get('system')->get('blog_timezone');
|
||||
$tz = App::blog()->settings()->get('system')->get('blog_timezone');
|
||||
Date::setTZ(is_string($tz) ? $tz : 'UTC');
|
||||
$time = time();
|
||||
|
||||
@ -500,8 +515,8 @@ class ZoneclearFeedServer
|
||||
|
||||
$i = 0;
|
||||
|
||||
$cur_post = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
|
||||
$cur_meta = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcMeta::META_TABLE_NAME);
|
||||
$cur_post = App::blog()->openPostCursor();
|
||||
$cur_meta = App::meta()->openMetaCursor();
|
||||
|
||||
while ($f->fetch()) {
|
||||
$row = new FeedRow($f);
|
||||
@ -540,7 +555,7 @@ class ZoneclearFeedServer
|
||||
# Set update time of this feed
|
||||
$this->enableFeed($row->id, (bool) $row->status, $time);
|
||||
|
||||
dcCore::app()->con->begin();
|
||||
App::con()->begin();
|
||||
|
||||
foreach ($feed->items as $item) {
|
||||
$item_TS = $item->TS ? $item->TS : $time;
|
||||
@ -555,7 +570,7 @@ class ZoneclearFeedServer
|
||||
continue;
|
||||
}
|
||||
|
||||
$item_link = dcCore::app()->con->escapeStr((string) $item_link);
|
||||
$item_link = App::con()->escapeStr((string) $item_link);
|
||||
$is_new_published_entry = false;
|
||||
|
||||
# Not updated since last visit
|
||||
@ -576,15 +591,15 @@ class ZoneclearFeedServer
|
||||
'P.post_id',
|
||||
'P.post_status',
|
||||
])
|
||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
||||
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->inner()
|
||||
->from($sql->as(dcCore::app()->prefix . dcMeta::META_TABLE_NAME, 'M'))
|
||||
->from($sql->as(App::con()->prefix() . App::meta()::META_TABLE_NAME, 'M'))
|
||||
->on('P.post_id = M.post_id')
|
||||
->statement()
|
||||
)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and("meta_type = '" . My::META_PREFIX . "url'")
|
||||
->and('meta_id = ' . $sql->quote($item_link))
|
||||
->select();
|
||||
@ -609,14 +624,14 @@ class ZoneclearFeedServer
|
||||
# Create entry
|
||||
if ($old_post->isEmpty()) {
|
||||
# Post
|
||||
$cur_post->setField('user_id', dcCore::app()->auth->userID());
|
||||
$cur_post->setField('user_id', App::auth()->userID());
|
||||
$cur_post->setField('post_format', 'xhtml');
|
||||
$cur_post->setField('post_status', $s->post_status_new);
|
||||
$cur_post->setField('post_status', $s->post_status_new ? App::blog()::POST_PUBLISHED : App::blog()::POST_UNPUBLISHED);
|
||||
$cur_post->setField('post_open_comment', 0);
|
||||
$cur_post->setField('post_open_tb', 0);
|
||||
|
||||
$post_id = dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'addPost'],
|
||||
$post_id = App::auth()->sudo(
|
||||
App::blog()->addPost(...),
|
||||
$cur_post
|
||||
);
|
||||
|
||||
@ -629,22 +644,22 @@ class ZoneclearFeedServer
|
||||
} else {
|
||||
$post_id = is_numeric($old_post->f('post_id')) ? (int) $old_post->f('post_id') : 0;
|
||||
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'updPost'],
|
||||
App::auth()->sudo(
|
||||
App::blog()->updPost(...),
|
||||
$post_id,
|
||||
$cur_post
|
||||
);
|
||||
|
||||
# Quick delete old meta
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
->where('post_id = ' . $post_id)
|
||||
->and($sql->like('meta_type', My::META_PREFIX . '%'))
|
||||
->delete();
|
||||
|
||||
# Delete old tags
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'delPostMeta'],
|
||||
App::auth()->sudo(
|
||||
App::meta()->delPostMeta(...),
|
||||
$post_id,
|
||||
'tag'
|
||||
);
|
||||
@ -683,11 +698,11 @@ class ZoneclearFeedServer
|
||||
$cur_meta->insert();
|
||||
|
||||
# Add new tags
|
||||
$tags = dcCore::app()->meta->splitMetaValues($row->tags);
|
||||
$tags = App::meta()->splitMetaValues($row->tags);
|
||||
if ($row->get_tags) {
|
||||
# Some feed subjects contains more than one tag
|
||||
foreach ($item->subject as $subjects) {
|
||||
$tmp = dcCore::app()->meta->splitMetaValues($subjects);
|
||||
$tmp = App::meta()->splitMetaValues($subjects);
|
||||
$tags = array_merge($tags, $tmp);
|
||||
}
|
||||
$tags = array_unique($tags);
|
||||
@ -709,33 +724,33 @@ class ZoneclearFeedServer
|
||||
}
|
||||
if (!in_array($tag, $formated_tags)) {
|
||||
$formated_tags[] = $tag;
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'delPostMeta'],
|
||||
App::auth()->sudo(
|
||||
App::meta()->delPostMeta(...),
|
||||
$post_id,
|
||||
'tag',
|
||||
dcMeta::sanitizeMetaID($tag)
|
||||
App::meta()::sanitizeMetaID($tag)
|
||||
);
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'setPostMeta'],
|
||||
App::auth()->sudo(
|
||||
App::meta()->setPostMeta(...),
|
||||
$post_id,
|
||||
'tag',
|
||||
dcMeta::sanitizeMetaID($tag)
|
||||
App::meta()::sanitizeMetaID($tag)
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->rollback();
|
||||
App::con()->rollback();
|
||||
$this->enableUser(false);
|
||||
$this->unlockUpdate();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
dcCore::app()->con->commit();
|
||||
App::con()->commit();
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterCheckFeedUpdate -- FeedRow
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterCheckFeedUpdate', $row);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerAfterCheckFeedUpdate', $row);
|
||||
}
|
||||
}
|
||||
if ($enabled) {
|
||||
@ -756,21 +771,18 @@ class ZoneclearFeedServer
|
||||
# Enable
|
||||
if ($enable) {
|
||||
// backup current user
|
||||
if (!is_null(dcCore::app()->auth->userID()) && !is_string(dcCore::app()->auth->userID())) {
|
||||
if (!App::auth()->userID()) {
|
||||
throw new Exception('Unable to backup user');
|
||||
}
|
||||
$this->user = dcCore::app()->auth->userID();
|
||||
$this->user = App::auth()->userID();
|
||||
// set zcfs posts user
|
||||
if (!dcCore::app()->auth->checkUser($this->settings->user)) {
|
||||
if (!App::auth()->checkUser($this->settings->user)) {
|
||||
throw new Exception('Unable to set user');
|
||||
}
|
||||
# Disable
|
||||
} else {
|
||||
// auth on branch My goes readonly
|
||||
//dcCore::app()->auth = null;
|
||||
//dcCore::app()->auth = new dcAuth();
|
||||
// restore current user
|
||||
dcCore::app()->auth->checkUser($this->user ?? '');
|
||||
App::auth()->checkUser($this->user ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,7 +797,7 @@ class ZoneclearFeedServer
|
||||
{
|
||||
try {
|
||||
$feed_reader = new Reader();
|
||||
$feed_reader->setCacheDir(DC_TPL_CACHE);
|
||||
$feed_reader->setCacheDir(App::config()->cacheRoot());
|
||||
$feed_reader->setTimeout(self::NET_HTTP_TIMEOUT);
|
||||
$feed_reader->setMaxRedirects(self::NET_HTTP_MAX_REDIRECT);
|
||||
$feed_reader->setUserAgent(self::NET_HTTP_AGENT);
|
||||
@ -801,7 +813,7 @@ class ZoneclearFeedServer
|
||||
*/
|
||||
private function trigger(): void
|
||||
{
|
||||
dcCore::app()->blog?->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -864,7 +876,7 @@ class ZoneclearFeedServer
|
||||
# Get super admins
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql
|
||||
->from(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME)
|
||||
->from(App::con()->prefix() . App::auth()::USER_TABLE_NAME)
|
||||
->columns([
|
||||
'user_id',
|
||||
'user_super',
|
||||
@ -878,7 +890,7 @@ class ZoneclearFeedServer
|
||||
|
||||
if (!is_null($rs) && !$rs->isEmpty()) {
|
||||
while ($rs->fetch()) {
|
||||
$user_cn = dcUtils::getUserCN(
|
||||
$user_cn = App::users()->getUserCN(
|
||||
$rs->f('user_id'),
|
||||
$rs->f('user_name'),
|
||||
$rs->f('user_firstname'),
|
||||
@ -898,22 +910,22 @@ class ZoneclearFeedServer
|
||||
'U.user_firstname',
|
||||
'U.user_displayname',
|
||||
])
|
||||
->from($sql->as(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME, 'U'))
|
||||
->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from($sql->as(dcCore::app()->prefix . dcAuth::PERMISSIONS_TABLE_NAME, 'P'))
|
||||
->from($sql->as(App::con()->prefix() . App::auth()::PERMISSIONS_TABLE_NAME, 'P'))
|
||||
->on('U.user_id = P.user_id')
|
||||
->statement()
|
||||
)
|
||||
->where('U.user_status = 1')
|
||||
->and('P.blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->and('P.blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and($sql->like('P.permissions', '%|admin|%'))
|
||||
->select();
|
||||
|
||||
if (!is_null($rs) && !$rs->isEmpty()) {
|
||||
while ($rs->fetch()) {
|
||||
$user_cn = dcUtils::getUserCN(
|
||||
$user_cn = App::users()->getUserCN(
|
||||
$rs->f('user_id'),
|
||||
$rs->f('user_name'),
|
||||
$rs->f('user_firstname'),
|
||||
@ -943,7 +955,7 @@ class ZoneclearFeedServer
|
||||
]);
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes -- ArrayObject
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
|
||||
App::behavior()->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
|
||||
|
||||
return $types->getArrayCopy();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user