diff --git a/CHANGELOG.md b/CHANGELOG.md index b6650d0..03baede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +noodles 1.2 - 2023.10.12 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + noodles 1.1 - 2023.08.15 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 2607986..045cbc2 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/oodles/releases) -[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/oodles/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-1.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/noodles/releases) +![Date](https://img.shields.io/badge/date-2023.10.12-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/oodles) -[![License](https://img.shields.io/github/license/JcDenis/oodles)](https://git.dotclear.watch/JcDenis/oodles/blob/master/LICENSE) +[![License](https://img.shields.io/github/license/JcDenis/noodles)](https://git.dotclear.watch/JcDenis/noodles/blob/master/LICENSE) -## WHAT IS NOODLES ? +## ABOUT -_noodles_ is a plugin for the open-source -web publishing software called Dotclear. +_whiteListCom_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -It adds gravatars everywhere it is possible on -your blog. comments, posts, widgets... +> Add gravatars everywhere it is possible on your blog. comments, posts, widgets... ## REQUIREMENTS -_noodles_ requires: - -* Permissions admin -* Dotclear 2.26 +* Dotclear 2.28 * PHP 8.1+ +* Permissions admin ## USAGE @@ -32,9 +28,11 @@ go to ''configure plugin'', fill in form. ## 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/oodles) or [GitHub Page](https://github.com/JcDenis/oodles) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/oodles/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/oodles) +* [License](https://git.dotclear.watch/JcDenis/noodles/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/noodles/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/noodles)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/noodles) (or on [GitHub](https://github.com/JcDenis/noodles)) +* [Issues & security](https://git.dotclear.watch/JcDenis/noodles/issues) (or on [GitHub](https://github.com/JcDenis/noodles/issues)) + ## CONTRIBUTORS diff --git a/_define.php b/_define.php index d437195..df7fa0e 100644 --- a/_define.php +++ b/_define.php @@ -1,38 +1,30 @@ registerModule( 'Noodles', 'Add users gravatars everywhere', 'Jean-Christian Denis and contributors', - '1.1', + '1.2', [ - 'requires' => [ - ['php', '8.1'], - ['core', '2.27'], - ], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, - ]), - 'settings' => [ - 'self' => '', - ], - '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' => ['self' => ''], + '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/dcstore.xml b/dcstore.xml index 1326b89..9cb35d5 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Noodles - 1.1 + 1.2 Jean-Christian Denis and contributors Add users gravatars everywhere - https://git.dotclear.watch/JcDenis/noodles/releases/download/v1.1/plugin-noodles.zip - 2.27 + https://git.dotclear.watch/JcDenis/noodles/releases/download/v1.2/plugin-noodles.zip + 2.28 https://git.dotclear.watch/JcDenis/noodles/src/branch/master/README.md https://git.dotclear.watch/JcDenis/noodles/issues diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php index e6add25..144e99a 100644 --- a/locales/fr/main.lang.php +++ b/locales/fr/main.lang.php @@ -21,7 +21,7 @@ L10n::$locales['See local default avatar.'] L10n::$locales['Enable plugin noodles on this blog'] = 'Activer le plugin Noodles sur ce blog'; L10n::$locales['Image API:'] = 'API des avatars :'; L10n::$locales['Default image:'] = 'Avatar par défaut :'; -L10n::$locales['You can add your own default avatar by adding file "%s" in media manager.'] = 'Vous pouvez ajouter votr epropre avatar par défaut en ajoutant un fichier "%s" au gestionnaire de média.'; +L10n::$locales['You can add your own default avatar by adding file "%s" in media manager.'] = 'Vous pouvez ajouter votre propre avatar par défaut en ajoutant un fichier "%s" au gestionnaire de média.'; L10n::$locales['Search area'] = 'Zone de recherche'; L10n::$locales['Rating'] = 'Évaluation'; L10n::$locales['Target'] = 'Cible'; diff --git a/locales/fr/main.po b/locales/fr/main.po index d5c346c..90cb73a 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -58,7 +58,7 @@ msgstr "Avatar par défaut :" #: src/Manage.php:130 msgid "You can add your own default avatar by adding file \"%s\" in media manager." -msgstr "Vous pouvez ajouter votr epropre avatar par défaut en ajoutant un fichier \"%s\" au gestionnaire de média." +msgstr "Vous pouvez ajouter votre propre avatar par défaut en ajoutant un fichier \"%s\" au gestionnaire de média." #: src/Manage.php:136 msgid "Search area" diff --git a/src/Backend.php b/src/Backend.php index f791679..7014e88 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,21 +1,18 @@ + * @return array */ public static function api(): array { diff --git a/src/Frontend.php b/src/Frontend.php index 58334dd..e3cc261 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,23 +1,19 @@ tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates'); + App::frontend()->tpl->setPath(App::frontend()->tpl->getPath(), My::path() . '/default-templates'); foreach ($targets->dump() as $target) { if ($target->active() && $target->hasPhpCallback()) { @@ -45,15 +41,15 @@ class Frontend extends Process } } - dcCore::app()->addBehavior('publicHeadContent', function (): void { - if (is_null(dcCore::app()->blog)) { + App::behavior()->addBehavior('publicHeadContent', function (): void { + if (!App::blog()->isDefined()) { return; } echo - dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('noodles_css')) . - dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getBase('noodles_file') . '/js/jquery.noodles.js') . - dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('noodles_js')); + App::plugins()->cssLoad(App::blog()->url() . App::url()->getURLFor('noodles_css')) . + App::plugins()->jsLoad(App::blog()->url() . App::url()->getBase('noodles_file') . '/js/jquery.noodles.js') . + App::plugins()->jsLoad(App::blog()->url() . App::url()->getURLFor('noodles_js')); }); return true; diff --git a/src/Image.php b/src/Image.php index e3ecc3c..87b925b 100644 --- a/src/Image.php +++ b/src/Image.php @@ -1,25 +1,26 @@ blog) - || !dcCore::app()->url->getBase('noodles_file') - ) { + if (!App::blog()->isDefined() || !App::url()->getBase('noodles_file')) { return [ 'theme' => ['dir' => null, 'url' => null], 'public' => ['dir' => null, 'url' => null], @@ -37,23 +36,23 @@ class Image ]; } - $public_url = dcCore::app()->blog->settings->get('system')->get('public_url'); + $public_url = App::blog()->settings()->get('system')->get('public_url'); if (!is_string($public_url)) { $public_url = ''; } return [ 'theme' => [ - 'dir' => Path::real(dcCore::app()->blog->themes_path . '/' . dcCore::app()->blog->settings->get('system')->get('theme') . '/img') . '/' . My::IMAGE, - 'url' => dcCore::app()->blog->settings->get('system')->get('themes_url') . dcCore::app()->blog->settings->get('system')->get('theme') . '/img/' . My::IMAGE, + 'dir' => Path::real(App::blog()->themesPath() . '/' . App::blog()->settings()->get('system')->get('theme') . '/img') . '/' . My::IMAGE, + 'url' => App::blog()->settings()->get('system')->get('themes_url') . App::blog()->settings()->get('system')->get('theme') . '/img/' . My::IMAGE, ], 'public' => [ - 'dir' => Path::real(dcCore::app()->blog->public_path) . '/' . My::IMAGE, - 'url' => dcCore::app()->blog->host . Path::clean($public_url) . '/' . My::IMAGE, + 'dir' => Path::real(App::blog()->publicPath()) . '/' . My::IMAGE, + 'url' => App::blog()->host() . Path::clean($public_url) . '/' . My::IMAGE, ], 'module' => [ 'dir' => Path::real(My::path() . '/default-templates/img') . '/' . My::IMAGE, - 'url' => dcCore::app()->blog->url . dcCore::app()->url->getBase('noodles_file') . '/img/' . My::IMAGE, + 'url' => App::blog()->url() . App::url()->getBase('noodles_file') . '/img/' . My::IMAGE, ], ]; } diff --git a/src/Install.php b/src/Install.php index 4d5e975..d04d96e 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,23 +1,20 @@ put('active', false, 'boolean', 'enable module', false, true); $s->put('api', 'http://www.gravatar.com/', 'string', 'external API', false, true); $s->put('local', false, 'boolean', 'use local image', false, true); @@ -44,7 +37,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 85e1035..ad62b2b 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -1,20 +1,10 @@ blog)) { + if (!App::blog()->isDefined()) { return false; } @@ -81,11 +78,11 @@ class Manage extends Process } $targets->export(); - 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; @@ -98,7 +95,7 @@ class Manage extends Process } // nullsafe check - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return; } diff --git a/src/My.php b/src/My.php index 41f1c1c..d64d179 100644 --- a/src/My.php +++ b/src/My.php @@ -1,26 +1,39 @@ App::task()->checkContext('BACKEND') + && App::blog()->isDefined() + && App::auth()->check(App::auth()->makePermissions([ + App::auth()::PERMISSION_CONTENT_ADMIN, + ]), App::blog()->id()), + + default => null, + }; + } } diff --git a/src/Prepend.php b/src/Prepend.php index 0c6e037..55c6c8d 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -1,22 +1,19 @@ url->register( + App::url()->register( 'noodles_file', 'noodles', '^noodles/(.+)$', - [UrlHandler::class, 'file'] + UrlHandler::file(...) ); // public URL for noodles service - dcCore::app()->url->register( + App::url()->register( 'noodles_service', 'noodle', '^noodle/$', - [UrlHandler::class, 'service'] + UrlHandler::service(...) ); // public URL for targets CSS contents - dcCore::app()->url->register( + App::url()->register( 'noodles_css', 'noodles.css', '^noodles\.css', - [UrlHandler::class, 'css'] + UrlHandler::css(...) ); // public URL for targets JS contents - dcCore::app()->url->register( + App::url()->register( 'noodles_js', 'noodles.js', '^noodles\.js', - [UrlHandler::class, 'js'] + UrlHandler::js(...) ); return true; diff --git a/src/Target.php b/src/Target.php index 313e8bf..daa4730 100644 --- a/src/Target.php +++ b/src/Target.php @@ -1,40 +1,57 @@ getUser($m[1]); + $rs = App::users()->getUser($m[1]); if ($rs->isEmpty()) { return ''; } @@ -47,7 +41,7 @@ class AuthorMode public static function author(Target $target): void { if ($target->active()) { - dcCore::app()->addBehavior('publicHeadContent', [self::class, 'publicHeadContent']); + App::behavior()->addBehavior('publicHeadContent', self::publicHeadContent(...)); } } @@ -57,14 +51,14 @@ class AuthorMode $target = $targets->get('author'); if (is_null($target) - || is_null(dcCore::app()->ctx) - || is_null(dcCore::app()->blog) - || dcCore::app()->ctx->__get('current_tpl') != 'author.html' + || !isset(App::frontend()->ctx) + || !App::blog()->isDefined() + || App::frontend()->ctx->__get('current_tpl') != 'author.html' ) { return; } - $u = dcCore::app()->ctx->__get('users'); + $u = App::frontend()->ctx->__get('users'); if (!($u instanceof MetaRecord)) { return; } @@ -72,7 +66,7 @@ class AuthorMode if (!is_string($u)) { return; } - $u = dcCore::app()->getUser($u)->f('user_email'); + $u = App::users()->getUser($u)->f('user_email'); if (!is_string($u)) { $u = ''; } diff --git a/src/Target/Generic.php b/src/Target/Generic.php index 964eb1e..27dd59a 100644 --- a/src/Target/Generic.php +++ b/src/Target/Generic.php @@ -1,39 +1,32 @@ blog)) { + if (!App::blog()->isDefined()) { return ''; } - $types = dcCore::app()->getPostTypes(); - $reg = '@^' . str_replace('%s', '(.*?)', preg_quote(dcCore::app()->blog->url . $types['post']['public_url'])) . '$@'; - $ok = preg_match($reg, $content, $m); + $reg = '@^' . str_replace('%s', '(.*?)', preg_quote(App::blog()->url() . App::postTypes()->get('post')->public_url)) . '$@'; + $ok = preg_match($reg, $content, $m); if (!$ok || !$m[1]) { return ''; } - $rs = dcCore::app()->blog->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]); + $rs = App::blog()->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]); if ($rs->isEmpty()) { return ''; } diff --git a/src/Target/Other.php b/src/Target/Other.php index ef1aea4..b4b0268 100644 --- a/src/Target/Other.php +++ b/src/Target/Other.php @@ -1,20 +1,10 @@ place() == 'prepend' || $target->place() == 'before' ? 'publicEntryBeforeContent' : 'publicEntryAfterContent'; - dcCore::app()->addBehavior($bhv, [self::class, 'publicEntryContent']); + App::behavior()->addBehavior($bhv, self::publicEntryContent(...)); } public static function publicEntryContent(): void @@ -45,14 +39,14 @@ class Other $target = $targets->get('posts'); if (is_null($target) - || is_null(dcCore::app()->ctx) - || is_null(dcCore::app()->blog) - || dcCore::app()->ctx->__get('current_tpl') != 'post.html' + || !isset(App::frontend()->ctx) + || !App::blog()->isDefined() + || App::frontend()->ctx->__get('current_tpl') != 'post.html' ) { return; } - $m = dcCore::app()->ctx->__get('posts'); + $m = App::frontend()->ctx->__get('posts'); if (!($m instanceof MetaRecord)) { return; } @@ -76,7 +70,7 @@ class Other $bhv = $target->place() == 'prepend' || $target->place() == 'before' ? 'publicCommentBeforeContent' : 'publicCommentAfterContent'; - dcCore::app()->addBehavior($bhv, [self::class, 'publicCommentContent']); + App::behavior()->addBehavior($bhv, self::publicCommentContent(...)); } public static function publicCommentContent(): void @@ -85,14 +79,14 @@ class Other $target = $targets->get('comments'); if (is_null($target) - || is_null(dcCore::app()->ctx) - || is_null(dcCore::app()->blog) - || dcCore::app()->ctx->__get('current_tpl') != 'post.html' + || !isset(App::frontend()->ctx) + || !App::blog()->isDefined() + || App::frontend()->ctx->__get('current_tpl') != 'post.html' ) { return; } - $m = dcCore::app()->ctx->__get('comments'); + $m = App::frontend()->ctx->__get('comments'); if (!($m instanceof MetaRecord)) { return; } diff --git a/src/Target/Wigets.php b/src/Target/Widgets.php similarity index 54% rename from src/Target/Wigets.php rename to src/Target/Widgets.php index 4fedb15..ba2a3fc 100644 --- a/src/Target/Wigets.php +++ b/src/Target/Widgets.php @@ -1,37 +1,31 @@ blog)) { + if (!App::blog()->isDefined()) { return ''; } $ok = preg_match('@\#c([0-9]+)$@', urldecode($content), $m); if (!$ok || !$m[1]) { return ''; } - $rs = dcCore::app()->blog->getComments(['no_content' => 1, 'comment_id' => $m[1], 'limit' => 1]); + $rs = App::blog()->getComments(['no_content' => 1, 'comment_id' => $m[1], 'limit' => 1]); if ($rs->isEmpty()) { return ''; } diff --git a/src/Targets.php b/src/Targets.php index 03d0b9e..d628fc5 100644 --- a/src/Targets.php +++ b/src/Targets.php @@ -1,40 +1,54 @@ The noodles stack */ + /** + * The noodles stack. + * + * @var array $targets + */ private array $targets = []; /** @@ -55,7 +69,7 @@ final class Targets $this->local = is_bool($local) ? $local : false; // add noodles - dcCore::app()->callBehavior('TargetsConstruct', $this); + App::behavior()->callBehavior('TargetsConstruct', $this); // add default noodles $this->registerDefault(); @@ -176,7 +190,7 @@ final class Targets */ private function registerDefault(): void { - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return; } @@ -185,7 +199,7 @@ final class Targets (new Target( id: 'posts', name: __('Entries'), - php_callback: [Target\Other::class, 'publicPosts'] + php_callback: Target\Other::publicPosts(...) )) ->setSize(48) ->setCss('float:right;margin:4px;') @@ -196,7 +210,7 @@ final class Targets (new Target( id: 'comments', name: __('Comments'), - php_callback: [Target\Other::class, 'publicComments'] + php_callback: Target\Other::publicComments(...) )) ->setActive(true) ->setSize(48) @@ -208,19 +222,19 @@ final class Targets (new Target( id: 'titlesposts', name: __('Entries titles'), - js_callback: [Target\Generic::class, 'postURL'] + js_callback: Target\Generic::postURL(...) )) ->setTarget('.post-title a') ->setCss('margin-right:2px;') ); - if (dcCore::app()->plugins->moduleExists('widgets')) { + if (App::plugins()->moduleExists('widgets')) { # Widget Selected entries $this->set( (new Target( id: 'bestof', name: __('Selected entries'), - js_callback: [Target\Generic::class, 'postURL'] + js_callback: Target\Generic::postURL(...) )) ->setTarget('.selected li a') ->setCss('margin-right:2px;') @@ -231,7 +245,7 @@ final class Targets (new Target( id: 'lastposts', name: __('Last entries'), - js_callback: [Target\Generic::class, 'postURL'] + js_callback: Target\Generic::postURL(...) )) ->setTarget('.lastposts li a') ->setCss('margin-right:2px;') @@ -242,7 +256,7 @@ final class Targets (new Target( id: 'lastcomments', name: __('Last comments'), - js_callback: [Target\Widgets::class, 'lastcomments'] + js_callback: Target\Widgets::lastcomments(...) )) ->setActive(true) ->setTarget('.lastcomments li a') @@ -251,14 +265,14 @@ final class Targets } # Plugin auhtorMode - if (dcCore::app()->plugins->moduleExists('authorMode') - && dcCore::app()->blog->settings->get('authormode')->get('authormode_active') + if (App::plugins()->moduleExists('authorMode') + && App::blog()->settings()->get('authormode')->get('authormode_active') ) { $this->set( (new Target( id: 'authorswidget', name: __('Authors widget'), - js_callback: [Target\AuthorMode::class, 'authors'] + js_callback: Target\AuthorMode::authors(...) )) ->setTarget('#authors ul li a') ->setCss('margin-right:2px;') @@ -268,7 +282,7 @@ final class Targets (new Target( id: 'author', name: __('Author'), - php_callback: [Target\AuthorMode::class, 'author'] + php_callback: Target\AuthorMode::author(...) )) ->setActive(true) ->setSize(48) @@ -280,7 +294,7 @@ final class Targets (new Target( id: 'authors', name: __('Authors'), - js_callback: [Target\AuthorMode::class, 'authors'] + js_callback: Target\AuthorMode::authors(...) )) ->setActive(true) ->setSize(32) @@ -290,14 +304,14 @@ final class Targets } # Plugin rateIt - if (dcCore::app()->plugins->moduleExists('rateIt') - && dcCore::app()->blog->settings->get('rateit')->get('rateit_active') + if (App::plugins()->moduleExists('rateIt') + && App::blog()->settings()->get('rateit')->get('rateit_active') ) { $this->set( (new Target( id: 'rateitpostsrank', name: __('Top rated entries'), - js_callback: [Target\Generic::class, 'postURL'] + js_callback: Target\Generic::postURL(...) )) ->setTarget('.rateitpostsrank.rateittypepost ul li a') // Only "post" type ->setCss('margin-right:2px;') @@ -305,12 +319,12 @@ final class Targets } # Plugin lastpostsExtend - if (dcCore::app()->plugins->moduleExists('lastpostsExtend')) { + if (App::plugins()->moduleExists('lastpostsExtend')) { $this->set( (new Target( id: 'lastpostsextend', name: __('Last entries (extend)'), - js_callback: [Target\Generic::class, 'postURL'] + js_callback: Target\Generic::postURL(...) )) ->setTarget('.lastpostsextend ul li a') ->setCss('margin-right:2px;') diff --git a/src/Uninstall.php b/src/Uninstall.php index aed40d9..ca7bcf3 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -1,23 +1,19 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; } diff --git a/src/UrlHandler.php b/src/UrlHandler.php index dad9736..e4e068f 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -1,28 +1,25 @@ blog)) { + if (!App::blog()->isDefined()) { self::p404(); } @@ -62,7 +59,7 @@ class UrlHandler extends dcUrlHandlers echo "\$(function(){if(!document.getElementById){return;} \n" . - "\$.fn.noodles.defaults.service_url = '" . Html::escapeJS(dcCore::app()->blog->url . dcCore::app()->url->getBase('noodles_service') . '/') . "'; \n" . + "\$.fn.noodles.defaults.service_url = '" . Html::escapeJS(App::blog()->url() . App::url()->getBase('noodles_service') . '/') . "'; \n" . "\$.fn.noodles.defaults.service_func = '" . Html::escapeJS('getNoodle') . "'; \n" . implode("\n", $targets) . "})\n"; @@ -72,7 +69,7 @@ class UrlHandler extends dcUrlHandlers public static function service(string $args): void { - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { self::p404(); } @@ -147,7 +144,7 @@ class UrlHandler extends dcUrlHandlers public static function file(string $args): void { - if (is_null(dcCore::app()->blog) + if (!App::blog()->isDefined() || !Targets::instance()->active || str_contains('..', $args) || !preg_match('#^([^\?]*)#', $args, $m) @@ -169,12 +166,12 @@ class UrlHandler extends dcUrlHandlers header('Content-Type: ' . $type . '; charset=UTF-8'); header('Content-Length: ' . filesize($f)); - if ($type != 'text/css' || dcCore::app()->blog->settings->get('system')->get('url_scan') == 'path_info') { + if ($type != 'text/css' || App::blog()->settings()->get('system')->get('url_scan') == 'path_info') { readfile($f); } else { echo preg_replace( '#url\((?!(http:)|/)#', - 'url(' . dcCore::app()->blog->url . dcCore::app()->url->getBase('noodles_file') . '/', + 'url(' . App::blog()->url() . App::url()->getBase('noodles_file') . '/', (string) file_get_contents($f) ); } @@ -187,7 +184,7 @@ class UrlHandler extends dcUrlHandlers if (str_contains($file, '..')) { return ''; } - $paths = dcCore::app()->tpl->getPath(); + $paths = App::frontend()->tpl->getPath(); foreach ($paths as $path) { if (preg_match('/tpl(\/|)$/', $path)) {