From 687c549f95dc441266dcb5c78be5d2f2d28718b4 Mon Sep 17 00:00:00 2001 From: Amenadiel Date: Fri, 7 Feb 2020 06:01:21 -0300 Subject: Fixes null boxes, closes #254 --- src/controllers/DisplayController.php | 167 +++++++++---------- src/controllers/TablesController.php | 293 ++++++++++++++++++---------------- 2 files changed, 244 insertions(+), 216 deletions(-) (limited to 'src') diff --git a/src/controllers/DisplayController.php b/src/controllers/DisplayController.php index f1d49a20..abc2bf1d 100644 --- a/src/controllers/DisplayController.php +++ b/src/controllers/DisplayController.php @@ -29,13 +29,13 @@ class DisplayController extends BaseController set_time_limit(0); - $scripts = ''; + $scripts = ''; - $scripts .= ''.PHP_EOL; + $scripts .= '' . PHP_EOL; $footer_template = 'footer.twig'; $header_template = 'header.twig'; @@ -161,7 +161,7 @@ class DisplayController extends BaseController $this->printTabs($subject, $tabsPosition); list($query, $title, $type) = $this->getQueryTitleAndType($data, $object); - $this->printTitle($title); + $this->printTitle($this->lang[$title]); //$this->prtrace($subject, $object, $query, $_SESSION['sqlquery']); @@ -237,10 +237,10 @@ class DisplayController extends BaseController //die(htmlspecialchars($query)); - echo '
'; + echo ''; echo $this->misc->form; if ($object) { - echo ''.PHP_EOL; + echo '' . PHP_EOL; } echo '\n\t".PHP_EOL; + htmlspecialchars($_REQUEST['tblcomment']), "\n\t" . PHP_EOL; - echo ''.PHP_EOL; - echo '

'.PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; + echo '

' . PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo "lang['strnext']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />

".PHP_EOL; - echo '
'.PHP_EOL; + echo "lang['strnext']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />

" . PHP_EOL; + echo '' . PHP_EOL; break; case 2: @@ -534,15 +534,15 @@ class TablesController extends BaseController $this->printTitle($this->lang['strcreatetable'], 'pg.table.create'); $this->printMsg($msg); - echo ''; - echo '
'.PHP_EOL; + echo ''; + echo '' . PHP_EOL; // Output table header - echo ''.PHP_EOL; + echo '
' . PHP_EOL; echo "\t"; echo ""; echo ""; - echo "".PHP_EOL; + echo "" . PHP_EOL; for ($i = 0; $i < $_REQUEST['fields']; ++$i) { if (!isset($_REQUEST['field'][$i])) { @@ -561,16 +561,16 @@ class TablesController extends BaseController $_REQUEST['colcomment'][$i] = ''; } - echo "\t\n\t\t'.PHP_EOL; + echo "\t\n\t\t' . PHP_EOL; echo "\t\t'.PHP_EOL; - echo "\t\t' . PHP_EOL; + echo "\t\t"; + echo '\n\t"; } // Output array type selector - echo "\t\t".PHP_EOL; + echo "\t\t" . PHP_EOL; echo "\t\t'.PHP_EOL; - echo "\t\t'.PHP_EOL; + htmlspecialchars($_REQUEST['length'][$i]), '" />' . PHP_EOL; + echo "\t\t' . PHP_EOL; echo "\t\t'.PHP_EOL; + . (isset($_REQUEST['uniquekey'][$i]) ? ' checked="checked"' : '') . ' />' . PHP_EOL; echo "\t\t'.PHP_EOL; + . (isset($_REQUEST['primarykey'][$i]) ? ' checked="checked"' : '') + . ' />' . PHP_EOL; echo "\t\t'.PHP_EOL; + htmlspecialchars($_REQUEST['default'][$i]), '" />' . PHP_EOL; echo "\t\t\n\t".PHP_EOL; + \n\t" . PHP_EOL; } - echo '
{$this->lang['strcolumn']}{$this->lang['strtype']}{$this->lang['strlength']}{$this->lang['strnotnull']}{$this->lang['struniquekey']}{$this->lang['strprimarykey']}{$this->lang['strdefault']}{$this->lang['strcomment']}
{$this->lang['strdefault']}{$this->lang['strcomment']}
", $i + 1, '. 
", $i + 1, '. _maxNameLen}\" value=\"", - htmlspecialchars($_REQUEST['field'][$i]), '" />\n\t\t\t\n\t\t\t\n\t\t\n"; @@ -589,46 +589,46 @@ class TablesController extends BaseController foreach ($predefined_size_types as $value) { $escaped_predef_types[] = "'{$value}'"; } - echo '\n\t\n\t\t\t\n\t\t\n\t\t\t\n\t\t -
'.PHP_EOL; - echo '

