1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\BrowseForeigners;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
/**
* Display selection for relational field values
*/
class BrowseForeignersController extends AbstractController
{
/** @var BrowseForeigners */
private $browseForeigners;
/** @var Relation */
private $relation;
public function __construct(
ResponseRenderer $response,
Template $template,
BrowseForeigners $browseForeigners,
Relation $relation
) {
parent::__construct($response, $template);
$this->browseForeigners = $browseForeigners;
$this->relation = $relation;
}
public function __invoke(ServerRequest $request): void
{
/** @var string|null $database */
$database = $request->getParsedBodyParam('db');
/** @var string|null $table */
$table = $request->getParsedBodyParam('table');
/** @var string|null $field */
$field = $request->getParsedBodyParam('field');
/** @var string $fieldKey */
$fieldKey = $request->getParsedBodyParam('fieldkey', '');
/** @var string $data */
$data = $request->getParsedBodyParam('data', '');
/** @var string|null $foreignShowAll */
$foreignShowAll = $request->getParsedBodyParam('foreign_showAll');
/** @var string $foreignFilter */
$foreignFilter = $request->getParsedBodyParam('foreign_filter', '');
if (! isset($database, $table, $field)) {
return;
}
$this->response->getFooter()->setMinimal();
$header = $this->response->getHeader();
$header->disableMenuAndConsole();
$header->setBodyId('body_browse_foreigners');
$foreigners = $this->relation->getForeigners($database, $table);
$foreignLimit = $this->browseForeigners->getForeignLimit($foreignShowAll);
$foreignData = $this->relation->getForeignData(
$foreigners,
$field,
true,
$foreignFilter,
$foreignLimit ?? '',
true
);
$this->response->addHTML($this->browseForeigners->getHtmlForRelationalFieldSelection(
$database,
$table,
$field,
$foreignData,
$fieldKey,
$data
));
}
}
|