diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ca790d..20b6df4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +comListe 0.9 - 2023.10.15 +=========================================================== +* Require dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + comListe 0.8 - 2023.08.06 =========================================================== * Require dotclear 2.27 diff --git a/README.md b/README.md index 1e6d315..1e92b0d 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-0.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/comListe/releases) -[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/comListe/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-0.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/comListe/releases) +![Date](https://img.shields.io/badge/date-2023.10.15-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/comListe) -[![License](https://img.shields.io/github/license/JcDenis/comListe)](https://git.dotclear.watch/JcDenis/comListe/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/comListe/src/branch/master/LICENSE) -## WHAT IS COMLISTE ? +## ABOUT -_comListe_ is a plugin for the open-source -web publishing software called Dotclear. +_comListe_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -It adds public page of all comments and trackbacks. +> Add public page of all comments and trackbacks. ## REQUIREMENTS - _comListe_ requires: - - * admin perms for configuration - * Dotclear 2.27 +* Dotclear 2.28 +* PHP 8.1 +* Dotclear admin permissons for configuration ## USAGE @@ -35,15 +33,15 @@ to your theme tpl path and adapt them. ## 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/comListe) or [GitHub Page](https://github.com/JcDenis/comListe) - * Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/comListe/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/comListe) - * Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=333985) +* [Packages & details](https://git.dotclear.watch/JcDenis/comListe/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/comListe)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/comListe) (or on [GitHub](https://github.com/JcDenis/comListe)) +* [Issues & security](https://git.dotclear.watch/JcDenis/comListe/issues) (or on [GitHub](https://github.com/JcDenis/comListe/issues)) +* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=333985) ## CONTRIBUTORS - * Benoit de Marne (author) - * Pierre Van Glabeke - * Jean-Christian Denis +* Benoit de Marne (author) +* Pierre Van Glabeke +* Jean-Christian Denis (latest) - You are welcome to contribute to this code. \ No newline at end of file +You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index d5d1f1a..44f0471 100644 --- a/_define.php +++ b/_define.php @@ -1,35 +1,31 @@ registerModule( 'Comments list', 'Display a list of all comments and trackbacks of a blog in a public page', 'Benoit de Marne, Pierre Van Glabeke and contributors', - '0.8', + '0.9', [ - 'requires' => [['core', '2.26']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_ADMIN, - ]), - 'type' => 'plugin', - 'settings' => [ - 'self' => '', - ], - 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', - 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', - 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', + 'requires' => [['core', '2.28']], + 'permissions' => 'My', + 'type' => 'plugin', + 'settings' => ['self' => ''], + '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/dcstore.xml b/dcstore.xml index 256baea..41dec6b 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Comments list - 0.8 + 0.9 Benoit de Marne, Pierre Van Glabeke and contributors Display a list of all comments and trackbacks of a blog in a public page - https://git.dotclear.watch/JcDenis/comListe/releases/download/v0.8/plugin-comListe.zip - 2.26 + https://git.dotclear.watch/JcDenis/comListe/releases/download/v0.9/plugin-comListe.zip + 2.28 https://git.dotclear.watch/JcDenis/comListe/src/branch/master/README.md https://git.dotclear.watch/JcDenis/comListe/issues diff --git a/locales/en/resources.php b/locales/en/resources.php index b0f4a5c..a9c47bb 100644 --- a/locales/en/resources.php +++ b/locales/en/resources.php @@ -1,13 +1,10 @@ resources['help']['comListe'] = __DIR__ . '/help/comListe.html'; diff --git a/locales/fr/resources.php b/locales/fr/resources.php index b0f4a5c..a9c47bb 100644 --- a/locales/fr/resources.php +++ b/locales/fr/resources.php @@ -1,13 +1,10 @@ resources['help']['comListe'] = __DIR__ . '/help/comListe.html'; diff --git a/src/Backend.php b/src/Backend.php index 6f73f4b..cca7c48 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,24 +1,22 @@ addBehaviors([ + App::behavior()->addBehaviors([ // Dashboard favorites 'adminDashboardFavoritesV2' => function (Favorites $favs): void { $favs->register(My::id(), [ @@ -43,7 +41,7 @@ class Backend extends Process 'url' => My::manageUrl(), 'small-icon' => My::icons(), 'large-icon' => My::icons(), - 'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), + 'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), ]); }, 'adminSimpleMenuAddType' => function (ArrayObject $items): void { @@ -53,7 +51,7 @@ class Backend extends Process if (My::id() == $type) { $item[0] = My::name(); $item[1] = My::settings()->get('page_title') ?? My::name(); - $item[2] = dcCore::app()->admin->__get('blog_url') . dcCore::app()->url->getURLFor(My::id()); + $item[2] = App::backend()->__get('blog_url') . App::url()->getURLFor(My::id()); } }, ]); diff --git a/src/Frontend.php b/src/Frontend.php index fa62dd0..f414400 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,22 +1,20 @@ tpl->addValue('ComListeURL', [Template::class,'comListeURL']); - dcCore::app()->tpl->addValue('ComListePageTitle', [Template::class,'comListePageTitle']); - dcCore::app()->tpl->addValue('ComListeNbComments', [Template::class,'comListeNbComments']); - dcCore::app()->tpl->addValue('ComListeNbCommentsPerPage', [Template::class,'comListeNbCommentsPerPage']); - dcCore::app()->tpl->addBlock('ComListeCommentsEntries', [Template::class,'comListeCommentsEntries']); - dcCore::app()->tpl->addValue('ComListePaginationLinks', [Template::class,'comListePaginationLinks']); - dcCore::app()->tpl->addValue('ComListeOpenPostTitle', [Template::class,'comListeOpenPostTitle']); - dcCore::app()->tpl->addValue('ComListeCommentOrderNumber', [Template::class,'comListeCommentOrderNumber']); + App::frontend()->template()->addValue('ComListeURL', Template::comListeURL(...)); + App::frontend()->template()->addValue('ComListePageTitle', Template::comListePageTitle(...)); + App::frontend()->template()->addValue('ComListeNbComments', Template::comListeNbComments(...)); + App::frontend()->template()->addValue('ComListeNbCommentsPerPage', Template::comListeNbCommentsPerPage(...)); + App::frontend()->template()->addBlock('ComListeCommentsEntries', Template::comListeCommentsEntries(...)); + App::frontend()->template()->addValue('ComListePaginationLinks', Template::comListePaginationLinks(...)); + App::frontend()->template()->addValue('ComListeOpenPostTitle', Template::comListeOpenPostTitle(...)); + App::frontend()->template()->addValue('ComListeCommentOrderNumber', Template::comListeCommentOrderNumber(...)); - dcCore::app()->tpl->addBlock('ComListePagination', [Template::class,'comListePagination']); - dcCore::app()->tpl->addValue('ComListePaginationCounter', [Template::class,'comListePaginationCounter']); - dcCore::app()->tpl->addValue('ComListePaginationCurrent', [Template::class,'comListePaginationCurrent']); - dcCore::app()->tpl->addBlock('ComListePaginationIf', [Template::class,'comListePaginationIf']); - dcCore::app()->tpl->addValue('ComListePaginationURL', [Template::class,'comListePaginationURL']); + App::frontend()->template()->addBlock('ComListePagination', Template::comListePagination(...)); + App::frontend()->template()->addValue('ComListePaginationCounter', Template::comListePaginationCounter(...)); + App::frontend()->template()->addValue('ComListePaginationCurrent', Template::comListePaginationCurrent(...)); + App::frontend()->template()->addBlock('ComListePaginationIf', Template::comListePaginationIf(...)); + App::frontend()->template()->addValue('ComListePaginationURL', Template::comListePaginationURL(...)); - dcCore::app()->addBehavior( + App::behavior()->addBehavior( 'publicBreadcrumb', function (string $context, string $separator): ?string { if ($context == 'comListe') { diff --git a/src/Install.php b/src/Install.php index b5b5280..64850ac 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,23 +1,21 @@ blog)) { - return false; - } - try { $s = My::settings(); $s->put('enable', false, 'boolean', 'Enable comListe', false, true); @@ -44,7 +38,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 05120d8..51b8df9 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -1,20 +1,10 @@ blog)) { + if (!App::blog()->isDefined()) { return false; } @@ -67,11 +65,11 @@ class Manage extends Process $s->put('nb_comments_per_page', $_POST['comliste_nb_comments_per_page'] ?? 10); $s->put('comments_order', $_POST['comliste_comments_order'] == 'asc' ? 'asc' : 'desc'); - dcCore::app()->blog->triggerBlog(); + App::blog()->triggerBlog(); Notices::addSuccessNotice(__('Configuration successfully updated.')); My::redirect(); } catch (Exception $e) { - dcCore::app()->error->add($e->getMessage()); + App::error()->add($e->getMessage()); } return true; @@ -83,7 +81,7 @@ class Manage extends Process return; } - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return; } @@ -92,8 +90,8 @@ class Manage extends Process Page::openModule(My::name()); echo Page::breadcrumb([ - Html::escapeHTML(dcCore::app()->blog->name) => '', - My::name() => '', + Html::escapeHTML(App::blog()->name()) => '', + My::name() => '', ]) . Notices::getNotices() . diff --git a/src/My.php b/src/My.php index 3d8dfdb..91c53ff 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ url->register( + App::url()->register( 'comListe', 'comListe', '^comListe(?:/(.+))?$', - [UrlHandler::class, 'comListe'] + UrlHandler::comListe(...) ); return true; diff --git a/src/Template.php b/src/Template.php index ccd2d2f..16e559d 100644 --- a/src/Template.php +++ b/src/Template.php @@ -1,23 +1,21 @@ tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("comListe")') . '; ?>'; + return 'template()->getFilters($attr), 'App::blog()->url.App::url()->getBase("comListe")') . '; ?>'; } /* ComListePageTitle --------------------------------------- */ public static function comListePageTitle(ArrayObject $attr): string { - return 'tpl->getFilters($attr), 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("page_title")') . '; ?>'; + return 'template()->getFilters($attr), 'App::blog()->settings()->get("' . My::id() . '")->get("page_title")') . '; ?>'; } /* ComListeNbCommentsPerPage --------------------------------------- */ public static function comListeNbCommentsPerPage(ArrayObject $attr): string { - if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) { + if (!App::blog()->isDefined()) { return '10'; } - dcCore::app()->ctx->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page')); + App::frontend()->context()->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page')); - return Html::escapeHTML((string) dcCore::app()->ctx->__get('nb_comment_per_page')); + return Html::escapeHTML((string) App::frontend()->context()->__get('nb_comment_per_page')); } /* comListeNbComments --------------------------------------- */ public static function comListeNbComments(ArrayObject$attr): string { - if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) { + if (!App::blog()->isDefined()) { return '0'; } - if (!dcCore::app()->ctx->exists('pagination')) { - dcCore::app()->ctx->__set('pagination', dcCore::app()->blog->getComments([], true)); + if (!App::frontend()->context()->exists('pagination')) { + App::frontend()->context()->__set('pagination', App::blog()->getComments([], true)); } - $nb_comments = dcCore::app()->ctx->__get('pagination')->f(0); + $nb_comments = App::frontend()->context()->__get('pagination')->f(0); return Html::escapeHTML((string) $nb_comments); } @@ -63,9 +61,9 @@ class Template /* ComListeCommentsEntries --------------------------------------- */ public static function comListeCommentsEntries(ArrayObject $attr, string $content): string { - $p = 'if (dcCore::app()->ctx->posts !== null) { ' . - "\$params['post_id'] = dcCore::app()->ctx->posts->post_id; " . - "dcCore::app()->blog->withoutPassword(false);\n" . + $p = 'if (App::frontend()->context()->posts !== null) { ' . + "\$params['post_id'] = App::frontend()->context()->posts->post_id; " . + "App::blog()->withoutPassword(false);\n" . "}\n"; if (empty($attr['with_pings'])) { @@ -80,23 +78,23 @@ class Template if ($lastn > 0) { $p .= "\$params['limit'] = " . $lastn . ";\n"; } else { - $p .= "if (dcCore::app()->ctx->nb_comment_per_page !== null) { \$params['limit'] = dcCore::app()->ctx->nb_comment_per_page; }\n"; + $p .= "if (App::frontend()->context()->nb_comment_per_page !== null) { \$params['limit'] = App::frontend()->context()->nb_comment_per_page; }\n"; } - $p .= "\$params['limit'] = array(((dcCore::app()->public->getPageNumber()-1)*\$params['limit']),\$params['limit']);\n"; + $p .= "\$params['limit'] = array(((App::frontend()->getPageNumber()-1)*\$params['limit']),\$params['limit']);\n"; if (empty($attr['no_context'])) { - $p .= 'if (dcCore::app()->ctx->exists("categories")) { ' . - "\$params['cat_id'] = dcCore::app()->ctx->categories->cat_id; " . + $p .= 'if (App::frontend()->context()->exists("categories")) { ' . + "\$params['cat_id'] = App::frontend()->context()->categories->cat_id; " . "}\n"; - $p .= 'if (dcCore::app()->ctx->exists("langs")) { ' . - "\$params['sql'] = \"AND P.post_lang = '\".dcCore::app()->blog->con->escapeStr((string) dcCore::app()->langs->post_lang).\"' \"; " . + $p .= 'if (App::frontend()->context()->exists("langs")) { ' . + "\$params['sql'] = \"AND P.post_lang = '\".App::con()->escapeStr((string) App::frontend()->context()->langs->post_lang).\"' \"; " . "}\n"; } // Sens de tri issu des paramètres du plugin - $order = is_null(dcCore::app()->blog) ? 'desc' : My::settings()->get('comments_order'); + $order = !App::blog()->isDefined() ? 'desc' : My::settings()->get('comments_order'); if (isset($attr['order']) && preg_match('/^(desc|asc)$/i', $attr['order'])) { $order = $attr['order']; } @@ -109,17 +107,17 @@ class Template $res = "ctx->comments_params = $params; '; - $res .= 'dcCore::app()->ctx->comments = dcCore::app()->blog->getComments($params); unset($params);' . "\n"; - $res .= "if (dcCore::app()->ctx->posts !== null) { dcCore::app()->blog->withoutPassword(true);}\n"; + $res .= 'App::frontend()->context()->comments_params = $params; '; + $res .= 'App::frontend()->context()->comments = App::blog()->getComments($params); unset($params);' . "\n"; + $res .= "if (App::frontend()->context()->posts !== null) { App::blog()->withoutPassword(true);}\n"; if (!empty($attr['with_pings'])) { - $res .= 'dcCore::app()->ctx->pings = dcCore::app()->ctx->comments;' . "\n"; + $res .= 'App::frontend()->context()->pings = App::frontend()->context()->comments;' . "\n"; } $res .= "?>\n"; - $res .= 'ctx->comments->fetch()) : ?>' . $content . 'ctx->pop("comments"); ?>'; + $res .= 'context()->comments->fetch()) : ?>' . $content . 'context()->pop("comments"); ?>'; return $res; } @@ -131,10 +129,10 @@ class Template $p = 'public->getPageNumber()) { + if ($pageNumber != App::frontend()->getPageNumber()) { $args = $_SERVER["URL_REQUEST_PART"]; $args = preg_replace("#(^|/)page/([0-9]+)$#","",$args); - $url = dcCore::app()->blog->url.$args; + $url = App::blog()->url().$args; if ($pageNumber > 1) { $url = preg_replace("#/$#","",$url); @@ -152,20 +150,20 @@ class Template } } - $current = dcCore::app()->public->getPageNumber(); + $current = App::frontend()->getPageNumber(); if(empty($params)) { - dcCore::app()->ctx->pagination = dcCore::app()->blog->getComments(null,true); + App::frontend()->context()->pagination = App::blog()->getComments(null,true); } else { - dcCore::app()->ctx->pagination = dcCore::app()->blog->getComments($params,true); + App::frontend()->context()->pagination = App::blog()->getComments($params,true); unset($params); } - if (dcCore::app()->ctx->exists("pagination")) { - $nb_comments = dcCore::app()->ctx->pagination->f(0); + if (App::frontend()->context()->exists("pagination")) { + $nb_comments = App::frontend()->context()->pagination->f(0); } - $nb_per_page = abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page")); + $nb_per_page = abs((integer) App::blog()->settings->get("' . My::id() . '")->get("nb_comments_per_page")); $nb_pages = ceil($nb_comments/$nb_per_page); $nb_max_pages = 10; $nb_sequence = 2*3+1; @@ -222,17 +220,17 @@ class Template { return 'ctx->comments->index() + 1 +' . - '(dcCore::app()->public->getPageNumber() - 1) * ' . - 'abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page"));' . + 'App::frontend()->context()->comments->index() + 1 +' . + '(App::frontend()->getPageNumber() - 1) * ' . + 'abs((integer) App::blog()->settings()->get("' . My::id() . '")->get("nb_comments_per_page"));' . '?>'; } public static function comListePagination(ArrayObject $attr, string $content): string { $params = "ctx->comments_params;' . "\n" . - dcCore::app()->callBehavior( + '$params = App::frontend()->context()->comments_params;' . "\n" . + App::behavior()->callBehavior( 'templatePrepareParams', [ 'tag' => 'Pagination', @@ -241,7 +239,7 @@ class Template $attr, $content ) . - 'dcCore::app()->ctx->pagination = dcCore::app()->blog->getComments($params,true); unset($params);' . "\n" . + 'App::frontend()->context()->pagination = App::blog()->getComments($params,true); unset($params);' . "\n" . "?>\n"; if (isset($attr['no_context']) && $attr['no_context']) { @@ -250,27 +248,27 @@ class Template return "ctx->nb_entry_per_page; ' . "\n" . - 'dcCore::app()->ctx->nb_entry_per_page = abs((integer) dcCore::app()->blog->settings->get("' . My::id() . '")->get("nb_comments_per_page"));' . "\n" . + '$bakcup_old_nbpp = App::frontend()->context()->nb_entry_per_page; ' . "\n" . + 'App::frontend()->context()->nb_entry_per_page = abs((integer) App::blog()->settings()->get("' . My::id() . '")->get("nb_comments_per_page"));' . "\n" . "?>\n" . $params . - 'ctx->pagination->f(0) > dcCore::app()->ctx->comments->count()) : ?>' . + 'context()->pagination->f(0) > App::frontend()->context()->comments->count()) : ?>' . $content . "ctx->nb_entry_per_page = $bakcup_old_nbpp; ' . "\n" . + 'App::frontend()->context()->nb_entry_per_page = $bakcup_old_nbpp; ' . "\n" . '?>'; } public static function comListePaginationCounter(ArrayObject $attr): string { - return 'tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationNbPages()') . '; ?>'; + return 'template()->getFilters($attr), 'App::frontend()->context()::PaginationNbPages()') . '; ?>'; } public static function comListePaginationCurrent(ArrayObject $attr): string { $offset = isset($attr['offset']) ? (int) $attr['offset'] : 0; - return 'tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationPosition(' . $offset . ')') . '; ?>'; + return 'template()->getFilters($attr), 'App::frontend()->context()::PaginationPosition(' . $offset . ')') . '; ?>'; } public static function comListePaginationIf(ArrayObject $attr, string $content): string @@ -279,12 +277,12 @@ class Template if (isset($attr['start'])) { $sign = (bool) $attr['start'] ? '' : '!'; - $if[] = $sign . 'dcCore::app()->ctx::PaginationStart()'; + $if[] = $sign . 'App::frontend()->context()::PaginationStart()'; } if (isset($attr['end'])) { $sign = (bool) $attr['end'] ? '' : '!'; - $if[] = $sign . 'dcCore::app()->ctx::PaginationEnd()'; + $if[] = $sign . 'App::frontend()->context()::PaginationEnd()'; } if (count($if)) { @@ -301,6 +299,6 @@ class Template $offset = (int) $attr['offset']; } - return 'tpl->getFilters($attr), 'dcCore::app()->ctx::PaginationURL(' . $offset . ')') . '; ?>'; + return 'template()->getFilters($attr), 'App::frontend()->context()::PaginationURL(' . $offset . ')') . '; ?>'; } } diff --git a/src/Uninstall.php b/src/Uninstall.php index 7a7e134..cd94f02 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -1,23 +1,20 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; } diff --git a/src/UrlHandler.php b/src/UrlHandler.php index fc7ca5c..a4b02ba 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -1,43 +1,40 @@ blog) - || is_null(dcCore::app()->ctx) + if (!App::blog()->isDefined() || !My::settings()->get('enable') ) { self::p404(); } - dcCore::app()->public->setPageNumber(self::getPageNumber($args) ?: 1); - dcCore::app()->ctx->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page')); + App::frontend()->setPageNumber(self::getPageNumber($args) ?: 1); + App::frontend()->context()->__set('nb_comment_per_page', (int) My::settings()->get('nb_comments_per_page')); - $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset'); + $tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset'); if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()])); } self::serveDocument('comListe.html'); diff --git a/src/Widgets.php b/src/Widgets.php index eca2a0e..7207b34 100644 --- a/src/Widgets.php +++ b/src/Widgets.php @@ -1,24 +1,22 @@ create( My::id(), My::name(), - [self::class, 'parseWidget'], + self::parseWidget(...), null, __('Link to comments list public page') ) @@ -44,9 +42,9 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { - if (is_null(dcCore::app()->blog) + if (!App::blog()->isDefined() || $w->__get('offline') - || !$w->checkHomeOnly(dcCore::app()->url->type) + || !$w->checkHomeOnly(App::url()->type) || !My::settings()->get('enable') ) { return ''; @@ -59,7 +57,7 @@ class Widgets ($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') . sprintf( '

%s

', - dcCore::app()->blog->url . dcCore::app()->url->getBase('comListe'), + App::blog()->url() . App::url()->getBase('comListe'), $w->__get('link_title') ? Html::escapeHTML($w->__get('link_title')) : (My::settings()->get('page_title') ?? My::name()) ) );