Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
akrys committed Sep 13, 2024
2 parents fd4e02f + 45bea49 commit 31e17db
Show file tree
Hide file tree
Showing 44 changed files with 234 additions and 233 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ node_modules
/gulpfile.js
/composer.lock
/composer.json
/FriendsOfRedaxo/addon/UsageCheck/Tests

/lib/Tests
.phpunit.cache
_docs
49 changes: 0 additions & 49 deletions FriendsOfRedaxo/addon/UsageCheck/Config.php

This file was deleted.

This file was deleted.

18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Mit der Version 2.1 wandern die Bearbeiten-Links in eine Detail-Seite. Dadurch k
Normalerweise kann man das Addon normal über das Redaxo-Backend installieren. Im Normalfall sollte man als Benutzer auch
diesen Weg wählen.


### Manuelle Installation
Eine Ausnahme stellt das Testen von Beta-Funktionalitäten dar. Dann muss man ganz "old school" die Dateien laden und an
die richtige Stelle kopieren.
Expand All @@ -33,17 +32,6 @@ Man kann auch das hier generierte ZIP herunterladen und an die richtige Stelle k
Dann muss man das Addon nur noch über das Redaxo-Backend installieren und aktivieren.

## Kompatibilität
- PHP Version: __5.6.11__ oder höher
- getestet mit Redaxo __5.0.1__, __5.1__, __5.2__, __5.3__, __5.4__, __5.5__, __5.6__, __5.7__

## Hinweis Code-Analyse-Tools
Mit der Verison 1.0-Beta7 habe ich Code-Anlayse-Tools, wie z.B. `PHPUnit` eingebaut. Dafür schein es am Einfachsten zu
sein, eine `composer.json` zu erstellen und die Hilfsprogramme ins Projekt zu installieren. Leider kann durch den
AutoLoader im Redaxo-Core aber dazu kommen, dass sich die Seite in einen Timeout läuft. Es werden alle Dateien - auch
die in `vendor`-Ordnern - analysiert und u.U. eingebunden. Sollte man also in den Fall rennen, kann man den `vendor`-
Ordner in diesem Addon einfach löschen, sofern vorhanden. Wenn er nicht vorhanden ist, so war ich auch nicht der
Übeltäter ;-)

Am Besten führt man die Tests komplett separat durch. Generell sind sie eh nur für mich, um ungenutzten Code bzw.
(SQL-)Fehler zu finden.

- PHP Version: __8.1__ oder höher
- der neuesten Redaxo-Version zum Zeitpunkt des Releases (Mehrere Instanzen zu betreuen, schaffe ich zeigtlich nicht
mehr.)
15 changes: 3 additions & 12 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ your Redaxo copy version.
After copying the files you'll need to install and activate this addon using the Redaxo backend.

## Compatibility
- PHP version: __5.6.11__ or later
- tested on Redaxo versions __5.0.1__, __5.1__, __5.2__, __5.3__, __5.4__, __5.5__, __5.6__, __5.7__

## Notice on code-analyzing tools
As of version 1.0-Beta7, I'm using some code analyzing tools such as `PHPUnit`.
It seems to be the easiest way to write a `composer.json` and install these tools into the project. I didn't notice the
redaxo Autoloader. It analyzes all PHP-Files, including `vendor`-directories. So, it's possible for the page to run into
a timeout. In this case, simply you can simply delete the `vendor`-directory in this addon. If it's not present, it
wasn't me, who killed your page ;-)

The best way of testing: just do it seperatly from your redaxo installation. Basicly, these tests are ment for me. Just
to find unused code or (SQL-)Erros.
- PHP version: __8.1__ or later
- tested on lagetes Redaxo version at release time (to maintain more instances of redaxo is not possible anymore due
to a lack of time)
17 changes: 11 additions & 6 deletions boot.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

/**
* Generelle Configuration
*/
require_once __DIR__.'/FriendsOfRedaxo/addon/UsageCheck/Config.php';
require_once __DIR__.'/lib/Config.php'; // remove in v4

/** @phpstan-ignore-next-line */
spl_autoload_register(['FriendsOfRedaxo\\addon\\UsageCheck\\Config', 'autoload'], true, true);
spl_autoload_register(['FriendsOfRedaxo\\UsageCheck\\Config', 'autoload'], true, true); // remove in v4

