Start the Slony branch. Please ignore all of this, it's just the depraved ramblings...
authorchriskl <chriskl>
Wed, 11 May 2005 15:48:03 +0000 (15:48 +0000)
committerchriskl <chriskl>
Wed, 11 May 2005 15:48:03 +0000 (15:48 +0000)
classes/Misc.php
classes/plugins/Plugin.php [new file with mode: 0755]
classes/plugins/Slony.php [new file with mode: 0755]
conf/slony.inc.php [new file with mode: 0755]
libraries/lib.inc.php
plugin_slony.php [new file with mode: 0755]

index 1cd892f76023a4ec7b0a7d6a6f0c565462ded079..7fac66d3af5e178ea08d0050932956ed2f8d7879 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.100 2005/05/02 15:47:25 chriskl Exp $
+        * $Id: Misc.php,v 1.100.2.1 2005/05/11 15:48:03 chriskl Exp $
         */
         
        class Misc {
 
                                case 'database':
 #                                      $vars = $servervar . $databasevar . '&subject=database';
-                                       return array (
+                                       $tabs = array (
                                                'schemas' => array (
                                                        'title' => $lang['strschemas'],
                                                        'url'   => 'database.php',
                                                        'hide'  => (!$this->isDumpEnabled()),
                                                ),
                                        );
-
+                                       // Add plugin tabs
+                                       global $plugins;
+                                       foreach ($plugins as $v) {
+                                               $tab = $v->getDatabaseTab();
+                                               if ($tab !== null) {
+                                                       $tabs[$tab['id']] = $tab;
+                                               }       
+                                       }
+                                       
+                                       return $tabs;
                                case 'schema':
 #                                      $vars = $servervar . $databasevar . $schemavar . '&subject=schema';
                                        return array (
diff --git a/classes/plugins/Plugin.php b/classes/plugins/Plugin.php
new file mode 100755 (executable)
index 0000000..4043a6e
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * A class that implements the plugin system
+ *
+ * $Id: Plugin.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+class Plugin {
+
+       var $tabname = null;
+       var $config = null;
+       var $name = null;
+       
+       /**
+        * Constructor
+        */
+       function Plugin($name) {
+               $this->name = $name;
+               
+               // Read in configuration
+               if ($this->config !== null) {
+                       global $conf;
+                       include('./conf/' . $name . '.inc.php');                        
+               }
+       }
+
+}
+
+?>
diff --git a/classes/plugins/Slony.php b/classes/plugins/Slony.php
new file mode 100755 (executable)
index 0000000..c3223a4
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * A class that implements the Slony 1.0.x support plugin
+ *
+ * $Id: Slony.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+include_once('./classes/plugins/Plugin.php');
+
+class Slony extends Plugin {
+
+       var $config = 'slony.inc.php';
+       
+       /**
+        * Constructor
+        */
+       function Slony() {
+               $this->Plugin('slony');
+       }
+
+       /**
+        * Gets the database tab details
+        * @return array The array of tab details, null for none
+        */
+       function getDatabaseTab() {
+               return array(
+                       'id' => 'slony',
+                       'title' => 'Slony',
+                       'url'   => 'plugin_slony.php',
+                       'urlvars' => array('subject' => 'database', 'action' => 'slony'),
+                       'hide'  => false
+               );                              
+       }
+
+       /**
+        * Gets the nodes in this database
+        */
+       function getNodes() {
+               global $data;
+               
+               $sql = "SELECT * FROM sl_node ORDER BY no_id";
+               
+               return $data->selectSet($sql);
+       }
+
+       /**
+        * Gets a single node
+        */
+       function getNode($no_id) {
+               global $data;
+               $data->clean($no_id);
+               
+               $sql = "SELECT * FROM sl_node WHERE no_id='{$no_id}'";
+               
+               return $data->selectSet($sql);
+       }
+       
+       /**
+        * Gets node listens
+        */
+       function getNodeClients($no_id) {
+               global $data;
+               $data->clean($no_id);
+               
+               $sql = "SELECT * FROM sl_path sp, sl_node sn
+                                       WHERE sp.pa_client=sn.no_id 
+                                       AND pa_server='{$no_id}'
+                                       ORDER BY sn.no_id";
+               
+               return $data->selectSet($sql);
+       }
+}
+
+?>
diff --git a/conf/slony.inc.php b/conf/slony.inc.php
new file mode 100755 (executable)
index 0000000..0637b52
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+       /**
+        * Slony plugin configuration
+        *
+        * $Id: slony.inc.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+        */
+
+       $conf['slony_enabled'] = true;
+       
+?>
index 79ab471370b4aa2cbaa3265ce6c08bc278b4c7b0..b299ded0bda2f0ec6157a1fc7205da19177ba8e1 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.94 2005/05/02 15:47:28 chriskl Exp $
+        * $Id: lib.inc.php,v 1.94.2.1 2005/05/11 15:48:03 chriskl Exp $
         */
        include_once('decorator.inc.php');
        include_once('./lang/translations.php');
                }
        }
 
+       // XXX: THIS IS A TEMPORARY HACK TO GET SLONY OBJECT LOADED
+       include('./classes/plugins/Slony.php');
+       $slony = new Slony();
+       $plugins = array(&$slony);
+
 ?>
diff --git a/plugin_slony.php b/plugin_slony.php
new file mode 100755 (executable)
index 0000000..160cf8c
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+
+       /**
+        * Slony database tab plugin
+        *
+        * $Id: plugin_slony.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+        */
+
+       // Include application functions
+       include_once('./libraries/lib.inc.php');
+
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+       $PHP_SELF = $_SERVER['PHP_SELF'];
+
+       function doProperties() {
+               global $slony, $misc;
+               global $lang;
+
+               $misc->printTrail('database');
+               $misc->printTabs('database','slony');
+
+               $clients = $slony->getNodeClients($_REQUEST['no_id']);
+
+               echo "<h3>Clients</h3>\n";
+               
+               $columns = array(
+                       'no_id' => array(
+                               'title' => 'Node ID',
+                               'field' => 'no_id'
+                       ),
+                       'no_active' => array(
+                               'title' => 'Active',
+                               'field' => 'no_active'
+                       ),
+                       'no_spool' => array(
+                               'title' => 'Spool',
+                               'field' => 'no_spool'
+                       ),
+                       'pa_conninfo' => array(
+                               'title' => 'Connection',
+                               'field' => 'pa_conninfo'
+                       ),
+                       'pa_connretry' => array(
+                               'title' => 'Retry',
+                               'field' => 'pa_connretry'
+                       ),
+                       'actions' => array(
+                               'title' => $lang['stractions'],
+                       ),
+                       'no_comment' => array(
+                               'title' => $lang['strcomment'],
+                               'field' => 'no_comment'
+                       )
+               );
+               
+               $actions = array (
+                       'detail' => array(
+                               'title' => $lang['strproperties'],
+                               'url'   => "plugin_slony.php?{$misc->href}&amp;action=properties&amp;",
+                               'vars'  => array('no_id' => 'no_id')
+                       )
+               );
+               
+               $misc->printTable($clients, $columns, $actions, 'No nodes found.');
+       }
+
+       /**
+        * List all the information on the table
+        */
+       function doDefault($msg = '') {
+               global $slony, $misc;
+               global $lang;
+
+               $misc->printTrail('database');
+               $misc->printTabs('database','slony');
+               $misc->printMsg($msg);
+
+               $nodes = $slony->getNodes();
+
+               echo "<h3>Nodes</h3>\n";
+               
+               $columns = array(
+                       'no_id' => array(
+                               'title' => 'Node ID',
+                               'field' => 'no_id'
+                       ),
+                       'no_active' => array(
+                               'title' => 'Active',
+                               'field' => 'no_active'
+                       ),
+                       'no_spool' => array(
+                               'title' => 'Spool',
+                               'field' => 'no_spool'
+                       ),
+                       'actions' => array(
+                               'title' => $lang['stractions'],
+                       ),
+                       'no_comment' => array(
+                               'title' => $lang['strcomment'],
+                               'field' => 'no_comment'
+                       )
+               );
+               
+               $actions = array (
+                       'detail' => array(
+                               'title' => $lang['strproperties'],
+                               'url'   => "plugin_slony.php?{$misc->href}&amp;action=properties&amp;",
+                               'vars'  => array('no_id' => 'no_id')
+                       )
+               );
+               
+               $misc->printTable($nodes, $columns, $actions, 'No nodes found.');
+       }
+
+       $misc->printHeader('Slony');
+       $misc->printBody();
+       
+       switch ($action) {
+               case 'properties':
+                       doProperties();
+                       break;
+               default:
+                       doDefault();
+                       break;
+       }
+       
+       $misc->printFooter();
+
+?>