Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controller/BrowserController.php')
-rw-r--r--src/Controller/BrowserController.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/Controller/BrowserController.php b/src/Controller/BrowserController.php
new file mode 100644
index 00000000..e98933c6
--- /dev/null
+++ b/src/Controller/BrowserController.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * PHPPgAdmin6
+ */
+
+namespace PHPPgAdmin\Controller;
+
+use PHPPgAdmin\Core\ArrayRecordset;
+use PHPPgAdmin\Decorators\Decorator;
+
+/**
+ * Base controller class.
+ */
+class BrowserController extends BaseController
+{
+ protected $no_db_connection = true;
+
+ /**
+ * Default method to render the controller according to the action parameter.
+ *
+ * @param null|mixed $action
+ *
+ * @return string
+ */
+ public function render($action = null)
+ {
+ if (null === $action) {
+ $action = $this->action;
+ }
+
+ switch ($action) {
+ case 'tree':
+ return $this->doTree();
+
+ break;
+
+ default:
+ return $this->doDefault();
+
+ break;
+ }
+ }
+
+ /**
+ * Default method to render the browser iframe using jstree.
+ *
+ * @return string rendered html of the jstree template
+ */
+ public function doDefault()
+ {
+ $this->misc->setNoDBConnection(true);
+
+ $this->setNoBottomLink(true);
+
+ $viewVars = ['icon' => [
+ 'Refresh' => $this->view->icon('Refresh'),
+ 'Servers' => $this->view->icon('Servers'),
+ ]];
+
+ return $this->view->fetch('browser.twig', $viewVars);
+ }
+
+ /**
+ * Renders the root element of the jstree.
+ *
+ * @return string json representation of the root element of the jstree
+ */
+ public function doTree()
+ {
+ $treedata = new ArrayRecordset([]);
+ $reqvars = [];
+ $action = Decorator::url('/src/views/servers');
+ $branch = Decorator::url('/src/views/servers', $reqvars, ['action' => 'tree']);
+ // $this->dump($branch);
+ $attrs = [
+ 'text' => 'Servers',
+ 'icon' => 'Servers',
+ 'is_root' => 'true',
+ 'action' => $action,
+ 'branch' => $branch,
+ ];
+
+ return $this->printTree($treedata, $attrs, 'server');
+ }
+}