'.PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; + echo '

' . PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo ''.PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; if (isset($_REQUEST['withoutoids'])) { - echo ''.PHP_EOL; + echo '' . PHP_EOL; } - echo ''.PHP_EOL; + echo '' . PHP_EOL; if (isset($_REQUEST['spcname'])) { - echo ''.PHP_EOL; + echo '' . PHP_EOL; } - echo "lang['strcreate']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />

".PHP_EOL; - echo '
'.PHP_EOL; + echo "lang['strcreate']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />

" . PHP_EOL; + echo '' . PHP_EOL; break; case 3: @@ -693,7 +693,7 @@ class TablesController extends BaseController break; default: - echo "

{$this->lang['strinvalidparam']}

".PHP_EOL; + echo "

{$this->lang['strinvalidparam']}

" . PHP_EOL; } } @@ -736,13 +736,13 @@ class TablesController extends BaseController unset($tbltmp); - echo '
'.PHP_EOL; - echo "\n\t\n\t\t".PHP_EOL; - echo "\t\t\n\t".PHP_EOL; - echo "\t\n\t\t".PHP_EOL; + echo '' . PHP_EOL; + echo "
{$this->lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" />
{$this->lang['strcreatetablelikeparent']}
\n\t\n\t\t" . PHP_EOL; + echo "\t\t\n\t" . PHP_EOL; + echo "\t\n\t\t" . PHP_EOL; echo "\t\t\n\t".PHP_EOL; + echo "\n\t" . PHP_EOL; if ($data->hasTablespaces()) { $tblsp_ = $data->getTablespaces(); if ($tblsp_->recordCount() > 0) { @@ -752,10 +752,10 @@ class TablesController extends BaseController $tblsp[$a['spcname']] = $a['spcname']; } - echo "\t\n\t\t".PHP_EOL; + echo "\t\n\t\t" . PHP_EOL; echo "\t\t\n\t".PHP_EOL; + echo "\n\t" . PHP_EOL; } } echo "\t\n\t\t\n\t\t\n\t".PHP_EOL; + echo "\n\t" . PHP_EOL; echo '
{$this->lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" />
{$this->lang['strcreatetablelikeparent']}"; echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tables, 'like', true, $tblsel, false); - echo "
{$this->lang['strtablespace']}
{$this->lang['strtablespace']}"; echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tblsp, 'tablespace', true, $_REQUEST['tablespace'], false); - echo "
{$this->lang['stroptions']}"; @@ -772,14 +772,14 @@ class TablesController extends BaseController isset($_REQUEST['withindexes']) ? ' checked="checked"' : '', "/>{$this->lang['strcreatelikewithindexes']}"; } - echo "
'; - echo ''.PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo "

lang['strcreate']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />

".PHP_EOL; - echo '
'.PHP_EOL; + echo "

lang['strcreate']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />

" . PHP_EOL; + echo '' . PHP_EOL; } else { if ('' == trim($_REQUEST['name'])) { $this->doCreateLike(false, $this->lang['strtableneedsname']); @@ -831,10 +831,10 @@ class TablesController extends BaseController $attrs = $data->getTableAttributes($_REQUEST['table']); - echo '
'.PHP_EOL; + echo '' . PHP_EOL; if ($attrs->recordCount() > 0) { // JavaScript for select all feature - echo ''.PHP_EOL; + echo '//]]>' . PHP_EOL; + echo '' . PHP_EOL; - echo ''.PHP_EOL; + echo '
' . PHP_EOL; // Output table header echo ""; @@ -866,42 +866,42 @@ class TablesController extends BaseController // Continue drawing row $id = (0 == ($i % 2) ? '1' : '2'); - echo "".PHP_EOL; + echo "" . PHP_EOL; echo ''; echo ''; echo ''; echo '".PHP_EOL; + echo "\n" . PHP_EOL; echo ''; - echo ''.PHP_EOL; + echo '' . PHP_EOL; ++$i; $attrs->moveNext(); } // Select all checkbox echo ""; - echo '
{$this->lang['strshow']}{$this->lang['strcolumn']}
'; echo 'fields['attname']]) ? ' checked="checked"' : '', ' />', $this->misc->printVal($attrs->fields['attname']), '', $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])), ''; - echo "fields['attname']}]\">" . PHP_EOL; foreach (array_keys($data->selectOps) as $v) { echo ''.PHP_EOL; + '>', htmlspecialchars($v), '' . PHP_EOL; } - echo "\n', $data->printField( "values[{$attrs->fields['attname']}]", $_REQUEST['values'][$attrs->fields['attname']], $attrs->fields['type'] ), '
'.PHP_EOL; + echo '' . PHP_EOL; } else { - echo "

