Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
admin_database
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
admin_database
Merge requests
!2
Issue
#3459986
by kalash: fixed the coding standards.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3459986
by kalash: fixed the coding standards.
issue/admin_database-3459986:3459986-PHPCS-errors
into
main
Overview
0
Commits
2
Pipelines
0
Changes
10
Open
kalash jain
requested to merge
issue/admin_database-3459986:3459986-PHPCS-errors
into
main
10 months ago
Overview
0
Commits
2
Pipelines
0
Changes
10
Expand
Closes
#3459986
0
0
Merge request reports
Compare
main
version 1
d098ba07
10 months ago
main (HEAD)
and
latest version
latest version
e2fcd82b
2 commits,
10 months ago
version 1
d098ba07
1 commit,
10 months ago
10 files
+
476
−
523
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
Search (e.g. *.vue) (Ctrl+P)
assets/plugins/AdminDatabaseAdminerPlugin.php
0 → 100644
+
270
−
0
Options
<?php
/**
* @file
* Adminer customization allowing usage of plugins.
*/
/**
* Class AdminDatabaseAdminerPlugin.
*
* Adminer plugin to extend functionality.
*/
class
AdminDatabaseAdminerPlugin
extends
Adminer
{
/**
* Array of plugin instances or NULL if no plugins are loaded.
*
* @var array|null
*/
public
$plugins
;
/**
* Find root class for a given class.
*
* @param string $class
* The class name to find the root for.
*
* @return string
* The root class name.
*/
protected
function
findRootClass
(
$class
)
{
do
{
$return
=
$class
;
}
while
(
$class
=
get_parent_class
(
$class
));
return
$return
;
}
/**
* Constructor for AdminerPlugin.
*
* @param array|null $plugins
* (optional) Array of plugin instances or NULL to register all
* classes starting by 'Adminer'.
*/
public
function
__construct
(
$plugins
=
NULL
)
{
if
(
$plugins
===
NULL
)
{
$plugins
=
[];
foreach
(
get_declared_classes
()
as
$class
)
{
if
(
preg_match
(
'~^Adminer.~i'
,
$class
)
&&
strcasecmp
(
$this
->
findRootClass
(
$class
),
'Adminer'
))
{
$plugins
[
$class
]
=
new
$class
();
}
}
}
$this
->
plugins
=
$plugins
;
}
/**
* Call parent method.
*
* @param string $function
* The function name to call.
* @param array $args
* Array of arguments to pass to the function.
*
* @return mixed
* The return value of the parent method call.
*/
protected
function
callParent
(
$function
,
$args
)
{
return
call_user_func_array
([
'parent'
,
$function
],
$args
);
}
/**
* Apply plugin method.
*
* @param string $function
* The function name to call on plugins.
* @param array $args
* Array of arguments to pass to the function.
*
* @return mixed|null
* The return value from the plugin method.
*/
protected
function
applyPlugin
(
$function
,
$args
)
{
foreach
(
$this
->
plugins
as
$plugin
)
{
if
(
method_exists
(
$plugin
,
$function
))
{
switch
(
count
(
$args
))
{
case
0
:
$return
=
$plugin
->
$function
();
break
;
case
1
:
$return
=
$plugin
->
$function
(
$args
[
0
]);
break
;
case
2
:
$return
=
$plugin
->
$function
(
$args
[
0
],
$args
[
1
]);
break
;
case
3
:
$return
=
$plugin
->
$function
(
$args
[
0
],
$args
[
1
],
$args
[
2
]);
break
;
case
4
:
$return
=
$plugin
->
$function
(
$args
[
0
],
$args
[
1
],
$args
[
2
],
$args
[
3
]);
break
;
case
5
:
$return
=
$plugin
->
$function
(
$args
[
0
],
$args
[
1
],
$args
[
2
],
$args
[
3
],
$args
[
4
]);
break
;
case
6
:
$return
=
$plugin
->
$function
(
$args
[
0
],
$args
[
1
],
$args
[
2
],
$args
[
3
],
$args
[
4
],
$args
[
5
]);
break
;
default
:
trigger_error
(
'Too many parameters.'
,
E_USER_WARNING
);
break
;
}
if
(
$return
!==
NULL
)
{
return
$return
;
}
}
}
return
$this
->
callParent
(
$function
,
$args
);
}
/**
* Append plugin method.
*
* @param string $function
* The function name to call on plugins.
* @param array $args
* Array of arguments to pass to the function.
*
* @return mixed
* The combined return value from all plugins.
*/
protected
function
appendPlugin
(
$function
,
$args
)
{
$return
=
$this
->
callParent
(
$function
,
$args
);
foreach
(
$this
->
plugins
as
$plugin
)
{
if
(
method_exists
(
$plugin
,
$function
))
{
$value
=
call_user_func_array
([
$plugin
,
$function
],
$args
);
if
(
$value
)
{
$return
+=
$value
;
}
}
}
return
$return
;
}
/**
* {@inheritdoc}
*/
public
function
dumpFormat
()
{
return
$this
->
appendPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpOutput
()
{
return
$this
->
appendPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
editRowPrint
(
$table
,
$fields
,
$row
,
$update
)
{
return
$this
->
appendPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
editFunctions
(
$field
)
{
return
$this
->
appendPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
tableName
(
$tableStatus
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
fieldName
(
$field
,
$order
=
0
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
selectLinks
(
$tableStatus
,
$set
=
""
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpDatabase
(
$db
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpTable
(
$table
,
$style
,
$is_view
=
0
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpData
(
$table
,
$style
,
$query
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpFilename
(
$identifier
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
dumpHeaders
(
$identifier
,
$multi_table
=
FALSE
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
importServerPath
()
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
homepage
()
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
navigation
(
$missing
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
databasesPrint
(
$missing
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
/**
* {@inheritdoc}
*/
public
function
tablesPrint
(
$tables
)
{
return
$this
->
applyPlugin
(
__FUNCTION__
,
func_get_args
());
}
}
Loading