diff options
author | Amenadiel <amenadiel@gmail.com> | 2020-02-07 12:01:21 +0300 |
---|---|---|
committer | Amenadiel <amenadiel@gmail.com> | 2020-02-07 12:01:21 +0300 |
commit | 687c549f95dc441266dcb5c78be5d2f2d28718b4 (patch) | |
tree | 669ccd12e696cd3ca0716c0ee9c7c4626e37b0d7 | |
parent | edd985f38051fe012d6f0cf1de9e9d3ac8e908dc (diff) |
Fixes null boxes, closes #254
-rw-r--r-- | src/controllers/DisplayController.php | 167 | ||||
-rw-r--r-- | src/controllers/TablesController.php | 293 |
2 files changed, 244 insertions, 216 deletions
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 = '<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">'.PHP_EOL; + $scripts .= '<script type="text/javascript">' . PHP_EOL; $scripts .= "var Display = {\n"; - $scripts .= "errmsg: '".str_replace("'", "\\'", $this->lang['strconnectionfail'])."'\n"; + $scripts .= "errmsg: '" . str_replace("'", "\\'", $this->lang['strconnectionfail']) . "'\n"; $scripts .= "};\n"; - $scripts .= '</script>'.PHP_EOL; + $scripts .= '</script>' . 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 '<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), '" />'.PHP_EOL; + echo '<input type="hidden" name="' . $subject . '" value="', htmlspecialchars($object), '" />' . PHP_EOL; } echo '<textarea width="90%" name="query" id="query" rows="5" cols="100" resizable="true">'; echo htmlspecialchars($query); @@ -516,7 +516,7 @@ class DisplayController extends BaseController public function printResultsTable($resultset, $page, $max_pages, $_gets, $object) { if (!is_object($resultset) || $resultset->recordCount() <= 0) { - echo "<p>{$this->lang['strnodata']}</p>".PHP_EOL; + echo "<p>{$this->lang['strnodata']}</p>" . PHP_EOL; return; } @@ -530,18 +530,18 @@ class DisplayController extends BaseController $paginator = $this->_printPages($page, $max_pages, $_gets); echo $paginator; - echo '<table id="data">'.PHP_EOL; + echo '<table id="data">' . PHP_EOL; echo '<tr>'; // Display edit and delete actions if we have a key $display_action_column = (count($actions['actionbuttons']) > 0 && count($key) > 0); - echo $display_action_column ? "<th class=\"data\">{$this->lang['stractions']}</th>".PHP_EOL : ''; + echo $display_action_column ? "<th class=\"data\">{$this->lang['stractions']}</th>" . PHP_EOL : ''; // we show OIDs only if we are in TABLE or SELECT type browsing $this->printTableHeaderCells($resultset, $_gets, isset($object)); - echo '</tr>'.PHP_EOL; + echo '</tr>' . PHP_EOL; reset($resultset->fields); @@ -552,18 +552,18 @@ class DisplayController extends BaseController $trclass = ($trclass === 'data2') ? 'data1' : 'data2'; $buttonclass = ($buttonclass === 'opbutton2') ? 'opbutton1' : 'opbutton2'; - echo sprintf('<tr class="%s">', $trclass).PHP_EOL; + echo sprintf('<tr class="%s">', $trclass) . PHP_EOL; $this->_printResultsTableActionButtons($resultset, $key, $actions, $display_action_column, $buttonclass); $this->printTableRowCells($resultset, $fkey_information, isset($object)); - echo '</tr>'.PHP_EOL; + echo '</tr>' . PHP_EOL; $resultset->moveNext(); } - echo '</table>'.PHP_EOL; + echo '</table>' . PHP_EOL; - echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>".PHP_EOL; + echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>" . PHP_EOL; // Show page navigation echo $paginator; } @@ -588,7 +588,7 @@ class DisplayController extends BaseController $keys_array["key[{$v}]"] = $resultset->fields[$v]; } if ($has_nulls) { - echo '<td> </td>'.PHP_EOL; + echo '<td> </td>' . PHP_EOL; return; } @@ -612,7 +612,7 @@ class DisplayController extends BaseController foreach ($actions['actionbuttons'] as $action) { $this->printLink($action, true, __METHOD__); } - echo '</td>'.PHP_EOL; + echo '</td>' . PHP_EOL; } /** @@ -637,7 +637,7 @@ class DisplayController extends BaseController $finfo = $resultset->fetchField($index); if (false === $args) { - echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>'.PHP_EOL; + echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>' . PHP_EOL; continue; } @@ -654,7 +654,7 @@ class DisplayController extends BaseController $icon = ('asc' == $_REQUEST['sortdir']) ? $this->misc->icon('RaiseArgument') : $this->misc->icon('LowerArgument'); echo sprintf('<img src="%s" alt="%s">', $icon, $_REQUEST['sortdir']); } - echo '</a></th>'.PHP_EOL; + echo '</a></th>' . PHP_EOL; } reset($resultset->fields); @@ -706,11 +706,11 @@ class DisplayController extends BaseController $query_params = $fkey_information['byconstr'][$conid]['url_data']; foreach ($fkey_information['byconstr'][$conid]['fkeys'] as $p_field => $f_field) { - $query_params .= '&'.urlencode("fkey[{$f_field}]").'='.urlencode($resultset->fields[$p_field]); + $query_params .= '&' . urlencode("fkey[{$f_field}]") . '=' . urlencode($resultset->fields[$p_field]); } // $fkey_information['common_url'] is already urlencoded - $query_params .= '&'.$fkey_information['common_url']; + $query_params .= '&' . $fkey_information['common_url']; $title = htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8'); echo '<div style="display:inline-block;">'; echo sprintf('<a class="fk fk_%s" href="display?%s">', htmlentities($conid, ENT_QUOTES, 'UTF-8'), $query_params); @@ -753,16 +753,16 @@ class DisplayController extends BaseController $fksprops = $this->_getFKProps(); - echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post" id="ac_form">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post" id="ac_form">' . PHP_EOL; $elements = 0; $error = true; if (1 == $resultset->recordCount() && $attrs->recordCount() > 0) { - echo '<table>'.PHP_EOL; + echo '<table>' . PHP_EOL; // 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>".PHP_EOL; + echo "<th class=\"data\">{$this->lang['strformat']}</th>" . PHP_EOL; echo "<th class=\"data\">{$this->lang['strnull']}</th><th class=\"data\">{$this->lang['strvalue']}</th></tr>"; $i = 0; @@ -775,29 +775,32 @@ class DisplayController extends BaseController $_REQUEST['format'][$attrs->fields['attname']] = 'VALUE'; } - echo "<tr class=\"data{$id}\">".PHP_EOL; + echo "<tr class=\"data{$id}\">" . PHP_EOL; echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>'; - echo '<td style="white-space:nowrap;">'.PHP_EOL; + echo '<td style="white-space:nowrap;">' . PHP_EOL; 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;">'.PHP_EOL; - echo '<select name="format['.htmlspecialchars($attrs->fields['attname']), ']">'.PHP_EOL; - echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>".PHP_EOL; + echo '<td style="white-space:nowrap;">' . PHP_EOL; + echo '<select name="format[' . htmlspecialchars($attrs->fields['attname']), ']">' . PHP_EOL; + echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>" . PHP_EOL; $selected = ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : ''; - echo '<option value="EXPRESSION"'.$selected.">{$this->lang['strexpression']}</option>".PHP_EOL; - echo "</select>\n</td>".PHP_EOL; + echo '<option value="EXPRESSION"' . $selected . ">{$this->lang['strexpression']}</option>" . PHP_EOL; + echo "</select>\n</td>" . PHP_EOL; ++$elements; echo '<td style="white-space:nowrap;">'; // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS) if (!$attrs->fields['attnotnull']) { // Set initial null values - if ('confeditrow' == $_REQUEST['action'] && null === $resultset->fields[$attrs->fields['attname']]) { + if ( + 'confeditrow' == $_REQUEST['action'] + && null === $resultset->fields[$attrs->fields['attname']] + ) { $_REQUEST['nulls'][$attrs->fields['attname']] = 'on'; } echo "<label><span><input type=\"checkbox\" class=\"nullcheckbox\" name=\"nulls[{$attrs->fields['attname']}]\"", - isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>'.PHP_EOL; + isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>' . PHP_EOL; ++$elements; } else { echo ' </td>'; @@ -824,20 +827,20 @@ class DisplayController extends BaseController echo '</td>'; ++$elements; - echo '</tr>'.PHP_EOL; + echo '</tr>' . PHP_EOL; ++$i; $attrs->moveNext(); } - echo '</table>'.PHP_EOL; + echo '</table>' . PHP_EOL; $error = false; } elseif (1 != $resultset->recordCount()) { - echo "<p>{$this->lang['strrownotunique']}</p>".PHP_EOL; + echo "<p>{$this->lang['strrownotunique']}</p>" . PHP_EOL; } else { - echo "<p>{$this->lang['strinvalidparam']}</p>".PHP_EOL; + echo "<p>{$this->lang['strinvalidparam']}</p>" . PHP_EOL; } - echo '<input type="hidden" name="action" value="editrow" />'.PHP_EOL; + echo '<input type="hidden" name="action" value="editrow" />' . PHP_EOL; echo $this->misc->form; echo isset($_REQUEST['table']) ? sprintf('<input type="hidden" name="table" value="%s" />%s', htmlspecialchars($_REQUEST['table']), PHP_EOL) : ''; @@ -849,29 +852,29 @@ class DisplayController extends BaseController echo isset($_REQUEST['return']) ? sprintf('<input type="hidden" name="return" value="%s" />%s', htmlspecialchars($_REQUEST['return']), PHP_EOL) : ''; - echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'.PHP_EOL; - echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'.PHP_EOL; - echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'.PHP_EOL; - echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'.PHP_EOL; - echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />'.PHP_EOL; + echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . PHP_EOL; + echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . PHP_EOL; + echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . PHP_EOL; + echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . PHP_EOL; + echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />' . PHP_EOL; echo '<p>'; if (!$error) { - echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />".PHP_EOL; + echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />" . PHP_EOL; } - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; if (false !== $fksprops) { $autocomplete_string = "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"; if ('default off' != $this->conf['autocomplete']) { $autocomplete_string = "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"; } - echo $autocomplete_string.PHP_EOL; + echo $autocomplete_string . PHP_EOL; } - echo '</p>'.PHP_EOL; - echo '</form>'.PHP_EOL; - echo '<script src="'.\SUBFOLDER.'/assets/js/insert_or_edit_row.js" type="text/javascript"></script>'; + echo '</p>' . PHP_EOL; + echo '</form>' . PHP_EOL; + echo '<script src="' . \SUBFOLDER . '/assets/js/insert_or_edit_row.js" type="text/javascript"></script>'; } /** @@ -920,58 +923,58 @@ class DisplayController extends BaseController $resultset = $data->browseRow($_REQUEST['table'], $_REQUEST['key']); - echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post">' . PHP_EOL; echo $this->misc->form; if (1 == $resultset->recordCount()) { - echo "<p>{$this->lang['strconfdeleterow']}</p>".PHP_EOL; + echo "<p>{$this->lang['strconfdeleterow']}</p>" . PHP_EOL; $fkinfo = []; echo '<table><tr>'; $this->printTableHeaderCells($resultset, false, true); echo '</tr>'; - echo '<tr class="data1">'.PHP_EOL; + echo '<tr class="data1">' . PHP_EOL; $this->printTableRowCells($resultset, $fkinfo, true); - echo '</tr>'.PHP_EOL; - echo '</table>'.PHP_EOL; - echo '<br />'.PHP_EOL; + echo '</tr>' . PHP_EOL; + echo '</table>' . PHP_EOL; + echo '<br />' . PHP_EOL; - echo '<input type="hidden" name="action" value="delrow" />'.PHP_EOL; - echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />".PHP_EOL; + echo '<input type="hidden" name="action" value="delrow" />' . PHP_EOL; + echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />" . PHP_EOL; } elseif (1 != $resultset->recordCount()) { - echo "<p>{$this->lang['strrownotunique']}</p>".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<p>{$this->lang['strrownotunique']}</p>" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; } else { - echo "<p>{$this->lang['strinvalidparam']}</p>".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<p>{$this->lang['strinvalidparam']}</p>" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; } if (isset($_REQUEST['table'])) { - echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'.PHP_EOL; + echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . PHP_EOL; } if (isset($_REQUEST['subject'])) { - echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'.PHP_EOL; + echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . PHP_EOL; } if (isset($_REQUEST['query'])) { - echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'.PHP_EOL; + echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . PHP_EOL; } if (isset($_REQUEST['count'])) { - echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'.PHP_EOL; + echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . PHP_EOL; } if (isset($_REQUEST['return'])) { - echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'.PHP_EOL; + echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . PHP_EOL; } - echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'.PHP_EOL; - echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'.PHP_EOL; - echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'.PHP_EOL; - echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'.PHP_EOL; - echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />'.PHP_EOL; - echo '</form>'.PHP_EOL; + echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . PHP_EOL; + echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . PHP_EOL; + echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . PHP_EOL; + echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . PHP_EOL; + echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />' . PHP_EOL; + echo '</form>' . PHP_EOL; } else { $status = $data->deleteRow($_POST['table'], unserialize(urldecode($_POST['key']))); if (0 == $status) { @@ -1000,7 +1003,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').'&subject=table'; + $fkey_information['common_url'] = $this->misc->getHREF('schema') . '&subject=table'; // build the FK constraints data structure while (!$constraints->EOF) { @@ -1008,7 +1011,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']).'&schema='.urlencode($constr['f_schema']), + 'url_data' => 'table=' . urlencode($constr['f_table']) . '&schema=' . urlencode($constr['f_schema']), 'fkeys' => [], 'consrc' => $constr['consrc'], ]; @@ -1057,7 +1060,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>'.PHP_EOL; + echo '<a href="javascript:void(0);" style="display:table-cell;" class="fk_delete"><img alt="[delete]" src="' . $this->misc->icon('Delete') . '" /></a>' . PHP_EOL; echo '<div style="display:table-cell;">'; if (is_object($resultset) && $resultset->recordCount() > 0) { @@ -1068,10 +1071,10 @@ class DisplayController extends BaseController echo '<table><tr>'; $this->printTableHeaderCells($resultset, false, true); echo '</tr>'; - echo '<tr class="data1">'.PHP_EOL; + echo '<tr class="data1">' . PHP_EOL; $this->printTableRowCells($resultset, $fkinfo, true); - echo '</tr>'.PHP_EOL; - echo '</table>'.PHP_EOL; + echo '</tr>' . PHP_EOL; + echo '</table>' . PHP_EOL; } else { echo $this->lang['strnodata']; } @@ -1122,7 +1125,7 @@ class DisplayController extends BaseController unset($gets['page']); $url = http_build_query($gets); - $result = '<p style="text-align: center">'.PHP_EOL; + $result = '<p style="text-align: center">' . PHP_EOL; if ($page != 1) { $result .= sprintf('<a class="pagenav" href="?%s&page=1">%s</a>%s ', $url, $lang['strfirst'], PHP_EOL); $result .= sprintf('<a class="pagenav" href="?%s&page=%s">%s</a>%s', $url, $page - 1, $lang['strprev'], PHP_EOL); @@ -1131,14 +1134,14 @@ 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)).PHP_EOL; + $result .= (($i === $page) ? $i : sprintf('<a class="pagenav" href="display?%s&page=%s">%s</a>', $url, $i, $i)) . PHP_EOL; } if ($page != $pages) { $result .= sprintf('<a class="pagenav" href="?%s&page=%s">%s</a>%s', $url, $page + 1, $lang['strnext'], PHP_EOL); $result .= sprintf(' <a class="pagenav" href="?%s&page=%s">%s</a>%s', $url, $pages, $lang['strlast'], PHP_EOL); } - $result .= '</p>'.PHP_EOL; + $result .= '</p>' . PHP_EOL; return $result; } diff --git a/src/controllers/TablesController.php b/src/controllers/TablesController.php index 5b983120..9402c048 100644 --- a/src/controllers/TablesController.php +++ b/src/controllers/TablesController.php @@ -142,7 +142,7 @@ class TablesController extends BaseController 'table' => [ 'title' => $this->lang['strtable'], 'field' => Decorator::field('relname'), - 'url' => \SUBFOLDER."/redirect/table?{$this->misc->href}&", + 'url' => \SUBFOLDER . "/redirect/table?{$this->misc->href}&", 'vars' => ['table' => 'relname'], ], 'owner' => [ @@ -469,46 +469,46 @@ class TablesController extends BaseController $this->printTitle($this->lang['strcreatetable'], 'pg.table.create'); $this->printMsg($msg); - echo '<form action="'.\SUBFOLDER.'/src/views/'.$this->script.'" method="post">'; + echo '<form action="' . \SUBFOLDER . '/src/views/' . $this->script . '" method="post">'; echo PHP_EOL; - echo '<table>'.PHP_EOL; - echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>".PHP_EOL; + echo '<table>' . PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>" . PHP_EOL; echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", - htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>".PHP_EOL; - echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strnumcols']}</th>".PHP_EOL; + htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>" . PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strnumcols']}</th>" . PHP_EOL; echo "\t\t<td class=\"data\"><input name=\"fields\" size=\"5\" maxlength=\"{$data->_maxNameLen}\" value=\"", - htmlspecialchars($_REQUEST['fields']), "\" /></td>\n\t</tr>".PHP_EOL; - echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['stroptions']}</th>".PHP_EOL; - echo "\t\t<td class=\"data\"><label for=\"withoutoids\"><input type=\"checkbox\" id=\"withoutoids\" name=\"withoutoids\"", isset($_REQUEST['withoutoids']) ? ' checked="checked"' : '', " />WITHOUT OIDS</label></td>\n\t</tr>".PHP_EOL; + htmlspecialchars($_REQUEST['fields']), "\" /></td>\n\t</tr>" . PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['stroptions']}</th>" . PHP_EOL; + echo "\t\t<td class=\"data\"><label for=\"withoutoids\"><input type=\"checkbox\" id=\"withoutoids\" name=\"withoutoids\"", isset($_REQUEST['withoutoids']) ? ' checked="checked"' : '', " />WITHOUT OIDS</label></td>\n\t</tr>" . PHP_EOL; // Tablespace (if there are any) if ($data->hasTablespaces() && $tablespaces->recordCount() > 0) { - echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strtablespace']}</th>".PHP_EOL; - echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"spcname\">".PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strtablespace']}</th>" . PHP_EOL; + echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"spcname\">" . PHP_EOL; // Always offer the default (empty) option echo "\t\t\t\t<option value=\"\"", - ('' == $_REQUEST['spcname']) ? ' selected="selected"' : '', '></option>'.PHP_EOL; + ('' == $_REQUEST['spcname']) ? ' selected="selected"' : '', '></option>' . PHP_EOL; // Display all other tablespaces while (!$tablespaces->EOF) { $spcname = htmlspecialchars($tablespaces->fields['spcname']); echo "\t\t\t\t<option value=\"{$spcname}\"", - ($tablespaces->fields['spcname'] == $_REQUEST['spcname']) ? ' selected="selected"' : '', ">{$spcname}</option>".PHP_EOL; + ($tablespaces->fields['spcname'] == $_REQUEST['spcname']) ? ' selected="selected"' : '', ">{$spcname}</option>" . PHP_EOL; $tablespaces->moveNext(); } - echo "\t\t\t</select>\n\t\t</td>\n\t</tr>".PHP_EOL; + echo "\t\t\t</select>\n\t\t</td>\n\t</tr>" . PHP_EOL; } - echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>".PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>" . PHP_EOL; echo "\t\t<td><textarea name=\"tblcomment\" rows=\"3\" cols=\"32\">", - htmlspecialchars($_REQUEST['tblcomment']), "</textarea></td>\n\t</tr>".PHP_EOL; + htmlspecialchars($_REQUEST['tblcomment']), "</textarea></td>\n\t</tr>" . PHP_EOL; - echo '</table>'.PHP_EOL; - echo '<p><input type="hidden" name="action" value="create" />'.PHP_EOL; - echo '<input type="hidden" name="stage" value="2" />'.PHP_EOL; + echo '</table>' . PHP_EOL; + echo '<p><input type="hidden" name="action" value="create" />' . PHP_EOL; + echo '<input type="hidden" name="stage" value="2" />' . PHP_EOL; echo $this->misc->form; - echo "<input type=\"submit\" value=\"{$this->lang['strnext']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>".PHP_EOL; - echo '</form>'.PHP_EOL; + echo "<input type=\"submit\" value=\"{$this->lang['strnext']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>" . PHP_EOL; + echo '</form>' . 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 '<script src="'.\SUBFOLDER.'/assets/js/tables.js" type="text/javascript"></script>'; - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; + echo '<script src="' . \SUBFOLDER . '/assets/js/tables.js" type="text/javascript"></script>'; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; // Output table header - echo '<table>'.PHP_EOL; + echo '<table>' . PHP_EOL; echo "\t<tr><th colspan=\"2\" class=\"data required\">{$this->lang['strcolumn']}</th><th colspan=\"2\" class=\"data required\">{$this->lang['strtype']}</th>"; echo "<th class=\"data\">{$this->lang['strlength']}</th><th class=\"data\">{$this->lang['strnotnull']}</th>"; echo "<th class=\"data\">{$this->lang['struniquekey']}</th><th class=\"data\">{$this->lang['strprimarykey']}</th>"; - echo "<th class=\"data\">{$this->lang['strdefault']}</th><th class=\"data\">{$this->lang['strcomment']}</th></tr>".PHP_EOL; + echo "<th class=\"data\">{$this->lang['strdefault']}</th><th class=\"data\">{$this->lang['strcomment']}</th></tr>" . 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<tr>\n\t\t<td>", $i + 1, '. </td>'.PHP_EOL; + echo "\t<tr>\n\t\t<td>", $i + 1, '. </td>' . PHP_EOL; echo "\t\t<td><input name=\"field[{$i}]\" size=\"16\" maxlength=\"{$data->_maxNameLen}\" value=\"", - htmlspecialchars($_REQUEST['field'][$i]), '" /></td>'.PHP_EOL; - echo "\t\t<td>\n\t\t\t<select name=\"type[{$i}]\" class=\"select2\" id=\"types{$i}\" onchange=\"checkLengths(this.options[this.selectedIndex].value,{$i});\">".PHP_EOL; + htmlspecialchars($_REQUEST['field'][$i]), '" /></td>' . PHP_EOL; + echo "\t\t<td>\n\t\t\t<select name=\"type[{$i}]\" class=\"select2\" id=\"types{$i}\" onchange=\"checkLengths(this.options[this.selectedIndex].value,{$i});\">" . PHP_EOL; // Output any "magic" types foreach ($data->extraTypes as $v) { $types_for_js[strtolower($v)] = 1; echo "\t\t\t\t<option value=\"", htmlspecialchars($v), '"', (isset($_REQUEST['type'][$i]) && $_REQUEST['type'][$i] == $v) ? ' selected="selected"' : '', '>', - $this->misc->printVal($v), '</option>'.PHP_EOL; + $this->misc->printVal($v), '</option>' . PHP_EOL; } $types->moveFirst(); while (!$types->EOF) { @@ -578,7 +578,7 @@ class TablesController extends BaseController $types_for_js[$typname] = 1; echo "\t\t\t\t<option value=\"", htmlspecialchars($typname), '"', (isset($_REQUEST['type'][$i]) && $_REQUEST['type'][$i] == $typname) ? ' selected="selected"' : '', '>', - $this->misc->printVal($typname), '</option>'.PHP_EOL; + $this->misc->printVal($typname), '</option>' . PHP_EOL; $types->moveNext(); } echo "\t\t\t</select>\n\t\t\n"; @@ -589,46 +589,46 @@ class TablesController extends BaseController foreach ($predefined_size_types as $value) { $escaped_predef_types[] = "'{$value}'"; } - echo '<script type="text/javascript">predefined_lengths = new Array('.implode(',', $escaped_predef_types).");</script>\n\t</td>"; + echo '<script type="text/javascript">predefined_lengths = new Array(' . implode(',', $escaped_predef_types) . ");</script>\n\t</td>"; } // Output array type selector - echo "\t\t<td>\n\t\t\t<select name=\"array[{$i}]\">".PHP_EOL; - echo "\t\t\t\t<option value=\"\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '') ? ' selected="selected"' : '', '></option>'.PHP_EOL; - echo "\t\t\t\t<option value=\"[]\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '[]') ? ' selected="selected"' : '', '>[ ]</option>'.PHP_EOL; - echo "\t\t\t</select>\n\t\t</td>".PHP_EOL; + echo "\t\t<td>\n\t\t\t<select name=\"array[{$i}]\">" . PHP_EOL; + echo "\t\t\t\t<option value=\"\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '') ? ' selected="selected"' : '', '></option>' . PHP_EOL; + echo "\t\t\t\t<option value=\"[]\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '[]') ? ' selected="selected"' : '', '>[ ]</option>' . PHP_EOL; + echo "\t\t\t</select>\n\t\t</td>" . PHP_EOL; echo "\t\t<td><input name=\"length[{$i}]\" id=\"lengths{$i}\" size=\"10\" value=\"", - htmlspecialchars($_REQUEST['length'][$i]), '" /></td>'.PHP_EOL; - echo "\t\t<td><input type=\"checkbox\" name=\"notnull[{$i}]\"", (isset($_REQUEST['notnull'][$i])) ? ' checked="checked"' : '', ' /></td>'.PHP_EOL; + htmlspecialchars($_REQUEST['length'][$i]), '" /></td>' . PHP_EOL; + echo "\t\t<td><input type=\"checkbox\" name=\"notnull[{$i}]\"", (isset($_REQUEST['notnull'][$i])) ? ' checked="checked"' : '', ' /></td>' . PHP_EOL; echo "\t\t<td style=\"text-align: center\"><input type=\"checkbox\" name=\"uniquekey[{$i}]\"" - .(isset($_REQUEST['uniquekey'][$i]) ? ' checked="checked"' : '').' /></td>'.PHP_EOL; + . (isset($_REQUEST['uniquekey'][$i]) ? ' checked="checked"' : '') . ' /></td>' . PHP_EOL; echo "\t\t<td style=\"text-align: center\"><input type=\"checkbox\" name=\"primarykey[{$i}]\" " - .(isset($_REQUEST['primarykey'][$i]) ? ' checked="checked"' : '') - .' /></td>'.PHP_EOL; + . (isset($_REQUEST['primarykey'][$i]) ? ' checked="checked"' : '') + . ' /></td>' . PHP_EOL; echo "\t\t<td><input name=\"default[{$i}]\" size=\"20\" value=\"", - htmlspecialchars($_REQUEST['default'][$i]), '" /></td>'.PHP_EOL; + htmlspecialchars($_REQUEST['default'][$i]), '" /></td>' . PHP_EOL; echo "\t\t<td><input name=\"colcomment[{$i}]\" size=\"40\" value=\"", htmlspecialchars($_REQUEST['colcomment'][$i]), "\" /> <script type=\"text/javascript\">checkLengths(document.getElementById('types{$i}').value,{$i});</script> - </td>\n\t</tr>".PHP_EOL; + </td>\n\t</tr>" . PHP_EOL; } - echo '</table>'.PHP_EOL; - echo '<p><input type="hidden" name="action" value="create" />'.PHP_EOL; - echo '<input type="hidden" name="stage" value="3" />'.PHP_EOL; + echo '</table>' . PHP_EOL; + echo '<p><input type="hidden" name="action" value="create" />' . PHP_EOL; + echo '<input type="hidden" name="stage" value="3" />' . PHP_EOL; echo $this->misc->form; - echo '<input type="hidden" name="name" value="', htmlspecialchars($_REQUEST['name']), '" />'.PHP_EOL; - echo '<input type="hidden" name="fields" value="', htmlspecialchars($_REQUEST['fields']), '" />'.PHP_EOL; + echo '<input type="hidden" name="name" value="', htmlspecialchars($_REQUEST['name']), '" />' . PHP_EOL; + echo '<input type="hidden" name="fields" value="', htmlspecialchars($_REQUEST['fields']), '" />' . PHP_EOL; if (isset($_REQUEST['withoutoids'])) { - echo '<input type="hidden" name="withoutoids" value="true" />'.PHP_EOL; + echo '<input type="hidden" name="withoutoids" value="true" />' . PHP_EOL; } - echo '<input type="hidden" name="tblcomment" value="', htmlspecialchars($_REQUEST['tblcomment']), '" />'.PHP_EOL; + echo '<input type="hidden" name="tblcomment" value="', htmlspecialchars($_REQUEST['tblcomment']), '" />' . PHP_EOL; if (isset($_REQUEST['spcname'])) { - echo '<input type="hidden" name="spcname" value="', htmlspecialchars($_REQUEST['spcname']), '" />'.PHP_EOL; + echo '<input type="hidden" name="spcname" value="', htmlspecialchars($_REQUEST['spcname']), '" />' . PHP_EOL; } - echo "<input type=\"submit\" value=\"{$this->lang['strcreate']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>".PHP_EOL; - echo '</form>'.PHP_EOL; + echo "<input type=\"submit\" value=\"{$this->lang['strcreate']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>" . PHP_EOL; + echo '</form>' . PHP_EOL; break; case 3: @@ -693,7 +693,7 @@ class TablesController extends BaseController break; default: - echo "<p>{$this->lang['strinvalidparam']}</p>".PHP_EOL; + echo "<p>{$this->lang['strinvalidparam']}</p>" . PHP_EOL; } } @@ -736,13 +736,13 @@ class TablesController extends BaseController unset($tbltmp); - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; - echo "<table>\n\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>".PHP_EOL; - echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>".PHP_EOL; - echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strcreatetablelikeparent']}</th>".PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; + echo "<table>\n\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>" . PHP_EOL; + echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>" . PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strcreatetablelikeparent']}</th>" . PHP_EOL; echo "\t\t<td class=\"data\">"; echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tables, 'like', true, $tblsel, false); - echo "</td>\n\t</tr>".PHP_EOL; + echo "</td>\n\t</tr>" . 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<tr>\n\t\t<th class=\"data left\">{$this->lang['strtablespace']}</th>".PHP_EOL; + echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strtablespace']}</th>" . PHP_EOL; echo "\t\t<td class=\"data\">"; echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tblsp, 'tablespace', true, $_REQUEST['tablespace'], false); - echo "</td>\n\t</tr>".PHP_EOL; + echo "</td>\n\t</tr>" . PHP_EOL; } } echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['stroptions']}</th>\n\t\t<td class=\"data\">"; @@ -772,14 +772,14 @@ class TablesController extends BaseController isset($_REQUEST['withindexes']) ? ' checked="checked"' : '', "/>{$this->lang['strcreatelikewithindexes']}</label>"; } - echo "</td>\n\t</tr>".PHP_EOL; + echo "</td>\n\t</tr>" . PHP_EOL; echo '</table>'; - echo '<input type="hidden" name="action" value="confcreatelike" />'.PHP_EOL; + echo '<input type="hidden" name="action" value="confcreatelike" />' . PHP_EOL; echo $this->misc->form; - echo "<p><input type=\"submit\" value=\"{$this->lang['strcreate']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>".PHP_EOL; - echo '</form>'.PHP_EOL; + echo "<p><input type=\"submit\" value=\"{$this->lang['strcreate']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>" . PHP_EOL; + echo '</form>' . 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 '<form action="'.\SUBFOLDER.'/src/views/display" method="post" id="selectform">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post" id="selectform">' . PHP_EOL; if ($attrs->recordCount() > 0) { // JavaScript for select all feature - echo '<script type="text/javascript">'.PHP_EOL; + echo '<script type="text/javascript">' . PHP_EOL; echo "//<![CDATA[\n"; echo " function selectAll() {\n"; echo " for (var i=0; i<document.getElementById('selectform').elements.length; i++) {\n"; @@ -842,10 +842,10 @@ class TablesController extends BaseController echo " if (e.name.indexOf('show') == 0) e.checked = document.getElementById('selectform').selectall.checked;\n"; echo " }\n"; echo " }\n"; - echo '//]]>'.PHP_EOL; - echo '</script>'.PHP_EOL; + echo '//]]>' . PHP_EOL; + echo '</script>' . PHP_EOL; - echo '<table>'.PHP_EOL; + echo '<table>' . PHP_EOL; // Output table header echo "<tr><th class=\"data\">{$this->lang['strshow']}</th><th class=\"data\">{$this->lang['strcolumn']}</th>"; @@ -866,42 +866,42 @@ class TablesController extends BaseController // Continue drawing row $id = (0 == ($i % 2) ? '1' : '2'); - echo "<tr class=\"data{$id}\">".PHP_EOL; + echo "<tr class=\"data{$id}\">" . PHP_EOL; echo '<td style="white-space:nowrap;">'; echo '<input type="checkbox" name="show[', htmlspecialchars($attrs->fields['attname']), ']"', isset($_REQUEST['show'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></td>'; echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>'; echo '<td style="white-space:nowrap;">', $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])), '</td>'; echo '<td style="white-space:nowrap;">'; - echo "<select name=\"ops[{$attrs->fields['attname']}]\">".PHP_EOL; + echo "<select name=\"ops[{$attrs->fields['attname']}]\">" . PHP_EOL; foreach (array_keys($data->selectOps) as $v) { echo '<option value="', htmlspecialchars($v), '"', ($_REQUEST['ops'][$attrs->fields['attname']] == $v) ? ' selected="selected"' : '', - '>', htmlspecialchars($v), '</option>'.PHP_EOL; + '>', htmlspecialchars($v), '</option>' . PHP_EOL; } - echo "</select>\n</td>".PHP_EOL; + echo "</select>\n</td>" . PHP_EOL; echo '<td style="white-space:nowrap;">', $data->printField( "values[{$attrs->fields['attname']}]", $_REQUEST['values'][$attrs->fields['attname']], $attrs->fields['type'] ), '</td>'; - echo '</tr>'.PHP_EOL; + echo '</tr>' . PHP_EOL; ++$i; $attrs->moveNext(); } // Select all checkbox echo "<tr><td colspan=\"5\"><input type=\"checkbox\" id=\"selectall\" name=\"selectall\" accesskey=\"a\" onclick=\"javascript:selectAll()\" /><label for=\"selectall\">{$this->lang['strselectallfields']}</label></td>"; - echo '</tr></table>'.PHP_EOL; + echo '</tr></table>' . PHP_EOL; } else { - echo "<p>{$this->lang['strinvalidparam']}</p>".PHP_EOL; + echo "<p>{$this->lang['strinvalidparam']}</p>" . PHP_EOL; } - echo '<p><input type="hidden" name="action" value="selectrows" />'.PHP_EOL; - echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'.PHP_EOL; - echo '<input type="hidden" name="subject" value="table" />'.PHP_EOL; + echo '<p><input type="hidden" name="action" value="selectrows" />' . PHP_EOL; + echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . PHP_EOL; + echo '<input type="hidden" name="subject" value="table" />' . PHP_EOL; echo $this->misc->form; - echo "<input type=\"submit\" name=\"select\" accesskey=\"r\" value=\"{$this->lang['strselect']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>".PHP_EOL; - echo '</form>'.PHP_EOL; + echo "<input type=\"submit\" name=\"select\" accesskey=\"r\" value=\"{$this->lang['strselect']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>" . PHP_EOL; + echo '</form>' . PHP_EOL; return; } @@ -963,9 +963,9 @@ class TablesController extends BaseController $this->coalesceArr($_REQUEST, 'nulls', []); $this->coalesceArr($_REQUEST, 'format', []); - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post" id="ac_form">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post" id="ac_form">' . PHP_EOL; if ($attrs->recordCount() > 0) { - echo '<table>'.PHP_EOL; + echo '<table>' . PHP_EOL; // Output table header echo "<tr><th class=\"data\">{$this->lang['strcolumn']}</th><th class=\"data\">{$this->lang['strtype']}</th>"; @@ -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 "<tr class=\"data{$id}\">".PHP_EOL; + echo "<tr class=\"data{$id}\">" . PHP_EOL; echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>'; - echo '<td style="white-space:nowrap;">'.PHP_EOL; - echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])); + echo '<td style="white-space:nowrap;">' . PHP_EOL; + echo $this->misc->printVal( + $data->formatType( + $attrs->fields['type'], + $attrs->fields['atttypmod'] + ) + ); echo "<input type=\"hidden\" name=\"types[{$attrs->fields['attnum']}]\" value=\"", htmlspecialchars($attrs->fields['type']), '" /></td>'; - echo '<td style="white-space:nowrap;">'.PHP_EOL; - echo "<select name=\"format[{$attrs->fields['attnum']}]\">".PHP_EOL; - echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attnum']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>".PHP_EOL; - echo '<option value="EXPRESSION"', ($_REQUEST['format'][$attrs->fields['attnum']] == 'EXPRESSION') ? ' selected="selected"' : '', ">{$this->lang['strexpression']}</option>".PHP_EOL; - echo "</select>\n</td>".PHP_EOL; + echo '<td style="white-space:nowrap;">' . PHP_EOL; + + echo "<select name=\"format[{$attrs->fields['attnum']}]\">" . PHP_EOL; + echo sprintf( + '<option value="VALUE" %s >%s</option> %s', + ($requested_format == 'VALUE') ? ' selected="selected" ' : '', + $this->lang['strvalue'], + PHP_EOL + ); + echo sprintf( + '<option value="EXPRESSION" %s >%s</option> %s', + ($requested_format == 'EXPRESSION') ? ' selected="selected" ' : '', + $this->lang['strexpression'], + PHP_EOL + ); + + echo "</select>\n</td>" . PHP_EOL; echo '<td style="white-space:nowrap;">'; - // 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 "<label><span><input type=\"checkbox\" class=\"nullcheckbox\" name=\"nulls[{$attrs->fields['attnum']}]\""; - echo isset($_REQUEST['nulls'][$attrs->fields['attnum']]) ? ' checked="checked"' : ''; - echo ' /></span></label>'; + + echo '<label><span>'; + echo sprintf( + '<input type="checkbox" class="nullcheckbox" name="nulls[%s]" %s />', + $attrs->fields['attnum'], + ' checked="checked"' + ); + echo '</span></label>'; + } echo '</td>'; @@ -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 '</td>'.PHP_EOL; - echo '</tr>'.PHP_EOL; + echo '</td>' . PHP_EOL; + echo '</tr>' . PHP_EOL; ++$i; $attrs->moveNext(); } - echo '</table>'.PHP_EOL; + echo '</table>' . PHP_EOL; if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; } - echo '<input type="hidden" name="action" value="insertrow" />'.PHP_EOL; - echo '<input type="hidden" name="fields" value="', htmlentities(serialize($fields), ENT_QUOTES, 'UTF-8'), '" />'.PHP_EOL; - echo '<input type="hidden" name="protection_counter" value="'.$_SESSION['counter'].'" />'.PHP_EOL; - echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'.PHP_EOL; - echo "<p><input type=\"submit\" name=\"insert\" value=\"{$this->lang['strinsert']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"insertandrepeat\" accesskey=\"r\" value=\"{$this->lang['strinsertandrepeat']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo '<input type="hidden" name="action" value="insertrow" />' . PHP_EOL; + echo '<input type="hidden" name="fields" value="', htmlentities(serialize($fields), ENT_QUOTES, 'UTF-8'), '" />' . PHP_EOL; + echo '<input type="hidden" name="protection_counter" value="' . $_SESSION['counter'] . '" />' . PHP_EOL; + echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . PHP_EOL; + echo "<p><input type=\"submit\" name=\"insert\" value=\"{$this->lang['strinsert']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"insertandrepeat\" accesskey=\"r\" value=\"{$this->lang['strinsertandrepeat']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; 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>".PHP_EOL; + echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . PHP_EOL; } else { - echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>".PHP_EOL; + echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . PHP_EOL; } } - echo '</p>'.PHP_EOL; + echo '</p>' . PHP_EOL; } else { - echo "<p>{$this->lang['strnofieldsforinsert']}</p>".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<p>{$this->lang['strnofieldsforinsert']}</p>" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; } echo $this->misc->form; - echo '</form>'.PHP_EOL; - echo '<script src="'.\SUBFOLDER.'/assets/js/insert_or_edit_row.js" type="text/javascript"></script>'; + echo '</form>' . PHP_EOL; + echo '<script src="' . \SUBFOLDER . '/assets/js/insert_or_edit_row.js" type="text/javascript"></script>'; } /** @@ -1114,29 +1139,29 @@ class TablesController extends BaseController $this->printTrail('schema'); $this->printTitle($this->lang['strempty'], 'pg.table.empty'); - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); - echo '<p>'.sprintf($this->lang['strconfemptytable'], $this->misc->printVal($a['table'])); + echo '<p>' . sprintf($this->lang['strconfemptytable'], $this->misc->printVal($a['table'])); - echo '</p>'.PHP_EOL; + echo '</p>' . PHP_EOL; printf('<input type="hidden" name="table[]" value="%s" />', htmlspecialchars($a['table'])); } // END mutli empty } else { $this->printTrail('table'); $this->printTitle($this->lang['strempty'], 'pg.table.empty'); - echo '<p>', sprintf($this->lang['strconfemptytable'], $this->misc->printVal($_REQUEST['table'])), '</p>'.PHP_EOL; + echo '<p>', sprintf($this->lang['strconfemptytable'], $this->misc->printVal($_REQUEST['table'])), '</p>' . PHP_EOL; - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; - echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'.PHP_EOL; + echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . PHP_EOL; // END not mutli empty } echo "<input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label>"; - echo '<input type="hidden" name="action" value="empty" />'.PHP_EOL; + echo '<input type="hidden" name="action" value="empty" />' . PHP_EOL; echo $this->misc->form; - echo "<input type=\"submit\" name=\"empty\" value=\"{$this->lang['strempty']}\" /> <input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<input type=\"submit\" name=\"empty\" value=\"{$this->lang['strempty']}\" /> <input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; echo "</form>\n"; // END if confirm } else { // Do Empty @@ -1163,7 +1188,7 @@ class TablesController extends BaseController return $this->doDefault($msg); } - return $this->doDefault($sql.'<br>'.$this->lang['strtableemptiedbad']); + return $this->doDefault($sql . '<br>' . $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 '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); - echo '<p>', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($a['table'])), '</p>'.PHP_EOL; + echo '<p>', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($a['table'])), '</p>' . PHP_EOL; printf('<input type="hidden" name="table[]" value="%s" />', htmlspecialchars($a['table'])); } } else { $this->printTrail('table'); $this->printTitle($this->lang['strdrop'], 'pg.table.drop'); - echo '<p>', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($_REQUEST['table'])), '</p>'.PHP_EOL; + echo '<p>', sprintf($this->lang['strconfdroptable'], $this->misc->printVal($_REQUEST['table'])), '</p>' . PHP_EOL; - echo '<form action="'.\SUBFOLDER.'/src/views/tables" method="post">'.PHP_EOL; - echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'.PHP_EOL; + echo '<form action="' . \SUBFOLDER . '/src/views/tables" method="post">' . PHP_EOL; + echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . PHP_EOL; // END if multi drop } - echo '<input type="hidden" name="action" value="drop" />'.PHP_EOL; + echo '<input type="hidden" name="action" value="drop" />' . PHP_EOL; echo $this->misc->form; - echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label></p>".PHP_EOL; - echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />".PHP_EOL; - echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; + echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label></p>" . PHP_EOL; + echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />" . PHP_EOL; + echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . PHP_EOL; echo "</form>\n"; // END confirm } else { //If multi drop |