| Total Complexity | 74 |
| Total Lines | 846 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like SequencesController 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 SequencesController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 14 | class SequencesController extends BaseController |
||
| 15 | { |
||
| 16 | public $controller_title = 'strsequences'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Default method to render the controller according to the action parameter. |
||
| 20 | */ |
||
| 21 | public function render() |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Display list of all sequences in the database/schema. |
||
| 110 | * |
||
| 111 | * @param mixed $msg |
||
| 112 | */ |
||
| 113 | public function doDefault($msg = ''): void |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Generate XML for the browser tree. |
||
| 209 | */ |
||
| 210 | public function doTree() |
||
| 211 | { |
||
| 212 | $data = $this->misc->getDatabaseAccessor(); |
||
| 213 | |||
| 214 | $sequences = $data->getSequences(); |
||
| 215 | $reqvars = $this->misc->getRequestVars('sequence'); |
||
| 216 | |||
| 217 | $attrs = [ |
||
| 218 | 'text' => Decorator::field('seqname'), |
||
| 219 | 'icon' => 'Sequence', |
||
| 220 | 'toolTip' => Decorator::field('seqcomment'), |
||
| 221 | 'iconAction' => Decorator::url('sequences', $reqvars, ['action' => 'properties', 'sequence' => Decorator::field('seqname')]), |
||
| 222 | 'action' => Decorator::url('sequences', $reqvars, ['action' => 'properties', 'sequence' => Decorator::field('seqname')]), |
||
| 223 | ]; |
||
| 224 | |||
| 225 | return $this->printTree($sequences, $attrs, 'sequences'); |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Display the properties of a sequence. |
||
| 230 | * |
||
| 231 | * @param mixed $msg |
||
| 232 | */ |
||
| 233 | public function doProperties($msg = ''): void |
||
| 234 | { |
||
| 235 | $data = $this->misc->getDatabaseAccessor(); |
||
| 236 | $this->printTrail('sequence'); |
||
| 237 | $this->printTitle($this->lang['strproperties'], 'pg.sequence'); |
||
| 238 | $this->printMsg($msg); |
||
| 239 | |||
| 240 | // Fetch the sequence information |
||
| 241 | $sequence = $data->getSequence($_REQUEST['sequence']); |
||
| 242 | |||
| 243 | if (\is_object($sequence) && 0 < $sequence->recordCount()) { |
||
| 244 | $sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']); |
||
| 245 | $sequence->fields['is_called'] = $data->phpBool($sequence->fields['is_called']); |
||
| 246 | |||
| 247 | // Show comment if any |
||
| 248 | if (null !== $sequence->fields['seqcomment']) { |
||
| 249 | echo '<p class="comment">', $this->misc->printVal($sequence->fields['seqcomment']), '</p>' . \PHP_EOL; |
||
| 250 | } |
||
| 251 | |||
| 252 | echo '<table border="0">'; |
||
| 253 | echo "<tr><th class=\"data\">{$this->lang['strname']}</th>"; |
||
| 254 | |||
| 255 | if ($data->hasAlterSequenceStart()) { |
||
| 256 | echo "<th class=\"data\">{$this->lang['strstartvalue']}</th>"; |
||
| 257 | } |
||
| 258 | echo "<th class=\"data\">{$this->lang['strlastvalue']}</th>"; |
||
| 259 | echo "<th class=\"data\">{$this->lang['strincrementby']}</th>"; |
||
| 260 | echo "<th class=\"data\">{$this->lang['strmaxvalue']}</th>"; |
||
| 261 | echo "<th class=\"data\">{$this->lang['strminvalue']}</th>"; |
||
| 262 | echo "<th class=\"data\">{$this->lang['strcachevalue']}</th>"; |
||
| 263 | echo "<th class=\"data\">{$this->lang['strlogcount']}</th>"; |
||
| 264 | echo "<th class=\"data\">{$this->lang['strcancycle']}</th>"; |
||
| 265 | echo "<th class=\"data\">{$this->lang['striscalled']}</th></tr>"; |
||
| 266 | echo '<tr>'; |
||
| 267 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['seqname']), '</td>'; |
||
| 268 | |||
| 269 | if ($data->hasAlterSequenceStart()) { |
||
| 270 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['start_value']), '</td>'; |
||
| 271 | } |
||
| 272 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['last_value']), '</td>'; |
||
| 273 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['increment_by']), '</td>'; |
||
| 274 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['max_value']), '</td>'; |
||
| 275 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['min_value']), '</td>'; |
||
| 276 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['cache_value']), '</td>'; |
||
| 277 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['log_cnt']), '</td>'; |
||
| 278 | echo '<td class="data1">', ($sequence->fields['is_cycled'] ? $this->lang['stryes'] : $this->lang['strno']), '</td>'; |
||
| 279 | echo '<td class="data1">', ($sequence->fields['is_called'] ? $this->lang['stryes'] : $this->lang['strno']), '</td>'; |
||
| 280 | echo '</tr>'; |
||
| 281 | echo '</table>'; |
||
| 282 | |||
| 283 | $navlinks = [ |
||
| 284 | 'alter' => [ |
||
| 285 | 'attr' => [ |
||
| 286 | 'href' => [ |
||
| 287 | 'url' => 'sequences', |
||
| 288 | 'urlvars' => [ |
||
| 289 | 'action' => 'confirm_alter', |
||
| 290 | 'server' => $_REQUEST['server'], |
||
| 291 | 'database' => $_REQUEST['database'], |
||
| 292 | 'schema' => $_REQUEST['schema'], |
||
| 293 | 'sequence' => $sequence->fields['seqname'], |
||
| 294 | ], |
||
| 295 | ], |
||
| 296 | ], |
||
| 297 | 'content' => $this->lang['stralter'], |
||
| 298 | ], |
||
| 299 | 'setval' => [ |
||
| 300 | 'attr' => [ |
||
| 301 | 'href' => [ |
||
| 302 | 'url' => 'sequences', |
||
| 303 | 'urlvars' => [ |
||
| 304 | 'action' => 'confirm_setval', |
||
| 305 | 'server' => $_REQUEST['server'], |
||
| 306 | 'database' => $_REQUEST['database'], |
||
| 307 | 'schema' => $_REQUEST['schema'], |
||
| 308 | 'sequence' => $sequence->fields['seqname'], |
||
| 309 | ], |
||
| 310 | ], |
||
| 311 | ], |
||
| 312 | 'content' => $this->lang['strsetval'], |
||
| 313 | ], |
||
| 314 | 'nextval' => [ |
||
| 315 | 'attr' => [ |
||
| 316 | 'href' => [ |
||
| 317 | 'url' => 'sequences', |
||
| 318 | 'urlvars' => [ |
||
| 319 | 'action' => 'nextval', |
||
| 320 | 'server' => $_REQUEST['server'], |
||
| 321 | 'database' => $_REQUEST['database'], |
||
| 322 | 'schema' => $_REQUEST['schema'], |
||
| 323 | 'sequence' => $sequence->fields['seqname'], |
||
| 324 | ], |
||
| 325 | ], |
||
| 326 | ], |
||
| 327 | 'content' => $this->lang['strnextval'], |
||
| 328 | ], |
||
| 329 | 'restart' => [ |
||
| 330 | 'attr' => [ |
||
| 331 | 'href' => [ |
||
| 332 | 'url' => 'sequences', |
||
| 333 | 'urlvars' => [ |
||
| 334 | 'action' => 'restart', |
||
| 335 | 'server' => $_REQUEST['server'], |
||
| 336 | 'database' => $_REQUEST['database'], |
||
| 337 | 'schema' => $_REQUEST['schema'], |
||
| 338 | 'sequence' => $sequence->fields['seqname'], |
||
| 339 | ], |
||
| 340 | ], |
||
| 341 | ], |
||
| 342 | 'content' => $this->lang['strrestart'], |
||
| 343 | ], |
||
| 344 | 'reset' => [ |
||
| 345 | 'attr' => [ |
||
| 346 | 'href' => [ |
||
| 347 | 'url' => 'sequences', |
||
| 348 | 'urlvars' => [ |
||
| 349 | 'action' => 'reset', |
||
| 350 | 'server' => $_REQUEST['server'], |
||
| 351 | 'database' => $_REQUEST['database'], |
||
| 352 | 'schema' => $_REQUEST['schema'], |
||
| 353 | 'sequence' => $sequence->fields['seqname'], |
||
| 354 | ], |
||
| 355 | ], |
||
| 356 | ], |
||
| 357 | 'content' => $this->lang['strreset'], |
||
| 358 | ], |
||
| 359 | 'showall' => [ |
||
| 360 | 'attr' => [ |
||
| 361 | 'href' => [ |
||
| 362 | 'url' => 'sequences', |
||
| 363 | 'urlvars' => [ |
||
| 364 | 'server' => $_REQUEST['server'], |
||
| 365 | 'database' => $_REQUEST['database'], |
||
| 366 | 'schema' => $_REQUEST['schema'], |
||
| 367 | ], |
||
| 368 | ], |
||
| 369 | ], |
||
| 370 | 'content' => $this->lang['strshowallsequences'], |
||
| 371 | ], |
||
| 372 | ]; |
||
| 373 | |||
| 374 | if (!$data->hasAlterSequenceStart()) { |
||
| 375 | unset($navlinks['restart']); |
||
| 376 | } |
||
| 377 | |||
| 378 | $this->printNavLinks($navlinks, 'sequences-properties', \get_defined_vars()); |
||
| 379 | } else { |
||
| 380 | echo "<p>{$this->lang['strnodata']}</p>" . \PHP_EOL; |
||
| 381 | } |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Drop a sequence. |
||
| 386 | * |
||
| 387 | * @param mixed $confirm |
||
| 388 | * @param mixed $msg |
||
| 389 | */ |
||
| 390 | public function doDrop($confirm, $msg = '') |
||
| 391 | { |
||
| 392 | $data = $this->misc->getDatabaseAccessor(); |
||
| 393 | |||
| 394 | if (empty($_REQUEST['sequence']) && empty($_REQUEST['ma'])) { |
||
| 395 | return $this->doDefault($this->lang['strspecifysequencetodrop']); |
||
| 396 | } |
||
| 397 | |||
| 398 | if ($confirm) { |
||
| 399 | $this->printTrail('sequence'); |
||
| 400 | $this->printTitle($this->lang['strdrop'], 'pg.sequence.drop'); |
||
| 401 | $this->printMsg($msg); |
||
| 402 | |||
| 403 | echo '<form action="' . \containerInstance()->subFolder . '/src/views/sequences" method="post">' . \PHP_EOL; |
||
| 404 | |||
| 405 | //If multi drop |
||
| 406 | if (isset($_REQUEST['ma'])) { |
||
| 407 | foreach ($_REQUEST['ma'] as $v) { |
||
| 408 | $a = \unserialize(\htmlspecialchars_decode($v, \ENT_QUOTES)); |
||
| 409 | echo '<p>', \sprintf($this->lang['strconfdropsequence'], $this->misc->printVal($a['sequence'])), '</p>' . \PHP_EOL; |
||
| 410 | \printf('<input type="hidden" name="sequence[]" value="%s" />', \htmlspecialchars($a['sequence'])); |
||
| 411 | } |
||
| 412 | } else { |
||
| 413 | echo '<p>', \sprintf($this->lang['strconfdropsequence'], $this->misc->printVal($_REQUEST['sequence'])), '</p>' . \PHP_EOL; |
||
| 414 | echo '<input type="hidden" name="sequence" value="', \htmlspecialchars($_REQUEST['sequence']), '" />' . \PHP_EOL; |
||
| 415 | } |
||
| 416 | |||
| 417 | echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label></p>" . \PHP_EOL; |
||
| 418 | echo '<p><input type="hidden" name="action" value="drop" />' . \PHP_EOL; |
||
| 419 | echo $this->view->form; |
||
| 420 | echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />" . \PHP_EOL; |
||
| 421 | echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
||
| 422 | echo '</form>' . \PHP_EOL; |
||
| 423 | } else { |
||
| 424 | if (\is_array($_POST['sequence'])) { |
||
| 425 | $msg = ''; |
||
| 426 | $status = $data->beginTransaction(); |
||
| 427 | |||
| 428 | if (0 === $status) { |
||
| 429 | foreach ($_POST['sequence'] as $s) { |
||
| 430 | $status = $data->dropSequence($s, isset($_POST['cascade'])); |
||
| 431 | |||
| 432 | if (0 === $status) { |
||
| 433 | $msg .= \sprintf( |
||
| 434 | '%s: %s<br />', |
||
| 435 | \htmlentities($s, \ENT_QUOTES, 'UTF-8'), |
||
| 436 | $this->lang['strsequencedropped'] |
||
| 437 | ); |
||
| 438 | } else { |
||
| 439 | $data->endTransaction(); |
||
| 440 | $this->doDefault(\sprintf( |
||
| 441 | '%s%s: %s<br />', |
||
| 442 | $msg, |
||
| 443 | \htmlentities($s, \ENT_QUOTES, 'UTF-8'), |
||
| 444 | $this->lang['strsequencedroppedbad'] |
||
| 445 | )); |
||
| 446 | |||
| 447 | return; |
||
| 448 | } |
||
| 449 | } |
||
| 450 | } |
||
| 451 | |||
| 452 | if (0 === $data->endTransaction()) { |
||
| 453 | // Everything went fine, back to the Default page.... |
||
| 454 | $this->view->setReloadBrowser(true); |
||
| 455 | $this->doDefault($msg); |
||
| 456 | } else { |
||
| 457 | $this->doDefault($this->lang['strsequencedroppedbad']); |
||
| 458 | } |
||
| 459 | } else { |
||
| 460 | $status = $data->dropSequence($_POST['sequence'], isset($_POST['cascade'])); |
||
| 461 | |||
| 462 | if (0 === $status) { |
||
| 463 | $this->view->setReloadBrowser(true); |
||
| 464 | $this->doDefault($this->lang['strsequencedropped']); |
||
| 465 | } else { |
||
| 466 | $this->doDrop(true, $this->lang['strsequencedroppedbad']); |
||
| 467 | } |
||
| 468 | } |
||
| 469 | } |
||
| 470 | } |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Displays a screen where they can enter a new sequence. |
||
| 474 | * |
||
| 475 | * @param mixed $msg |
||
| 476 | */ |
||
| 477 | public function doCreateSequence($msg = ''): void |
||
| 478 | { |
||
| 479 | $data = $this->misc->getDatabaseAccessor(); |
||
| 480 | |||
| 481 | $this->coalesceArr($_POST, 'formSequenceName', ''); |
||
| 482 | |||
| 483 | $this->coalesceArr($_POST, 'formIncrement', ''); |
||
| 484 | |||
| 485 | $this->coalesceArr($_POST, 'formMinValue', ''); |
||
| 486 | |||
| 487 | $this->coalesceArr($_POST, 'formMaxValue', ''); |
||
| 488 | |||
| 489 | $this->coalesceArr($_POST, 'formStartValue', ''); |
||
| 490 | |||
| 491 | $this->coalesceArr($_POST, 'formCacheValue', ''); |
||
| 492 | |||
| 493 | $this->printTrail('schema'); |
||
| 494 | $this->printTitle($this->lang['strcreatesequence'], 'pg.sequence.create'); |
||
| 495 | $this->printMsg($msg); |
||
| 496 | |||
| 497 | echo '<form action="' . \containerInstance()->subFolder . '/src/views/sequences" method="post">' . \PHP_EOL; |
||
| 498 | echo '<table>' . \PHP_EOL; |
||
| 499 | |||
| 500 | echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>" . \PHP_EOL; |
||
| 501 | echo "<td class=\"data1\"><input name=\"formSequenceName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
| 502 | \htmlspecialchars($_POST['formSequenceName']), |
||
| 503 | '" /></td></tr>' . \PHP_EOL; |
||
| 504 | |||
| 505 | echo "<tr><th class=\"data left\">{$this->lang['strincrementby']}</th>" . \PHP_EOL; |
||
| 506 | echo '<td class="data1"><input name="formIncrement" size="5" value="', |
||
| 507 | \htmlspecialchars($_POST['formIncrement']), |
||
| 508 | '" /> </td></tr>' . \PHP_EOL; |
||
| 509 | |||
| 510 | echo "<tr><th class=\"data left\">{$this->lang['strminvalue']}</th>" . \PHP_EOL; |
||
| 511 | echo '<td class="data1"><input name="formMinValue" size="5" value="', |
||
| 512 | \htmlspecialchars($_POST['formMinValue']), |
||
| 513 | '" /></td></tr>' . \PHP_EOL; |
||
| 514 | |||
| 515 | echo "<tr><th class=\"data left\">{$this->lang['strmaxvalue']}</th>" . \PHP_EOL; |
||
| 516 | echo '<td class="data1"><input name="formMaxValue" size="5" value="', |
||
| 517 | \htmlspecialchars($_POST['formMaxValue']), |
||
| 518 | '" /></td></tr>' . \PHP_EOL; |
||
| 519 | |||
| 520 | echo "<tr><th class=\"data left\">{$this->lang['strstartvalue']}</th>" . \PHP_EOL; |
||
| 521 | echo '<td class="data1"><input name="formStartValue" size="5" value="', |
||
| 522 | \htmlspecialchars($_POST['formStartValue']), |
||
| 523 | '" /></td></tr>' . \PHP_EOL; |
||
| 524 | |||
| 525 | echo "<tr><th class=\"data left\">{$this->lang['strcachevalue']}</th>" . \PHP_EOL; |
||
| 526 | echo '<td class="data1"><input name="formCacheValue" size="5" value="', |
||
| 527 | \htmlspecialchars($_POST['formCacheValue']), |
||
| 528 | '" /></td></tr>' . \PHP_EOL; |
||
| 529 | |||
| 530 | echo "<tr><th class=\"data left\"><label for=\"formCycledValue\">{$this->lang['strcancycle']}</label></th>" . \PHP_EOL; |
||
| 531 | echo '<td class="data1"><input type="checkbox" id="formCycledValue" name="formCycledValue" ', |
||
| 532 | (isset($_POST['formCycledValue']) ? ' checked="checked"' : ''), |
||
| 533 | ' /></td></tr>' . \PHP_EOL; |
||
| 534 | |||
| 535 | echo '</table>' . \PHP_EOL; |
||
| 536 | echo '<p><input type="hidden" name="action" value="save_create_sequence" />' . \PHP_EOL; |
||
| 537 | echo $this->view->form; |
||
| 538 | echo "<input type=\"submit\" name=\"create\" value=\"{$this->lang['strcreate']}\" />" . \PHP_EOL; |
||
| 539 | echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
||
| 540 | echo '</form>' . \PHP_EOL; |
||
| 541 | } |
||
| 542 | |||
| 543 | /** |
||
| 544 | * Actually creates the new sequence in the database. |
||
| 545 | */ |
||
| 546 | public function doSaveCreateSequence(): void |
||
| 547 | { |
||
| 548 | $data = $this->misc->getDatabaseAccessor(); |
||
| 549 | |||
| 550 | // Check that they've given a name and at least one column |
||
| 551 | if ('' === $_POST['formSequenceName']) { |
||
| 552 | $this->doCreateSequence($this->lang['strsequenceneedsname']); |
||
| 553 | } else { |
||
| 554 | $status = $data->createSequence( |
||
| 555 | $_POST['formSequenceName'], |
||
| 556 | $_POST['formIncrement'], |
||
| 557 | $_POST['formMinValue'], |
||
| 558 | $_POST['formMaxValue'], |
||
| 559 | $_POST['formStartValue'], |
||
| 560 | $_POST['formCacheValue'], |
||
| 561 | isset($_POST['formCycledValue']) |
||
| 562 | ); |
||
| 563 | |||
| 564 | if (0 === $status) { |
||
| 565 | $this->doDefault($this->lang['strsequencecreated']); |
||
| 566 | } else { |
||
| 567 | $this->doCreateSequence($this->lang['strsequencecreatedbad']); |
||
| 568 | } |
||
| 569 | } |
||
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * Restarts a sequence. |
||
| 574 | */ |
||
| 575 | public function doRestart(): void |
||
| 576 | { |
||
| 577 | $data = $this->misc->getDatabaseAccessor(); |
||
| 578 | |||
| 579 | $status = $data->restartSequence($_REQUEST['sequence']); |
||
| 580 | |||
| 581 | if (0 === $status) { |
||
| 582 | $this->doProperties($this->lang['strsequencerestart']); |
||
| 583 | } else { |
||
| 584 | $this->doProperties($this->lang['strsequencerestartbad']); |
||
| 585 | } |
||
| 586 | } |
||
| 587 | |||
| 588 | /** |
||
| 589 | * Resets a sequence. |
||
| 590 | */ |
||
| 591 | public function doReset(): void |
||
| 592 | { |
||
| 593 | $data = $this->misc->getDatabaseAccessor(); |
||
| 594 | |||
| 595 | $status = $data->resetSequence($_REQUEST['sequence']); |
||
| 596 | |||
| 597 | if (0 === $status) { |
||
| 598 | $this->doProperties($this->lang['strsequencereset']); |
||
| 599 | } else { |
||
| 600 | $this->doProperties($this->lang['strsequenceresetbad']); |
||
| 601 | } |
||
| 602 | } |
||
| 603 | |||
| 604 | /** |
||
| 605 | * Set Nextval of a sequence. |
||
| 606 | */ |
||
| 607 | public function doNextval(): void |
||
| 608 | { |
||
| 609 | $data = $this->misc->getDatabaseAccessor(); |
||
| 610 | |||
| 611 | $status = $data->nextvalSequence($_REQUEST['sequence']); |
||
| 612 | |||
| 613 | if (0 === $status) { |
||
| 614 | $this->doProperties($this->lang['strsequencenextval']); |
||
| 615 | } else { |
||
| 616 | $this->doProperties($this->lang['strsequencenextvalbad']); |
||
| 617 | } |
||
| 618 | } |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Function to save after 'setval'ing a sequence. |
||
| 622 | */ |
||
| 623 | public function doSaveSetval(): void |
||
| 624 | { |
||
| 625 | $data = $this->misc->getDatabaseAccessor(); |
||
| 626 | |||
| 627 | $status = $data->setvalSequence($_POST['sequence'], $_POST['nextvalue']); |
||
| 628 | |||
| 629 | if (0 === $status) { |
||
| 630 | $this->doProperties($this->lang['strsequencesetval']); |
||
| 631 | } else { |
||
| 632 | $this->doProperties($this->lang['strsequencesetvalbad']); |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | /** |
||
| 637 | * Function to allow 'setval'ing of a sequence. |
||
| 638 | * |
||
| 639 | * @param mixed $msg |
||
| 640 | */ |
||
| 641 | public function doSetval($msg = ''): void |
||
| 642 | { |
||
| 643 | $data = $this->misc->getDatabaseAccessor(); |
||
| 644 | |||
| 645 | $this->printTrail('sequence'); |
||
| 646 | $this->printTitle($this->lang['strsetval'], 'pg.sequence'); |
||
| 647 | $this->printMsg($msg); |
||
| 648 | |||
| 649 | // Fetch the sequence information |
||
| 650 | $sequence = $data->getSequence($_REQUEST['sequence']); |
||
| 651 | |||
| 652 | if (\is_object($sequence) && 0 < $sequence->recordCount()) { |
||
| 653 | echo '<form action="' . \containerInstance()->subFolder . '/src/views/sequences" method="post">' . \PHP_EOL; |
||
| 654 | echo '<table border="0">'; |
||
| 655 | echo "<tr><th class=\"data left required\">{$this->lang['strlastvalue']}</th>" . \PHP_EOL; |
||
| 656 | echo '<td class="data1">'; |
||
| 657 | echo "<input name=\"nextvalue\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
| 658 | $this->misc->printVal($sequence->fields['last_value']), |
||
| 659 | '" /></td></tr>' . \PHP_EOL; |
||
| 660 | echo '</table>' . \PHP_EOL; |
||
| 661 | echo '<p><input type="hidden" name="action" value="setval" />' . \PHP_EOL; |
||
| 662 | echo '<input type="hidden" name="sequence" value="', \htmlspecialchars($_REQUEST['sequence']), '" />' . \PHP_EOL; |
||
| 663 | echo $this->view->form; |
||
| 664 | echo "<input type=\"submit\" name=\"setval\" value=\"{$this->lang['strsetval']}\" />" . \PHP_EOL; |
||
| 665 | echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
||
| 666 | echo '</form>' . \PHP_EOL; |
||
| 667 | } else { |
||
| 668 | echo "<p>{$this->lang['strnodata']}</p>" . \PHP_EOL; |
||
| 669 | } |
||
| 670 | } |
||
| 671 | |||
| 672 | /** |
||
| 673 | * Function to save after altering a sequence. |
||
| 674 | */ |
||
| 675 | public function doSaveAlter(): void |
||
| 728 | } |
||
| 729 | } |
||
| 730 | |||
| 731 | /** |
||
| 732 | * Function to allow altering of a sequence. |
||
| 733 | * |
||
| 734 | * @param mixed $msg |
||
| 735 | */ |
||
| 736 | public function doAlter($msg = ''): void |
||
| 860 | } |
||
| 861 | } |
||
| 862 | } |
||
| 863 |