Compare commits
No commits in common. "master" and "v2023.08.15" have entirely different histories.
master
...
v2023.08.1
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,17 +1,3 @@
|
|||
periodical 2023.11.04
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Fix typo
|
||||
* Fix perms
|
||||
* Code review (phpstan)
|
||||
|
||||
periodical 2023.10.20
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
periodical 2023.08.15
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
30
README.md
30
README.md
|
@ -1,25 +1,28 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/periodical/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.15-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/periodical/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/periodical/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/periodical)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/periodical)](https://git.dotclear.watch/JcDenis/periodical/blob/master/LICENSE)
|
||||
|
||||
## ABOUT
|
||||
## WHAT IS PERIODICAL ?
|
||||
|
||||
_periodical_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
_Periodical_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
|
||||
> Manage and publish automatically lists of posts
|
||||
You can manage and publish automatically lists of posts
|
||||
at regular periods. For exemple, you just need to add posts to a period
|
||||
and they will be publish ones after the others every week.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
* Dotclear 2.28
|
||||
_periodical_ requires:
|
||||
|
||||
* admin permissions to configure plugin
|
||||
* usage,contentadmin permissions to link feeds
|
||||
* Dotclear 2.27
|
||||
* PHP 8.1+
|
||||
* Dotclear admin permissions to configure plugin
|
||||
* Dotclear usage,contentadmin permissions to link feeds
|
||||
|
||||
## NOTICE
|
||||
|
||||
|
@ -42,11 +45,10 @@ You can also add or remove period to multiple posts from posts actions page.
|
|||
|
||||
## LINKS
|
||||
|
||||
* [License](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/periodical/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/periodical))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/periodical) (or on [GitHub](https://github.com/JcDenis/periodical))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/periodical/issues) (or on [GitHub](https://github.com/JcDenis/periodical/issues))
|
||||
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=42289)
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/periodical) or [GitHub Page](https://github.com/JcDenis/periodical)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/periodical/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/periodical)
|
||||
* Discuss & help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=42289)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
|
|
41
_define.php
41
_define.php
|
@ -1,30 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin periodical definition
|
||||
* @ingroup periodical
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @defgroup periodical Plugin periodical.
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* Published periodically entries.
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
'Periodical',
|
||||
'Published periodically entries',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'2023.11.04',
|
||||
'2023.08.15',
|
||||
[
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'settings' => [
|
||||
'blog' => '#params.' . basename(__DIR__) . '_params',
|
||||
],
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class initPeriodical
|
||||
{
|
||||
// now use My::id()
|
||||
public const PERIOD_TABLE_NAME = 'periodical';
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="periodical">
|
||||
<name>Periodical</name>
|
||||
<version>2023.11.04</version>
|
||||
<version>2023.08.15</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<desc>Published periodically entries</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.11.04/plugin-periodical.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.08.15/plugin-periodical.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/periodical/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/periodical/issues</da:support>
|
||||
</module>
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin periodical definition
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'periodical', __DIR__ . '/help/help.html');
|
||||
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of periodical, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin periodical definition
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'periodical', __DIR__ . '/help/help.html');
|
||||
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of periodical, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief periodical backend class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -28,14 +31,14 @@ class Backend extends Process
|
|||
}
|
||||
|
||||
// register backend behaviors
|
||||
App::behavior()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
|
||||
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
|
||||
'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
|
||||
'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
|
||||
'adminPostListHeaderV2' => BackendBehaviors::adminPostListHeaderV2(...),
|
||||
'adminPostListValueV2' => BackendBehaviors::adminPostListValueV2(...),
|
||||
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
|
||||
'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
|
||||
'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
|
||||
'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
|
||||
'adminPostListHeaderV2' => [BackendBehaviors::class, 'adminPostListHeaderV2'],
|
||||
'adminPostListValueV2' => [BackendBehaviors::class, 'adminPostListValueV2'],
|
||||
'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
|
||||
]);
|
||||
|
||||
if (My::settings()->get('periodical_active')) {
|
||||
|
@ -43,13 +46,13 @@ class Backend extends Process
|
|||
My::addBackendMenuItem();
|
||||
|
||||
// register bakend behaviors required user permissions
|
||||
App::behavior()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => BackendBehaviors::adminDashboardFavoritesV2(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'],
|
||||
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
|
||||
'adminPostsActions' => [BackendBehaviors::class, 'adminPostsActions'],
|
||||
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
|
||||
'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'],
|
||||
'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostSave'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use dcSettings;
|
||||
use Dotclear\Core\Backend\{
|
||||
Favorites,
|
||||
Notices,
|
||||
|
@ -28,31 +39,23 @@ use Dotclear\Helper\Html\Form\{
|
|||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Interface\Core\BlogSettingsInterface;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical backend behaviors class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @ingroup DC_PLUGIN_PERIODICAL
|
||||
* @brief Periodical - admin methods.
|
||||
* @since 2.6
|
||||
*/
|
||||
class BackendBehaviors
|
||||
{
|
||||
/**
|
||||
* Periods combo.
|
||||
*
|
||||
* @var array<string, int> $combo_period
|
||||
*/
|
||||
private static array $combo_period = [];
|
||||
|
||||
/**
|
||||
* Add settings to blog preference.
|
||||
*
|
||||
* @param BlogSettingsInterface $blog_settings BlogSettingsInterface instance
|
||||
* @param dcSettings $blog_settings dcSettings instance
|
||||
*/
|
||||
public static function adminBlogPreferencesFormV2(BlogSettingsInterface $blog_settings): void
|
||||
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
|
||||
{
|
||||
$s = $blog_settings->get(My::id());
|
||||
|
||||
|
@ -84,9 +87,9 @@ class BackendBehaviors
|
|||
/**
|
||||
* Save blog settings.
|
||||
*
|
||||
* @param BlogSettingsInterface $blog_settings BlogSettingsInterface instance
|
||||
* @param dcSettings $blog_settings dcSettings instance
|
||||
*/
|
||||
public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
|
||||
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings): void
|
||||
{
|
||||
$blog_settings->get(My::id())->put('periodical_active', !empty($_POST['periodical_active']));
|
||||
$blog_settings->get(My::id())->put('periodical_upddate', !empty($_POST['periodical_upddate']));
|
||||
|
@ -96,7 +99,7 @@ class BackendBehaviors
|
|||
/**
|
||||
* User pref for periods columns lists.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $cols Columns
|
||||
* @param ArrayObject $cols Columns
|
||||
*/
|
||||
public static function adminColumnsListsV2(ArrayObject $cols): void
|
||||
{
|
||||
|
@ -117,7 +120,7 @@ class BackendBehaviors
|
|||
/**
|
||||
* User pref periods filters options.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $sorts Sort options
|
||||
* @param ArrayObject $sorts Sort options
|
||||
*/
|
||||
public static function adminFiltersListsV2(ArrayObject $sorts): void
|
||||
{
|
||||
|
@ -133,8 +136,8 @@ class BackendBehaviors
|
|||
/**
|
||||
* Add columns period to posts list header.
|
||||
*
|
||||
* @param MetaRecord $rs Record instance
|
||||
* @param ArrayObject<string, mixed> $cols Columns
|
||||
* @param MetaRecord $rs record instance
|
||||
* @param ArrayObject $cols Columns
|
||||
*/
|
||||
public static function adminPostListHeaderV2(MetaRecord $rs, ArrayObject $cols): void
|
||||
{
|
||||
|
@ -146,8 +149,8 @@ class BackendBehaviors
|
|||
/**
|
||||
* Add columns period to posts list values.
|
||||
*
|
||||
* @param MetaRecord $rs Record instance
|
||||
* @param ArrayObject<string, mixed> $cols Columns
|
||||
* @param MetaRecord $rs record instance
|
||||
* @param ArrayObject $cols Columns
|
||||
*/
|
||||
public static function adminPostListValueV2(MetaRecord $rs, ArrayObject $cols): void
|
||||
{
|
||||
|
@ -177,9 +180,9 @@ class BackendBehaviors
|
|||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
'permissions' => App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_USAGE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
@ -213,16 +216,16 @@ class BackendBehaviors
|
|||
{
|
||||
$pa->addAction(
|
||||
[My::name() => [__('Add to periodical') => 'periodical_add']],
|
||||
self::callbackAdd(...)
|
||||
[self::class, 'callbackAdd']
|
||||
);
|
||||
|
||||
if (App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_DELETE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id())) {
|
||||
if (dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_DELETE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog?->id)) {
|
||||
$pa->addAction(
|
||||
[My::name() => [__('Remove from periodical') => 'periodical_remove']],
|
||||
self::callbackRemove(...)
|
||||
[self::class, 'callbackRemove']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -230,8 +233,8 @@ class BackendBehaviors
|
|||
/**
|
||||
* Posts actions callback to remove period.
|
||||
*
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject<string, mixed> $post _POST actions
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject $post _POST actions
|
||||
*/
|
||||
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
|
||||
{
|
||||
|
@ -242,16 +245,16 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
// No right
|
||||
if (!App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_DELETE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id())) {
|
||||
if (!dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_DELETE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog?->id)) {
|
||||
throw new Exception(__('No enough right'));
|
||||
}
|
||||
|
||||
// Remove linked period
|
||||
foreach ($posts_ids as $post_id) {
|
||||
self::delPeriod((int) $post_id);
|
||||
self::delPeriod($post_id);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(__('Posts have been removed from periodical.'));
|
||||
|
@ -261,8 +264,8 @@ class BackendBehaviors
|
|||
/**
|
||||
* Posts actions callback to add period.
|
||||
*
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject<string, mixed> $post _POST actions
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @param ArrayObject $post _POST actions
|
||||
*/
|
||||
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
|
||||
{
|
||||
|
@ -277,8 +280,8 @@ class BackendBehaviors
|
|||
// Save action
|
||||
if (!empty($post['periodical'])) {
|
||||
foreach ($posts_ids as $post_id) {
|
||||
self::delPeriod((int) $post_id);
|
||||
self::addPeriod((int) $post_id, (int) $post['periodical']);
|
||||
self::delPeriod($post_id);
|
||||
self::addPeriod($post_id, (int) $post['periodical']);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(__('Posts have been added to periodical.'));
|
||||
|
@ -289,9 +292,9 @@ class BackendBehaviors
|
|||
else {
|
||||
$pa->beginPage(
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Add a period to this selection') => '',
|
||||
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Add a period to this selection') => '',
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -299,12 +302,14 @@ class BackendBehaviors
|
|||
(new Form('periodicaladd'))->method('post')->action($pa->getURI())->fields([
|
||||
(new Text('', $pa->getCheckboxes())),
|
||||
self::formPeriod(0),
|
||||
(new Para())->items([
|
||||
App::nonce()->formNonce(),
|
||||
(new Hidden(['action'], 'periodical_add')),
|
||||
(new Submit(['do']))->value(__('Save')),
|
||||
... $pa->hiddenFields(),
|
||||
]),
|
||||
(new Para())->items(array_merge(
|
||||
[
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden(['action'], 'periodical_add')),
|
||||
(new Submit(['do']))->value(__('Save')),
|
||||
],
|
||||
$pa->hiddenFields()
|
||||
)),
|
||||
])->render();
|
||||
|
||||
$pa->endPage();
|
||||
|
@ -314,9 +319,9 @@ class BackendBehaviors
|
|||
/**
|
||||
* Add form to post sidebar.
|
||||
*
|
||||
* @param ArrayObject<string, mixed> $main_items Main items
|
||||
* @param ArrayObject<string, mixed> $sidebar_items Sidebar items
|
||||
* @param null|MetaRecord $post Post record or null
|
||||
* @param ArrayObject $main_items Main items
|
||||
* @param ArrayObject $sidebar_items Sidebar items
|
||||
* @param null|MetaRecord $post Post record or null
|
||||
*/
|
||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
|
||||
{
|
||||
|
@ -370,7 +375,7 @@ class BackendBehaviors
|
|||
/**
|
||||
* Combo of available periods.
|
||||
*
|
||||
* @return array<string, int> List of period
|
||||
* @return array List of period
|
||||
*/
|
||||
private static function comboPeriod(): array
|
||||
{
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use DateTimeZone;
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical date helper.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* Tools to manupilate period date
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Dater
|
||||
{
|
||||
|
@ -29,7 +33,7 @@ class Dater
|
|||
*/
|
||||
public static function fromUser(string $date, string $format = 'Y-m-d H:i:00'): string
|
||||
{
|
||||
$tz = App::auth()->getInfo('user_tz');
|
||||
$tz = dcCore::app()->auth?->getInfo('user_tz');
|
||||
$d = date_create($date, new DateTimeZone($tz ?? 'UTC'));
|
||||
|
||||
return $d ? date_format($d->setTimezone(new DateTimeZone('UTC')), $format) : '';
|
||||
|
@ -45,7 +49,7 @@ class Dater
|
|||
*/
|
||||
public static function toUser(string $date, string $format = 'Y-m-d\TH:i'): string
|
||||
{
|
||||
$tz = App::auth()->getInfo('user_tz');
|
||||
$tz = dcCore::app()->auth?->getInfo('user_tz');
|
||||
$d = date_create($date, new DateTimeZone('UTC'));
|
||||
|
||||
return $d ? date_format($d->setTimezone(new DateTimeZone($tz ?? 'UTC')), $format) : '';
|
||||
|
|
|
@ -1,25 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical frontend class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Update posts from periods on frontend
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::FRONTEND) && in_array((string) App::url()->type, ['default', 'feed']));
|
||||
return self::status(My::checkContext(My::FRONTEND) && in_array(dcCore::app()->url->type, ['default', 'feed']));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
|
@ -28,8 +35,8 @@ class Frontend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
|
||||
if (!App::blog()->isDefined()) {
|
||||
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -39,7 +46,7 @@ class Frontend extends Process
|
|||
Utils::lockUpdate();
|
||||
|
||||
// Get periods
|
||||
$periods = App::auth()->sudo(Utils::getPeriods(...));
|
||||
$periods = dcCore::app()->auth->sudo([Utils::class, 'getPeriods']);
|
||||
|
||||
// No period
|
||||
if ($periods->isEmpty()) {
|
||||
|
@ -53,7 +60,7 @@ class Frontend extends Process
|
|||
if (!preg_match('/^(post_dt|post_creadt|post_id) (asc|desc)$/', $posts_order)) {
|
||||
$posts_order = 'post_dt asc';
|
||||
}
|
||||
$cur_period = App::con()->openCursor(App::con()->prefix() . My::id());
|
||||
$cur_period = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::id());
|
||||
|
||||
while ($periods->fetch()) {
|
||||
// Check if period is ongoing
|
||||
|
@ -82,19 +89,19 @@ class Frontend extends Process
|
|||
// Get posts to publish related to this period
|
||||
$posts_params = [];
|
||||
$posts_params['periodical_id'] = $periods->f('periodical_id');
|
||||
$posts_params['post_status'] = App::blog()::POST_PENDING;
|
||||
$posts_params['post_status'] = dcBlog::POST_PENDING;
|
||||
$posts_params['order'] = $posts_order;
|
||||
$posts_params['limit'] = $limit * $max_nb;
|
||||
$posts_params['no_content'] = true;
|
||||
$posts = App::auth()->sudo(Utils::getPosts(...), $posts_params);
|
||||
$posts = dcCore::app()->auth->sudo([Utils::class, 'getPosts'], $posts_params);
|
||||
|
||||
if (!$posts->isEmpty()) {
|
||||
$cur_post = App::blog()->openPostCursor();
|
||||
$cur_post = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
|
||||
|
||||
while ($posts->fetch()) {
|
||||
// Publish post with right date
|
||||
$cur_post->clean();
|
||||
$cur_post->setField('post_status', App::blog()::POST_PUBLISHED);
|
||||
$cur_post->setField('post_status', dcBlog::POST_PUBLISHED);
|
||||
|
||||
// Update post date with right date
|
||||
if ($s->get('periodical_upddate')) {
|
||||
|
@ -105,7 +112,7 @@ class Frontend extends Process
|
|||
|
||||
// Also update post url with right date
|
||||
if ($s->get('periodical_updurl')) {
|
||||
$cur_post->setField('post_url', App::blog()->getPostURL(
|
||||
$cur_post->setField('post_url', dcCore::app()->blog->getPostURL(
|
||||
'',
|
||||
$cur_post->getField('post_dt'),
|
||||
$posts->f('post_title'),
|
||||
|
@ -115,7 +122,7 @@ class Frontend extends Process
|
|||
|
||||
$cur_post->update(
|
||||
'WHERE post_id = ' . $posts->f('post_id') . ' ' .
|
||||
"AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
|
||||
"AND blog_id = '" . dcCore::app()->con->escapeStr(dcCore::app()->blog->id) . "' "
|
||||
);
|
||||
|
||||
// Delete post relation to this period
|
||||
|
@ -130,9 +137,9 @@ class Frontend extends Process
|
|||
}
|
||||
|
||||
// --BEHAVIOR-- periodicalAfterPublishedPeriodicalEntry
|
||||
App::behavior()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
|
||||
dcCore::app()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
|
||||
}
|
||||
App::blog()->triggerBlog();
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +148,7 @@ class Frontend extends Process
|
|||
$cur_period->setField('periodical_curdt', Dater::toDate($loop_ts, 'Y-m-d H:i:00'));
|
||||
$cur_period->update(
|
||||
'WHERE periodical_id = ' . $periods->f('periodical_id') . ' ' .
|
||||
"AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
|
||||
"AND blog_id = '" . dcCore::app()->con->escapeStr(dcCore::app()->blog->id) . "' "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical insatll class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,7 +33,7 @@ class Install extends Process
|
|||
}
|
||||
|
||||
try {
|
||||
$t = new Structure(App::con(), App::con()->prefix());
|
||||
$t = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
|
||||
// create database table
|
||||
$t->__get(My::id())
|
||||
|
@ -46,7 +49,7 @@ class Install extends Process
|
|||
->primary('pk_periodical', 'periodical_id')
|
||||
->index('idx_periodical_type', 'btree', 'periodical_type');
|
||||
|
||||
(new Structure(App::con(), App::con()->prefix()))->synchronize($t);
|
||||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($t);
|
||||
|
||||
// set default settings
|
||||
$s = My::settings();
|
||||
|
@ -57,7 +60,7 @@ class Install extends Process
|
|||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
|
@ -19,11 +29,7 @@ use Dotclear\Helper\Network\Http;
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical manage periods class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Admin page for periods
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
|
@ -71,7 +77,7 @@ class Manage extends Process
|
|||
My::redirect(['part' => 'periods']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +98,7 @@ class Manage extends Process
|
|||
My::redirect(['part' => 'periods']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +133,7 @@ class Manage extends Process
|
|||
$counter = Utils::getPeriods($params, true);
|
||||
$period_list = new ManageList($periods, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
// Display
|
||||
|
@ -144,7 +150,7 @@ class Manage extends Process
|
|||
Notices::getNotices() .
|
||||
|
||||
'<p class="top-add">
|
||||
<a class="button add" href="' . My::manageUrl(['part' => 'period']) . '">' . __('New period') . '</a>
|
||||
<a class="button add" href="' . dcCore::app()->admin->getPageURL() . '&part=period">' . __('New period') . '</a>
|
||||
</p>';
|
||||
|
||||
if (isset($period_list)) {
|
||||
|
@ -154,7 +160,7 @@ class Manage extends Process
|
|||
// Periods list
|
||||
$period_list->periodDisplay(
|
||||
$p_filter,
|
||||
'<form action="' . My::manageUrl() . '" method="post" id="form-periods">' .
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-periods">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\App;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filters,
|
||||
FilterPosts
|
||||
|
@ -19,11 +30,9 @@ use Dotclear\Helper\Html\Form\Checkbox;
|
|||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* @brief periodical periods list class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @ingroup DC_PLUGIN_PERIODICAL
|
||||
* @brief Periodical - admin pager methods.
|
||||
* @since 2.6
|
||||
*/
|
||||
class ManageList extends Listing
|
||||
{
|
||||
|
@ -92,7 +101,7 @@ class ManageList extends Listing
|
|||
*/
|
||||
private function periodLine(bool $checked): void
|
||||
{
|
||||
$tz = App::auth()->getInfo('user_tz');
|
||||
$tz = dcCore::app()->auth?->getInfo('user_tz');
|
||||
$nb_posts = Utils::getPosts(['periodical_id' => $this->rs->f('periodical_id')], true)->f(0);
|
||||
$url = My::manageUrl(['part' => 'period', 'period_id' => $this->rs->f('periodical_id')]);
|
||||
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . Html::escapeHTML($this->rs->periodical_title) . '</a>';
|
||||
|
@ -194,7 +203,7 @@ class ManageList extends Listing
|
|||
*/
|
||||
private function postLine(bool $checked): void
|
||||
{
|
||||
if (App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_CATEGORIES]), App::blog()->id())) {
|
||||
if (dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CATEGORIES]), dcCore::app()->blog?->id)) {
|
||||
$cat_link = '<a href="category.php?id=%s">%s</a>';
|
||||
} else {
|
||||
$cat_link = '%2$s';
|
||||
|
@ -213,22 +222,22 @@ class ManageList extends Listing
|
|||
$img_status = '';
|
||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||
switch ((int) $this->rs->f('post_status')) {
|
||||
case App::blog()::POST_PUBLISHED:
|
||||
case dcBlog::POST_PUBLISHED:
|
||||
$img_status = sprintf($img, __('published'), 'check-on.png');
|
||||
|
||||
break;
|
||||
|
||||
case App::blog()::POST_UNPUBLISHED:
|
||||
case dcBlog::POST_UNPUBLISHED:
|
||||
$img_status = sprintf($img, __('unpublished'), 'check-off.png');
|
||||
|
||||
break;
|
||||
|
||||
case App::blog()::POST_SCHEDULED:
|
||||
case dcBlog::POST_SCHEDULED:
|
||||
$img_status = sprintf($img, __('scheduled'), 'scheduled.png');
|
||||
|
||||
break;
|
||||
|
||||
case App::blog()::POST_PENDING:
|
||||
case dcBlog::POST_PENDING:
|
||||
$img_status = sprintf($img, __('pending'), 'check-wrn.png');
|
||||
|
||||
break;
|
||||
|
@ -251,11 +260,11 @@ class ManageList extends Listing
|
|||
$attach = sprintf($img, sprintf($attach_str, $nb_media), 'attach.png');
|
||||
}
|
||||
|
||||
$tz = App::auth()->getInfo('user_tz');
|
||||
$tz = dcCore::app()->auth?->getInfo('user_tz');
|
||||
|
||||
$cols = [
|
||||
'check' => '<td class="minimal">' . (new Checkbox(['periodical_entries[]'], $checked))->value($this->rs->f('post_id'))->render() . '</td>',
|
||||
'title' => '<td class="maximal"><a href="' . App::postTypes()->getPostAdminURL($this->rs->f('post_type'), $this->rs->f('post_id')) . '" ' .
|
||||
'title' => '<td class="maximal"><a href="' . dcCore::app()->getPostAdminURL($this->rs->f('post_type'), $this->rs->f('post_id')) . '" ' .
|
||||
'title="' . Html::escapeHTML($this->rs->getURL()) . '">' . Html::escapeHTML($this->rs->post_title) . '</a></td>',
|
||||
'date' => '<td class="nowrap">' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt')) . '</td>',
|
||||
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
|
@ -39,11 +39,7 @@ use Dotclear\Helper\Network\Http;
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical manage a period class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Admin page for a period
|
||||
*/
|
||||
class ManagePeriod extends Process
|
||||
{
|
||||
|
@ -58,7 +54,7 @@ class ManagePeriod extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!App::blog()->isDefined()) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,13 +63,13 @@ class ManagePeriod extends Process
|
|||
|
||||
// Get period
|
||||
if ($vars->bad_period_id) {
|
||||
App::error()->add(__('This period does not exist.'));
|
||||
dcCore::app()->error->add(__('This period does not exist.'));
|
||||
}
|
||||
|
||||
// Set period
|
||||
if ($vars->action == 'setperiod') {
|
||||
if ($vars->bad_period_curdt || $vars->bad_period_enddt) {
|
||||
App::error()->add(__('Invalid date'));
|
||||
dcCore::app()->error->add(__('Invalid date'));
|
||||
}
|
||||
|
||||
// Check period title and dates
|
||||
|
@ -83,19 +79,19 @@ class ManagePeriod extends Process
|
|||
if (!$old_titles->isEmpty()) {
|
||||
while ($old_titles->fetch()) {
|
||||
if (!$vars->period_id || $old_titles->f('periodical_id') != $vars->period_id) {
|
||||
App::error()->add(__('Period title is already taken'));
|
||||
dcCore::app()->error->add(__('Period title is already taken'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($vars->period_title)) {
|
||||
App::error()->add(__('Period title is required'));
|
||||
dcCore::app()->error->add(__('Period title is required'));
|
||||
}
|
||||
if (strtotime($vars->period_curdt) > strtotime($vars->period_enddt)) {
|
||||
App::error()->add(__('Start date must be older than end date'));
|
||||
dcCore::app()->error->add(__('Start date must be older than end date'));
|
||||
}
|
||||
|
||||
// If no error, set period
|
||||
if (!App::error()->flag()) {
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
$cur = Utils::openCursor();
|
||||
$cur->setField('periodical_title', $vars->period_title);
|
||||
$cur->setField('periodical_curdt', $vars->period_curdt);
|
||||
|
@ -118,18 +114,18 @@ class ManagePeriod extends Process
|
|||
}
|
||||
|
||||
// Actions on related posts
|
||||
if (!App::error()->flag() && $vars->period_id && $vars->action && !empty($vars->entries)) {
|
||||
if (!dcCore::app()->error->flag() && $vars->period_id && $vars->action && !empty($vars->entries)) {
|
||||
// Publish posts
|
||||
if ($vars->action == 'publish') {
|
||||
try {
|
||||
foreach ($vars->entries as $id) {
|
||||
App::blog()->updPostStatus($id, 1);
|
||||
dcCore::app()->blog->updPostStatus($id, 1);
|
||||
Utils::delPost($id);
|
||||
}
|
||||
|
||||
self::redirect($vars->redir, $vars->period_id, '#posts', __('Entries successfully published.'));
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,13 +133,13 @@ class ManagePeriod extends Process
|
|||
if ($vars->action == 'unpublish') {
|
||||
try {
|
||||
foreach ($vars->entries as $id) {
|
||||
App::blog()->updPostStatus($id, 0);
|
||||
dcCore::app()->blog->updPostStatus($id, 0);
|
||||
Utils::delPost($id);
|
||||
}
|
||||
|
||||
self::redirect($vars->redir, $vars->period_id, '#posts', __('Entries successfully unpublished.'));
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +152,7 @@ class ManagePeriod extends Process
|
|||
|
||||
self::redirect($vars->redir, $vars->period_id, '#posts', __('Entries successfully removed.'));
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +190,7 @@ class ManagePeriod extends Process
|
|||
$counter = Utils::getPosts($params, true);
|
||||
$post_list = new ManageList($posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
$starting_script = My::jsLoad('checkbox') .
|
||||
|
@ -213,7 +209,7 @@ class ManagePeriod extends Process
|
|||
echo
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => App::backend()->getPageURL() . '&part=periods',
|
||||
My::name() => dcCore::app()->admin->getPageURL() . '&part=periods',
|
||||
(null === $vars->period_id ? __('New period') : __('Edit period')) => '',
|
||||
]) .
|
||||
Notices::getNotices();
|
||||
|
@ -222,10 +218,10 @@ class ManagePeriod extends Process
|
|||
echo
|
||||
(new Div('period'))->items([
|
||||
(new Text('h3', null === $vars->period_id ? __('New period') : __('Edit period'))),
|
||||
(new Form('periodicalbhv'))->method('post')->action(App::backend()->getPageURL())->fields([
|
||||
(new Form('periodicalbhv'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
||||
(new Para())->items([
|
||||
(new Label(__('Title:')))->for('period_title'),
|
||||
(new Input('period_title'))->size(65)->maxlength(255)->class('maximal')->value(Html::escapeHTML($vars->period_title)),
|
||||
(new Input('period_title'))->size(65)->maxlenght(255)->class('maximal')->value(Html::escapeHTML($vars->period_title)),
|
||||
]),
|
||||
(new Div())->class('two-boxes')->items([
|
||||
(new Div())->class('box odd')->items([
|
||||
|
@ -262,8 +258,8 @@ class ManagePeriod extends Process
|
|||
]),
|
||||
])->render();
|
||||
|
||||
if ($vars->period_id && isset($post_filter) && isset($post_list) && !App::error()->flag()) {
|
||||
$base_url = App::backend()->getPageURL() .
|
||||
if ($vars->period_id && isset($post_filter) && isset($post_list) && !dcCore::app()->error->flag()) {
|
||||
$base_url = dcCore::app()->admin->getPageURL() .
|
||||
'&period_id=' . $vars->period_id .
|
||||
'&part=period' .
|
||||
'&user_id=' . $post_filter->value('user_id', '') .
|
||||
|
@ -295,7 +291,7 @@ class ManagePeriod extends Process
|
|||
$post_list->postDisplay(
|
||||
$post_filter,
|
||||
$base_url,
|
||||
'<form action="' . App::backend()->getPageURL() . '" method="post" id="form-entries">' .
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-entries">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
|
|
|
@ -1,114 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
/**
|
||||
* @brief periodical vars helper class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Admin page vars
|
||||
*/
|
||||
class ManageVars
|
||||
{
|
||||
/**
|
||||
* Self instance.
|
||||
*
|
||||
* @var ManageVars $container
|
||||
*/
|
||||
/** @var ManageVars $container Self instance */
|
||||
private static $container;
|
||||
|
||||
/**
|
||||
* The post form action.
|
||||
*
|
||||
* @var string $action
|
||||
*/
|
||||
/** @var string $action The post form action */
|
||||
public readonly string $action;
|
||||
|
||||
/**
|
||||
* The post form redirection.
|
||||
*
|
||||
* @var string $redir
|
||||
*/
|
||||
/** @var string $redir The post form redirection */
|
||||
public readonly string $redir;
|
||||
|
||||
/**
|
||||
* The post form periods.
|
||||
*
|
||||
* @var array<int, int> $periods
|
||||
*/
|
||||
/** @var array $periods The post form periods */
|
||||
public readonly array $periods;
|
||||
|
||||
/**
|
||||
* The post form entries.
|
||||
*
|
||||
* @var array<int, int> $entries
|
||||
*/
|
||||
/** @var array $entries The post form entries */
|
||||
public readonly array $entries;
|
||||
|
||||
/**
|
||||
* The post form period id.
|
||||
*
|
||||
* @var null|int $period_id
|
||||
*/
|
||||
/** @var null|int $period_id The post form period id */
|
||||
public readonly ?int $period_id;
|
||||
|
||||
/**
|
||||
* The psort form period title.
|
||||
*
|
||||
* @var string $period_title
|
||||
*/
|
||||
/** @var string $period_title The psort form period title */
|
||||
public readonly string $period_title;
|
||||
|
||||
/**
|
||||
* The post form period publication number.
|
||||
*
|
||||
* @var int $period_pub_nb
|
||||
*/
|
||||
/** @var int $period_pub_nb The post form period publication number */
|
||||
public readonly int $period_pub_nb;
|
||||
|
||||
/**
|
||||
* The post form period publication interval.
|
||||
*
|
||||
* @var string $period_pub_int
|
||||
*/
|
||||
/** @var string $period_pub_int The post form period publication interval */
|
||||
public readonly string $period_pub_int;
|
||||
|
||||
/**
|
||||
* The post form period current date.
|
||||
*
|
||||
* @var string $period_curdt
|
||||
*/
|
||||
/** @var string $period_curdt The post form period current date */
|
||||
public readonly string $period_curdt;
|
||||
|
||||
/**
|
||||
* The post form period end date.
|
||||
*
|
||||
* @var string $period_curdt
|
||||
*/
|
||||
/** @var string $period_curdt The post form period end date */
|
||||
public readonly string $period_enddt;
|
||||
|
||||
/**
|
||||
* Is period ID wrong .
|
||||
*
|
||||
* @var bool $bad_period_id
|
||||
*/
|
||||
/** @var bool $bad_period_id Is period ID wrong */
|
||||
public readonly bool $bad_period_id;
|
||||
|
||||
/**
|
||||
* Is period current date wrong.
|
||||
*
|
||||
* @var bool $bad_period_curdt
|
||||
*/
|
||||
/** @var bool $bad_period_curdt Is period current date wrong */
|
||||
public readonly bool $bad_period_curdt;
|
||||
|
||||
/**
|
||||
* Is period end date wrong.
|
||||
*
|
||||
* @var bool $bad_period_enddt
|
||||
*/
|
||||
/** @var bool $bad_period_enddt Is period end date wrong */
|
||||
public readonly bool $bad_period_enddt;
|
||||
|
||||
/**
|
||||
|
|
46
src/My.php
46
src/My.php
|
@ -1,39 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief periodical My helper.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* This module definitions.
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return match ($context) {
|
||||
// Add usage perm to backend
|
||||
self::MANAGE, self::MENU => App::task()->checkContext('BACKEND')
|
||||
&& App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_USAGE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]), App::blog()->id()),
|
||||
|
||||
default => null,
|
||||
};
|
||||
return in_array($context, [My::MANAGE, My::MENU]) ?
|
||||
defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->blog)
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Periods action combo.
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @return array<string,sting>
|
||||
*/
|
||||
public static function periodsActionCombo(): array
|
||||
{
|
||||
|
@ -46,7 +50,7 @@ class My extends MyPlugin
|
|||
/**
|
||||
* Period entries action combo.
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
* @return array<string,array{string,string}>
|
||||
*/
|
||||
public static function entriesActionsCombo(): array
|
||||
{
|
||||
|
@ -64,7 +68,7 @@ class My extends MyPlugin
|
|||
/**
|
||||
* Periods sortby combo.
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public static function sortbyCombo(): array
|
||||
{
|
||||
|
@ -78,7 +82,7 @@ class My extends MyPlugin
|
|||
/**
|
||||
* Period combo.
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public static function periodCombo(): array
|
||||
{
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief periodical uninstall class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -23,7 +27,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
106
src/Utils.php
106
src/Utils.php
|
@ -1,11 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @brief periodical, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\periodical;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\App;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcMeta;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
|
@ -22,20 +34,12 @@ use Dotclear\Helper\File\{
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief periodical utils class.
|
||||
* @ingroup periodical
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Manage periodical records
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* File lock for update.
|
||||
*
|
||||
* @var null|string $lock
|
||||
*/
|
||||
private static ?string $lock = null;
|
||||
/** @var null|string $lock File lock for update */
|
||||
private static $lock = null;
|
||||
|
||||
/**
|
||||
* Get periodical table cursor.
|
||||
|
@ -44,15 +48,15 @@ class Utils
|
|||
*/
|
||||
public static function openCursor(): Cursor
|
||||
{
|
||||
return App::con()->openCursor(App::con()->prefix() . My::id());
|
||||
return dcCore::app()->con->openCursor(dcCore::app()->prefix . My::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get periods.
|
||||
*
|
||||
* @param array<string, mixed>|ArrayObject<string, mixed> $params Parameters
|
||||
* @param bool $count_only Only counts results
|
||||
* @param SelectStatement $ext_sql Optional SelectStatement instance
|
||||
* @param array|ArrayObject $params Parameters
|
||||
* @param bool $count_only Only counts results
|
||||
* @param SelectStatement $ext_sql Optional SelectStatement instance
|
||||
*
|
||||
* @return MetaRecord A record with some more capabilities
|
||||
*/
|
||||
|
@ -78,7 +82,7 @@ class Utils
|
|||
]);
|
||||
}
|
||||
|
||||
$sql->from($sql->as(App::con()->prefix() . My::id(), 'T'), false, true);
|
||||
$sql->from($sql->as(dcCore::app()->prefix . My::id(), 'T'), false, true);
|
||||
|
||||
if (!empty($params['join'])) {
|
||||
$sql->join($params['join']);
|
||||
|
@ -90,9 +94,9 @@ class Utils
|
|||
|
||||
if (!empty($params['where'])) {
|
||||
$sql->where($params['where']);
|
||||
$sql->and('T.blog_id = ' . $sql->quote(App::blog()->id()));
|
||||
$sql->and('T.blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id));
|
||||
} else {
|
||||
$sql->where('T.blog_id = ' . $sql->quote(App::blog()->id()));
|
||||
$sql->where('T.blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id));
|
||||
}
|
||||
|
||||
if (isset($params['periodical_type'])) {
|
||||
|
@ -132,7 +136,9 @@ class Utils
|
|||
$sql->limit($params['limit']);
|
||||
}
|
||||
|
||||
return $sql->select() ?? MetaRecord::newFromArray([]);
|
||||
$rs = $sql->select();
|
||||
|
||||
return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,12 +150,12 @@ class Utils
|
|||
*/
|
||||
public static function addPeriod(Cursor $cur): int
|
||||
{
|
||||
App::con()->writeLock(App::con()->prefix() . My::id());
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::id());
|
||||
|
||||
try {
|
||||
// get next id
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(App::con()->prefix() . My::id())
|
||||
$rs = $sql->from(dcCore::app()->prefix . My::id())
|
||||
->column($sql->max('periodical_id'))
|
||||
->select();
|
||||
|
||||
|
@ -157,12 +163,12 @@ class Utils
|
|||
|
||||
// insert
|
||||
$cur->setField('periodical_id', $id);
|
||||
$cur->setField('blog_id', App::blog()->id());
|
||||
$cur->setField('blog_id', (string) dcCore::app()->blog?->id);
|
||||
$cur->setField('periodical_type', 'post');
|
||||
$cur->insert();
|
||||
App::con()->unlock();
|
||||
dcCore::app()->con->unlock();
|
||||
} catch (Exception $e) {
|
||||
App::con()->unlock();
|
||||
dcCore::app()->con->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
@ -179,7 +185,7 @@ class Utils
|
|||
public static function updPeriod(int $period_id, Cursor $cur): void
|
||||
{
|
||||
$cur->update(
|
||||
"WHERE blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' " .
|
||||
"WHERE blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id) . "' " .
|
||||
'AND periodical_id = ' . $period_id . ' '
|
||||
);
|
||||
}
|
||||
|
@ -201,8 +207,8 @@ class Utils
|
|||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(App::con()->prefix() . My::id())
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
$sql->from(dcCore::app()->prefix . My::id())
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->and('periodical_id = ' . $period_id)
|
||||
->delete();
|
||||
}
|
||||
|
@ -229,7 +235,7 @@ class Utils
|
|||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
->where('meta_type = ' . $sql->quote(My::id()))
|
||||
->and('post_id ' . $sql->in($ids))
|
||||
->delete();
|
||||
|
@ -238,9 +244,9 @@ class Utils
|
|||
/**
|
||||
* Get posts related to periods.
|
||||
*
|
||||
* @param array<string, mixed>|ArrayObject<string, mixed> $params Parameters
|
||||
* @param bool $count_only Only counts results
|
||||
* @param SelectStatement $ext_sql Optional SelectStatement instance
|
||||
* @param array|ArrayObject $params Parameters
|
||||
* @param bool $count_only Only counts results
|
||||
* @param SelectStatement $ext_sql Optional SelectStatement instance
|
||||
*
|
||||
* @return MetaRecord A record with some more capabilities
|
||||
*/
|
||||
|
@ -269,14 +275,14 @@ class Utils
|
|||
->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from($sql->as(App::con()->prefix() . App::meta()::META_TABLE_NAME, 'R'))
|
||||
->from($sql->as(dcCore::app()->prefix . dcMeta::META_TABLE_NAME, 'R'))
|
||||
->on('P.post_id = R.post_id')
|
||||
->statement()
|
||||
)
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from($sql->as(App::con()->prefix() . My::id(), 'T'))
|
||||
->from($sql->as(dcCore::app()->prefix . My::id(), 'T'))
|
||||
->on('CAST(T.periodical_id as char) = CAST(R.meta_id as char)')
|
||||
->statement()
|
||||
)
|
||||
|
@ -297,7 +303,7 @@ class Utils
|
|||
$sql->and('T.periodical_id ' . $sql->in($params['periodical_id']));
|
||||
unset($params['periodical_id']);
|
||||
}
|
||||
if (App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), App::blog()->id())) {
|
||||
if (dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog?->id)) {
|
||||
if (isset($params['post_status'])) {
|
||||
if ($params['post_status'] != '') {
|
||||
$sql->and('P.post_status = ' . (int) $params['post_status']);
|
||||
|
@ -305,10 +311,12 @@ class Utils
|
|||
unset($params['post_status']);
|
||||
}
|
||||
} else {
|
||||
$sql->and('P.post_status = ' . App::blog()::POST_PENDING);
|
||||
$sql->and('P.post_status = ' . dcBlog::POST_PENDING);
|
||||
}
|
||||
|
||||
return App::blog()->getPosts($params, $count_only, $sql);
|
||||
$rs = dcCore::app()->blog?->getPosts($params, $count_only, $sql);
|
||||
|
||||
return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,17 +337,17 @@ class Utils
|
|||
return;
|
||||
}
|
||||
|
||||
$cur = App::meta()->openMetaCursor();
|
||||
App::con()->writeLock(App::con()->prefix() . App::meta()::META_TABLE_NAME);
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcMeta::META_TABLE_NAME);
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . dcMeta::META_TABLE_NAME);
|
||||
|
||||
try {
|
||||
$cur->setField('post_id', $post_id);
|
||||
$cur->setField('meta_id', $period_id);
|
||||
$cur->setField('meta_type', My::id());
|
||||
$cur->insert();
|
||||
App::con()->unlock();
|
||||
dcCore::app()->con->unlock();
|
||||
} catch (Exception $e) {
|
||||
App::con()->unlock();
|
||||
dcCore::app()->con->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
@ -353,7 +361,7 @@ class Utils
|
|||
public static function delPost(int $post_id): void
|
||||
{
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
->where('meta_type = ' . $sql->quote(My::id()))
|
||||
->and('post_id = ' . $post_id)
|
||||
->delete();
|
||||
|
@ -366,10 +374,10 @@ class Utils
|
|||
*/
|
||||
public static function cleanPosts(?int $period_id = null): void
|
||||
{
|
||||
// hack post status of App::blog()->getPost()
|
||||
// hack post status of dcBlog::getPost()
|
||||
$params = [
|
||||
'post_status' => '',
|
||||
'sql' => 'AND post_status != ' . App::blog()::POST_PENDING . ' ',
|
||||
'sql' => 'AND post_status != ' . dcBlog::POST_PENDING . ' ',
|
||||
];
|
||||
if ($period_id !== null) {
|
||||
$params['periodical_id'] = $period_id;
|
||||
|
@ -386,7 +394,7 @@ class Utils
|
|||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(App::con()->prefix() . App::meta()::META_TABLE_NAME)
|
||||
$sql->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME)
|
||||
->where('meta_type = ' . $sql->quote(My::id()))
|
||||
->and('post_id ' . $sql->in($ids))
|
||||
->delete();
|
||||
|
@ -401,14 +409,14 @@ class Utils
|
|||
{
|
||||
try {
|
||||
# Cache writable ?
|
||||
if (!is_writable(App::config()->cacheRoot())) {
|
||||
if (!is_writable(DC_TPL_CACHE)) {
|
||||
throw new Exception("Can't write in cache fodler");
|
||||
}
|
||||
# Set file path
|
||||
$f_md5 = md5(App::blog()->id());
|
||||
$f_md5 = md5((string) dcCore::app()->blog?->id);
|
||||
$file = sprintf(
|
||||
'%s/%s/%s/%s/%s.txt',
|
||||
App::config()->cacheRoot(),
|
||||
DC_TPL_CACHE,
|
||||
My::id(),
|
||||
substr($f_md5, 0, 2),
|
||||
substr($f_md5, 2, 2),
|
||||
|
|
Loading…
Reference in New Issue