Skip to content

Commit d13d58c

Browse files
committed
removes usage of plugin manager
removes logic that is now handled in ContainerUtils moves conf logic out of db folder removes plugin manager adds id to results table (will enable handling for wide columns)
1 parent 4403660 commit d13d58c

17 files changed

+96
-313
lines changed

src/classes/ContainerUtils.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ public static function createContainer()
8888
self::$instance = new self();
8989
}
9090

91+
$display_sizes = $conf['display_sizes'] ?? false;
92+
93+
$conf['display_sizes'] = [
94+
'schemas' => (bool) $display_sizes,
95+
'tables' => (bool) $display_sizes,
96+
];
97+
if (is_array($display_sizes)) {
98+
$conf['display_sizes'] = [
99+
'schemas' => $display_sizes['schemas'] ?? in_array('schemas', $display_sizes, true),
100+
'tables' => $display_sizes['tables'] ?? in_array('tables', $display_sizes, true),
101+
];
102+
}
91103
return [self::$instance->container, self::$instance->app];
92104
}
93105

src/classes/Misc.php

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function __construct(\Slim\Container $container)
5757
$this->conf = $container->get('conf');
5858

5959
//$this->view = $container->get('view');
60-
$this->plugin_manager = $container->get('plugin_manager');
61-
$this->appLangFiles = $container->get('appLangFiles');
60+
61+
$this->appLangFiles = $container->get('appLangFiles');
6262

6363
$this->appName = $container->get('settings')['appName'];
6464
$this->appVersion = $container->get('settings')['appVersion'];
@@ -729,49 +729,37 @@ public function getRequestVars($subject = '')
729729

