diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95eaf96..b33a508 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+postWidgetText 2023.10.20
+===========================================================
+* Require Dotclear 2.28
+* Require PHP 8.1
+* Upgrade to Dotclear 2.28
+
postWidgetText 2023.08.15
===========================================================
* Require Dotclear 2.27
diff --git a/README.md b/README.md
index b5fbfe5..81ac8fc 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,25 @@
# README
-[![Release](https://img.shields.io/badge/release-2023.08.15-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/releases)
-[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/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.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/releases)
+![Date](https://img.shields.io/badge/date-2023.10.20-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/postWidgetText)
-[![License](https://img.shields.io/github/license/JcDenis/postWidgetText)](https://git.dotclear.watch/JcDenis/postWidgetText/blob/master/LICENSE)
+[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/LICENSE)
-## WHAT IS POSTWIDGETTEXT ?
+## ABOUT
-_Post widget text_ is a plugin for the open-source
-web publishing software called Dotclear.
+_postWidgetText_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
-Add a widget related to an entry with custom titles and content.
+> Add a widget related to an entry with custom titles and content.
## REQUIREMENTS
-_postWidgetText_ requires:
+* Dotclear 2.28
+* PHP 8.1+
+* Dotclear permissions to manage widgets
+* Dotclear permissions to manage entries
-* permissions to manage widgets
-* permissions to manage entries
-* Dotclear 2.27
-* PHP 8.0+
-
-Note this plugin add table called post_option to Dotclear database.
+Note this plugin add table called "post_option" to Dotclear database.
## USAGE
@@ -36,9 +33,10 @@ Manage (delete) "widgets" from sidebar menu called "Post widget text".
## 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/postWidgetText) or [GitHub Page](https://github.com/JcDenis/postWidgetText)
-* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postWidgetText/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postWidgetText)
+* [License](https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/LICENSE)
+* [Packages & details](https://git.dotclear.watch/JcDenis/postWidgetText/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/postWidgetText))
+* [Sources & contributions](https://git.dotclear.watch/JcDenis/postWidgetText) (or on [GitHub](https://github.com/JcDenis/postWidgetText))
+* [Issues & security](https://git.dotclear.watch/JcDenis/postWidgetText/issues) (or on [GitHub](https://github.com/JcDenis/postWidgetText/issues))
## CONTRIBUTORS
diff --git a/_define.php b/_define.php
index 9205f30..98b20ce 100644
--- a/_define.php
+++ b/_define.php
@@ -1,39 +1,31 @@
registerModule(
'Post widget text',
'Add a widget with a text related to an entry',
'Jean-Christian Denis and Contributors',
- '2023.08.15',
+ '2023.10.20',
[
- 'requires' => [
- ['php', '8.0'],
- ['core', '2.27'],
- ],
- 'permissions' => dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_USAGE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]),
- 'settings' => [
- 'blog' => '#params.pwt_params',
- ],
- 'type' => 'plugin',
- 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
- 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
- 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
+ 'requires' => [['core', '2.28']],
+ 'permissions' => 'My',
+ 'settings' => ['blog' => '#params.pwt_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',
]
);
diff --git a/_init.php b/_init.php
deleted file mode 100644
index 719156f..0000000
--- a/_init.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
Post widget text
- 2023.08.15
+ 2023.10.20
Jean-Christian Denis and Contributors
Add a widget with a text related to an entry
- https://git.dotclear.watch/JcDenis/postWidgetText/releases/download/v2023.08.15/plugin-postWidgetText.zip
- 2.27
+ https://git.dotclear.watch/JcDenis/postWidgetText/releases/download/v2023.10.20/plugin-postWidgetText.zip
+ 2.28
https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/README.md
https://git.dotclear.watch/JcDenis/postWidgetText/issues
diff --git a/src/Backend.php b/src/Backend.php
index 99bc63f..927e84e 100644
--- a/src/Backend.php
+++ b/src/Backend.php
@@ -1,22 +1,19 @@
addBehaviors([
+ App::behavior()->addBehaviors([
// user pref
- 'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
- 'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
- 'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
- 'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
+ 'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
+ 'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
+ 'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
+ 'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
// post
- 'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
- 'adminPostEditorTags' => [BackendBehaviors::class, 'adminPostEditorTags'],
- 'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
- 'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'],
- 'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostSave'],
- 'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
+ 'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
+ 'adminPostEditorTags' => BackendBehaviors::adminPostEditorTags(...),
+ 'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
+ 'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
+ 'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
+ 'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
// Plugin "pages"
- 'adminPageHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
- 'adminPageFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
- 'adminAfterPageUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'],
- 'adminAfterPageCreate' => [BackendBehaviors::class, 'adminAfterPostSave'],
- 'adminBeforePageDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
+ 'adminPageHeaders' => BackendBehaviors::adminPostHeaders(...),
+ 'adminPageFormItems' => BackendBehaviors::adminPostFormItems(...),
+ 'adminAfterPageUpdate' => BackendBehaviors::adminAfterPostSave(...),
+ 'adminAfterPageCreate' => BackendBehaviors::adminAfterPostSave(...),
+ 'adminBeforePageDelete' => BackendBehaviors::adminBeforePostDelete(...),
// widgets registration
- 'initWidgets' => [Widgets::class, 'initWidgets'],
+ 'initWidgets' => Widgets::initWidgets(...),
]);
// add plugin "importExport" features
if (!My::settings()->get('importexport_active')) {
- dcCore::app()->addBehaviors([
- 'exportFullV2' => [ImportExport::class, 'exportFullV2'],
- 'exportSingleV2' => [ImportExport::class, 'exportSingleV2'],
- 'importInitV2' => [ImportExport::class, 'importInitV2'],
- 'importSingleV2' => [ImportExport::class, 'importSingleV2'],
- 'importFullV2' => [ImportExport::class, 'importFullV2'],
+ App::behavior()->addBehaviors([
+ 'exportFullV2' => ImportExport::exportFullV2(...),
+ 'exportSingleV2' => ImportExport::exportSingleV2(...),
+ 'importInitV2' => ImportExport::importInitV2(...),
+ 'importSingleV2' => ImportExport::importSingleV2(...),
+ 'importFullV2' => ImportExport::importFullV2(...),
]);
}
diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php
index 9d048e3..2791a65 100644
--- a/src/BackendBehaviors.php
+++ b/src/BackendBehaviors.php
@@ -1,32 +1,26 @@
@@ -111,7 +105,7 @@ class BackendBehaviors
*
* @param dcSettings $blog_settings The blog settings
*/
- public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings): void
+ public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
{
$blog_settings->get(My::id())->put('active', !empty($_POST['active']));
$blog_settings->get(My::id())->put('importexport_active', !empty($_POST['importexport_active']));
diff --git a/src/Frontend.php b/src/Frontend.php
index 1f8c5a1..c8187a2 100644
--- a/src/Frontend.php
+++ b/src/Frontend.php
@@ -1,22 +1,19 @@
addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
+ App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}
diff --git a/src/ImportExport.php b/src/ImportExport.php
index 2f46b85..cb983c2 100644
--- a/src/ImportExport.php
+++ b/src/ImportExport.php
@@ -1,24 +1,17 @@
prefix . My::TABLE_NAME . ' W ' .
- 'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
+ 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' W ' .
+ 'LEFT JOIN ' . App::con()->prefix() . App::blog()::POST_TABLE_NAME . ' P ' .
'ON P.post_id = W.post_id ' .
"WHERE P.blog_id = '" . $blog_id . "' " .
- "AND W.option_type = '" . dcCore::app()->con->escapeStr((string) My::id()) . "' "
+ "AND W.option_type = '" . App::con()->escapeStr((string) My::id()) . "' "
);
}
@@ -44,17 +37,17 @@ class ImportExport
My::id(),
'SELECT option_type, option_content, ' .
'option_content_xhtml, W.post_id ' .
- 'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' W ' .
- 'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
+ 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' W ' .
+ 'LEFT JOIN ' . App::con()->prefix() . App::blog()::POST_TABLE_NAME . ' P ' .
'ON P.post_id = W.post_id ' .
- "WHERE W.option_type = '" . dcCore::app()->con->escapeStr((string) My::id()) . "' "
+ "WHERE W.option_type = '" . App::con()->escapeStr((string) My::id()) . "' "
);
}
public static function importInitV2($bk)
{
- self::$ie_cursor = dcCore::app()->con->openCursor(
- dcCore::app()->prefix . My::TABLE_NAME
+ self::$ie_cursor = App::con()->openCursor(
+ App::con()->prefix() . My::TABLE_NAME
);
}
diff --git a/src/Install.php b/src/Install.php
index f460019..f6311bc 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -1,24 +1,21 @@
con, dcCore::app()->prefix);
+ $s = new Structure(App::con(), App::con()->prefix());
$s->__get(My::TABLE_NAME)
->field('option_id', 'bigint', 0, false)
->field('post_id', 'bigint', 0, false)
@@ -51,7 +48,7 @@ class Install extends Process
->index('idx_post_option_post', 'btree', 'post_id')
->index('idx_post_option_type', 'btree', 'option_type');
- (new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
+ (new Structure(App::con(), App::con()->prefix()))->synchronize($s);
// Settings
$s = My::settings();
@@ -74,7 +71,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
return false;
}
diff --git a/src/Manage.php b/src/Manage.php
index 8dd0def..b9631c6 100644
--- a/src/Manage.php
+++ b/src/Manage.php
@@ -1,20 +1,10 @@
error->add($e->getMessage());
+ App::error()->add($e->getMessage());
}
}
@@ -65,12 +62,9 @@ class Manage extends Process
public static function render(): void
{
- if (!self::status()) {
- return;
- }
-
- // nullsafe check
- if (is_null(dcCore::app()->blog)) {
+ if (!self::status()
+ || !App::blog()->isDefined()
+ ) {
return;
}
@@ -88,7 +82,7 @@ class Manage extends Process
$counter = Utils::getWidgets($params, true);
$posts_list = new ManageList($posts, $counter->f(0));
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
$posts_list = null;
}
diff --git a/src/ManageList.php b/src/ManageList.php
index d96f679..1d2a3d5 100644
--- a/src/ManageList.php
+++ b/src/ManageList.php
@@ -1,22 +1,11 @@
blog)) {
+ if (!App::blog()->isDefined()) {
return;
}
// prepare page
$blocks = explode('%s', $enclose);
$pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10);
- $tz = dcCore::app()->auth->getInfo('user_tz') ?? (dcCore::app()->blog->settings->get('system')->get('blog_timezone') ?? 'UTC');
+ $tz = App::auth()->getInfo('user_tz') ?? (App::blog()->settings()->get('system')->get('blog_timezone') ?? 'UTC');
// no record
if ($this->rs->isEmpty()) {
@@ -84,7 +74,8 @@ class ManageList extends Listing
$w_title = Html::escapeHTML($this->rs->option_title);
if ($w_title == '') {
// widget title can accept HTML, but backend table not
- $w_title = context::global_filters(
+ /*
+ $w_title = App::frontend()->context()->global_filters(
$this->rs->option_content,
[
'encode_xml',
@@ -92,6 +83,8 @@ class ManageList extends Listing
'cut_string' => 80,
]
);
+ */
+ $w_title = '?';
}
// table body line
@@ -102,7 +95,7 @@ class ManageList extends Listing
->__call('disabled', [!$this->rs->isEditable()])
->render() .
'',
- 'name' => '
' .
+ 'name' => ' | ' .
Html::escapeHTML($this->rs->f('post_title')) . ' | ',
'post_dt' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt'), $tz) . ' | ',
'option_title' => '' . $w_title . ' | ',
diff --git a/src/My.php b/src/My.php
index 2dc54d3..aeb0c8b 100644
--- a/src/My.php
+++ b/src/My.php
@@ -1,15 +1,5 @@
plugins->moduleExists('Uninstaller')) {
+ if (!self::status()) {
return false;
}
diff --git a/src/Utils.php b/src/Utils.php
index 357b1a2..118d4c9 100644
--- a/src/Utils.php
+++ b/src/Utils.php
@@ -1,20 +1,10 @@
con->openCursor(dcCore::app()->prefix . My::TABLE_NAME);
+ return App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
}
/**
@@ -64,8 +56,7 @@ class Utils
*/
public static function getWidgets(array $params, bool $count_only = false): MetaRecord
{
- // nullsafe
- if (is_null(dcCore::app()->blog)) {
+ if (!App::blog()->isDefined()) {
throw new Exception(__('Blog is not set'));
}
@@ -88,7 +79,7 @@ class Utils
$sql->join(
(new JoinStatement())
->left()
- ->from($sql->as(dcCore::app()->prefix . My::TABLE_NAME, 'W'))
+ ->from($sql->as(App::con()->prefix() . My::TABLE_NAME, 'W'))
->on('P.post_id = W.post_id')
->statement()
);
@@ -132,7 +123,7 @@ class Utils
$params['post_type'] = '';
}
- return dcCore::app()->blog->getPosts($params, $count_only, $sql);
+ return App::blog()->getPosts($params, $count_only, $sql);
}
/**
@@ -144,16 +135,15 @@ class Utils
*/
public static function addWidget(Cursor $cur): int
{
- // nullsafe
- if (is_null(dcCore::app()->blog)) {
+ if (!App::blog()->isDefined()) {
throw new Exception(__('Blog is not set'));
}
// check permissions to add post
- if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_USAGE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog->id)) {
+ if (!App::auth()->check(App::auth()->makePermissions([
+ App::auth()::PERMISSION_USAGE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
+ ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to create an entry text widget'));
}
@@ -163,11 +153,11 @@ class Utils
}
// lock table
- dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME);
+ App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
try {
$sql = new SelectStatement();
- $rs = $sql->from(dcCore::app()->prefix . My::TABLE_NAME)->column($sql->max('option_id'))->select();
+ $rs = $sql->from(App::con()->prefix() . My::TABLE_NAME)->column($sql->max('option_id'))->select();
if (is_null($rs) || $rs->isEmpty()) {
throw new Exception(__('Something went wrong)'));
}
@@ -183,15 +173,15 @@ class Utils
// add new widgetText
$cur->insert();
- dcCore::app()->con->unlock();
+ App::con()->unlock();
} catch (Exception $e) {
- dcCore::app()->con->unlock();
+ App::con()->unlock();
throw $e;
}
// update blog
- dcCore::app()->blog->triggerBlog();
+ App::blog()->triggerBlog();
// return new widgetText ID
return (int) $cur->getField('option_id');
@@ -205,16 +195,15 @@ class Utils
*/
public static function updWidget(int $id, Cursor $cur): void
{
- // nullsafe
- if (is_null(dcCore::app()->blog)) {
+ if (!App::blog()->isDefined()) {
throw new Exception(__('Blog is not set'));
}
// check permission to delete post
- if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_USAGE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog->id)) {
+ if (!App::auth()->check(App::auth()->makePermissions([
+ App::auth()::PERMISSION_USAGE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
+ ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to update entries text widget'));
}
@@ -228,10 +217,10 @@ class Utils
$cur->setField('option_upddt', date('Y-m-d H:i:s'));
// check if user is post owner
- 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())) {
$rs = self::getWidgets([
'option_id' => $id,
- 'user_id' => dcCore::app()->con->escapeStr((string) dcCore::app()->auth->userID()),
+ 'user_id' => App::con()->escapeStr(App::auth()->userID()),
'no_content' => true,
'limit' => 1,
]);
@@ -245,7 +234,7 @@ class Utils
$cur->update('WHERE option_id = ' . $id . ' ');
// update blog
- dcCore::app()->blog->triggerBlog();
+ App::blog()->triggerBlog();
}
/**
@@ -256,16 +245,15 @@ class Utils
*/
public static function delWidget(int $id, ?string $type = null): void
{
- // nullsafe
- if (is_null(dcCore::app()->blog)) {
+ if (!App::blog()->idDefined()) {
throw new Exception(__('Blog is not set'));
}
// check permission to delete post
- if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_DELETE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog->id)) {
+ if (!App::auth()->check(App::auth()->makePermissions([
+ App::auth()::PERMISSION_DELETE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
+ ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to delete entries text widget'));
}
@@ -278,10 +266,10 @@ class Utils
}
// check if user is post owner
- 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())) {
$rs = self::getWidgets([
'option_id' => $id,
- 'user_id' => dcCore::app()->con->escapeStr((string) dcCore::app()->auth->userID()),
+ 'user_id' => App::con()->escapeStr(App::auth()->userID()),
'no_content' => true,
'limit' => 1,
]);
@@ -293,13 +281,13 @@ class Utils
// delete widgetText
$sql = new DeleteStatement();
- $sql->from(dcCore::app()->prefix . My::TABLE_NAME)
+ $sql->from(App::con()->prefix() . My::TABLE_NAME)
->where('option_id = ' . $id)
->and('option_type = ' . $sql->quote($type))
->delete();
// update blog
- dcCore::app()->blog->triggerBlog();
+ App::blog()->triggerBlog();
}
/**
@@ -314,16 +302,16 @@ class Utils
public static function setWidgetContent(int $option_id, string $format, string $lang, ?string &$content, ?string &$content_xhtml): void
{
if ($format == 'wiki') {
- dcCore::app()->initWikiPost();
- dcCore::app()->wiki2xhtml->setOpt('note_prefix', 'wnote-' . $option_id);
+ App::filter()->initWikiPost();
+ App::filter()->wiki()->setOpt('note_prefix', 'wnote-' . $option_id);
if (strpos($lang, 'fr') === 0) {
- dcCore::app()->wiki2xhtml->setOpt('active_fr_syntax', 1);
+ App::filter()->wiki()->setOpt('active_fr_syntax', 1);
}
}
if ($content) {
- $content_xhtml = dcCore::app()->callFormater($format, $content);
- $content_xhtml = dcCore::app()->HTMLfilter($content_xhtml);
+ $content_xhtml = App::formater()->callEditorFormater('dcLegacyEditor', $format, $content);
+ $content_xhtml = App::filter()->HTMLfilter($content_xhtml);
} else {
$content_xhtml = '';
}
@@ -331,7 +319,7 @@ class Utils
$excerpt = $excerpt_xhtml = '';
# --BEHAVIOR-- coreAfterPostContentFormat -- array
- dcCore::app()->callBehavior('coreAfterPostContentFormat', [
+ App::behavior()->callBehavior('coreAfterPostContentFormat', [
'excerpt' => &$excerpt,
'content' => &$content,
'excerpt_xhtml' => &$excerpt_xhtml,
diff --git a/src/Widgets.php b/src/Widgets.php
index 0591ce8..001896c 100644
--- a/src/Widgets.php
+++ b/src/Widgets.php
@@ -1,28 +1,20 @@
create(
basename(__DIR__),
__('Post widget text'),
- [self::class, 'parseWidget'],
+ self::parseWidget(...),
null,
__('Add a widget with a text related to an entry')
)
@@ -68,9 +60,8 @@ class Widgets
{
if ($w->__get('offline')
|| !Utils::isActive()
- || is_null(dcCore::app()->ctx)
- || !dcCore::app()->ctx->exists('posts')
- || !dcCore::app()->ctx->__get('posts')->f('post_id')
+ || !App::frontend()->context()->exists('posts')
+ || !App::frontend()->context()->__get('posts')->f('post_id')
) {
return '';
}
@@ -78,7 +69,7 @@ class Widgets
$title = $w->__get('title') ?: null;
$content = '';
- $rs = Utils::getWidgets(['post_id' => dcCore::app()->ctx->__get('posts')->f('post_id')]);
+ $rs = Utils::getWidgets(['post_id' => App::frontend()->context()->__get('posts')->f('post_id')]);
if ($rs->isEmpty()) {
return '';
}
@@ -86,11 +77,11 @@ class Widgets
if ('' != $rs->f('option_title')) {
$title = $rs->f('option_title');
}
- if ('' != $rs->f('option_content_xhtml')) {
- $content = $rs->f('option_content_xhtml');
+ if ('' != $rs->f('option_content')) {
+ $content = $rs->f('option_content');
}
if ('' == $content && $w->__get('excerpt')) {
- $content = dcCore::app()->ctx->__get('posts')->f('post_excerpt_xhtml');
+ $content = App::frontend()->context()->__get('posts')->f('post_excerpt');
}
return $w->renderDiv(