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:
authorFelipe Figueroa <amenadiel@gmail.com>2018-05-28 17:03:15 +0300
committerFelipe Figueroa <amenadiel@gmail.com>2018-05-28 17:03:15 +0300
commitc45464abace7901f1fc340f34f9fb5573538c739 (patch)
tree7ce465b5130d93343d8c2e32bb02aa0bde252fef /src/controllers/DisplayController.php
parenta4192e1eaf04a985d0a9f97ee75028fb87d6f23e (diff)
display null only if value is null, not if it's empty or zero
Diffstat (limited to 'src/controllers/DisplayController.php')
-rw-r--r--src/controllers/DisplayController.php366
1 files changed, 184 insertions, 182 deletions
diff --git a/src/controllers/DisplayController.php b/src/controllers/DisplayController.php
index d8d80323..ebb3e09e 100644
--- a/src/controllers/DisplayController.php
+++ b/src/controllers/DisplayController.php
@@ -28,13 +28,13 @@ class DisplayController extends BaseController
set_time_limit(0);
- $scripts = '<script src="'.\SUBFOLDER.'/assets/js/display.js" type="text/javascript"></script>';
+ $scripts = '<script src="' . \SUBFOLDER . '/assets/js/display.js" type="text/javascript"></script>';
- $scripts .= '<script type="text/javascript">'."\n";
+ $scripts .= '<script type="text/javascript">' . "\n";
$scripts .= "var Display = {\n";
- $scripts .= "errmsg: '".str_replace("'", "\\'", $this->lang['strconnectionfail'])."'\n";
+ $scripts .= "errmsg: '" . str_replace("'", "\\'", $this->lang['strconnectionfail']) . "'\n";
$scripts .= "};\n";
- $scripts .= '</script>'."\n";
+ $scripts .= '</script>' . "\n";
$footer_template = 'footer.twig';
$header_template = 'header.twig';
@@ -257,10 +257,10 @@ class DisplayController extends BaseController
//die(htmlspecialchars($query));
- echo '<form method="post" id="sqlform" action="'.$_SERVER['REQUEST_URI'].'">';
+ echo '<form method="post" id="sqlform" action="' . $_SERVER['REQUEST_URI'] . '">';
echo $this->misc->form;
if ($object) {
- echo '<input type="hidden" name="'.$subject.'" value="', htmlspecialchars($object), '" />'."\n";
+ echo '<input type="hidden" name="' . $subject . '" value="', htmlspecialchars($object), '" />' . "\n";
}
echo '<textarea width="90%" name="query" id="query" rows="5" cols="100" resizable="true">';
echo htmlspecialchars($query);
@@ -343,19 +343,19 @@ class DisplayController extends BaseController
// Display edit and delete actions if we have a key
$colspan = count($buttons);
if ($colspan > 0 and count($key) > 0) {
- echo "<th colspan=\"{$colspan}\" class=\"data\">{$this->lang['stractions']}</th>"."\n";
+ echo "<th colspan=\"{$colspan}\" class=\"data\">{$this->lang['stractions']}</th>" . "\n";
}
// we show OIDs only if we are in TABLE or SELECT type browsing
$this->printTableHeaderCells($resultset, $_gets, isset($object));
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
$i = 0;
reset($resultset->fields);
while (!$resultset->EOF) {
$id = (0 == ($i % 2) ? '1' : '2');
- echo "<tr class=\"data{$id}\">"."\n";
+ echo "<tr class=\"data{$id}\">" . "\n";
// Display edit and delete links if we have a key
if ($colspan > 0 and count($key) > 0) {
$keys_array = [];
@@ -369,7 +369,7 @@ class DisplayController extends BaseController
$keys_array["key[{$v}]"] = $resultset->fields[$v];
}
if ($has_nulls) {
- echo "<td colspan=\"{$colspan}\">&nbsp;</td>"."\n";
+ echo "<td colspan=\"{$colspan}\">&nbsp;</td>" . "\n";
} else {
if (isset($actions['actionbuttons']['edit'])) {
$actions['actionbuttons']['edit'] = $edit_params;
@@ -390,24 +390,24 @@ class DisplayController extends BaseController
foreach ($actions['actionbuttons'] as $this->action) {
echo "<td class=\"opbutton{$id}\">";
$this->printLink($this->action, true, __METHOD__);
- echo '</td>'."\n";
+ echo '</td>' . "\n";
}
}
}
$this->printTableRowCells($resultset, $fkey_information, isset($object));
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
$resultset->moveNext();
++$i;
}
- echo '</table>'."\n";
+ echo '</table>' . "\n";
- echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>"."\n";
+ echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>" . "\n";
// Show page navigation
echo $paginator;
} else {
- echo "<p>{$this->lang['strnodata']}</p>"."\n";
+ echo "<p>{$this->lang['strnodata']}</p>" . "\n";
}
// Navigation links
@@ -565,6 +565,110 @@ class DisplayController extends BaseController
}
/**
+ * Print table header cells.
+ *
+ * @param \PHPPgAdmin\ADORecordSet $resultset set of results from getRow operation
+ * @param array $args - associative array for sort link parameters
+ * @param bool $withOid either to display OIDs or not
+ */
+ public function printTableHeaderCells(&$resultset, $args, $withOid)
+ {
+ $data = $this->misc->getDatabaseAccessor();
+ $j = 0;
+
+ foreach ($resultset->fields as $k => $v) {
+ if (($k === $data->id) && (!($withOid && $this->conf['show_oids']))) {
+ ++$j;
+
+ continue;
+ }
+ $finfo = $resultset->fetchField($j);
+
+ if (false === $args) {
+ echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>' . "\n";
+ } else {
+ $args['page'] = $_REQUEST['page'];
+ $args['sortkey'] = $j + 1;
+ // Sort direction opposite to current direction, unless it's currently ''
+ $args['sortdir'] = (
+ 'asc' == $_REQUEST['sortdir']
+ and $_REQUEST['sortkey'] == ($j + 1)
+ ) ? 'desc' : 'asc';
+
+ $sortLink = http_build_query($args);
+
+ echo "<th class=\"data\"><a href=\"?{$sortLink}\">"
+ , $this->misc->printVal($finfo->name);
+ if ($_REQUEST['sortkey'] == ($j + 1)) {
+ if ('asc' == $_REQUEST['sortdir']) {
+ echo '<img src="' . $this->misc->icon('RaiseArgument') . '" alt="asc">';
+ } else {
+ echo '<img src="' . $this->misc->icon('LowerArgument') . '" alt="desc">';
+ }
+ }
+ echo '</a></th>' . "\n";
+ }
+ ++$j;
+ }
+
+ reset($resultset->fields);
+ }
+
+ /**
+ * Print table rows.
+ *
+ * @param \PHPPgAdmin\ADORecordSet $resultset The resultset
+ * @param array $fkey_information The fkey information
+ * @param bool $withOid either to display OIDs or not
+ */
+ public function printTableRowCells(&$resultset, &$fkey_information, $withOid)
+ {
+ $data = $this->misc->getDatabaseAccessor();
+ $j = 0;
+
+ $this->coalesceArr($_REQUEST, 'strings', 'collapsed');
+
+ foreach ($resultset->fields as $k => $v) {
+ $finfo = $resultset->fetchField($j++);
+
+ if (($k === $data->id) && (!($withOid && $this->conf['show_oids']))) {
+ continue;
+ }
+ if (null !== $v && '' == $v) {
+ echo '<td>&nbsp;</td>';
+ } else {
+ echo '<td style="white-space:nowrap;">';
+
+ if ((null !== $v) && isset($fkey_information['byfield'][$k])) {
+ foreach ($fkey_information['byfield'][$k] as $conid) {
+ $query_params = $fkey_information['byconstr'][$conid]['url_data'];
+
+ foreach ($fkey_information['byconstr'][$conid]['fkeys'] as $p_field => $f_field) {
+ $query_params .= '&amp;' . urlencode("fkey[{$f_field}]") . '=' . urlencode($resultset->fields[$p_field]);
+ }
+
+ // $fkey_information['common_url'] is already urlencoded
+ $query_params .= '&amp;' . $fkey_information['common_url'];
+ echo '<div style="display:inline-block;">';
+ echo '<a class="fk fk_' . htmlentities($conid, ENT_QUOTES, 'UTF-8') . "\" href=\"display?{$query_params}\">";
+ echo '<img src="' . $this->misc->icon('ForeignKey') . '" style="vertical-align:middle;" alt="[fk]" title="'
+ . htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8')
+ . '" />';
+ echo '</a>';
+ echo '</div>';
+ }
+ $val = $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings']), 'class' => 'fk_value']);
+ } else {
+ $val = $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings'])]);
+ }
+
+ echo $val;
+ echo '</td>';
+ }
+ }
+ }
+
+ /**
* Show confirmation of edit and perform actual update.
*
* @param bool $confirm if true, display row edit form. If false, perform the update
@@ -597,7 +701,7 @@ class DisplayController extends BaseController
$fksprops = false;
}
- echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post" id="ac_form">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post" id="ac_form">' . "\n";
/*echo '<p>';
if (!$error) {
@@ -611,11 +715,11 @@ class DisplayController extends BaseController
$elements = 0;
$error = true;
if (1 == $resultset->recordCount() && $attrs->recordCount() > 0) {
- echo '<table>'."\n";
+ echo '<table>' . "\n";
// Output table header
echo "<tr><th class=\"data\">{$this->lang['strcolumn']}</th><th class=\"data\">{$this->lang['strtype']}</th>";
- echo "<th class=\"data\">{$this->lang['strformat']}</th>"."\n";
+ echo "<th class=\"data\">{$this->lang['strformat']}</th>" . "\n";
echo "<th class=\"data\">{$this->lang['strnull']}</th><th class=\"data\">{$this->lang['strvalue']}</th></tr>";
$i = 0;
@@ -628,19 +732,19 @@ class DisplayController extends BaseController
$_REQUEST['format'][$attrs->fields['attname']] = 'VALUE';
}
- echo "<tr class=\"data{$id}\">"."\n";
+ echo "<tr class=\"data{$id}\">" . "\n";
echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>';
- echo '<td style="white-space:nowrap;">'."\n";
+ echo '<td style="white-space:nowrap;">' . "\n";
echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod']));
echo '<input type="hidden" name="types[', htmlspecialchars($attrs->fields['attname']), ']" value="',
htmlspecialchars($attrs->fields['type']), '" /></td>';
++$elements;
- echo '<td style="white-space:nowrap;">'."\n";
- echo '<select name="format['.htmlspecialchars($attrs->fields['attname']), ']">'."\n";
- echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>"."\n";
+ echo '<td style="white-space:nowrap;">' . "\n";
+ echo '<select name="format[' . htmlspecialchars($attrs->fields['attname']), ']">' . "\n";
+ echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>" . "\n";
$selected = ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : '';
- echo '<option value="EXPRESSION"'.$selected.">{$this->lang['strexpression']}</option>"."\n";
- echo "</select>\n</td>"."\n";
+ echo '<option value="EXPRESSION"' . $selected . ">{$this->lang['strexpression']}</option>" . "\n";
+ echo "</select>\n</td>" . "\n";
++$elements;
echo '<td style="white-space:nowrap;">';
// Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS)
@@ -650,7 +754,7 @@ class DisplayController extends BaseController
$_REQUEST['nulls'][$attrs->fields['attname']] = 'on';
}
echo "<label><span><input type=\"checkbox\" name=\"nulls[{$attrs->fields['attname']}]\"",
- isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>'."\n";
+ isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>' . "\n";
++$elements;
} else {
echo '&nbsp;</td>';
@@ -665,7 +769,7 @@ class DisplayController extends BaseController
// keep track of which element offset we're up to. We can't refer to the null checkbox by name
// as it contains '[' and ']' characters.
if (!$attrs->fields['attnotnull']) {
- $extras['onChange'] = 'elements['.($elements - 1).'].checked = false;';
+ $extras['onChange'] = 'elements[' . ($elements - 1) . '].checked = false;';
}
if ((false !== $fksprops) && isset($fksprops['byfield'][$attrs->fields['attnum']])) {
@@ -677,63 +781,63 @@ class DisplayController extends BaseController
echo '</td>';
++$elements;
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
++$i;
$attrs->moveNext();
}
- echo '</table>'."\n";
+ echo '</table>' . "\n";
$error = false;
} elseif (1 != $resultset->recordCount()) {
- echo "<p>{$this->lang['strrownotunique']}</p>"."\n";
+ echo "<p>{$this->lang['strrownotunique']}</p>" . "\n";
} else {
- echo "<p>{$this->lang['strinvalidparam']}</p>"."\n";
+ echo "<p>{$this->lang['strinvalidparam']}</p>" . "\n";
}
- echo '<input type="hidden" name="action" value="editrow" />'."\n";
+ echo '<input type="hidden" name="action" value="editrow" />' . "\n";
echo $this->misc->form;
if (isset($_REQUEST['table'])) {
- echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'."\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n";
}
if (isset($_REQUEST['subject'])) {
- echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'."\n";
+ echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n";
}
if (isset($_REQUEST['query'])) {
- echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'."\n";
+ echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n";
}
if (isset($_REQUEST['count'])) {
- echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'."\n";
+ echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n";
}
if (isset($_REQUEST['return'])) {
- echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'."\n";
+ echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n";
}
- echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n";
- echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n";
- echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n";
- echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n";
- echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />'."\n";
+ echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n";
+ echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n";
+ echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n";
+ echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n";
+ echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />' . "\n";
echo '<p>';
if (!$error) {
- echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />"."\n";
+ echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />" . "\n";
}
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
if (false !== $fksprops) {
if ('default off' != $this->conf['autocomplete']) {
- echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"."\n";
+ echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . "\n";
} else {
- echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"."\n";
+ echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . "\n";
}
}
- echo '</p>'."\n";
- echo '</form>'."\n";
+ echo '</p>' . "\n";
+ echo '</form>' . "\n";
} else {
$this->coalesceArr($_POST, 'values', []);
@@ -772,58 +876,58 @@ class DisplayController extends BaseController
$resultset = $data->browseRow($_REQUEST['table'], $_REQUEST['key']);
- echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post">' . "\n";
echo $this->misc->form;
if (1 == $resultset->recordCount()) {
- echo "<p>{$this->lang['strconfdeleterow']}</p>"."\n";
+ echo "<p>{$this->lang['strconfdeleterow']}</p>" . "\n";
$fkinfo = [];
echo '<table><tr>';
$this->printTableHeaderCells($resultset, false, true);
echo '</tr>';
- echo '<tr class="data1">'."\n";
+ echo '<tr class="data1">' . "\n";
$this->printTableRowCells($resultset, $fkinfo, true);
- echo '</tr>'."\n";
- echo '</table>'."\n";
- echo '<br />'."\n";
+ echo '</tr>' . "\n";
+ echo '</table>' . "\n";
+ echo '<br />' . "\n";
- echo '<input type="hidden" name="action" value="delrow" />'."\n";
- echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />"."\n";
- echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />"."\n";
+ echo '<input type="hidden" name="action" value="delrow" />' . "\n";
+ echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />" . "\n";
+ echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />" . "\n";
} elseif (1 != $resultset->recordCount()) {
- echo "<p>{$this->lang['strrownotunique']}</p>"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<p>{$this->lang['strrownotunique']}</p>" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
} else {
- echo "<p>{$this->lang['strinvalidparam']}</p>"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<p>{$this->lang['strinvalidparam']}</p>" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
}
if (isset($_REQUEST['table'])) {
- echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'."\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n";
}
if (isset($_REQUEST['subject'])) {
- echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'."\n";
+ echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n";
}
if (isset($_REQUEST['query'])) {
- echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'."\n";
+ echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n";
}
if (isset($_REQUEST['count'])) {
- echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'."\n";
+ echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n";
}
if (isset($_REQUEST['return'])) {
- echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'."\n";
+ echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n";
}
- echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n";
- echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n";
- echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n";
- echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n";
- echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />'."\n";
- echo '</form>'."\n";
+ echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n";
+ echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n";
+ echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n";
+ echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n";
+ echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />' . "\n";
+ echo '</form>' . "\n";
} else {
$status = $data->deleteRow($_POST['table'], unserialize(urldecode($_POST['key'])));
if (0 == $status) {
@@ -852,7 +956,7 @@ class DisplayController extends BaseController
if (isset($_REQUEST['table'])) {
$constraints = $data->getConstraintsWithFields($_REQUEST['table']);
if ($constraints->recordCount() > 0) {
- $fkey_information['common_url'] = $this->misc->getHREF('schema').'&amp;subject=table';
+ $fkey_information['common_url'] = $this->misc->getHREF('schema') . '&amp;subject=table';
// build the FK constraints data structure
while (!$constraints->EOF) {
@@ -860,7 +964,7 @@ class DisplayController extends BaseController
if ('f' == $constr['contype']) {
if (!isset($fkey_information['byconstr'][$constr['conid']])) {
$fkey_information['byconstr'][$constr['conid']] = [
- 'url_data' => 'table='.urlencode($constr['f_table']).'&amp;schema='.urlencode($constr['f_schema']),
+ 'url_data' => 'table=' . urlencode($constr['f_table']) . '&amp;schema=' . urlencode($constr['f_schema']),
'fkeys' => [],
'consrc' => $constr['consrc'],
];
@@ -882,108 +986,6 @@ class DisplayController extends BaseController
return $fkey_information;
}
- /**
- * Print table header cells.
- *
- * @param \PHPPgAdmin\ADORecordSet $resultset set of results from getRow operation
- * @param array $args - associative array for sort link parameters
- * @param bool $withOid either to display OIDs or not
- */
- public function printTableHeaderCells(&$resultset, $args, $withOid)
- {
- $data = $this->misc->getDatabaseAccessor();
- $j = 0;
-
- foreach ($resultset->fields as $k => $v) {
- if (($k === $data->id) && (!($withOid && $this->conf['show_oids']))) {
- ++$j;
-
- continue;
- }
- $finfo = $resultset->fetchField($j);
-
- if (false === $args) {
- echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>'."\n";
- } else {
- $args['page'] = $_REQUEST['page'];
- $args['sortkey'] = $j + 1;
- // Sort direction opposite to current direction, unless it's currently ''
- $args['sortdir'] = (
- 'asc' == $_REQUEST['sortdir']
- and $_REQUEST['sortkey'] == ($j + 1)
- ) ? 'desc' : 'asc';
-
- $sortLink = http_build_query($args);
-
- echo "<th class=\"data\"><a href=\"?{$sortLink}\">"
- , $this->misc->printVal($finfo->name);
- if ($_REQUEST['sortkey'] == ($j + 1)) {
- if ('asc' == $_REQUEST['sortdir']) {
- echo '<img src="'.$this->misc->icon('RaiseArgument').'" alt="asc">';
- } else {
- echo '<img src="'.$this->misc->icon('LowerArgument').'" alt="desc">';
- }
- }
- echo '</a></th>'."\n";
- }
- ++$j;
- }
-
- reset($resultset->fields);
- }
-
- /**
- * Print table rows.
- *
- * @param \PHPPgAdmin\ADORecordSet $resultset The resultset
- * @param array $fkey_information The fkey information
- * @param bool $withOid either to display OIDs or not
- */
- public function printTableRowCells(&$resultset, &$fkey_information, $withOid)
- {
- $data = $this->misc->getDatabaseAccessor();
- $j = 0;
-
- $this->coalesceArr($_REQUEST, 'strings', 'collapsed');
-
- foreach ($resultset->fields as $k => $v) {
- $finfo = $resultset->fetchField($j++);
-
- if (($k === $data->id) && (!($withOid && $this->conf['show_oids']))) {
- continue;
- }
- if (null !== $v && '' == $v) {
- echo '<td>&nbsp;</td>';
- } else {
- echo '<td style="white-space:nowrap;">';
-
- if ((null !== $v) && isset($fkey_information['byfield'][$k])) {
- foreach ($fkey_information['byfield'][$k] as $conid) {
- $query_params = $fkey_information['byconstr'][$conid]['url_data'];
-
- foreach ($fkey_information['byconstr'][$conid]['fkeys'] as $p_field => $f_field) {
- $query_params .= '&amp;'.urlencode("fkey[{$f_field}]").'='.urlencode($resultset->fields[$p_field]);
- }
-
- // $fkey_information['common_url'] is already urlencoded
- $query_params .= '&amp;'.$fkey_information['common_url'];
- echo '<div style="display:inline-block;">';
- echo '<a class="fk fk_'.htmlentities($conid, ENT_QUOTES, 'UTF-8')."\" href=\"display?{$query_params}\">";
- echo '<img src="'.$this->misc->icon('ForeignKey').'" style="vertical-align:middle;" alt="[fk]" title="'
- .htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8')
- .'" />';
- echo '</a>';
- echo '</div>';
- }
- echo $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings']), 'class' => 'fk_value']);
- } else {
- echo $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings'])]);
- }
- echo '</td>';
- }
- }
- }
-
// Print the FK row, used in ajax requests
public function doBrowseFK()
{
@@ -1011,7 +1013,7 @@ class DisplayController extends BaseController
$max_pages
);
- echo '<a href="javascript:void(0);" style="display:table-cell;" class="fk_delete"><img alt="[delete]" src="'.$this->misc->icon('Delete').'" /></a>'."\n";
+ echo '<a href="javascript:void(0);" style="display:table-cell;" class="fk_delete"><img alt="[delete]" src="' . $this->misc->icon('Delete') . '" /></a>' . "\n";
echo '<div style="display:table-cell;">';
if (is_object($resultset) && $resultset->recordCount() > 0) {
@@ -1022,10 +1024,10 @@ class DisplayController extends BaseController
echo '<table><tr>';
$this->printTableHeaderCells($resultset, false, true);
echo '</tr>';
- echo '<tr class="data1">'."\n";
+ echo '<tr class="data1">' . "\n";
$this->printTableRowCells($resultset, $fkinfo, true);
- echo '</tr>'."\n";
- echo '</table>'."\n";
+ echo '</tr>' . "\n";
+ echo '</table>' . "\n";
} else {
echo $this->lang['strnodata'];
}
@@ -1076,7 +1078,7 @@ class DisplayController extends BaseController
unset($gets['page']);
$url = http_build_query($gets);
- $result = '<p style="text-align: center">'."\n";
+ $result = '<p style="text-align: center">' . "\n";
if ($page != 1) {
$result .= sprintf('<a class="pagenav" href="?%s&page=1">%s</a>%s&nbsp;', $url, $lang['strfirst'], "\n");
$result .= sprintf('<a class="pagenav" href="?%s&page=%s">%s</a>%s', $url, $page - 1, $lang['strprev'], "\n");
@@ -1085,7 +1087,7 @@ class DisplayController extends BaseController
list($min_page, $max_page) = $this->_getMinMaxPages($page, $pages);
for ($i = $min_page; $i <= $max_page; ++$i) {
- $result .= (($i === $page) ? $i : sprintf('<a class="pagenav" href="display?%s&page=%s">%s</a>', $url, $i, $i))."\n";
+ $result .= (($i === $page) ? $i : sprintf('<a class="pagenav" href="display?%s&page=%s">%s</a>', $url, $i, $i)) . "\n";
}
if ($page != $pages) {