730730
public function icon($icon)
731731
{
732-
if (is_string($icon)) {
733-
$path = "/assets/images/themes/{$this->conf['theme']}/{$icon}";
734-
if (file_exists(\BASE_PATH.$path.'.png')) {
735-
return SUBFOLDER.$path.'.png';
736-
}
737-
738-
if (file_exists(\BASE_PATH.$path.'.gif')) {
739-
return SUBFOLDER.$path.'.gif';
740-
}
741-
742-
if (file_exists(\BASE_PATH.$path.'.ico')) {
743-
return SUBFOLDER.$path.'.ico';
744-
}
732+
if (!is_string($icon)) {
733+
return '';
734+
}
735+
$theme = $this->conf['theme'];
736+
$path = 'assets/images/themes';
737+
$default_icon = sprintf('%s/%s/default/DisconnectedServer.png', SUBFOLDER, $path);
738+
if (is_readable(sprintf('%s/%s/%s/%s.png', \BASE_PATH, $path, $theme, $icon))) {
739+
return sprintf('%s/%s/%s/%s.png', \SUBFOLDER, $path, $theme, $icon);
740+
}
745741

746-
$path = "/assets/images/themes/default/{$icon}";
747-
if (file_exists(\BASE_PATH.$path.'.png')) {
748-
return SUBFOLDER.$path.'.png';
749-
}
742+
if (is_readable(sprintf('%s/%s/%s/%s.gif', \BASE_PATH, $path, $theme, $icon))) {
743+
return sprintf('%s/%s/%s/%s.gif', \SUBFOLDER, $path, $theme, $icon);
744+
}
750745

751-
if (file_exists(\BASE_PATH.$path.'.gif')) {
752-
return SUBFOLDER.$path.'.gif';
753-
}
746+
if (is_readable(sprintf('%s/%s/%s/%s.ico', \BASE_PATH, $path, $theme, $icon))) {
747+
return sprintf('%s/%s/%s/%s.ico', \SUBFOLDER, $path, $theme, $icon);
748+
}
754749

755-
if (file_exists(\BASE_PATH.$path.'.ico')) {
756-
return SUBFOLDER.$path.'.ico';
757-
}
758-
} else {
759-
// Icon from plugins
760-
$path = "/plugins/{$icon[0]}/images/{$icon[1]}";
761-
if (file_exists(\BASE_PATH.$path.'.png')) {
762-
return SUBFOLDER.$path.'.png';
763-
}
750+
if (is_readable(sprintf('%s/%s/default/%s.png', \BASE_PATH, $path, $icon))) {
751+
return sprintf('%s/%s/default/%s.png', \SUBFOLDER, $path, $icon);
752+
}
764753

765-
if (file_exists(\BASE_PATH.$path.'.gif')) {
766-
return SUBFOLDER.$path.'.gif';
767-
}
754+
if (is_readable(sprintf('%s/%s/default/%s.gif', \BASE_PATH, $path, $icon))) {
755+
return sprintf('%s/%s/default/%s.gif', \SUBFOLDER, $path, $icon);
756+
}
768757

769-
if (file_exists(\BASE_PATH.$path.'.ico')) {
770-
return SUBFOLDER.$path.'.ico';
771-
}
758+
if (is_readable(sprintf('%s/%s/default/%s.ico', \BASE_PATH, $path, $icon))) {
759+
return sprintf('%s/%s/default/%s.ico', \SUBFOLDER, $path, $icon);
772760
}
773761

774-
return '';
762+
return $default_icon;
775763
}
776764

777765
/**

src/classes/PluginManager.php

Lines changed: 0 additions & 158 deletions
This file was deleted.

src/controllers/BaseController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BaseController
5151
protected $scripts = '';
5252
public $msg = '';
5353
public $view;
54-
public $plugin_manager;
54+
5555
public $misc;
5656
public $conf;
5757
public $phpMinVer;
@@ -72,10 +72,10 @@ public function __construct(\Slim\Container $container)
7272
$this->view_name = str_replace('controller', '', strtolower($this->controller_name));
7373
$this->script = $this->view_name;
7474

75-
$this->view = $container->get('view');
76-
$this->plugin_manager = $container->get('plugin_manager');
77-
$this->msg = $container->get('msg');
78-
$this->appLangFiles = $container->get('appLangFiles');
75+
$this->view = $container->get('view');
76+
77+
$this->msg = $container->get('msg');
78+
$this->appLangFiles = $container->get('appLangFiles');
7979

8080
$this->misc = $container->get('misc');
8181
$this->conf = $this->misc->getConf();

src/controllers/DisplayController.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class DisplayController extends BaseController
2020
*/
2121
public function render()
2222
{
23-
$this->misc = $this->misc;
24-
$plugin_manager = $this->plugin_manager;
23+
$this->misc = $this->misc;
2524

2625
if ('dobrowsefk' == $this->action) {
2726
return $this->doBrowseFK();
@@ -443,9 +442,9 @@ public function getBrowseNavLinks($type, $_gets, $page, $subject, $object, $resu
443442

444443
private function _getKeyAndActions($resultset, $object, $data, $page, $_gets)
445444
{
446-
$key = [];
447-
$strings = $_gets['strings'];
448-
$plugin_manager = $this->plugin_manager;
445+
$key = [];
446+
$strings = $_gets['strings'];
447+
449448
// Fetch unique row identifier, if this is a table browse request.
450449
if ($object) {
451450
$key = $data->getRowIdentifier($object);
@@ -501,7 +500,6 @@ private function _getKeyAndActions($resultset, $object, $data, $page, $_gets)
501500
'actionbuttons' => &$buttons,
502501
'place' => 'display-browse',
503502
];
504-
$plugin_manager->doHook('actionbuttons', $actions);
505503

506504
foreach (array_keys($actions['actionbuttons']) as $action) {
507505
$actions['actionbuttons'][$action]['attr']['href']['urlvars'] = array_merge(

src/controllers/ServersController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ public function doTree()
190190

191191
public function doLogout()
192192
{
193-
$plugin_manager = $this->plugin_manager;
194-
195-
$plugin_manager->doHook('logout', $_REQUEST['logoutServer']);
196-
197193
$server_info = $this->misc->getServerInfo($_REQUEST['logoutServer']);
198194
$this->misc->setServerInfo(null, null, $_REQUEST['logoutServer']);
199195

src/database/Postgres10.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,7 @@ public function getTables()
4343
* Either display_sizes is true for tables and schemas,
4444
* or we must check if said config is an associative array
4545
*/
46-
if (isset($this->conf['display_sizes']) &&
47-
(
48-
$this->conf['display_sizes'] === true ||
49-
(
50-
is_array($this->conf['display_sizes']) &&
51-
array_key_exists('tables', $this->conf['display_sizes']) &&
52-
$this->conf['display_sizes']['tables'] === true
53-
)
54-
)
55-
) {
46+
if ($this->conf['display_sizes']['tables']) {
5647
$sql .= ' pg_size_pretty(pg_total_relation_size(c.oid)) as table_size ';
5748
} else {
5849
$sql .= " 'N/A' as table_size ";

src/database/databasetraits/PrivilegesTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public function setPrivileges(
334334
return -1;
335335
}
336336

337-
// Dump PUBLIC
337+
// Dump
338338
$first = true;
339339
$sql .= ($mode == 'GRANT') ? ' TO ' : ' FROM ';
340340
if ($public) {

src/database/databasetraits/SchemaTrait.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ public function getSchemas()
3737
* Either display_sizes is true for tables and schemas,
3838
* or we must check if said config is an associative array
3939
*/
40-
if (isset($this->conf['display_sizes']) &&
41-
(
42-
$this->conf['display_sizes'] === true ||
43-
(
44-
is_array($this->conf['display_sizes']) &&
45-
array_key_exists('schemas', $this->conf['display_sizes']) &&
46-
$this->conf['display_sizes']['schemas'] === true
47-
)
48-
)
49-
) {
40+
if ($this->conf['display_sizes']['tables']) {
5041
$sql .= ' pg_size_pretty(SUM(pg_total_relation_size(pg_class.oid))) as schema_size ';
5142
} else {
5243
$sql .= " 'N/A' as schema_size ";

src/database/databasetraits/TableTrait.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,7 @@ public function getTables()
5454
* Either display_sizes is true for tables and schemas,
5555
* or we must check if said config is an associative array
5656
*/
57-
if (isset($this->conf['display_sizes']) &&
58-
(
59-
$this->conf['display_sizes'] === true ||
60-
(
61-
is_array($this->conf['display_sizes']) &&
62-
array_key_exists('tables', $this->conf['display_sizes']) &&
63-
$this->conf['display_sizes']['tables'] === true
64-
)
65-
)
66-
) {
57+
if ($this->conf['display_sizes']['tables']) {
6758
$sql .= ' pg_size_pretty(pg_total_relation_size(c.oid)) as table_size ';
6859
} else {
6960
$sql .= " 'N/A' as table_size ";

0 commit comments

Comments
 (0)