diff options
author | Jehan-Guillaume (ioguix) de Rorthais | 2012-03-23 16:40:53 +0000 |
---|---|---|
committer | Jehan-Guillaume (ioguix) de Rorthais | 2012-08-22 10:31:16 +0000 |
commit | 2820a9812c17eaed93b88d12a35588d4baeea770 (patch) | |
tree | e8358f0eb0225daf1af4c3ef7229153c0237d176 | |
parent | 4f77054ad815d1d28e40e38e3c5cc08761e2fbad (diff) |
Add support for 'tree' hooks in the plugin architecture.
-rw-r--r-- | aggregates.php | 2 | ||||
-rw-r--r-- | all_db.php | 2 | ||||
-rw-r--r-- | casts.php | 2 | ||||
-rw-r--r-- | classes/Misc.php | 59 | ||||
-rw-r--r-- | classes/PluginManager.php | 9 | ||||
-rw-r--r-- | constraints.php | 2 | ||||
-rw-r--r-- | conversions.php | 2 | ||||
-rwxr-xr-x | database.php | 2 | ||||
-rw-r--r-- | domains.php | 2 | ||||
-rw-r--r-- | fulltext.php | 4 | ||||
-rw-r--r-- | functions.php | 2 | ||||
-rw-r--r-- | indexes.php | 2 | ||||
-rw-r--r-- | languages.php | 2 | ||||
-rw-r--r-- | opclasses.php | 2 | ||||
-rw-r--r-- | operators.php | 2 | ||||
-rw-r--r-- | rules.php | 2 | ||||
-rwxr-xr-x | schemas.php | 4 | ||||
-rw-r--r-- | sequences.php | 2 | ||||
-rw-r--r-- | servers.php | 8 | ||||
-rw-r--r-- | tables.php | 4 | ||||
-rw-r--r-- | tblproperties.php | 2 | ||||
-rw-r--r-- | triggers.php | 2 | ||||
-rw-r--r-- | types.php | 2 | ||||
-rwxr-xr-x | viewproperties.php | 2 | ||||
-rw-r--r-- | views.php | 4 |
25 files changed, 83 insertions, 45 deletions
diff --git a/aggregates.php b/aggregates.php index 6970d338..1e839d6e 100644 --- a/aggregates.php +++ b/aggregates.php @@ -418,7 +418,7 @@ ) ); - $misc->printTreeXML($aggregates, $attrs); + $misc->printTree($aggregates, $attrs, 'aggregates'); exit; } @@ -488,7 +488,7 @@ ), ); - $misc->printTreeXML($databases, $attrs); + $misc->printTree($databases, $attrs, 'databases'); exit; } @@ -80,7 +80,7 @@ 'icon' => 'Cast' ); - $misc->printTreeXML($casts, $attrs); + $misc->printTree($casts, $attrs, 'casts'); exit; } diff --git a/classes/Misc.php b/classes/Misc.php index 84c8be8e..44e395ff 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -1994,24 +1994,55 @@ * '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 @@ 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) { diff --git a/classes/PluginManager.php b/classes/PluginManager.php index e2a97c92..1f01390f 100644 --- a/classes/PluginManager.php +++ b/classes/PluginManager.php @@ -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(); diff --git a/constraints.php b/constraints.php index 5aa7462f..526e7b7d 100644 --- a/constraints.php +++ b/constraints.php @@ -572,7 +572,7 @@ 'icon' => callback('getIcon'), ); - $misc->printTreeXML($constraints, $attrs); + $misc->printTree($constraints, $attrs, 'constraints'); exit; } diff --git a/conversions.php b/conversions.php index 8b5ab7c4..32def8d7 100644 --- a/conversions.php +++ b/conversions.php @@ -68,7 +68,7 @@ 'toolTip'=> field('concomment') ); - $misc->printTreeXML($conversions, $attrs); + $misc->printTree($conversions, $attrs, 'conversions'); exit; } diff --git a/database.php b/database.php index 5a655780..8221237b 100755 --- a/database.php +++ b/database.php @@ -630,7 +630,7 @@ ), ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, 'database'); exit; } diff --git a/domains.php b/domains.php index 633535a0..c7e3e79f 100644 --- a/domains.php +++ b/domains.php @@ -531,7 +531,7 @@ ) ); - $misc->printTreeXML($domains, $attrs); + $misc->printTree($domains, $attrs, 'domains'); exit; } diff --git a/fulltext.php b/fulltext.php index b6bb9e70..cdc6a2ec 100644 --- a/fulltext.php +++ b/fulltext.php @@ -997,7 +997,7 @@ ), ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, 'fts'); exit; } @@ -1044,7 +1044,7 @@ ), ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, strtolower($what)); exit; } diff --git a/functions.php b/functions.php index cd36244b..fc0522c8 100644 --- a/functions.php +++ b/functions.php @@ -966,7 +966,7 @@ ) ); - $misc->printTreeXML($funcs, $attrs); + $misc->printTree($funcs, $attrs, 'functions'); exit; } diff --git a/indexes.php b/indexes.php index 113a26d4..fefe1a60 100644 --- a/indexes.php +++ b/indexes.php @@ -374,7 +374,7 @@ 'icon' => callback('getIcon'), ); - $misc->printTreeXML($indexes, $attrs); + $misc->printTree($indexes, $attrs, 'indexes'); exit; } diff --git a/languages.php b/languages.php index c201aba7..b337638b 100644 --- a/languages.php +++ b/languages.php @@ -59,7 +59,7 @@ 'icon' => 'Language' ); - $misc->printTreeXML($languages, $attrs); + $misc->printTree($languages, $attrs, 'languages'); exit; } diff --git a/opclasses.php b/opclasses.php index 9446dbad..f0e399f2 100644 --- a/opclasses.php +++ b/opclasses.php @@ -71,7 +71,7 @@ 'toolTip'=> field('opccomment'), ); - $misc->printTreeXML($opclasses, $attrs); + $misc->printTree($opclasses, $attrs, 'opclasses'); exit; } diff --git a/operators.php b/operators.php index 4aa0b10b..c3be64fb 100644 --- a/operators.php +++ b/operators.php @@ -211,7 +211,7 @@ ) ); - $misc->printTreeXML($operators, $attrs); + $misc->printTree($operators, $attrs, 'operators'); exit; } @@ -197,7 +197,7 @@ 'icon' => 'Rule', ); - $misc->printTreeXML($rules, $attrs); + $misc->printTree($rules, $attrs, 'rules'); exit; } diff --git a/schemas.php b/schemas.php index 73b74b77..750d3737 100755 --- a/schemas.php +++ b/schemas.php @@ -414,7 +414,7 @@ ), ); - $misc->printTreeXML($schemas, $attrs); + $misc->printTree($schemas, $attrs, 'schemas'); exit; } @@ -442,7 +442,7 @@ ) ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, 'schema'); exit; } diff --git a/sequences.php b/sequences.php index 5d72e575..223a8c8d 100644 --- a/sequences.php +++ b/sequences.php @@ -132,7 +132,7 @@ ) ); - $misc->printTreeXML($sequences, $attrs); + $misc->printTree($sequences, $attrs, 'sequences'); exit; } diff --git a/servers.php b/servers.php index ae8647a8..603dd2ed 100644 --- a/servers.php +++ b/servers.php @@ -148,11 +148,15 @@ '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(); @@ -960,7 +960,7 @@ ) ); - $misc->printTreeXML($tables, $attrs); + $misc->printTree($tables, $attrs, 'tables'); exit; } @@ -992,7 +992,7 @@ ), ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, 'table'); exit; } diff --git a/tblproperties.php b/tblproperties.php index dcb67f0d..37bcc728 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -425,7 +425,7 @@ 'toolTip'=> field('comment') ); - $misc->printTreeXML($columns, $attrs); + $misc->printTree($columns, $attrs, 'tblcolumns'); exit; } diff --git a/triggers.php b/triggers.php index cd8fb31b..fbe81058 100644 --- a/triggers.php +++ b/triggers.php @@ -393,7 +393,7 @@ 'icon' => 'Trigger', ); - $misc->printTreeXML($triggers, $attrs); + $misc->printTree($triggers, $attrs, 'triggers'); exit; } @@ -669,7 +669,7 @@ ) ); - $misc->printTreeXML($types, $attrs); + $misc->printTree($types, $attrs, 'types'); exit; } diff --git a/viewproperties.php b/viewproperties.php index 531d7613..d13a4f39 100755 --- a/viewproperties.php +++ b/viewproperties.php @@ -376,7 +376,7 @@ 'toolTip'=> field('comment') ); - $misc->printTreeXML($columns, $attrs); + $misc->printTree($columns, $attrs, 'viewcolumns'); exit; } @@ -705,7 +705,7 @@ ) ); - $misc->printTreeXML($views, $attrs); + $misc->printTree($views, $attrs, 'views'); exit; } @@ -730,7 +730,7 @@ ), ); - $misc->printTreeXML($items, $attrs); + $misc->printTree($items, $attrs, 'view'); exit; } |