use abstract plugin id
This commit is contained in:
parent
b7e3a0bdec
commit
652deff380
5 changed files with 24 additions and 24 deletions
12
_admin.php
12
_admin.php
|
@ -16,18 +16,18 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_BLOG]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_BLOG]->addItem(
|
||||||
__('Media sharing'),
|
__('Media sharing'),
|
||||||
dcCore::app()->adminurl->get('admin.plugin.filesAlias'),
|
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||||
urldecode(dcPage::getPF('filesAlias/icon.svg')),
|
urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
||||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.filesAlias')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
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()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) {
|
||||||
$favs->register('filesAlias', [
|
$favs->register('filesAlias', [
|
||||||
'title' => __('Media sharing'),
|
'title' => __('Media sharing'),
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.filesAlias'),
|
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||||
'small-icon' => dcPage::getPF('filesAlias/icon.svg'),
|
'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'),
|
||||||
'large-icon' => dcPage::getPF('filesAlias/icon.svg'),
|
'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'),
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_USAGE,
|
dcAuth::PERMISSION_USAGE,
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
|
|
|
@ -20,7 +20,7 @@ Clearbricks::lib()->autoload([
|
||||||
'PallazzoTools' => __DIR__ . '/inc/lib.files.alias.tools.php',
|
'PallazzoTools' => __DIR__ . '/inc/lib.files.alias.tools.php',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
dcCore::app()->filealias = new filesAliases();
|
dcCore::app()->__set('filealias', new filesAliases());
|
||||||
|
|
||||||
dcCore::app()->url->register(
|
dcCore::app()->url->register(
|
||||||
'filesalias',
|
'filesalias',
|
||||||
|
|
16
_public.php
16
_public.php
|
@ -33,27 +33,27 @@ class urlFilesAlias extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
$delete = false;
|
$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();
|
self::p404();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dcCore::app()->ctx->filealias->filesalias_disposable) {
|
if (dcCore::app()->ctx->__get('filealias')->filesalias_disposable) {
|
||||||
$delete = true;
|
$delete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dcCore::app()->ctx->filealias->filesalias_password) {
|
if (dcCore::app()->ctx->__get('filealias')->filesalias_password) {
|
||||||
# Check for match
|
# Check for match
|
||||||
if (!empty($_POST['filepassword']) && $_POST['filepassword'] == dcCore::app()->ctx->filealias->filesalias_password) {
|
if (!empty($_POST['filepassword']) && $_POST['filepassword'] == dcCore::app()->ctx->__get('filealias')->filesalias_password) {
|
||||||
self::servefile(dcCore::app()->ctx->filealias->filesalias_destination, $args, $delete);
|
self::servefile(dcCore::app()->ctx->__get('filealias')->filesalias_destination, $args, $delete);
|
||||||
} else {
|
} else {
|
||||||
self::serveDocument('file-password-form.html', 'text/html', false);
|
self::serveDocument('file-password-form.html', 'text/html', false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
readfile($file->file);
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
dcCore::app()->filealias->deleteAlias($alias);
|
dcCore::app()->__get('filealias')->deleteAlias($alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
index.php
16
index.php
|
@ -14,7 +14,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = dcCore::app()->filealias;
|
$o = dcCore::app()->__get('filealias');
|
||||||
$aliases = $o->getAliases();
|
$aliases = $o->getAliases();
|
||||||
$media = new dcMedia();
|
$media = new dcMedia();
|
||||||
$a = new aliasMedia();
|
$a = new aliasMedia();
|
||||||
|
@ -25,7 +25,7 @@ if (isset($_POST['a']) && is_array($_POST['a'])) {
|
||||||
try {
|
try {
|
||||||
$o->updateAliases($_POST['a']);
|
$o->updateAliases($_POST['a']);
|
||||||
dcAdminNotices::addSuccessNotice(__('Aliases successfully updated.'));
|
dcAdminNotices::addSuccessNotice(__('Aliases successfully updated.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.filesAlias');
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ if (isset($_POST['filesalias_url'])) {
|
||||||
try {
|
try {
|
||||||
$o->createAlias($url, $target, $totrash, $password);
|
$o->createAlias($url, $target, $totrash, $password);
|
||||||
dcAdminNotices::addSuccessNotice(__('Alias for this media created.'));
|
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) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ if (isset($_POST['filesalias_url'])) {
|
||||||
try {
|
try {
|
||||||
$o->createAlias($url, $target, $totrash, $password);
|
$o->createAlias($url, $target, $totrash, $password);
|
||||||
dcAdminNotices::addSuccessNotice(__('Alias for this media modified.'));
|
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) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,11 @@ if ($part == 'new') {
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
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') => '',
|
__('New alias') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.filesAlias') . '" method="post">' .
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post">' .
|
||||||
'<h3>' . __('New alias') . '</h3>' .
|
'<h3>' . __('New alias') . '</h3>' .
|
||||||
'<p ><label for="filesalias_destination" class="required">' . __('Destination:') . ' </label>' .
|
'<p ><label for="filesalias_destination" class="required">' . __('Destination:') . ' </label>' .
|
||||||
form::field('filesalias_destination', 70, 255) . '</p>' .
|
form::field('filesalias_destination', 70, 255) . '</p>' .
|
||||||
|
@ -113,14 +113,14 @@ if ($part == 'new') {
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
'<p class="top-add"><a class="button add" href="' .
|
'<p class="top-add"><a class="button add" href="' .
|
||||||
dcCore::app()->adminurl->get('admin.plugin.filesAlias', ['part' => 'new']) .
|
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'new']) .
|
||||||
'">' . __('New alias') . '</a></p>';
|
'">' . __('New alias') . '</a></p>';
|
||||||
|
|
||||||
if (empty($aliases)) {
|
if (empty($aliases)) {
|
||||||
echo '<p>' . __('No alias') . '</p>';
|
echo '<p>' . __('No alias') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
echo
|
echo
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.filesAlias') . '" method="post">' .
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post">' .
|
||||||
'<div class="table-outer">' .
|
'<div class="table-outer">' .
|
||||||
'<table><thead>' .
|
'<table><thead>' .
|
||||||
'<caption>' . __('Aliases list') . '</caption>' .
|
'<caption>' . __('Aliases list') . '</caption>' .
|
||||||
|
|
Loading…
Reference in a new issue