Skip to content

Commit

Permalink
[TASK] Documentation update and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abeutel committed Jul 19, 2020
1 parent 6964c9d commit a70ca95
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 41 deletions.
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.3.11","version":"2.16.1","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":true,"cast_spaces":{"space":"none"},"concat_space":{"spacing":"one"},"function_typehint_space":true,"hash_to_slash_comment":true,"lowercase_cast":true,"modernize_types_casting":true,"native_function_casing":true,"no_alias_functions":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_blank_lines_before_namespace":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_consecutive_blank_lines":true,"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unused_imports":true,"no_useless_else":true,"no_whitespace_in_blank_line":true,"ordered_imports":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_no_access":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_order":true,"phpdoc_scalar":true,"phpdoc_single_line_var_spacing":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"self_accessor":true,"single_quote":true,"trailing_comma_in_multiline_array":true,"whitespace_after_comma_in_array":true},"hashes":{"Classes\/Backend\/PmaModule.php":2811090119,"Classes\/Controller\/PhpmyadminController.php":1481525829,"Classes\/Hooks\/BeUserAuthLogOffHook.php":4054383919,"Classes\/Utility\/EnvironmentUtility.php":1648830403}}
78 changes: 78 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}

// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => true,
'cast_spaces' => [
'space' => 'none',
],
'concat_space' => [
'spacing' => 'one',
],
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'lowercase_cast' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'self_accessor' => true,
'single_quote' => true,
'trailing_comma_in_multiline_array' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(
[
__DIR__ . '/Classes/',
]
)
->exclude('Vendor')
);
44 changes: 21 additions & 23 deletions Classes/Backend/PmaModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@
*/

use Mehrwert\Phpmyadmin\Utility\EnvironmentUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

/**
* Utilities for the phpMyAdmin third party database administration Tool
*
* @package TYPO3
* @subpackage tx_phpmyadmin
* @author mehrwert <[email protected]>
* @author Kasper Skårhøj <[email protected]>
* @license GPL
*/
class PmaModule
{

/**
* Configuration for the module
* @var array $MCONF
* @var array
*/
public $MCONF = [];

Expand All @@ -53,8 +50,6 @@ class PmaModule

/**
* The main method of the backend module
*
* @return void
*/
public function main()
{
Expand Down Expand Up @@ -91,8 +86,11 @@ public function main()
// Abort if devIPmask is wildcarded
if ($devIPmask != '*') {
$message = '<h1>' . $GLOBALS['LANG']->getLL('module.headline.accessDenied') . '</h1>
<p>' . sprintf($GLOBALS['LANG']->getLL('module.message.accessDenied.devIpMask'),
$remoteAddress, $devIPmask) . '</p>';
<p>' . sprintf(
$GLOBALS['LANG']->getLL('module.message.accessDenied.devIpMask'),
$remoteAddress,
$devIPmask
) . '</p>';
if (!GeneralUtility::cmpIP($remoteAddress, $devIPmask)) {
die($message);
}
Expand All @@ -103,8 +101,11 @@ public function main()
$allowedIps = trim($extensionConfiguration['allowedIps']);
if (!empty($allowedIps)) {
$message = '<h1>' . $GLOBALS['LANG']->getLL('module.headline.accessDenied') . '</h1>
<p>' . sprintf($GLOBALS['LANG']->getLL('module.message.accessDenied.allowedIps'),
$remoteAddress, $allowedIps) . '</p>';
<p>' . sprintf(
$GLOBALS['LANG']->getLL('module.message.accessDenied.allowedIps'),
$remoteAddress,
$allowedIps
) . '</p>';
if (!GeneralUtility::cmpIP($remoteAddress, $allowedIps)) {
die($message);
}
Expand Down Expand Up @@ -193,7 +194,7 @@ public function main()
'nl' => 'nl',
'cz' => 'cs-iso',
'pl' => 'pl',
'si' => 'sk'
'si' => 'sk',
];
$languageKey = $languageKeyMapping[$GLOBALS['LANG']->lang];
if (!$languageKey) {
Expand All @@ -209,7 +210,7 @@ public function main()
$headers = [
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
'Pragma: no-cache',
'Cache-Control: private'
'Cache-Control: private',
];
// Send all headers
foreach ($headers as $header) {
Expand All @@ -220,24 +221,23 @@ public function main()
$redirectUri,
HttpUtility::HTTP_STATUS_302
);

} else {
// Render body
$this->doc = GeneralUtility::makeInstance('TYPO3\CMS\Backend\Template\DocumentTemplate');
$this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('module.title'));
$this->content .= '<h1>' . $GLOBALS['LANG']->getLL('module.headline.error') . '</h1>';
// No configuration set
$this->content .= '<p>' . sprintf($GLOBALS['LANG']->getLL('module.error.invalidConfiguration'),
$this->MCONF['PMA_subdir']) . '</p>';
$this->content .= '<p>' . sprintf(
$GLOBALS['LANG']->getLL('module.error.invalidConfiguration'),
$this->MCONF['PMA_subdir']
) . '</p>';
// End document
$this->content .= $this->doc->endPage();
}
}