class_alias(FriendsOfRedaxo\UsageCheck\Exception\CloneException::class, 'FriendsOfRedaxo\\addon\\UsageCheck\\Exception\\CloneException');// remove in v4
class_alias(FriendsOfRedaxo\UsageCheck\Exception\FunctionNotCallableException::class, 'FriendsOfRedaxo\\addon\\UsageCheck\\Exception\\FunctionNotCallableException');// remove in v4
class_alias(FriendsOfRedaxo\UsageCheck\Exception\InvalidParameterException::class, 'FriendsOfRedaxo\\addon\\UsageCheck\\Exception\\InvalidParameterException');// remove in v4
class_alias(FriendsOfRedaxo\UsageCheck\Exception\InvalidVersionException::class, 'FriendsOfRedaxo\\addon\\UsageCheck\\Exception\\InvalidVersionException');// remove in v4
class_alias(FriendsOfRedaxo\UsageCheck\Exception\MediaNotFoundException::class, 'FriendsOfRedaxo\\addon\\UsageCheck\\Exception\\MediaNotFoundException');// remove in v4

// Namespace-Test old namespace
//$x = new \FriendsOfRedaxo\addon\UsageCheck\Modules\Templates;

$dir = realpath(__DIR__);
if ($dir !== false) {
Expand Down
2 changes: 1 addition & 1 deletion fragments/modules/actions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use FriendsOfRedaxo\addon\UsageCheck\Modules\Actions;
use FriendsOfRedaxo\UsageCheck\Modules\Actions;
?>

<table class="table table-striped">
Expand Down
4 changes: 2 additions & 2 deletions fragments/modules/details/picture.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use FriendsOfRedaxo\addon\UsageCheck\Lib\FileSize;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Pictures;
use FriendsOfRedaxo\UsageCheck\Lib\FileSize;
use FriendsOfRedaxo\UsageCheck\Modules\Pictures;

if (count($this->errors) > 0) {
$fragment = new rex_fragment(['msg' => $this->errors]);
Expand Down
2 changes: 1 addition & 1 deletion fragments/modules/modules.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use FriendsOfRedaxo\addon\UsageCheck\Modules\Modules;
use FriendsOfRedaxo\UsageCheck\Modules\Modules;

$user = rex::getUser();
?>
Expand Down
6 changes: 3 additions & 3 deletions fragments/modules/pictures.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use FriendsOfRedaxo\addon\UsageCheck\Lib\FileSize;
use FriendsOfRedaxo\addon\UsageCheck\Medium;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Pictures;
use FriendsOfRedaxo\UsageCheck\Lib\FileSize;
use FriendsOfRedaxo\UsageCheck\Medium;
use FriendsOfRedaxo\UsageCheck\Modules\Pictures;

$user = rex::getUser();
$mediaPerm = $user?->getComplexPerm('media');
Expand Down
2 changes: 1 addition & 1 deletion fragments/modules/templates.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use FriendsOfRedaxo\addon\UsageCheck\Modules\Templates;
use FriendsOfRedaxo\UsageCheck\Modules\Templates;
$user = rex::getUser();
?>

Expand Down
12 changes: 2 additions & 10 deletions help.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@

<h3> Kompatibilität</h3>
<ul>
<li>PHP Version: <b>5.6</b> oder höher</li>
<li>PHP Version: <b>8.1</b> oder höher</li>
<li>
getestet mit Redaxo
<b>5.0.1</b>,
<b>5.1</b>,
<b>5.2</b>,
<b>5.3</b>,
<b>5.4</b>,
<b>5.5</b>,
<b>5.6</b>,
<b>5.7</b>
getestet mit der neuesten Redaxo-Version zum Zeitpunkt des Releases
</li>
</ul>
9 changes: 0 additions & 9 deletions install.php

This file was deleted.

5 changes: 2 additions & 3 deletions FriendsOfRedaxo/addon/UsageCheck/Addon.php → lib/Addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
/**
* Datei für ...
*
* @version 1.0 / 2020-02-18
* @author akrys
*/
namespace FriendsOfRedaxo\addon\UsageCheck;
namespace FriendsOfRedaxo\UsageCheck;

use FriendsOfRedaxo\addon\UsageCheck\Exception\CloneException;
use FriendsOfRedaxo\UsageCheck\Exception\CloneException;
use rex_addon;
use rex_addon_interface;

Expand Down
89 changes: 89 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

/**
* Config-Datei
* @author akrys
*/
namespace FriendsOfRedaxo\UsageCheck;

/**
* Config-Klasse mit Konstanten für die Runtime
* @author akrys
*/
class Config
{
/**
* Technischer Name des Addons
* @var string
*/
const NAME = 'usage_check';

/**
* (Absolutes) Basis Verzeichnis holen
* @return string
* @deprecated wird nicht mehr benötigt, sobald alte Klassen mit 'addon' im Namespace nicht mehr unterstützt werden
* @codeCoverageIgnore
*/
public static function getBaseDir() // remove in v4
{
return (string) realpath(__DIR__);
}

/**
* Autoload Funktion
* @param string $name
* @return void
*
* @deprecated wird nicht mehr benötigt, sobald alte Klassen mit 'addon' im Namespace nicht mehr unterstützt werden
* @codeCoverageIgnore
*/
public static function autoload($name): void // remove in v4
{
if (stristr($name, 'FriendsOfRedaxo\\addon\\UsageCheck')) {
$oldName = $name;
$newName = str_replace('FriendsOfRedaxo\\addon\\UsageCheck', 'FriendsOfRedaxo\\UsageCheck', $name);

$backtrace = debug_backtrace();
$backtraceText = '';
$i = 0;
foreach ($backtrace as $key => $item) {
if (isset($backtrace[$key]['file']) && isset($backtrace[$key]['line'])) {
if (stristr($backtrace[$key]['file'], '/usage_check/')) {
continue;
}

$backtraceText = ' in '.$backtrace[$key]['file'].': '.$backtrace[$key]['line'];
break;
}
$i++;
}

$msg = "Deprecated class name found: ".$oldName.$backtraceText.PHP_EOL.'New class: '.$newName;

class_alias($newName, $oldName);

user_error($msg, E_USER_DEPRECATED);
$name = $newName;
}


if (!stristr($name, __NAMESPACE__)) {
return; // not a UsageCheck class
}

if (class_exists($name)) {
return;
}

//namespace parts not in directory structure.
$name = str_replace(__NAMESPACE__, '', $name);

$filename = self::getBaseDir().'/'.str_replace('\\', '/', $name).'.php';
if (file_exists($filename)) {
require $filename;
return;
}
// throw new \Exception($filename.' not found');
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPEnum.php to edit this template
*/
namespace FriendsOfRedaxo\addon\UsageCheck\Enum;
namespace FriendsOfRedaxo\UsageCheck\Enum;

use FriendsOfRedaxo\addon\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Actions;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Modules;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Pictures;
use FriendsOfRedaxo\addon\UsageCheck\Modules\Templates;
use FriendsOfRedaxo\UsageCheck\Lib\BaseModule;
use FriendsOfRedaxo\UsageCheck\Modules\Actions;
use FriendsOfRedaxo\UsageCheck\Modules\Modules;
use FriendsOfRedaxo\UsageCheck\Modules\Pictures;
use FriendsOfRedaxo\UsageCheck\Modules\Templates;
use rex_i18n;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPEnum.php to edit this template
*/
namespace FriendsOfRedaxo\addon\UsageCheck\Enum;
namespace FriendsOfRedaxo\UsageCheck\Enum;

/**
*
Expand Down
5 changes: 2 additions & 3 deletions FriendsOfRedaxo/addon/UsageCheck/Error.php → lib/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
/**
* Datei für die Error-Klasse
*
* @version 1.0 / 2015-10-27
* @author akrys
*/
namespace FriendsOfRedaxo\addon\UsageCheck;
namespace FriendsOfRedaxo\UsageCheck;

use FriendsOfRedaxo\addon\UsageCheck\Exception\CloneException;
use FriendsOfRedaxo\UsageCheck\Exception\CloneException;
use Iterator;
use rex_fragment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
*
* Die Exception verhindert, dass Singleton-Objekte geklont werden können.
*
* @version 1.0 / 2015-10-27
* @author akrys
*/
namespace FriendsOfRedaxo\addon\UsageCheck\Exception;
namespace FriendsOfRedaxo\UsageCheck\Exception;

/**
* Description of CloneException
Expand Down
Loading

0 comments on commit 31e17db

Please sign in to comment.