Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	akrys/redaxo/addon/UsageCheck/Config.php
#	general/config.inc.php
#	package.yml
  • Loading branch information
akrys committed Sep 11, 2016
2 parents aa47bda + 4b946bc commit 7985805
Show file tree
Hide file tree
Showing 116 changed files with 12,183 additions and 1,308 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs
node_modules
/vendor/
composer.lock
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ aktivieren.

## Kompatibilität
- PHP Version: __5.3.2__ oder höher
- getestet mit Redaxo __4.3.2__, __4.4.1__, __4.5__, __4.6.1__, __5.0.1__, __5.1__
- getestet mit Redaxo __4.3.2__, __4.4.1__, __4.5__, __4.6.1__, __4.7__, __5.0.1__, __5.1__, __5.2__

Der Code funktioniert für Redaxo 4 und Redaxo 5

Expand All @@ -42,3 +42,15 @@ Verzeichnis.
Leider kommt man da nicht drum herum, wenn der Code für beide Redaxo-Versionen
kompatibel sein soll und man gleichzeitig die Sprachdateien nur 1x pflegen will.


##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.

12 changes: 11 additions & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the Redaxo backend.

## Compatibility
- PHP version: __5.3.2__ or later
- tested on Redaxo versions __4.3.2__, __4.4.1__, __4.5__, __4.6.1__, __5.0.1__, __5.1__
- tested on Redaxo versions __4.3.2__, __4.4.1__, __4.5__, __4.6.1__, __4.7__, __5.0.1__, __5.1__, __5.2__

This addon works with Redaxo 4 and Redaxo 5

Expand All @@ -35,3 +35,13 @@ Redaxo 4 needs these files in __ISO-8859-1__, Redaxo 5 in __UTF-8__. So I
decided to use the old `xx_yy_utf8.lang` files as these are always UTF-8.
These have to be converted according to the used Redaxo version. That's why it
needs writing rights.

##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.
74 changes: 61 additions & 13 deletions akrys/redaxo/addon/UsageCheck/Config.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
/**
* Config-Datei
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck;

/**
* Config-Klasse mit Konstanten für die Runtime
* @author akrys
*/
class Config
{
/**
* AddonID
* @todo Addon registrieren um eine echte ID zu bekommen
* @var int
*/
const ID = 'usage_check';

/**
* Technischer Name des Addons
* @var string
Expand All @@ -33,7 +29,7 @@ class Config
*
* @var string
*/
const VERSION = '1.0 Beta 6a';
const VERSION = '1.0 Beta 7';

/**
* release state
Expand All @@ -53,4 +49,56 @@ class Config
*/
const RELEASE_STATE_DEV = 0;

}
/**
* (Absolutes) Basis Verzeichnis holen
* @return string
*/
public static function getBaseDir()
{
return realpath(__DIR__.'/../../../../');
}

/**
* Test, ob das Vendor-Verzeichnis gelöscht wurde.
*
* Performance-Probleme durch den rex_autoloader verhindern.
* Dieser versucht alle Dateien zu analysieren.
*
* @throws \Exception
* @codeCoverageIgnore
*/
public static function checkVendorDir()
{
if (!isset($_SERVER['argv'])) {
$vendorDir = self::getBaseDir().'/vendor';
if (file_exists($vendorDir) && is_dir($vendorDir)) {
throw new \Exception('Please delete '.realpath($vendorDir));
}

// $nodeDir = self::getBaseDir().'/node_modules';
// if(file_exists($nodeDir) && is_dir($nodeDir)){
// throw new \Exception('Please delete '.realpath($nodeDir));
// }
}
return true;
}

/**
* Autoload Funktion
* @param string $name
* @return boolean
*
* @codeCoverageIgnore
*/
public static function autoload($name)
{
$filename = self::getBaseDir().'/'.str_replace('\\', '/', $name).'.php';

if (file_exists($filename)) {
require $filename;
return true;
}
// throw new \Exception($filename.' not found');
return false;
}
}
66 changes: 49 additions & 17 deletions akrys/redaxo/addon/UsageCheck/Error.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace akrys\redaxo\addon\UsageCheck;