{$this->lang['strinvalidparam']}

".PHP_EOL; + echo "

{$this->lang['strinvalidparam']}

" . PHP_EOL; } - echo '

'.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; + echo '

' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo "lang['strselect']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />

".PHP_EOL; - echo '
'.PHP_EOL; + echo "lang['strselect']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />

" . PHP_EOL; + echo '' . PHP_EOL; return; } @@ -963,9 +963,9 @@ class TablesController extends BaseController $this->coalesceArr($_REQUEST, 'nulls', []); $this->coalesceArr($_REQUEST, 'format', []); - echo '
'.PHP_EOL; + echo '' . PHP_EOL; if ($attrs->recordCount() > 0) { - echo ''.PHP_EOL; + echo '
' . PHP_EOL; // Output table header echo ""; @@ -991,25 +991,50 @@ class TablesController extends BaseController $_REQUEST['format'][$attrs->fields['attnum']] = (null === $attrs->fields['adsrc']) ? 'VALUE' : 'EXPRESSION'; } + $requested_format = $_REQUEST['format'][$attrs->fields['attnum']]; // Continue drawing row $id = (0 == ($i % 2) ? '1' : '2'); - echo "".PHP_EOL; + echo "" . PHP_EOL; echo ''; - echo ''; - echo '".PHP_EOL; + echo '" . PHP_EOL; echo ''; @@ -1029,40 +1054,40 @@ class TablesController extends BaseController } else { echo $data->printField("values[{$attrs->fields['attnum']}]", $_REQUEST['values'][$attrs->fields['attnum']], $attrs->fields['type'], ['class' => 'insert_row_input']); } - echo ''.PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; ++$i; $attrs->moveNext(); } - echo '
{$this->lang['strcolumn']}{$this->lang['strtype']}
', $this->misc->printVal($attrs->fields['attname']), ''.PHP_EOL; - echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])); + echo '' . PHP_EOL; + echo $this->misc->printVal( + $data->formatType( + $attrs->fields['type'], + $attrs->fields['atttypmod'] + ) + ); echo "fields['attnum']}]\" value=\"", htmlspecialchars($attrs->fields['type']), '" />'.PHP_EOL; - echo "\n' . PHP_EOL; + + echo "\n'; - // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS) + // Output null box if the column allows nulls + // Edit: if it can be null, then null it is. if (!$attrs->fields['attnotnull']) { - echo "'; + + echo ''; + } echo '
'.PHP_EOL; + echo '' . PHP_EOL; if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; } - echo ''.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; - echo "

