Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 18, 2011
@leonardosapiras Domains
-Changed way to show the domain's constraints.
5f85cb9
Commits on Jun 19, 2011
@leonardosapiras Info
-Refactored code that displays referrers, parents and childs tables.
998c94e
@leonardosapiras Fixed children info aa6ba09
@leonardosapiras Print tables refactor
-Refactored group's table.
-Fixed info children table.
9c68312
Commits on Jun 20, 2011
@leonardosapiras Display's buttons
-Created a new hook for display's buttons.
-Refactored function doBrowse in display.php.
0d7426e
@leonardosapiras Created new action as example of display's buttons 56b43c6
View
2  classes/PluginManager.php
@@ -10,7 +10,7 @@ class PluginManager {
* Attributes
*/
private $plugins_list = array();
- private $available_hooks = array('toplinks', 'tabs', 'trail', 'navlinks', 'actionbuttons');
+ private $available_hooks = array('toplinks', 'tabs', 'trail', 'navlinks', 'actionbuttons', 'displaybuttons');
private $actions = array();
private $hooks = array();
View
33 display.php
@@ -404,7 +404,7 @@ function doBrowseFK() {
* Displays requested data
*/
function doBrowse($msg = '') {
- global $data, $conf, $misc, $lang;
+ global $data, $conf, $misc, $lang, $plugin_manager;
$save_history = false;
// If current page is not set, default to first page
@@ -515,9 +515,17 @@ function doBrowse($msg = '') {
break;
}
}
+
+ $buttons = array();
+ $plugin_functions_parameters = array(
+ 'displaybuttons' => &$buttons
+ );
+ $plugin_manager->do_hook('displaybuttons', $plugin_functions_parameters);
+
// Display edit and delete actions if we have a key
- if (sizeof($key) > 0)
- echo "<th colspan=\"2\" class=\"data\">{$lang['stractions']}</th>\n";
+ $colspan = count($buttons) + 2;
+ if (sizeof($key) > 0)
+ echo "<th colspan=\"{$colspan}\" class=\"data\">{$lang['stractions']}</th>\n";
/* we show OIDs only if we are in TABLE or SELECT type browsing */
printTableHeaderCells($rs, $gets, isset($object));
@@ -542,14 +550,19 @@ function doBrowse($msg = '') {
$key_str .= urlencode("key[{$v}]") . '=' . urlencode($rs->fields[$v]);
}
if ($has_nulls) {
- echo "<td colspan=\"2\">&nbsp;</td>\n";
+ echo "<td colspan=\"{$colspan}\">&nbsp;</td>\n";
} else {
- echo "<td class=\"opbutton{$id}\"><a href=\"display.php?action=confeditrow&amp;strings=",
- urlencode($_REQUEST['strings']), "&amp;page=",
- urlencode($_REQUEST['page']), "&amp;{$key_str}&amp;{$gets}&amp;{$getsort}\">{$lang['stredit']}</a></td>\n";
- echo "<td class=\"opbutton{$id}\"><a href=\"display.php?action=confdelrow&amp;strings=",
- urlencode($_REQUEST['strings']), "&amp;page=",
- urlencode($_REQUEST['page']), "&amp;{$key_str}&amp;{$gets}&amp;{$getsort}\">{$lang['strdelete']}</a></td>\n";
+ // Display action buttons
+ $buttons['edit'] = array (
+ 'title' => $lang['stredit'],
+ 'url' => "display.php?action=confeditrow&amp;strings=" . urlencode($_REQUEST['strings']) . "&amp;page=" . urlencode($_REQUEST['page']) . "&amp;{$key_str}&amp;{$gets}&amp;{$getsort}");
+ $buttons['delete'] = array (
+ 'title' => $lang['strdelete'],
+ 'url' => "display.php?action=confdelrow&amp;strings=" . urlencode($_REQUEST['strings']) . "&amp;page=" . urlencode($_REQUEST['page']) . "&amp;{$key_str}&amp;{$gets}&amp;{$getsort}");
+
+ foreach ($buttons as $button) {
+ echo "<td class=\"opbutton{$id}\"><a href=\"{$button['url']}\">{$button['title']}</a></td>\n";
+ }
}
}
View
47 domains.php
@@ -200,30 +200,33 @@ function doProperties($msg = '') {
echo "</table>\n";
// Display domain constraints
+ echo "<h3>{$lang['strconstraints']}</h3>\n";
if ($data->hasDomainConstraints()) {
$domaincons = $data->getDomainConstraints($_REQUEST['domain']);
- if ($domaincons->recordCount() > 0) {
- echo "<h3>{$lang['strconstraints']}</h3>\n";
- echo "<table>\n";
- echo "<tr><th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strdefinition']}</th><th class=\"data\">{$lang['stractions']}</th>\n";
- $i = 0;
-
- while (!$domaincons->EOF) {
- $id = (($i % 2 ) == 0 ? '1' : '2');
- echo "<tr class=\"data{$id}\"><td>", $misc->printVal($domaincons->fields['conname']), "</td>";
- echo "<td>";
- echo $misc->printVal($domaincons->fields['consrc']);
- echo "</td>";
- echo "<td class=\"opbutton{$id}\">";
- echo "<a href=\"domains.php?action=confirm_drop_con&amp;{$misc->href}&amp;constraint=", urlencode($domaincons->fields['conname']),
- "&amp;domain=", urlencode($_REQUEST['domain']), "&amp;type=", urlencode($domaincons->fields['contype']), "\">{$lang['strdrop']}</a></td></tr>\n";
-
- $domaincons->moveNext();
- $i++;
- }
-
- echo "</table>\n";
- }
+ $columns = array (
+ 'name' => array (
+ 'title' => $lang['strdatabase'],
+ 'field' => field('conname')
+ ),
+ 'definition' => array (
+ 'title' => $lang['strdefinition'],
+ 'field' => field('consrc'),
+ ),
+ 'actions' => array (
+ 'title' => $lang['stractions'],
+ )
+ );
+
+ $actions = array (
+ 'drop' => array (
+ 'title' => $lang['strdrop'],
+ 'url' => "domains.php?action=confirm_drop_con&amp;{$misc->href}&amp;domain=".urlencode($_REQUEST['domain'])."&amp;",
+ 'vars' => array ('constraint' => 'conname', 'type' => 'contype'),
+ 'multiaction' => 'confirm_drop_con',
+ )
+ );
+
+ $misc->printTable($domaincons, $columns, $actions, $lang['strnodata'], null, 'domains-properties');
}
}
else echo "<p>{$lang['strnodata']}</p>\n";
View
33 groups.php
@@ -74,20 +74,27 @@ function doProperties($msg = '') {
$users = $data->getUsers();
if ($groupdata->recordCount() > 0) {
- echo "<table>\n";
- echo "<tr><th class=\"data\">{$lang['strmembers']}</th><th class=\"data\">{$lang['stractions']}</th></tr>\n";
- $i = 0;
- while (!$groupdata->EOF) {
- $id = (($i % 2) == 0 ? '1' : '2');
- echo "<tr class=\"data{$id}\"><td>", $misc->printVal($groupdata->fields['usename']), "</td>\n";
- echo "<td class=\"opbutton{$id}\"><a href=\"groups.php?action=confirm_drop_member&{$misc->href}&group=",
- urlencode($_REQUEST['group']), "&user=", urlencode($groupdata->fields['usename']), "\">{$lang['strdrop']}</a></td>\n";
- echo "</tr>\n";
- $groupdata->moveNext();
- }
- echo "</table>\n";
+ $columns = array (
+ 'members' => array (
+ 'title' => $lang['strmembers'],
+ 'field' => field('usename')
+ ),
+ 'actions' => array (
+ 'title' => $lang['stractions'],
+ )
+ );
+
+ $actions = array (
+ 'drop' => array (
+ 'title' => $lang['strdrop'],
+ 'url' => "groups.php?action=confirm_drop_member&{$misc->href}&group=".urlencode($_REQUEST['group'])."&amp;",
+ 'vars' => array ('user' => 'usename'),
+ 'multiaction' => 'confirm_drop_member',
+ )
+ );
+
+ $misc->printTable($groupdata, $columns, $actions, $lang['strnodata'], null, 'groups-properties');
}
- else echo "<p>{$lang['strnousers']}</p>\n";
// Display form for adding a user to the group
echo "<form action=\"groups.php\" method=\"post\">\n";
View
148 info.php
@@ -45,85 +45,95 @@ function doDefault($msg = '') {
// Referring foreign tables
if ($referrers !== -99 && $referrers->recordCount() > 0) {
echo "<h3>{$lang['strreferringtables']}</h3>\n";
- echo "<table>\n";
- echo "\t<tr>\n\t\t";
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- echo "<th class=\"data\">{$lang['strtable']}</th>";
- echo "<th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strdefinition']}</th>";
- echo "<th class=\"data\">{$lang['stractions']}</th>\n";
- echo "\t</tr>\n";
- $i = 0;
-
- while (!$referrers->EOF) {
- $id = ( ($i % 2 ) == 0 ? '1' : '2' );
- echo "\t<tr class=\"data{$id}\">\n\t\t";
- echo "<td>", $misc->printVal($referrers->fields['nspname']), "</td>";
- echo "<td>", $misc->printVal($referrers->fields['relname']), "</td>";
- echo "<td>", $misc->printVal($referrers->fields['conname']), "</td>";
- echo "<td>", $misc->printVal($referrers->fields['consrc']), "</td>";
- echo "<td class=\"opbutton{$id}\"><a href=\"constraints.php?{$misc->href}",
- "&amp;schema=", urlencode($referrers->fields['nspname']),
- "&amp;table=", urlencode($referrers->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
- echo "\t</tr>\n";
- $referrers->movenext();
- $i++;
- }
-
- echo "</table>\n";
+ $columns = array (
+ 'schema' => array (
+ 'title' => $lang['strschema'],
+ 'field' => field('nspname')
+ ),
+ 'table' => array (
+ 'title' => $lang['strtable'],
+ 'field' => field('relname'),
+ ),
+ 'name' => array (
+ 'title' => $lang['strname'],
+ 'field' => field('conname'),
+ ),
+ 'definition' => array (
+ 'title' => $lang['strdefinition'],
+ 'field' => field('consrc'),
+ ),
+ 'actions' => array (
+ 'title' => $lang['stractions'],
+ )
+ );
+
+ $actions = array (
+ 'properties' => array (
+ 'title' => $lang['strproperties'],
+ 'url' => "constraints.php?{$misc->href}&amp;",
+ 'vars' => array ('schema' => 'nspname', 'table' => 'relname'),
+ )
+ );
+
+ $misc->printTable($referrers, $columns, $actions, $lang['strnodata'], null, 'info-referrers');
}
// Parent tables
if ($parents->recordCount() > 0) {
echo "<h3>{$lang['strparenttables']}</h3>\n";
- echo "<table>\n";
- echo "\t<tr>\n\t\t";
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
- echo "<th class=\"data\">{$lang['stractions']}</th>\n";
- echo "\t</tr>\n";
- $i = 0;
-
- while (!$parents->EOF) {
- $id = ( ($i % 2 ) == 0 ? '1' : '2' );
- echo "\t<tr class=\"data{$id}\">\n";
- echo "\t\t<td>", $misc->printVal($parents->fields['nspname']), "</td>";
- echo "<td>", $misc->printVal($parents->fields['relname']), "</td>";
- echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
- "&amp;schema=", urlencode($parents->fields['nspname']),
- "&amp;table=", urlencode($parents->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
- echo "\t</tr>\n";
- $parents->movenext();
- $i++;
- }
-
- echo "</table>\n";
+
+ $columns = array (
+ 'schema' => array (
+ 'title' => $lang['strschema'],
+ 'field' => field('nspname')
+ ),
+ 'table' => array (
+ 'title' => $lang['strtable'],
+ 'field' => field('relname'),
+ ),
+ 'actions' => array (
+ 'title' => $lang['stractions'],
+ )
+ );
+
+ $actions = array (
+ 'properties' => array (
+ 'title' => $lang['strproperties'],
+ 'url' => "tblproperties.php?{$misc->href}&amp;",
+ 'vars' => array ('schema' => 'nspname', 'table' => 'relname'),
+ )
+ );
+
+ $misc->printTable($parents, $columns, $actions, $lang['strnodata'], null, 'info-parents');
}
// Child tables
if ($children->recordCount() > 0) {
echo "<h3>{$lang['strchildtables']}</h3>\n";
- echo "<table>\n";
- echo "\t<tr>\n";
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
- echo "<th class=\"data\">{$lang['stractions']}</th>\n";
- echo "\t</tr>\n";
- $i = 0;
-
- while (!$children->EOF) {
- $id = ( ($i % 2 ) == 0 ? '1' : '2' );
- echo "\t<tr class=\"data{$id}\">\n";
- echo "\t\t<td>", $misc->printVal($children->fields['nspname']), "</td>";
- echo "<td>", $misc->printVal($children->fields['relname']), "</td>";
- echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
- "&amp;schema=", urlencode($children->fields['nspname']),
- "&amp;table=", urlencode($children->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
- echo "\t</tr>\n";
- $children->movenext();
- $i++;
- }
-
- echo "</table>\n";
+
+ $columns = array (
+ 'schema' => array (
+ 'title' => $lang['strschema'],
+ 'field' => field('nspname')
+ ),
+ 'table' => array (
+ 'title' => $lang['strtable'],
+ 'field' => field('relname'),
+ ),
+ 'actions' => array (
+ 'title' => $lang['stractions'],
+ )
+ );
+
+ $actions = array (
+ 'properties' => array (
+ 'title' => $lang['strproperties'],
+ 'url' => "tblproperties.php?{$misc->href}&amp;",
+ 'vars' => array ('schema' => 'nspname', 'table' => 'relname'),
+ )
+ );
+
+ $misc->printTable($children, $columns, $actions, $lang['strnodata'], null, 'info-children');
}
// Row performance
View
55 plugins/Example/plugin.php
@@ -39,7 +39,8 @@ function get_hooks() {
'tabs' => array('add_plugin_tabs'),
'trail' => array('add_plugin_trail'),
'navlinks' => array('add_plugin_navlinks'),
- 'actionbuttons' => array('add_plugin_actionbuttons')
+ 'actionbuttons' => array('add_plugin_actionbuttons'),
+ 'displaybuttons' => array('add_plugin_displaybuttons')
);
return $hooks;
}
@@ -62,7 +63,8 @@ function get_actions() {
'show_level_3',
'show_level_4',
'show_display_extension',
- 'show_databases_extension'
+ 'show_databases_extension',
+ 'show_display_example'
);
return $actions;
}
@@ -236,6 +238,32 @@ function add_plugin_actionbuttons(&$plugin_functions_parameters) {
}
/**
+ * Add plugin in the action buttons of display.php
+ * @param $plugin_functions_parameters
+ */
+ function add_plugin_displaybuttons(&$plugin_functions_parameters) {
+ global $misc;
+
+ $buttons = array();
+
+ $href = "plugin.php?".$misc->href;
+ $href.= "&amp;plugin=".urlencode($this->name);
+ $href.= "&amp;subject=show_page";
+ $href.= "&amp;action=show_display_example";
+ $href.= "&amp;table=".urlencode($_REQUEST['table']);
+
+ $buttons['extraaction'] = array (
+ 'title' => $this->lang['strextraaction'],
+ 'url' => $href,
+ );
+
+ if (count($buttons) > 0) {
+ //Merge the original actionbuttons array with Examples' actionbuttons
+ $plugin_functions_parameters['displaybuttons'] = array_merge($plugin_functions_parameters['displaybuttons'], $buttons);
+ }
+ }
+
+ /**
* Show a simple page
* This function will be used as an action
*
@@ -410,5 +438,28 @@ function show_databases_extension() {
$misc->printFooter();
}
+
+ /**
+ * Simple example of how to put a hook in the display page.
+ */
+ function show_display_example() {
+ global $lang, $misc;
+
+ $misc->printHeader($lang['strdatabase']);
+ $misc->printBody();
+ $misc->printTrail($_REQUEST['subject']);
+
+ echo "<div>{$this->lang['strextraaction']}</div>\n";
+ echo "<br/>\n";
+
+ $back_link = "<a href=\"display.php?{$misc->href}";
+ $back_link.= "&amp;table=".urlencode($_REQUEST['table']);
+ $back_link.= "&amp;subject=table\">";
+ $back_link.= $lang['strback'];
+ $back_link.= "</a>\n";
+ echo $back_link;
+
+ $misc->printFooter();
+ }
}
?>

No commit comments for this range

Something went wrong with that request. Please try again.