Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
akrys committed Nov 12, 2024
2 parents 31e17db + f6e2bcf commit 5695532
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 63 deletions.
20 changes: 20 additions & 0 deletions lib/Exception/PermissionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Datei für ...
*
* @version 1.0 / 2024-11-12
* @author akrys
*/
namespace FriendsOfRedaxo\UsageCheck\Exception;

/**
* Description of PermissionException
*
* @author akrys
*/
class PermissionException
extends \Exception
{
//put your code here
}
3 changes: 2 additions & 1 deletion lib/Modules/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use FriendsOfRedaxo\UsageCheck\Enum\ModuleType;
use FriendsOfRedaxo\UsageCheck\Enum\Perm;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\UsageCheck\Permission;
use rex_sql;
Expand Down Expand Up @@ -36,7 +37,7 @@ class Actions extends BaseModule
public function get(): array
{
if (!$this->hasPerm()) {
return [];
throw new PermissionException();
}

$rexSQL = $this->getRexSql();
Expand Down
4 changes: 2 additions & 2 deletions lib/Modules/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use FriendsOfRedaxo\UsageCheck\Enum\ModuleType;
use FriendsOfRedaxo\UsageCheck\Enum\Perm;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\UsageCheck\Permission;
use rex_sql;
Expand Down Expand Up @@ -36,8 +37,7 @@ class Modules extends BaseModule
public function get(): array
{
if (!$this->hasPerm()) {
//Permission::PERM_MODUL
return [];
throw new PermissionException();
}

$rexSQL = $this->getRexSql();
Expand Down
5 changes: 3 additions & 2 deletions lib/Modules/Pictures.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Exception;
use FriendsOfRedaxo\UsageCheck\Enum\ModuleType;
use FriendsOfRedaxo\UsageCheck\Enum\Perm;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\UsageCheck\Lib\PictureYFrom;
use FriendsOfRedaxo\UsageCheck\Medium;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function setCategory(int $id): void
public function get(): array
{
if (!$this->hasPerm()) {
return [];
throw new PermissionException();
}

$rexSQL = $this->getRexSql();
Expand Down Expand Up @@ -585,7 +586,7 @@ public static function showUsedInfo(array $item, array $fields): string
* Rechte prüfen
* @return bool
*/
public function hasPerm():bool
public function hasPerm(): bool
{
return Permission::getInstance()->check(Perm::PERM_MEDIA);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Modules/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use FriendsOfRedaxo\UsageCheck\Enum\ModuleType;
use FriendsOfRedaxo\UsageCheck\Enum\Perm;
use FriendsOfRedaxo\UsageCheck\Error;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\UsageCheck\Permission;
use rex;
Expand Down Expand Up @@ -56,8 +57,7 @@ public function get(): array
$showInactive = $this->showInactive;

if (!$this->hasPerm()) {
//Permission::PERM_TEMPLATE
return [];
throw new PermissionException();
}

$user = rex::getUser();
Expand Down
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: usage_check
version: '3.2'
version: '3.2.1'
author: Axel Krysztofiak
supportpage: https://github.com/akrys/redaxo-usage_check
#load: early
Expand Down
28 changes: 14 additions & 14 deletions pages/_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

use FriendsOfRedaxo\UsageCheck\Addon;
use FriendsOfRedaxo\UsageCheck\Config;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Modules\Actions;

if(!isset($subpage)) {
throw new \Exception("this file should not be called directly.");
if (!isset($subpage)) {
throw new Exception("this file should not be called directly.");
}

$title = new rex_fragment();
Expand All @@ -18,7 +19,6 @@
$title->setVar('version', Addon::getInstance()->getVersion());
echo rex_view::title($title->parse('fragments/title.php'));


$actions = new Actions();
$actions->setRexSql(rex_sql::factory());

Expand All @@ -34,18 +34,9 @@

$actions->showAll($showAll);

$items = $actions->get();
try {
$items = $actions->get();

if (empty($items)) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
} else {
$showAllParam = '&showall=true';
$showAllLinktext = rex_i18n::rawMsg('akrys_usagecheck_action_link_show_all');
if ($showAll) {
Expand All @@ -70,4 +61,13 @@
'actions' => $actions,
]);
echo $fragment->parse('fragments/modules/actions.php');
} catch (PermissionException $e) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
}
29 changes: 16 additions & 13 deletions pages/_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
/**
* Frontend-Ausagbe für die Seite Module
*/

use FriendsOfRedaxo\UsageCheck\Addon;
use FriendsOfRedaxo\UsageCheck\Config;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Modules\Modules;

if(!isset($subpage)) {
throw new \Exception("this file should not be called directly.");
if (!isset($subpage)) {
throw new Exception("this file should not be called directly.");
}

$modules = new Modules();
Expand All @@ -32,18 +34,9 @@
$title->setVar('version', Addon::getInstance()->getVersion());
echo rex_view::title($title->parse('fragments/title.php'));

$items = $modules->get();
try {
$items = $modules->get();

if (empty($items)) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
} else {
$showAllParam = '&showall=true';
$showAllLinktext = rex_i18n::rawMsg('akrys_usagecheck_module_link_show_all');
if ($showAll) {
Expand All @@ -68,4 +61,14 @@
'modules' => $modules,
]);
echo $fragment->parse('fragments/modules/modules.php');
} catch (PermissionException $e) {
$items = [];
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
}
29 changes: 15 additions & 14 deletions pages/_picture.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
/**
* Anzeige der nicht verwendeten Bilder.
*/

use FriendsOfRedaxo\UsageCheck\Addon;
use FriendsOfRedaxo\UsageCheck\Config;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Modules\Pictures;

if(!isset($subpage)) {
throw new \Exception("this file should not be called directly.");
if (!isset($subpage)) {
throw new Exception("this file should not be called directly.");
}

$pictures = new Pictures();
Expand Down Expand Up @@ -37,19 +39,9 @@
$pictures->setCategory($fileCat);
$catParam = '&rex_file_category='.$fileCat;
}
try {
$items = $pictures->get();

$items = $pictures->get();

if (empty($items)) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
} else {
$showAllLinktext = rex_i18n::rawMsg('akrys_usagecheck_images_link_show_unused');
$showAllParam = '';
if (!$showAll) {
Expand All @@ -74,4 +66,13 @@
'pictures' => $pictures,
]);
echo $fragment->parse('fragments/modules/pictures.php');
} catch (PermissionException $e) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
}
30 changes: 16 additions & 14 deletions pages/_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
/**
* Frontend-Ausagbe für die Seite Tempalte
*/

use FriendsOfRedaxo\UsageCheck\Addon;
use FriendsOfRedaxo\UsageCheck\Config;
use FriendsOfRedaxo\UsageCheck\Exception\PermissionException;
use FriendsOfRedaxo\UsageCheck\Modules\Templates;

if(!isset($subpage)) {
throw new \Exception("this file should not be called directly.");
if (!isset($subpage)) {
throw new Exception("this file should not be called directly.");
}

switch (rex_get('showall', 'string', "")) {
Expand Down Expand Up @@ -47,18 +49,10 @@
if ($showInactive) {
$templates->showInactive($showInactive);
}
$items = $templates->get();

if (empty($items)) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
} else {
try {
$items = $templates->get();

// <editor-fold defaultstate="collapsed" desc="Menü">

$param = [
Expand Down Expand Up @@ -106,7 +100,6 @@

$menu = new rex_fragment($params);


echo $menu->parse('fragments/menu/linklist.php');
// </editor-fold>

Expand All @@ -115,4 +108,13 @@
'templates' => $templates,
]);
echo $fragment->parse('fragments/modules/templates.php');
} catch (PermissionException $e) {
$msg = rex_i18n::rawMsg('akrys_usagecheck_no_rights');
$fragment = new rex_fragment([
'text' => $msg,
]);
$fragment = new rex_fragment([
'text' => $fragment->parse('fragments/msg/tagged_msg.php'),
]);
echo $fragment->parse('fragments/msg/error.php');
}
4 changes: 4 additions & 0 deletions pages/release_notes/de/2024-11-12_3.2.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<ul>
<li>Optimierung der Ansicht, wenn keine Ergebnisse gefunden werden.</li>
</ul>
4 changes: 4 additions & 0 deletions pages/release_notes/en/2024-11-12_3.2.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<ul>
<li>Output optimization if no results were found.</li>
</ul>

0 comments on commit 5695532

Please sign in to comment.