lang['strinsert']}\" />".PHP_EOL; - echo "lang['strinsertandrepeat']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />".PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + echo "

lang['strinsert']}\" />" . PHP_EOL; + echo "lang['strinsertandrepeat']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />" . PHP_EOL; if (false !== $fksprops) { if ('default off' != $this->conf['autocomplete']) { - echo "".PHP_EOL; + echo "" . PHP_EOL; } else { - echo "".PHP_EOL; + echo "" . PHP_EOL; } } - echo '

'.PHP_EOL; + echo '

' . PHP_EOL; } else { - echo "

{$this->lang['strnofieldsforinsert']}

".PHP_EOL; - echo "lang['strcancel']}\" />".PHP_EOL; + echo "

{$this->lang['strnofieldsforinsert']}

" . PHP_EOL; + echo "lang['strcancel']}\" />" . PHP_EOL; } echo $this->misc->form; - echo '
'.PHP_EOL; - echo ''; + echo '' . PHP_EOL; + echo ''; } /** @@ -1114,29 +1139,29 @@ class TablesController extends BaseController $this->printTrail('schema'); $this->printTitle($this->lang['strempty'], 'pg.table.empty'); - echo '
'.PHP_EOL; + echo '' . PHP_EOL; foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); - echo '

'.sprintf($this->lang['strconfemptytable'], $this->misc->printVal($a['table'])); + echo '

' . sprintf($this->lang['strconfemptytable'], $this->misc->printVal($a['table'])); - echo '

'.PHP_EOL; + echo '

' . PHP_EOL; printf('', htmlspecialchars($a['table'])); } // END mutli empty } else { $this->printTrail('table'); $this->printTitle($this->lang['strempty'], 'pg.table.empty'); - echo '

', sprintf($this->lang['strconfemptytable'], $this->misc->printVal($_REQUEST['table'])), '

'.PHP_EOL; + echo '

', sprintf($this->lang['strconfemptytable'], $this->misc->printVal($_REQUEST['table'])), '

' . PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; // END not mutli empty } echo " "; - echo ''.PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo "lang['strempty']}\" /> lang['strcancel']}\" />".PHP_EOL; + echo "lang['strempty']}\" /> lang['strcancel']}\" />" . PHP_EOL; echo "
\n"; // END if confirm } else { // Do Empty @@ -1163,7 +1188,7 @@ class TablesController extends BaseController return $this->doDefault($msg); } - return $this->doDefault($sql.'
'.$this->lang['strtableemptiedbad']); + return $this->doDefault($sql . '
' . $this->lang['strtableemptiedbad']); // END not mutli empty } // END do Empty @@ -1189,28 +1214,28 @@ class TablesController extends BaseController $this->printTrail('schema'); $this->printTitle($this->lang['strdrop'], 'pg.table.drop'); - echo '
'.PHP_EOL; + echo '' . PHP_EOL; foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); - echo '

', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($a['table'])), '

'.PHP_EOL; + echo '

', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($a['table'])), '

' . PHP_EOL; printf('', htmlspecialchars($a['table'])); } } else { $this->printTrail('table'); $this->printTitle($this->lang['strdrop'], 'pg.table.drop'); - echo '

', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($_REQUEST['table'])), '

'.PHP_EOL; + echo '

', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($_REQUEST['table'])), '

' . PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; // END if multi drop } - echo ''.PHP_EOL; + echo '' . PHP_EOL; echo $this->misc->form; - echo "

".PHP_EOL; - echo "lang['strdrop']}\" />".PHP_EOL; - echo "lang['strcancel']}\" />".PHP_EOL; + echo "

" . PHP_EOL; + echo "lang['strdrop']}\" />" . PHP_EOL; + echo "lang['strcancel']}\" />" . PHP_EOL; echo "
\n"; // END confirm } else { //If multi drop -- cgit v1.2.3