Compare commits

..

No commits in common. "ee39711e909507b19e399cd43df2ccd438a878b9" and "2b68c75c681118d7373d4ba1052dbcd7660ce6a2" have entirely different histories.

17 changed files with 70 additions and 159 deletions

View File

@ -1,9 +1,3 @@
zoneclearFeedServer 2023.11.04
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Code review (phpstan)
zoneclearFeedServer 2023.10.18
===========================================================
* Require Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README
[![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)
[![Release](https://img.shields.io/badge/release-2023.10.18-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases)
![Date](https://img.shields.io/badge/date-2023.10.18-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-ececec.svg)](https://git.dotclear.watch/JcDenis/zoneclearFeedServer/src/branch/master/LICENSE)

View File

@ -19,7 +19,7 @@ $this->registerModule(
'Feeds server',
'Mix your blog with a feeds planet',
'Jean-Christian Denis, BG, Pierre Van Glabeke',
'2023.11.04',
'2023.10.18',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="zoneclearFeedServer">
<name>Feeds server</name>
<version>2023.11.04</version>
<version>2023.10.18</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.11.04/plugin-zoneclearFeedServer.zip</file>
<file>https://git.dotclear.watch/JcDenis/zoneclearFeedServer/releases/download/v2023.10.18/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>

View File

@ -55,8 +55,6 @@ class BackendBehaviors
/**
* Lists columns user preference.
*
* @param ArrayObject<string, mixed> $cols
*/
public static function adminColumnsListsV2(ArrayObject $cols): void
{
@ -85,8 +83,6 @@ class BackendBehaviors
/**
* Lists filter.
*
* @param ArrayObject<string, mixed> $sorts
*/
public static function adminFiltersListsV2(ArrayObject $sorts): void
{
@ -110,18 +106,14 @@ 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 Text('th', __('Feed')))->extra('scope="col"')->render();
$cols['feed'] = (new Para(null, 'th'))->text(__('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
{
@ -148,9 +140,6 @@ 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
{

View File

@ -28,7 +28,7 @@ use Exception;
class Combo
{
/**
* @return array<string, string>
* @return array<string,string>
*/
public static function feedsSortby(): array
{
@ -42,7 +42,7 @@ class Combo
}
/**
* @return array<string, string>
* @return array<string,string>
*/
public static function postsSortby(): array
{
@ -56,7 +56,7 @@ class Combo
}
/**
* @return array<string, string>
* @return array<string,string>
*/
public static function feedsStatus(): array
{
@ -67,7 +67,7 @@ class Combo
}
/**
* @return array<string, int>
* @return array<string,int>
*/
public static function postsStatus(): array
{
@ -78,7 +78,7 @@ class Combo
}
/**
* @return array<string, int>
* @return array<string,int>
*/
public static function updateInterval(): array
{
@ -93,7 +93,7 @@ class Combo
}
/**
* @return array<string, int>
* @return array<string,int>
*/
public static function tagCase(): array
{
@ -106,7 +106,7 @@ class Combo
}
/**
* @return array<string, int>
* @return array<string,int>
*/
public static function pubUpdate(): array
{
@ -119,7 +119,7 @@ class Combo
}
/**
* @return array<string, string>
* @return array<string,string>
*/
public static function postCategories(): array
{
@ -127,7 +127,7 @@ class Combo
try {
$categories = 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') : '';
@ -138,6 +138,7 @@ class Combo
'&bull; ' . Html::escapeHTML($cat_title)
] = $cat_id;
}
}
} catch (Exception $e) {
}

View File

@ -76,7 +76,7 @@ class Config extends Process
Notices::addSuccessNotice(
__('Configuration has been successfully updated.')
);
App::backend()->url()->redirect('admin.plugins', [
App::bakcend()->url()->redirect('admin.plugins', [
'module' => My::id(),
'conf' => '1',
'redir' => !(App::backend()->__get('list') instanceof ModulesList) ? '' : App::backend()->__get('list')->getRedir(),
@ -99,8 +99,9 @@ class Config extends Process
$msg = [];
if (!is_writable(App::config()->cacheRoot())) {
$msg[] = (new Text('p', __('Dotclear cache is not writable or not well configured!')))
->class('error');
$msg[] = (new Para())
->class('error')
->text(__('Dotclear cache is not writable or not well configured!'));
}
if ($s->pub_active) {
$msg[] = (new Para())

View File

@ -98,7 +98,7 @@ class FeedsActions extends Actions
$feeds = ZoneclearFeedServer::instance()->getFeeds($params);
while ($feeds->fetch()) {
$row = new FeedRow($feeds);
$this->entries[(string) $row->id] = $row->name;
$this->entries[$row->id] = $row->name;
}
$this->rs = $feeds;
} else {

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -73,8 +72,6 @@ class FeedsDefaultActions
/**
* Enable / disable feeds.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doEnableFeed(FeedsActions $ap, ArrayObject $post): void
{
@ -88,7 +85,7 @@ class FeedsDefaultActions
}
foreach ($ids as $id) {
$ap->zcfs->enableFeed((int) $id, $enable);
$ap->zcfs->enableFeed($id, $enable);
}
Notices::addSuccessNotice(sprintf(
@ -111,8 +108,6 @@ class FeedsDefaultActions
/**
* Delete feeds posts.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doDeletePost(FeedsActions $ap, ArrayObject $post): void
{
@ -158,8 +153,6 @@ class FeedsDefaultActions
/**
* Delete feeds.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doDeleteFeed(FeedsActions $ap, ArrayObject $post): void
{
@ -172,7 +165,7 @@ class FeedsDefaultActions
}
foreach ($ids as $id) {
$ap->zcfs->deleteFeed((int) $id);
$ap->zcfs->deleteFeed($id);
}
Notices::addSuccessNotice(sprintf(
@ -188,8 +181,6 @@ class FeedsDefaultActions
/**
* Update feeds properties.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doUpdateFeed(FeedsActions $ap, ArrayObject $post): void
{
@ -202,7 +193,7 @@ class FeedsDefaultActions
}
foreach ($ids as $id) {
$ap->zcfs->checkFeedsUpdate((int) $id, true);
$ap->zcfs->checkFeedsUpdate($id, true);
}
Notices::addSuccessNotice(sprintf(
@ -214,8 +205,6 @@ class FeedsDefaultActions
/**
* Reset feeds update timer.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doResetUpdate(FeedsActions $ap, ArrayObject $post): void
{
@ -231,7 +220,7 @@ class FeedsDefaultActions
foreach ($ids as $id) {
$cur->clean();
$cur->setField('feed_upd_last', 0);
$ap->zcfs->updateFeed((int) $id, $cur);
$ap->zcfs->updateFeed($id, $cur);
//$ap->zcfs->checkFeedsUpdate($id, true);
}
@ -244,8 +233,6 @@ class FeedsDefaultActions
/**
* Change feeds categories.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doChangeCategory(FeedsActions $ap, ArrayObject $post): void
{
@ -264,7 +251,7 @@ class FeedsDefaultActions
foreach ($ids as $id) {
$cur->clean();
$cur->setField('cat_id', $cat_id == 0 ? null : $cat_id);
$ap->zcfs->updateFeed((int) $id, $cur);
$ap->zcfs->updateFeed($id, $cur);
}
Notices::addSuccessNotice(sprintf(
@ -312,8 +299,6 @@ class FeedsDefaultActions
/**
* Change feeds update interval.
*
* @param ArrayObject<string, mixed> $post
*/
public static function doChangeInterval(FeedsActions $ap, ArrayObject $post): void
{
@ -332,7 +317,7 @@ class FeedsDefaultActions
foreach ($ids as $id) {
$cur->clean();
$cur->setField('feed_upd_int', $upd_int);
$ap->zcfs->updateFeed((int) $id, $cur);
$ap->zcfs->updateFeed($id, $cur);
}
Notices::addSuccessNotice(sprintf(

View File

@ -182,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)),

View File

@ -235,7 +235,7 @@ class ManageFeed extends Process
(new Input('feed_name'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->name),
]),
// feed_owner
@ -247,7 +247,7 @@ class ManageFeed extends Process
(new Input('feed_owner'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->owner),
]),
// feed_url
@ -259,7 +259,7 @@ class ManageFeed extends Process
(new Input('feed_url'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->url),
]),
// feed_feed
@ -271,7 +271,7 @@ class ManageFeed extends Process
(new Input('feed_feed'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->feed),
]),
// feed_desc
@ -282,7 +282,7 @@ class ManageFeed extends Process
(new Input('feed_desc'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->desc),
]),
// feed_tags
@ -293,7 +293,7 @@ class ManageFeed extends Process
(new Input('feed_tags'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->tags),
]),
// feed_tweeter
@ -304,7 +304,7 @@ class ManageFeed extends Process
(new Input('feed_tweeter'))
->class('maximal')
->size(60)
->maxlength(255)
->maxlenght(255)
->value($v->tweeter),
]),
]),
@ -417,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()),

View File

@ -76,7 +76,7 @@ class ManageFeedVars
$feed = $z->getFeeds(['feed_id' => $_REQUEST['feed_id']]);
if ($feed->isEmpty()) {
App::error()->add(__('This feed does not exist.'));
Ap::error()->add(__('This feed does not exist.'));
$can_view_page = false;
} else {
$row = new FeedRow($feed);

View File

@ -56,7 +56,7 @@ class PostsFilter extends Filters
try {
$users = App::blog()->getPostsUsers();
if ($users->isEmpty()) {
if (is_null($users) || $users->isEmpty()) {
return null;
}
} catch (Exception $e) {
@ -89,7 +89,7 @@ class PostsFilter extends Filters
try {
$categories = App::blog()->getCategories();
if ($categories->isEmpty()) {
if (is_null($categories) || $categories->isEmpty()) {
return null;
}
} catch (Exception $e) {
@ -143,7 +143,7 @@ class PostsFilter extends Filters
try {
$dates = App::blog()->getDates(['type' => 'month']);
if ($dates->isEmpty()) {
if (is_null($dates) || $dates->isEmpty()) {
return null;
}
} catch (Exception $e) {

View File

@ -30,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;
@ -90,7 +90,7 @@ class Settings
{
$s = My::settings();
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
if (!is_null($s) && property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
$s->put($key, $value, gettype($this->{$key}));
return true;

View File

@ -19,9 +19,6 @@ use Dotclear\Helper\L10n;
*/
class Template
{
/**
* @param ArrayObject<string, mixed> $a
*/
public static function Feeds(ArrayObject $a, string $c): string
{
$lastn = -1;
@ -87,9 +84,6 @@ class Template
'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 = [];
@ -150,9 +144,6 @@ 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');
@ -162,9 +153,6 @@ class Template
"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');
@ -174,65 +162,41 @@ class Template
"echo '" . addslashes($ret) . "'; } ?>";
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedDesc(ArrayObject $a): string
{
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, 'App::frontend()->context()->feeds->feed_owner');
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedCategory(ArrayObject $a): string
{
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, 'App::frontend()->context()->feeds->cat_id');
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedCategoryURL(ArrayObject $a): string
{
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, 'App::frontend()->context()->feeds->cat_url');
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedID(ArrayObject $a): string
{
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']) ?
@ -244,49 +208,31 @@ class Template
'<?php ; } unset($langs); ?>';
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedName(ArrayObject $a): string
{
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, 'App::frontend()->context()->feeds->feed_url');
}
/**
* @param ArrayObject<string, mixed> $a
*/
public static function FeedFeedURL(ArrayObject $a): string
{
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 (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 (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';
@ -304,9 +250,6 @@ 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';
@ -331,9 +274,6 @@ 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';
@ -352,11 +292,8 @@ class Template
'} unset($fcount); ?>';
}
/**
* @param ArrayObject<string, mixed> $a
*/
protected static function getValue(ArrayObject $a, string $v): string
{
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), $v) . '; ?>';
return '<?php echo ' . sprintf(App::fontend()->template()->getFilters($a), $v) . '; ?>';
}
}

View File

@ -70,7 +70,7 @@ class UrlHandler extends Url
# Server js
} elseif ($args == '/zcfsupd.js' && 3 == $s->bhv_pub_upd) {
App::frontend()->template()->appendPath(My::path() . '/default-templates');
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates');
self::serveDocument(
'zcfsupd.js',
'text/javascript',
@ -84,11 +84,13 @@ class UrlHandler extends Url
if (!is_string($theme)) {
self::p404();
}
$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();
$tplset = App::themes()->getDefine($theme)->get('tplset');
$path = My::path() . '/default-templates/';
if (!empty($tplset) && is_dir($path . $tplset)) {
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), $path . $tplset);
} else {
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), $path . App::config()->defaultTplset());
}
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
self::serveDocument('zcfeeds.html');
}
# Unknow

View File

@ -38,7 +38,7 @@ use Exception;
class ZoneclearFeedServer
{
/**
* Net HTTP timeout.
* .
*
* @var int NET_HTTP_TIMEOUT
*/
@ -66,7 +66,7 @@ class ZoneclearFeedServer
private static $instance;
/**
* Settings.
* .
*
* @var Settings $settings
*/
@ -289,7 +289,7 @@ class ZoneclearFeedServer
/**
* Get related posts.
*
* @param array<string, mixed> $params The query params
* @param array<string,int|string|array> $params The query params
* @param bool $count_only Return only result count
*
* @return MetaRecord The record instance
@ -315,13 +315,15 @@ class ZoneclearFeedServer
unset($params['feed_id']);
return App::blog()->getPosts($params, $count_only, $sql);
$rs = App::blog()->getPosts($params, $count_only, $sql);
return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
}
/**
* Get feed record.
*
* @param array<string, mixed> $params The query params
* @param array<string,int|string|array> $params The query params
* @param bool $count_only Return only result count
*
* @return MetaRecord The record instance
@ -771,7 +773,7 @@ class ZoneclearFeedServer
# Enable
if ($enable) {
// backup current user
if (!App::auth()->userID()) {
if (!is_null(App::auth()->userID()) && !is_string(App::auth()->userID())) {
throw new Exception('Unable to backup user');
}
$this->user = App::auth()->userID();