/**
* Datei für ...
* Datei für die Error-Klasse
*
* @version 1.0 / 2015-10-27
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck;

/**
* Description of Error
* Container für Fehlermeldungen
*
* Hier werden Fehler gesammelt, über die dann später iteriert werden kann.
*
* Implementiert den PHP-Iterator, so dass man über die Meldungen mit
* einem einfachen foreach durlaufen werden können.
*
* @author akrys
*/
Expand All @@ -28,6 +27,12 @@ class Error
*/
private $errors = array();

/**
* Iterator-Zählervariable
* @var int
*/
private $index = 0;

/**
* add a text to the messages
* @param string $text
Expand All @@ -39,16 +44,24 @@ public function add($text)
// <editor-fold defaultstate="collapsed" desc="Iterator Implementation">

/**
* Move forward to next element
*
* @see \Iterator::next()
* @link https://secure.php.net/manual/en/iterator.next.php
*
* @return int
*/
public function next()
{
$this->i++;
$this->index++;
return $this->current();
}

/**
* Return the current element
*
* @see \Iterator::current()
* @link https://secure.php.net/manual/en/iterator.current.php
*
* @return string
*/
Expand All @@ -57,33 +70,44 @@ public function current()
if (!$this->valid()) {
return false;
}
return $this->errors[$this->i];
return $this->errors[$this->index];
}

/**
* Rewind the Iterator to the first element
*
* @see \Iterator::rewind()
* @link https://secure.php.net/manual/en/iterator.rewind.php
*/
public function rewind()
{
$this->i = 0;
$this->index = 0;
}

/**
* Return the key of the current element
*
* @see \Iterator::key()
* @link https://secure.php.net/manual/en/iterator.key.php
*
* @return int
*/
public function key()
{
return $this->i;
return $this->index;
}

/**
* Checks if current position is valid
*
* @see \Iterator::valid()
* @link https://secure.php.net/manual/en/iterator.valid.php
*
* @return boolean
*/
public function valid()
{
if (!isset($this->errors[$this->i])) {
if (!isset($this->errors[$this->index])) {
return false;
}
return true;
Expand All @@ -109,11 +133,19 @@ public static function getInstance()
}

/**
* forbid cloning
* Konstuktor
*/
public function __clone()
final private function __construct()
{
$this->errors = array();
}

/**
* forbid cloning
*/
final public function __clone()
{
throw new Exception\CloneException();
}
// </editor-fold>
}
}
22 changes: 22 additions & 0 deletions akrys/redaxo/addon/UsageCheck/Exception/CloneException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* Datei für CloneException
*
* Die Exception verhindert, dass Singleton-Objekte geklont werden können.
*
* @version 1.0 / 2015-10-27
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Description of LangFileGenError
*
* @author akrys
*/
class CloneException
extends \Exception
{

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Datei für ...
* Datei für die FunctionNotCallableException
*
* Die Exception wird geworfen, wenn ein Funktionsaufruf ungültig war. z.B. wenn keine gültige Redaxo-Version erkannt
* wurde.
*
* @version 1.0 / 2016-02-14
* @package new_package
* @subpackage new_subpackage
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Description of FunctionNotCallableException
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* Datei für die InvalidVersionException
*
* @version 1.0 / 2016-07-15
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Wird geworfen, wenn es keine passende Funktionalität für die zugrunde liegende
* Redaxo-Version gibt.
*
* @author akrys
*/
class InvalidVersionException
extends \Exception
{
//put your code here
}
12 changes: 4 additions & 8 deletions akrys/redaxo/addon/UsageCheck/Exception/LangFileGenError.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Datei für ...
* Datei für LangFileGenError
*
* Die Exception wird geworfen, wenn die Sprachaufbereitung nicht richtig funktioniert hat.
*
* @version 1.0 / 2015-10-27
* @author akrys
*/
namespace akrys\redaxo\addon\UsageCheck\Exception;

/**
* Description of LangFileGenError
Expand Down
Loading

0 comments on commit 7985805

Please sign in to comment.