Permalink
Browse files

Add support for 'tree' hooks in the plugin architecture.

  • Loading branch information...
1 parent 4f77054 commit 2820a9812c17eaed93b88d12a35588d4baeea770 @ioguix ioguix committed Mar 23, 2012
Showing with 83 additions and 45 deletions.
  1. +1 −1 aggregates.php
  2. +1 −1 all_db.php
  3. +1 −1 casts.php
  4. +43 −16 classes/Misc.php
  5. +8 −1 classes/PluginManager.php
  6. +1 −1 constraints.php
  7. +1 −1 conversions.php
  8. +1 −1 database.php
  9. +1 −1 domains.php
  10. +2 −2 fulltext.php
  11. +1 −1 functions.php
  12. +1 −1 indexes.php
  13. +1 −1 languages.php
  14. +1 −1 opclasses.php
  15. +1 −1 operators.php
  16. +1 −1 rules.php
  17. +2 −2 schemas.php
  18. +1 −1 sequences.php
  19. +6 −2 servers.php
  20. +2 −2 tables.php
  21. +1 −1 tblproperties.php
  22. +1 −1 triggers.php
  23. +1 −1 types.php
  24. +1 −1 viewproperties.php
  25. +2 −2 views.php
View
@@ -418,7 +418,7 @@ function doTree() {
)
);
- $misc->printTreeXML($aggregates, $attrs);
+ $misc->printTree($aggregates, $attrs, 'aggregates');
exit;
}
View
@@ -488,7 +488,7 @@ function doTree() {
),
);
- $misc->printTreeXML($databases, $attrs);
+ $misc->printTree($databases, $attrs, 'databases');
exit;
}
View
@@ -80,7 +80,7 @@ function doTree() {
'icon' => 'Cast'
);
- $misc->printTreeXML($casts, $attrs);
+ $misc->printTree($casts, $attrs, 'casts');
exit;
}
View
@@ -1994,24 +1994,55 @@ function printTable(&$tabledata, &$columns, &$actions, $place, $nodata = null, $
* 'branch' - URL for child nodes (tree XML)
* 'expand' - the action to return XML for the subtree
* 'nodata' - message to display when node has no children
- * 'nohead' - suppress headers and opening <tree> tag
- * 'nofoot' - suppress closing </tree> tag
+ * @param $section The section where the branch is linked in the tree
+ */
+ function printTree(&$_treedata, &$attrs, $section) {
+ global $plugin_manager;
+
+ $treedata = array();
+
+ if ($_treedata->recordCount() > 0) {
+ while (!$_treedata->EOF) {
+ $treedata[] = $_treedata->fields;
+ $_treedata->moveNext();
+ }
+ }
+
+ $plugin_functions_parameters = array(
+ 'treedata' => &$treedata,
+ 'attrs' => &$attrs,
+ 'section' => $section
+ );
+ $plugin_manager->do_hook('tree', $plugin_functions_parameters);
+
+ $this->printTreeXML($treedata, $attrs);
+ }
+
+ /** Produce XML data for the browser tree
+ * @param $treedata A set of records to populate the tree.
+ * @param $attrs Attributes for tree items
+ * 'text' - the text for the tree node
+ * 'icon' - an icon for node
+ * 'openIcon' - an alternative icon when the node is expanded
+ * 'toolTip' - tool tip text for the node
+ * 'action' - URL to visit when single clicking the node
+ * 'iconAction' - URL to visit when single clicking the icon node
+ * 'branch' - URL for child nodes (tree XML)
+ * 'expand' - the action to return XML for the subtree
+ * 'nodata' - message to display when node has no children
*/
function printTreeXML(&$treedata, &$attrs) {
global $conf, $lang;
- if (!isset($attrs['nohead']) || $attrs['nohead'] === false) {
- header("Content-Type: text/xml; charset=UTF-8");
- header("Cache-Control: no-cache");
+ header("Content-Type: text/xml; charset=UTF-8");
+ header("Cache-Control: no-cache");
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
- echo "<tree>\n";
- }
+ echo "<tree>\n";
- if ($treedata->recordCount() > 0) {
- while (!$treedata->EOF) {
- $rec =& $treedata->fields;
+ if (count($treedata) > 0) {
+ foreach($treedata as $rec) {
echo "<tree";
echo value_xml_attr('text', $attrs['text'], $rec);
@@ -2030,17 +2061,13 @@ function printTreeXML(&$treedata, &$attrs) {
echo value_xml_attr('tooltip', $attrs['toolTip'], $rec);
echo " />\n";
-
- $treedata->moveNext();
}
} else {
$msg = isset($attrs['nodata']) ? $attrs['nodata'] : $lang['strnoobjects'];
echo "<tree text=\"{$msg}\" onaction=\"tree.getSelected().getParent().reload()\" icon=\"", $this->icon('ObjectNotFound'), "\" />\n";
}
- if (!isset($attrs['nofoot']) || $attrs['nofoot'] === false) {
- echo "</tree>\n";
- }
+ echo "</tree>\n";
}
function adjustTabsForTree(&$tabs) {
@@ -10,7 +10,14 @@ class PluginManager {
* Attributes
*/
private $plugins_list = array();
- private $available_hooks = array('toplinks', 'tabs', 'trail', 'navlinks', 'actionbuttons' /* wip, more hooks to come in next commits */);
+ private $available_hooks = array(
+ 'toplinks',
+ 'tabs',
+ 'trail',
+ 'navlinks',
+ 'actionbuttons',
+ 'tree'
+ );
private $actions = array();
private $hooks = array();
View
@@ -572,7 +572,7 @@ function getIcon($f) {
'icon' => callback('getIcon'),
);
- $misc->printTreeXML($constraints, $attrs);
+ $misc->printTree($constraints, $attrs, 'constraints');
exit;
}
View
@@ -68,7 +68,7 @@ function doTree() {
'toolTip'=> field('concomment')
);
- $misc->printTreeXML($conversions, $attrs);
+ $misc->printTree($conversions, $attrs, 'conversions');
exit;
}
View
@@ -630,7 +630,7 @@ function doTree() {
),
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, 'database');
exit;
}
View
@@ -531,7 +531,7 @@ function doTree() {
)
);
- $misc->printTreeXML($domains, $attrs);
+ $misc->printTree($domains, $attrs, 'domains');
exit;
}
View
@@ -997,7 +997,7 @@ function doTree() {
),
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, 'fts');
exit;
}
@@ -1044,7 +1044,7 @@ function doSubTree($what) {
),
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, strtolower($what));
exit;
}
View
@@ -966,7 +966,7 @@ function doTree() {
)
);
- $misc->printTreeXML($funcs, $attrs);
+ $misc->printTree($funcs, $attrs, 'functions');
exit;
}
View
@@ -374,7 +374,7 @@ function getIcon($f) {
'icon' => callback('getIcon'),
);
- $misc->printTreeXML($indexes, $attrs);
+ $misc->printTree($indexes, $attrs, 'indexes');
exit;
}
View
@@ -59,7 +59,7 @@ function doTree() {
'icon' => 'Language'
);
- $misc->printTreeXML($languages, $attrs);
+ $misc->printTree($languages, $attrs, 'languages');
exit;
}
View
@@ -71,7 +71,7 @@ function doTree() {
'toolTip'=> field('opccomment'),
);
- $misc->printTreeXML($opclasses, $attrs);
+ $misc->printTree($opclasses, $attrs, 'opclasses');
exit;
}
View
@@ -211,7 +211,7 @@ function doTree() {
)
);
- $misc->printTreeXML($operators, $attrs);
+ $misc->printTree($operators, $attrs, 'operators');
exit;
}
View
@@ -197,7 +197,7 @@ function doTree() {
'icon' => 'Rule',
);
- $misc->printTreeXML($rules, $attrs);
+ $misc->printTree($rules, $attrs, 'rules');
exit;
}
View
@@ -414,7 +414,7 @@ function doTree() {
),
);
- $misc->printTreeXML($schemas, $attrs);
+ $misc->printTree($schemas, $attrs, 'schemas');
exit;
}
@@ -442,7 +442,7 @@ function doSubTree() {
)
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, 'schema');
exit;
}
View
@@ -132,7 +132,7 @@ function doTree() {
)
);
- $misc->printTreeXML($sequences, $attrs);
+ $misc->printTree($sequences, $attrs, 'sequences');
exit;
}
View
@@ -148,11 +148,15 @@ function doTree() {
'branch' => field('branch'),
);
- $misc->printTreeXML($nodes, $attrs);
+ $misc->printTree($servers, $attrs, 'servers');
exit;
}
- if ($action == 'tree') doTree();
+
+ if ($action == 'tree') {
+ if (isset($_GET['group'])) doTree($_GET['group']);
+ else doTree(false);
+ }
$misc->printHeader($lang['strservers']);
$misc->printBody();
View
@@ -960,7 +960,7 @@ function doTree() {
)
);
- $misc->printTreeXML($tables, $attrs);
+ $misc->printTree($tables, $attrs, 'tables');
exit;
}
@@ -992,7 +992,7 @@ function doSubTree() {
),
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, 'table');
exit;
}
View
@@ -425,7 +425,7 @@ function doTree() {
'toolTip'=> field('comment')
);
- $misc->printTreeXML($columns, $attrs);
+ $misc->printTree($columns, $attrs, 'tblcolumns');
exit;
}
View
@@ -393,7 +393,7 @@ function doTree() {
'icon' => 'Trigger',
);
- $misc->printTreeXML($triggers, $attrs);
+ $misc->printTree($triggers, $attrs, 'triggers');
exit;
}
View
@@ -669,7 +669,7 @@ function doTree() {
)
);
- $misc->printTreeXML($types, $attrs);
+ $misc->printTree($types, $attrs, 'types');
exit;
}
View
@@ -376,7 +376,7 @@ function doTree () {
'toolTip'=> field('comment')
);
- $misc->printTreeXML($columns, $attrs);
+ $misc->printTree($columns, $attrs, 'viewcolumns');
exit;
}
View
@@ -705,7 +705,7 @@ function doTree() {
)
);
- $misc->printTreeXML($views, $attrs);
+ $misc->printTree($views, $attrs, 'views');
exit;
}
@@ -730,7 +730,7 @@ function doSubTree() {
),
);
- $misc->printTreeXML($items, $attrs);
+ $misc->printTree($items, $attrs, 'view');
exit;
}

0 comments on commit 2820a98

Please sign in to comment.