/**
* Prints the content of the module directly to the browser
*
* @return void
*/
public function printContent()
{
Expand All @@ -247,17 +247,15 @@ public function printContent()

// Proceed if TYPO3_MODE is defined
if (!defined('TYPO3_MODE')) {
die ('<h1>Error</h1><p>Unable to determine TYPO3_MODE.</p>');
} else {
die('<h1>Error</h1><p>Unable to determine TYPO3_MODE.</p>');
}

// Proceed if BE loaded
if (TYPO3_MODE === 'BE') {
// Make instance:
$GLOBALS['SOBE'] = GeneralUtility::makeInstance(PmaModule::class);
$GLOBALS['SOBE']->main();
$GLOBALS['SOBE']->printContent();

} else {
die ('<h1>Error</h1><p>The TYPO3 Backend is required for phpMyAdmin module but was not loaded.</p>');
die('<h1>Error</h1><p>The TYPO3 Backend is required for phpMyAdmin module but was not loaded.</p>');
}
}
2 changes: 1 addition & 1 deletion Classes/Controller/PhpmyadminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function indexAction()
{
return GeneralUtility::makeInstance(\Mehrwert\Phpmyadmin\Backend\PmaModule::class);
}
}
}
11 changes: 3 additions & 8 deletions Classes/Hooks/BeUserAuthLogOffHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,25 @@
*/

use Mehrwert\Phpmyadmin\Utility\EnvironmentUtility;
use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

/**
* Utilities for the phpMyAdmin third party database Administration Tool
*
* @package TYPO3
* @subpackage tx_phpmyadmin
* @author mehrwert <[email protected]>
* @license GPL
*/
class BeUserAuthLogOffHook
{

/**
* Log off method for the signon-based phpMyAdmin extension. Called as post processing
* hook in t3lib_userauth.php. Deletes the signon cookies
*
* @param array $params Additional params passed to the method
* @param \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication $ref The parent object (BE User Auth)
* @return void
*/
public function pmaLogOff($params = array(), $ref = null)
public function pmaLogOff($params = [], $ref = null)
{

if (isset($GLOBALS['PHP_UNIT_TEST_RUNNING']) === false) {
// Define the cookie path
$cookiePath = substr(
Expand Down Expand Up @@ -89,4 +84,4 @@ public function pmaLogOff($params = array(), $ref = null)
session_start();
}
}
}
}
5 changes: 1 addition & 4 deletions Classes/Utility/EnvironmentUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
/**
* Utilities for the phpMyAdmin third party database Administration Tool
*
* @package TYPO3
* @subpackage tx_phpmyadmin
* @author mehrwert <[email protected]>
* @license GPL
*/
class EnvironmentUtility
{

/**
* The TYPO3 public web folder
*
Expand Down Expand Up @@ -63,4 +60,4 @@ public static function getBackendPath()
{
return self::getPublicPath() . '/typo3';
}
}
}
4 changes: 4 additions & 0 deletions Documentation/Changelog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Change Log

The following is an overview of the changes in this extension. For more details `read the online log <https://github.com/mehrwert/TYPO3-phpMyAdmin>`_.

2020-07-19 Andreas Beutel - Version 5.6.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- [BUGFIX] Resolve dropped PATH_typo3 for TYPO3 10.x - GH #44 (thanks to Alexander Nitsche for the contribution)

2020-03-23 Andreas Beutel - Version 5.6.2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- [FEATURE] Updated pMA to the latest stable 4.9.x release (4.9.5)
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ phpMyAdmin Extension for TYPO3
2002-11-01

:Changed:
2020-03-23
2020-07-19

:Changed by:
Andreas Beutel
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[general]

project = phpMyAdmin for TYPO3
version = 5.5
release = 5.6.2
version = 5.6
release = 5.6.3
t3author = mehrwert intermediale kommunikation GmbH
copyright = since 2002 by the authors

Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'description' => 'Third party \'phpMyAdmin\' administration module. Access to admin-users only.',
'category' => 'module',
'shy' => 0,
'version' => '5.6.2',
'version' => '5.6.3',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
Expand All @@ -26,7 +26,7 @@
'constraints' => [
'depends' => [
'php' => '7.0.0-7.3.99',
'typo3' => '8.7.0-10.99.99'
'typo3' => '8.7.0-10.4.99'
]
]
];

0 comments on commit a70ca95

Please sign in to comment.