| Total Complexity | 152 |
| Total Lines | 1102 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like DisplayController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DisplayController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 14 | class DisplayController extends BaseController |
||
| 15 | { |
||
| 16 | use \PHPPgAdmin\Traits\InsertEditRowTrait; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Default method to render the controller according to the action parameter. |
||
| 20 | */ |
||
| 21 | public function render() |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Displays requested data. |
||
| 111 | * |
||
| 112 | * @param mixed $msg |
||
| 113 | */ |
||
| 114 | public function doBrowse($msg = '') |
||
| 115 | { |
||
| 116 | $this->misc = $this->misc; |
||
| 117 | $data = $this->misc->getDatabaseAccessor(); |
||
| 118 | |||
| 119 | // If current page is not set, default to first page |
||
| 120 | $page = $this->coalesceArr($_REQUEST, 'page', 1)['page']; |
||
| 121 | |||
| 122 | $save_history = !isset($_REQUEST['nohistory']); |
||
| 123 | |||
| 124 | $subject = $this->coalesceArr($_REQUEST, 'subject', 'table')['subject']; |
||
| 125 | |||
| 126 | $object = $this->coalesceArr($_REQUEST, $subject)[$subject]; |
||
| 127 | |||
| 128 | if ($subject === 'column' && $object && isset($_REQUEST['f_schema'], $_REQUEST['f_table'])) { |
||
| 129 | $f_schema = $_REQUEST['f_schema']; |
||
| 130 | $f_table = $_REQUEST['f_table']; |
||
| 131 | |||
| 132 | $_REQUEST['query'] = "SELECT \"{$object}\", |
||
| 133 | count(*) AS \"count\" |
||
| 134 | FROM \"{$f_schema}\".\"{$f_table}\" |
||
| 135 | GROUP BY \"{$object}\" ORDER BY \"{$object}\""; |
||
| 136 | } |
||
| 137 | |||
| 138 | //$object = $this->setIfIsset($object, $_REQUEST[$subject]); |
||
| 139 | |||
| 140 | $this->printTrail($subject); |
||
| 141 | |||
| 142 | $tabsPosition = 'browse'; |
||
| 143 | if ($subject === 'database') { |
||
| 144 | $tabsPosition = 'sql'; |
||
| 145 | } elseif ($subject === 'column') { |
||
| 146 | $tabsPosition = 'colproperties'; |
||
| 147 | } |
||
| 148 | |||
| 149 | $this->printTabs($subject, $tabsPosition); |
||
| 150 | |||
| 151 | list($query, $title, $type) = $this->getQueryTitleAndType($data); |
||
| 152 | $this->printTitle($title); |
||
| 153 | |||
| 154 | //$this->prtrace($subject, $object, $query, $_SESSION['sqlquery']); |
||
| 155 | |||
| 156 | $this->printMsg($msg); |
||
| 157 | |||
| 158 | // If 'sortkey' is not set, default to '' |
||
| 159 | $sortkey = $this->coalesceArr($_REQUEST, 'sortkey', '')['sortkey']; |
||
| 160 | |||
| 161 | // If 'sortdir' is not set, default to '' |
||
| 162 | $sortdir = $this->coalesceArr($_REQUEST, 'sortdir', '')['sortdir']; |
||
| 163 | |||
| 164 | // If 'strings' is not set, default to collapsed |
||
| 165 | $strings = $this->coalesceArr($_REQUEST, 'strings', 'collapsed')['strings']; |
||
| 166 | |||
| 167 | $this->coalesceArr($_REQUEST, 'schema')['schema']; |
||
| 168 | $search_path = $this->coalesceArr($_REQUEST, 'search_path')['search_path']; |
||
| 169 | |||
| 170 | // Set the schema search path |
||
| 171 | if (isset($search_path) && (0 != $data->setSearchPath(array_map('trim', explode(',', $search_path))))) { |
||
| 172 | return; |
||
| 173 | } |
||
| 174 | |||
| 175 | try { |
||
| 176 | // Retrieve page from query. $max_pages is returned by reference. |
||
| 177 | $resultset = $data->browseQuery( |
||
| 178 | $type, |
||
| 179 | $object, |
||
| 180 | $query, |
||
| 181 | $sortkey, |
||
| 182 | $sortdir, |
||
| 183 | $page, |
||
| 184 | $this->conf['max_rows'], |
||
| 185 | $max_pages |
||
| 186 | ); |
||
| 187 | } catch (\PHPPgAdmin\ADOdbException $e) { |
||
| 188 | return $this->halt($e->getMessage()); |
||
| 189 | } |
||
| 190 | |||
| 191 | // Build strings for GETs in array |
||
| 192 | $_gets = [ |
||
| 193 | 'server' => $_REQUEST['server'], |
||
| 194 | 'database' => $_REQUEST['database'], |
||
| 195 | ]; |
||
| 196 | |||
| 197 | $this->coalesceArr($_REQUEST, 'query'); |
||
| 198 | $this->coalesceArr($_REQUEST, 'count'); |
||
| 199 | $this->coalesceArr($_REQUEST, 'return'); |
||
| 200 | $this->coalesceArr($_REQUEST, 'table'); |
||
| 201 | $this->coalesceArr($_REQUEST, 'nohistory'); |
||
| 202 | |||
| 203 | $this->setIfIsset($_gets['schema'], $_REQUEST['schema'], null, false); |
||
| 204 | $this->setIfIsset($_gets[$subject], $object, null, false); |
||
| 205 | $this->setIfIsset($_gets['subject'], $subject, null, false); |
||
| 206 | $this->setIfIsset($_gets['query'], $_REQUEST['query'], null, false); |
||
| 207 | $this->setIfIsset($_gets['count'], $_REQUEST['count'], null, false); |
||
| 208 | $this->setIfIsset($_gets['return'], $_REQUEST['return'], null, false); |
||
| 209 | $this->setIfIsset($_gets['search_path'], $_REQUEST['search_path'], null, false); |
||
| 210 | $this->setIfIsset($_gets['table'], $_REQUEST['table'], null, false); |
||
| 211 | $this->setIfIsset($_gets['nohistory'], $_REQUEST['nohistory'], null, false); |
||
| 212 | $_gets['sortkey'] = $sortkey; |
||
| 213 | $_gets['sortdir'] = $sortdir; |
||
| 214 | $_gets['strings'] = $strings; |
||
| 215 | |||
| 216 | if ($save_history && is_object($resultset) && ('QUERY' == $type)) { |
||
| 217 | //{ |
||
| 218 | $this->misc->saveScriptHistory($_REQUEST['query']); |
||
| 219 | } |
||
| 220 | |||
| 221 | $query = $query ? $query : sprintf('SELECT * FROM %s.%s', $_REQUEST['schema'], $object); |
||
| 222 | |||
| 223 | //$query = isset($_REQUEST['query'])? $_REQUEST['query'] : "select * from {$_REQUEST['schema']}.{$_REQUEST['table']};"; |
||
| 224 | //$this->prtrace($query); |
||
| 225 | |||
| 226 | //die(htmlspecialchars($query)); |
||
| 227 | |||
| 228 | echo '<form method="post" id="sqlform" action="'.$_SERVER['REQUEST_URI'].'">'; |
||
| 229 | echo $this->misc->form; |
||
| 230 | if ($object) { |
||
| 231 | echo '<input type="hidden" name="'.$subject.'" value="', htmlspecialchars($object), '" />'."\n"; |
||
| 232 | } |
||
| 233 | echo '<textarea width="90%" name="query" id="query" rows="5" cols="100" resizable="true">'; |
||
| 234 | echo htmlspecialchars($query); |
||
| 235 | echo '</textarea><br><input type="submit"/>'; |
||
| 236 | |||
| 237 | echo '</form>'; |
||
| 238 | |||
| 239 | $this->printResultsTable($resultset, $page, $max_pages, $_gets, $object); |
||
| 240 | // Navigation links |
||
| 241 | |||
| 242 | $navlinks = $this->getBrowseNavLinks($type, $_gets, $page, $subject, $object, $resultset); |
||
| 243 | $this->printNavLinks($navlinks, 'display-browse', get_defined_vars()); |
||
| 244 | } |
||
| 245 | |||
| 246 | public function getQueryTitleAndType($data) |
||
| 247 | { |
||
| 248 | $fkey = $this->coalesceArr($_REQUEST, 'fkey')['fkey']; |
||
| 249 | |||
| 250 | $query = $this->coalesceArr($_REQUEST, 'query')['query']; |
||
| 251 | // This code is used when browsing FK in pure-xHTML (without js) |
||
| 252 | if ($fkey) { |
||
| 253 | $ops = []; |
||
| 254 | foreach (array_keys($fkey) as $x) { |
||
| 255 | $ops[$x] = '='; |
||
| 256 | } |
||
| 257 | $query = $data->getSelectSQL($_REQUEST['table'], [], $fkey, $ops); |
||
| 258 | $_REQUEST['query'] = $query; |
||
| 259 | } |
||
| 260 | |||
| 261 | $title = 'strqueryresults'; |
||
| 262 | $type = 'QUERY'; |
||
| 263 | |||
| 264 | if ($object && $query) { |
||
|
|
|||
| 265 | $_SESSION['sqlquery'] = $query; |
||
| 266 | $title = 'strselect'; |
||
| 267 | $type = 'SELECT'; |
||
| 268 | } elseif ($object) { |
||
| 269 | $title = 'strselect'; |
||
| 270 | $type = 'TABLE'; |
||
| 271 | } elseif (isset($_SESSION['sqlquery'])) { |
||
| 272 | $query = $_SESSION['sqlquery']; |
||
| 273 | } |
||
| 274 | |||
| 275 | return [$query, $title, $type]; |
||
| 276 | } |
||
| 277 | |||
| 278 | public function getBrowseNavLinks($type, $_gets, $page, $subject, $object, $resultset) |
||
| 430 | } |
||
| 431 | |||
| 432 | public function printResultsTable($resultset, $page, $max_pages, $_gets, $object) |
||
| 595 | } |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Print table header cells. |
||
| 599 | * |
||
| 600 | * @param \PHPPgAdmin\ADORecordSet $resultset set of results from getRow operation |
||
| 601 | * @param array|bool $args - associative array for sort link parameters, or false if there isn't any |
||
| 602 | * @param bool $withOid either to display OIDs or not |
||
| 603 | */ |
||
| 604 | public function printTableHeaderCells(&$resultset, $args, $withOid) |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Print table rows. |
||
| 644 | * |
||
| 645 | * @param \PHPPgAdmin\ADORecordSet $resultset The resultset |
||
| 646 | * @param array $fkey_information The fkey information |
||
| 647 | * @param bool $withOid either to display OIDs or not |
||
| 648 | */ |
||
| 649 | public function printTableRowCells(&$resultset, &$fkey_information, $withOid) |
||
| 692 | } |
||
| 693 | } |
||
| 694 | } |
||
| 695 | |||
| 696 | private function _unserializeIfNotArray($the_array, $key) |
||
| 697 | { |
||
| 698 | if (!isset($the_array[$key])) { |
||
| 699 | return []; |
||
| 700 | } |
||
| 701 | if (is_array($the_array[$key])) { |
||
| 702 | return $the_array[$key]; |
||
| 703 | } |
||
| 704 | |||
| 705 | return unserialize(urldecode($the_array[$key])); |
||
| 706 | } |
||
| 707 | |||
| 708 | /** |
||
| 709 | * Show form to edit row. |
||
| 710 | * |
||
| 711 | * @param string $msg message to display on top of the form or after performing edition |
||
| 712 | */ |
||
| 713 | public function formEditRow($msg = '') |
||
| 714 | { |
||
| 715 | $data = $this->misc->getDatabaseAccessor(); |
||
| 716 | |||
| 717 | $key = $this->_unserializeIfNotArray($_REQUEST, 'key'); |
||
| 718 | |||
| 719 | $this->printTrail($_REQUEST['subject']); |
||
| 720 | $this->printTitle($this->lang['streditrow']); |
||
| 721 | $this->printMsg($msg); |
||
| 722 | |||
| 723 | $attrs = $data->getTableAttributes($_REQUEST['table']); |
||
| 724 | $resultset = $data->browseRow($_REQUEST['table'], $key); |
||
| 725 | |||
| 726 | $fksprops = $this->_getFKProps(); |
||
| 727 | |||
| 728 | echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post" id="ac_form">'."\n"; |
||
| 729 | |||
| 730 | $elements = 0; |
||
| 731 | $error = true; |
||
| 732 | if (1 == $resultset->recordCount() && $attrs->recordCount() > 0) { |
||
| 733 | echo '<table>'."\n"; |
||
| 734 | |||
| 735 | // Output table header |
||
| 736 | echo "<tr><th class=\"data\">{$this->lang['strcolumn']}</th><th class=\"data\">{$this->lang['strtype']}</th>"; |
||
| 737 | echo "<th class=\"data\">{$this->lang['strformat']}</th>"."\n"; |
||
| 738 | echo "<th class=\"data\">{$this->lang['strnull']}</th><th class=\"data\">{$this->lang['strvalue']}</th></tr>"; |
||
| 739 | |||
| 740 | $i = 0; |
||
| 741 | while (!$attrs->EOF) { |
||
| 742 | $attrs->fields['attnotnull'] = $data->phpBool($attrs->fields['attnotnull']); |
||
| 743 | $id = (0 == ($i % 2) ? '1' : '2'); |
||
| 744 | |||
| 745 | // Initialise variables |
||
| 746 | if (!isset($_REQUEST['format'][$attrs->fields['attname']])) { |
||
| 747 | $_REQUEST['format'][$attrs->fields['attname']] = 'VALUE'; |
||
| 748 | } |
||
| 749 | |||
| 750 | echo "<tr class=\"data{$id}\">"."\n"; |
||
| 751 | echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>'; |
||
| 752 | echo '<td style="white-space:nowrap;">'."\n"; |
||
| 753 | echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])); |
||
| 754 | echo '<input type="hidden" name="types[', htmlspecialchars($attrs->fields['attname']), ']" value="', |
||
| 755 | htmlspecialchars($attrs->fields['type']), '" /></td>'; |
||
| 756 | ++$elements; |
||
| 757 | echo '<td style="white-space:nowrap;">'."\n"; |
||
| 758 | echo '<select name="format['.htmlspecialchars($attrs->fields['attname']), ']">'."\n"; |
||
| 759 | echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>"."\n"; |
||
| 760 | $selected = ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : ''; |
||
| 761 | echo '<option value="EXPRESSION"'.$selected.">{$this->lang['strexpression']}</option>"."\n"; |
||
| 762 | echo "</select>\n</td>"."\n"; |
||
| 763 | ++$elements; |
||
| 764 | echo '<td style="white-space:nowrap;">'; |
||
| 765 | // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS) |
||
| 766 | if (!$attrs->fields['attnotnull']) { |
||
| 767 | // Set initial null values |
||
| 768 | if ('confeditrow' == $_REQUEST['action'] && null === $resultset->fields[$attrs->fields['attname']]) { |
||
| 769 | $_REQUEST['nulls'][$attrs->fields['attname']] = 'on'; |
||
| 770 | } |
||
| 771 | echo "<label><span><input type=\"checkbox\" class=\"nullcheckbox\" name=\"nulls[{$attrs->fields['attname']}]\"", |
||
| 772 | isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>'."\n"; |
||
| 773 | ++$elements; |
||
| 774 | } else { |
||
| 775 | echo ' </td>'; |
||
| 776 | } |
||
| 777 | |||
| 778 | echo "<td id=\"row_att_{$attrs->fields['attnum']}\" style=\"white-space:nowrap;\">"; |
||
| 779 | |||
| 780 | $extras = []; |
||
| 781 | |||
| 782 | // If the column allows nulls, then we put a JavaScript action on the data field to unset the |
||
| 783 | // NULL checkbox as soon as anything is entered in the field. We use the $elements variable to |
||
| 784 | // keep track of which element offset we're up to. We can't refer to the null checkbox by name |
||
| 785 | // as it contains '[' and ']' characters. |
||
| 786 | if (!$attrs->fields['attnotnull']) { |
||
| 787 | $extras['class'] = 'insert_row_input'; |
||
| 788 | } |
||
| 789 | |||
| 790 | if ((false !== $fksprops) && isset($fksprops['byfield'][$attrs->fields['attnum']])) { |
||
| 791 | $extras['id'] = "attr_{$attrs->fields['attnum']}"; |
||
| 792 | $extras['autocomplete'] = 'off'; |
||
| 793 | } |
||
| 794 | |||
| 795 | echo $data->printField("values[{$attrs->fields['attname']}]", $resultset->fields[$attrs->fields['attname']], $attrs->fields['type'], $extras); |
||
| 796 | |||
| 797 | echo '</td>'; |
||
| 798 | ++$elements; |
||
| 799 | echo '</tr>'."\n"; |
||
| 800 | ++$i; |
||
| 801 | $attrs->moveNext(); |
||
| 802 | } |
||
| 803 | echo '</table>'."\n"; |
||
| 804 | |||
| 805 | $error = false; |
||
| 806 | } elseif (1 != $resultset->recordCount()) { |
||
| 807 | echo "<p>{$this->lang['strrownotunique']}</p>"."\n"; |
||
| 808 | } else { |
||
| 809 | echo "<p>{$this->lang['strinvalidparam']}</p>"."\n"; |
||
| 810 | } |
||
| 811 | |||
| 812 | echo '<input type="hidden" name="action" value="editrow" />'."\n"; |
||
| 813 | echo $this->misc->form; |
||
| 814 | echo isset($_REQUEST['table']) ? sprintf('<input type="hidden" name="table" value="%s" />%s', htmlspecialchars($_REQUEST['table']), "\n") : ''; |
||
| 815 | |||
| 816 | echo isset($_REQUEST['subject']) ? sprintf('<input type="hidden" name="subject" value="%s" />%s', htmlspecialchars($_REQUEST['subject']), "\n") : ''; |
||
| 817 | |||
| 818 | echo isset($_REQUEST['query']) ? sprintf('<input type="hidden" name="query" value="%s" />%s', htmlspecialchars($_REQUEST['query']), "\n") : ''; |
||
| 819 | |||
| 820 | echo isset($_REQUEST['count']) ? sprintf('<input type="hidden" name="count" value="%s" />%s', htmlspecialchars($_REQUEST['count']), "\n") : ''; |
||
| 821 | |||
| 822 | echo isset($_REQUEST['return']) ? sprintf('<input type="hidden" name="return" value="%s" />%s', htmlspecialchars($_REQUEST['return']), "\n") : ''; |
||
| 823 | |||
| 824 | echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n"; |
||
| 825 | echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n"; |
||
| 826 | echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n"; |
||
| 827 | echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n"; |
||
| 828 | echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />'."\n"; |
||
| 829 | echo '<p>'; |
||
| 830 | if (!$error) { |
||
| 831 | echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />"."\n"; |
||
| 832 | } |
||
| 833 | |||
| 834 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n"; |
||
| 835 | |||
| 836 | if (false !== $fksprops) { |
||
| 837 | $autocomplete_string = "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"; |
||
| 838 | if ('default off' != $this->conf['autocomplete']) { |
||
| 839 | $autocomplete_string = "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"; |
||
| 840 | } |
||
| 841 | echo $autocomplete_string."\n"; |
||
| 842 | } |
||
| 843 | |||
| 844 | echo '</p>'."\n"; |
||
| 845 | echo '</form>'."\n"; |
||
| 846 | echo '<script src="'.\SUBFOLDER.'/assets/js/insert_or_edit_row.js" type="text/javascript"></script>'; |
||
| 847 | } |
||
| 848 | |||
| 849 | /** |
||
| 850 | * Performs actual edition of row. |
||
| 851 | */ |
||
| 852 | public function doEditRow() |
||
| 853 | { |
||
| 854 | $data = $this->misc->getDatabaseAccessor(); |
||
| 855 | |||
| 856 | $key = $this->_unserializeIfNotArray($_REQUEST, 'key'); |
||
| 857 | |||
| 858 | $this->coalesceArr($_POST, 'values', []); |
||
| 859 | |||
| 860 | $this->coalesceArr($_POST, 'nulls', []); |
||
| 861 | |||
| 862 | $status = $data->editRow( |
||
| 863 | $_POST['table'], |
||
| 864 | $_POST['values'], |
||
| 865 | $_POST['nulls'], |
||
| 866 | $_POST['format'], |
||
| 867 | $_POST['types'], |
||
| 868 | $key |
||
| 869 | ); |
||
| 870 | if (0 == $status) { |
||
| 871 | return $this->doBrowse($this->lang['strrowupdated']); |
||
| 872 | } |
||
| 873 | if ($status == -2) { |
||
| 874 | return $this->formEditRow($this->lang['strrownotunique']); |
||
| 875 | } |
||
| 876 | |||
| 877 | return $this->formEditRow($this->lang['strrowupdatedbad']); |
||
| 878 | } |
||
| 879 | |||
| 880 | /** |
||
| 881 | * Show confirmation of drop and perform actual drop. |
||
| 882 | * |
||
| 883 | * @param mixed $confirm |
||
| 884 | */ |
||
| 885 | public function doDelRow($confirm) |
||
| 886 | { |
||
| 887 | $data = $this->misc->getDatabaseAccessor(); |
||
| 888 | |||
| 889 | if ($confirm) { |
||
| 890 | $this->printTrail($_REQUEST['subject']); |
||
| 891 | $this->printTitle($this->lang['strdeleterow']); |
||
| 892 | |||
| 893 | $resultset = $data->browseRow($_REQUEST['table'], $_REQUEST['key']); |
||
| 894 | |||
| 895 | echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post">'."\n"; |
||
| 896 | echo $this->misc->form; |
||
| 897 | |||
| 898 | if (1 == $resultset->recordCount()) { |
||
| 899 | echo "<p>{$this->lang['strconfdeleterow']}</p>"."\n"; |
||
| 900 | |||
| 901 | $fkinfo = []; |
||
| 902 | echo '<table><tr>'; |
||
| 903 | $this->printTableHeaderCells($resultset, false, true); |
||
| 904 | echo '</tr>'; |
||
| 905 | echo '<tr class="data1">'."\n"; |
||
| 906 | $this->printTableRowCells($resultset, $fkinfo, true); |
||
| 907 | echo '</tr>'."\n"; |
||
| 908 | echo '</table>'."\n"; |
||
| 909 | echo '<br />'."\n"; |
||
| 910 | |||
| 911 | echo '<input type="hidden" name="action" value="delrow" />'."\n"; |
||
| 912 | echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />"."\n"; |
||
| 913 | echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />"."\n"; |
||
| 914 | } elseif (1 != $resultset->recordCount()) { |
||
| 915 | echo "<p>{$this->lang['strrownotunique']}</p>"."\n"; |
||
| 916 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n"; |
||
| 917 | } else { |
||
| 918 | echo "<p>{$this->lang['strinvalidparam']}</p>"."\n"; |
||
| 919 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n"; |
||
| 920 | } |
||
| 921 | if (isset($_REQUEST['table'])) { |
||
| 922 | echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'."\n"; |
||
| 923 | } |
||
| 924 | |||
| 925 | if (isset($_REQUEST['subject'])) { |
||
| 926 | echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'."\n"; |
||
| 927 | } |
||
| 928 | |||
| 929 | if (isset($_REQUEST['query'])) { |
||
| 930 | echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'."\n"; |
||
| 931 | } |
||
| 932 | |||
| 933 | if (isset($_REQUEST['count'])) { |
||
| 934 | echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'."\n"; |
||
| 935 | } |
||
| 936 | |||
| 937 | if (isset($_REQUEST['return'])) { |
||
| 938 | echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'."\n"; |
||
| 939 | } |
||
| 940 | |||
| 941 | echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n"; |
||
| 942 | echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n"; |
||
| 943 | echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n"; |
||
| 944 | echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n"; |
||
| 945 | echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />'."\n"; |
||
| 946 | echo '</form>'."\n"; |
||
| 947 | } else { |
||
| 948 | $status = $data->deleteRow($_POST['table'], unserialize(urldecode($_POST['key']))); |
||
| 949 | if (0 == $status) { |
||
| 950 | $this->doBrowse($this->lang['strrowdeleted']); |
||
| 951 | } elseif ($status == -2) { |
||
| 952 | $this->doBrowse($this->lang['strrownotunique']); |
||
| 953 | } else { |
||
| 954 | $this->doBrowse($this->lang['strrowdeletedbad']); |
||
| 955 | } |
||
| 956 | } |
||
| 957 | } |
||
| 958 | |||
| 959 | /** |
||
| 960 | * Build & return the FK information data structure |
||
| 961 | * used when deciding if a field should have a FK link or not. |
||
| 962 | * |
||
| 963 | * @return array associative array describing the FK |
||
| 964 | */ |
||
| 965 | public function &getFKInfo() |
||
| 1003 | } |
||
| 1004 | |||
| 1005 | // Print the FK row, used in ajax requests |
||
| 1006 | public function doBrowseFK() |
||
| 1051 | } |
||
| 1052 | |||
| 1053 | private function _getMinMaxPages($page, $pages) |
||
| 1073 | } |
||
| 1074 | |||
| 1075 | /** |
||
| 1076 | * Do multi-page navigation. Displays the prev, next and page options. |
||
| 1077 | * |
||
| 1078 | * @param int $page - the page currently viewed |
||
| 1079 | * @param int $pages - the maximum number of pages |
||
| 1080 | * @param array $gets - the parameters to include in the link to the wanted page |
||
| 1081 | * @param int $max_width - the number of pages to make available at any one time (default = 20) |
||
| 1082 | * |
||
| 1083 | * @return string the pagination links |
||
| 1084 | */ |
||
| 1085 | private function _printPages($page, $pages, $gets, $max_width = 20) |
||
| 1116 | } |
||
| 1117 | } |
||
| 1118 |