From 652deff380582d11ab48d713a141d213e1009ea7 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 22 Dec 2022 00:09:55 +0100 Subject: [PATCH] use abstract plugin id --- _admin.php | 12 ++++++------ _install.php | 2 +- _prepend.php | 2 +- _public.php | 16 ++++++++-------- index.php | 16 ++++++++-------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/_admin.php b/_admin.php index 2f22674..3ab44c7 100644 --- a/_admin.php +++ b/_admin.php @@ -16,18 +16,18 @@ if (!defined('DC_CONTEXT_ADMIN')) { dcCore::app()->menu[dcAdmin::MENU_BLOG]->addItem( __('Media sharing'), - dcCore::app()->adminurl->get('admin.plugin.filesAlias'), - urldecode(dcPage::getPF('filesAlias/icon.svg')), - preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.filesAlias')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), + dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), + urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')), + preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']), dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id) ); dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) { $favs->register('filesAlias', [ 'title' => __('Media sharing'), - 'url' => dcCore::app()->adminurl->get('admin.plugin.filesAlias'), - 'small-icon' => dcPage::getPF('filesAlias/icon.svg'), - 'large-icon' => dcPage::getPF('filesAlias/icon.svg'), + 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), + 'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'), + 'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'), 'permissions' => dcCore::app()->auth->makePermissions([ dcAuth::PERMISSION_USAGE, dcAuth::PERMISSION_CONTENT_ADMIN, diff --git a/_install.php b/_install.php index b25189a..1edc6a0 100644 --- a/_install.php +++ b/_install.php @@ -16,7 +16,7 @@ if (!defined('DC_CONTEXT_ADMIN')) { try { if (!dcCore::app()->newVersion( - basename(__DIR__), + basename(__DIR__), dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version') )) { return null; diff --git a/_prepend.php b/_prepend.php index 85fbf0a..eb326da 100644 --- a/_prepend.php +++ b/_prepend.php @@ -20,7 +20,7 @@ Clearbricks::lib()->autoload([ 'PallazzoTools' => __DIR__ . '/inc/lib.files.alias.tools.php', ]); -dcCore::app()->filealias = new filesAliases(); +dcCore::app()->__set('filealias', new filesAliases()); dcCore::app()->url->register( 'filesalias', diff --git a/_public.php b/_public.php index 19a779d..bd4961a 100644 --- a/_public.php +++ b/_public.php @@ -33,27 +33,27 @@ class urlFilesAlias extends dcUrlHandlers { $delete = false; - dcCore::app()->ctx->filealias = dcCore::app()->filealias->getAlias($args); + dcCore::app()->ctx->__set('filealias', dcCore::app()->__get('filealias')->getAlias($args)); - if (dcCore::app()->ctx->filealias->isEmpty()) { + if (dcCore::app()->ctx->__get('filealias')->isEmpty()) { self::p404(); } - if (dcCore::app()->ctx->filealias->filesalias_disposable) { + if (dcCore::app()->ctx->__get('filealias')->filesalias_disposable) { $delete = true; } - if (dcCore::app()->ctx->filealias->filesalias_password) { + if (dcCore::app()->ctx->__get('filealias')->filesalias_password) { # Check for match - if (!empty($_POST['filepassword']) && $_POST['filepassword'] == dcCore::app()->ctx->filealias->filesalias_password) { - self::servefile(dcCore::app()->ctx->filealias->filesalias_destination, $args, $delete); + if (!empty($_POST['filepassword']) && $_POST['filepassword'] == dcCore::app()->ctx->__get('filealias')->filesalias_password) { + self::servefile(dcCore::app()->ctx->__get('filealias')->filesalias_destination, $args, $delete); } else { self::serveDocument('file-password-form.html', 'text/html', false); return; } } else { - self::servefile(dcCore::app()->ctx->filealias->filesalias_destination, $args, $delete); + self::servefile(dcCore::app()->ctx->__get('filealias')->filesalias_destination, $args, $delete); } } @@ -83,7 +83,7 @@ class urlFilesAlias extends dcUrlHandlers readfile($file->file); if ($delete) { - dcCore::app()->filealias->deleteAlias($alias); + dcCore::app()->__get('filealias')->deleteAlias($alias); } } } diff --git a/index.php b/index.php index dc25a9c..e8b4b63 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$o = dcCore::app()->filealias; +$o = dcCore::app()->__get('filealias'); $aliases = $o->getAliases(); $media = new dcMedia(); $a = new aliasMedia(); @@ -25,7 +25,7 @@ if (isset($_POST['a']) && is_array($_POST['a'])) { try { $o->updateAliases($_POST['a']); dcAdminNotices::addSuccessNotice(__('Aliases successfully updated.')); - dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__)); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } @@ -47,7 +47,7 @@ if (isset($_POST['filesalias_url'])) { try { $o->createAlias($url, $target, $totrash, $password); dcAdminNotices::addSuccessNotice(__('Alias for this media created.')); - dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__)); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } @@ -61,7 +61,7 @@ if (isset($_POST['filesalias_url'])) { try { $o->createAlias($url, $target, $totrash, $password); dcAdminNotices::addSuccessNotice(__('Alias for this media modified.')); - dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__)); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } @@ -83,11 +83,11 @@ if ($part == 'new') { echo dcPage::breadcrumb([ html::escapeHTML(dcCore::app()->blog->name) => '', - __('Media sharing') => dcCore::app()->adminurl->get('admin.plugin.filesAlias'), + __('Media sharing') => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), __('New alias') => '', ]) . dcPage::notices() . - '
' . + '' . '

' . __('New alias') . '

' . '

' . form::field('filesalias_destination', 70, 255) . '

' . @@ -113,14 +113,14 @@ if ($part == 'new') { ]) . dcPage::notices() . '

' . __('New alias') . '

'; if (empty($aliases)) { echo '

' . __('No alias') . '

'; } else { echo - '' . + '' . '
' . '' . '' .
' . __('Aliases list') . '