aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/libraries/classes/Display
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Display')
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/ChangePassword.php182
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/CreateTable.php56
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/Error.php56
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/Export.php825
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/GitRevision.php144
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/Import.php127
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/ImportAjax.php140
-rw-r--r--srcs/phpmyadmin/libraries/classes/Display/Results.php5698
8 files changed, 7228 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Display/ChangePassword.php b/srcs/phpmyadmin/libraries/classes/Display/ChangePassword.php
new file mode 100644
index 0000000..a786b6c
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Display/ChangePassword.php
@@ -0,0 +1,182 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Displays form for password change
+ *
+ * @package PhpMyAdmin
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Display;
+
+use PhpMyAdmin\Message;
+use PhpMyAdmin\Relation;
+use PhpMyAdmin\RelationCleanup;
+use PhpMyAdmin\Server\Privileges;
+use PhpMyAdmin\Template;
+use PhpMyAdmin\Url;
+use PhpMyAdmin\Util;
+
+/**
+ * Displays form for password change
+ *
+ * @package PhpMyAdmin
+ */
+class ChangePassword
+{
+ /**
+ * Get HTML for the Change password dialog
+ *
+ * @param string $mode where is the function being called?
+ * values : 'change_pw' or 'edit_other'
+ * @param string $username username
+ * @param string $hostname hostname
+ *
+ * @return string html snippet
+ */
+ public static function getHtml($mode, $username, $hostname)
+ {
+ $relation = new Relation($GLOBALS['dbi']);
+ $serverPrivileges = new Privileges(
+ new Template(),
+ $GLOBALS['dbi'],
+ $relation,
+ new RelationCleanup($GLOBALS['dbi'], $relation)
+ );
+
+ /**
+ * autocomplete feature of IE kills the "onchange" event handler and it
+ * must be replaced by the "onpropertychange" one in this case
+ */
+ $chg_evt_handler = 'onchange';
+
+ $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php';
+
+ $html = '<form method="post" id="change_password_form" '
+ . 'action="' . basename($GLOBALS['PMA_PHP_SELF']) . '" '
+ . 'name="chgPassword" '
+ . 'class="' . ($is_privileges ? 'submenu-item' : '') . '">';
+
+ $html .= Url::getHiddenInputs();
+
+ if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
+ $html .= '<input type="hidden" name="username" '
+ . 'value="' . htmlspecialchars($username) . '">'
+ . '<input type="hidden" name="hostname" '
+ . 'value="' . htmlspecialchars($hostname) . '">';
+ }
+ $html .= '<fieldset id="fieldset_change_password">'
+ . '<legend'
+ . ($is_privileges
+ ? ' data-submenu-label="' . __('Change password') . '"'
+ : ''
+ )
+ . '>' . __('Change password') . '</legend>'
+ . '<table class="data noclick">'
+ . '<tr>'
+ . '<td colspan="2">'
+ . '<input type="radio" name="nopass" value="1" id="nopass_1" '
+ . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; '
+ . 'this.checked = true">'
+ . '<label for="nopass_1">' . __('No Password') . '</label>'
+ . '</td>'
+ . '</tr>'
+ . '<tr class="vmiddle">'
+ . '<td>'
+ . '<input type="radio" name="nopass" value="0" id="nopass_0" '
+ . 'onclick="document.getElementById(\'text_pma_change_pw\').focus();" '
+ . 'checked="checked">'
+ . '<label for="nopass_0">' . __('Password:') . '&nbsp;</label>'
+ . '</td>'
+ . '<td>'
+ . __('Enter:') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp'
+ . '<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" '
+ . 'class="textfield"'
+ . 'onkeyup="checkPasswordStrength($(this).val(), $(\'#change_password_strength_meter\'), meter_obj_label = $(\'#change_password_strength\'), CommonParams.get(\'user\'));" '
+ . $chg_evt_handler . '="nopass[1].checked = true">'
+ . '<span>Strength:</span> '
+ . '<meter max="4" id="change_password_strength_meter" name="pw_meter"></meter> '
+ . '<span id="change_password_strength" name="pw_strength">Good</span>'
+ . '<br>' . __('Re-type:') . '&nbsp;'
+ . '<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" '
+ . 'class="textfield"'
+ . $chg_evt_handler . '="nopass[1].checked = true">'
+ . '</td>'
+ . '</tr>';
+
+ $serverType = Util::getServerType();
+ $serverVersion = $GLOBALS['dbi']->getVersion();
+ $orig_auth_plugin = $serverPrivileges->getCurrentAuthenticationPlugin(
+ 'change',
+ $username,
+ $hostname
+ );
+
+ if (($serverType == 'MySQL'
+ && $serverVersion >= 50507)
+ || ($serverType == 'MariaDB'
+ && $serverVersion >= 50200)
+ ) {
+ // Provide this option only for 5.7.6+
+ // OR for privileged users in 5.5.7+
+ if (($serverType == 'MySQL'
+ && $serverVersion >= 50706)
+ || ($GLOBALS['dbi']->isSuperuser() && $mode == 'edit_other')
+ ) {
+ $auth_plugin_dropdown = $serverPrivileges->getHtmlForAuthPluginsDropdown(
+ $orig_auth_plugin,
+ 'change_pw',
+ 'new'
+ );
+
+ $html .= '<tr class="vmiddle">'
+ . '<td>' . __('Password Hashing:') . '</td><td>';
+ $html .= $auth_plugin_dropdown;
+ $html .= '</td></tr>'
+ . '<tr id="tr_element_before_generate_password"></tr>'
+ . '</table>';
+
+ $html .= '<div'
+ . ($orig_auth_plugin != 'sha256_password'
+ ? ' class="hide"'
+ : '')
+ . ' id="ssl_reqd_warning_cp">'
+ . Message::notice(
+ __(
+ 'This method requires using an \'<i>SSL connection</i>\' '
+ . 'or an \'<i>unencrypted connection that encrypts the '
+ . 'password using RSA</i>\'; while connecting to the server.'
+ )
+ . Util::showMySQLDocu(
+ 'sha256-authentication-plugin'
+ )
+ )
+ ->getDisplay()
+ . '</div>';
+ } else {
+ $html .= '<tr id="tr_element_before_generate_password"></tr>'
+ . '</table>';
+ }
+ } else {
+ $auth_plugin_dropdown = $serverPrivileges->getHtmlForAuthPluginsDropdown(
+ $orig_auth_plugin,
+ 'change_pw',
+ 'old'
+ );
+
+ $html .= '<tr class="vmiddle">'
+ . '<td>' . __('Password Hashing:') . '</td><td>';
+ $html .= $auth_plugin_dropdown . '</td></tr>'
+ . '<tr id="tr_element_before_generate_password"></tr>'
+ . '</table>';
+ }
+
+ $html .= '</fieldset>'
+ . '<fieldset id="fieldset_change_password_footer" class="tblFooters">'
+ . '<input type="hidden" name="change_pw" value="1">'
+ . '<input class="btn btn-primary" type="submit" value="' . __('Go') . '">'
+ . '</fieldset>'
+ . '</form>';
+ return $html;
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Display/CreateTable.php b/srcs/phpmyadmin/libraries/classes/Display/CreateTable.php
new file mode 100644
index 0000000..d984e55
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Display/CreateTable.php
@@ -0,0 +1,56 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Displays form for creating a table (if user has privileges for that)
+ *
+ * for MySQL >= 4.1.0, we should be able to detect if user has a CREATE
+ * privilege by looking at SHOW GRANTS output;
+ * for < 4.1.0, it could be more difficult because the logic tries to
+ * detect the current host and it might be expressed in many ways; also
+ * on a shared server, the user might be unable to define a controluser
+ * that has the proper rights to the "mysql" db;
+ * so we give up and assume that user has the right to create a table
+ *
+ * Note: in this case we could even skip the following "foreach" logic
+ *
+ * Addendum, 2006-01-19: ok, I give up. We got some reports about servers
+ * where the hostname field in mysql.user is not the same as the one
+ * in mysql.db for a user. In this case, SHOW GRANTS does not return
+ * the db-specific privileges. And probably, those users are on a shared
+ * server, so can't set up a control user with rights to the "mysql" db.
+ * We cannot reliably detect the db-specific privileges, so no more
+ * warnings about the lack of privileges for CREATE TABLE. Tested
+ * on MySQL 5.0.18.
+ *
+ * @package PhpMyAdmin
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Display;
+
+use PhpMyAdmin\CheckUserPrivileges;
+use PhpMyAdmin\Template;
+
+/**
+ * PhpMyAdmin\Display\CreateTable class
+ *
+ * @package PhpMyAdmin
+ */
+class CreateTable
+{
+ /**
+ * Returns the html for create table.
+ *
+ * @param string $db database name
+ *
+ * @return string
+ */
+ public static function getHtml($db)
+ {
+ $checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
+ $checkUserPrivileges->getPrivileges();
+
+ $template = new Template();
+ return $template->render('database/create_table', ['db' => $db]);
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Display/Error.php b/srcs/phpmyadmin/libraries/classes/Display/Error.php
new file mode 100644
index 0000000..a601532
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Display/Error.php
@@ -0,0 +1,56 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Displays Error
+ *
+ * @package PhpMyAdmin
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Display;
+
+use PhpMyAdmin\Sanitize;
+use PhpMyAdmin\Template;
+use Throwable;
+use Twig_Error_Loader;
+use Twig_Error_Runtime;
+use Twig_Error_Syntax;
+
+/**
+ * Displays Error
+ *
+ * @package PhpMyAdmin
+ */
+class Error
+{
+ /**
+ * @param Template $template Template object used to render the error
+ * @param string $lang Lang of the HTML page
+ * @param string $dir Direction of text of the HTML page
+ * @param string $errorHeader Error header
+ * @param string $errorMessage Error message
+ *
+ * @return string
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public static function display(
+ Template $template,
+ string $lang,
+ string $dir,
+ string $errorHeader,
+ string $errorMessage
+ ): string {
+ return $template->render(
+ 'error/generic',
+ [
+ 'lang' => $lang,
+ 'dir' => $dir,
+ 'error_header' => $errorHeader,
+ 'error_message' => Sanitize::sanitizeMessage($errorMessage),
+ ]
+ );
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Display/Export.php b/srcs/phpmyadmin/libraries/classes/Display/Export.php
new file mode 100644
index 0000000..db02a5e
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Display/Export.php
@@ -0,0 +1,825 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * functions for displaying server, database and table export
+ *
+ * @package PhpMyAdmin
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Display;
+
+use PhpMyAdmin\Core;
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Encoding;
+use PhpMyAdmin\Message;
+use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Relation;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Table;
+use PhpMyAdmin\Template;
+use PhpMyAdmin\Util;
+use Throwable;
+use Twig_Error_Loader;
+use Twig_Error_Runtime;
+use Twig_Error_Syntax;
+
+/**
+ * PhpMyAdmin\Display\Export class
+ *
+ * @package PhpMyAdmin
+ */
+class Export
+{
+ /**
+ * @var Relation
+ */
+ private $relation;
+
+ /**
+ * @var Template
+ */
+ public $template;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->relation = new Relation($GLOBALS['dbi']);
+ $this->template = new Template();
+ }
+
+ /**
+ * Outputs appropriate checked statement for checkbox.
+ *
+ * @param string $str option name
+ *
+ * @return boolean
+ */
+ private function checkboxCheck($str)
+ {
+ return isset($GLOBALS['cfg']['Export'][$str])
+ && $GLOBALS['cfg']['Export'][$str];
+ }
+
+ /**
+ * Prints Html For Export Selection Options
+ *
+ * @param string $tmpSelect Tmp selected method of export
+ *
+ * @return string
+ */
+ public function getHtmlForSelectOptions($tmpSelect = '')
+ {
+ // Check if the selected databases are defined in $_POST
+ // (from clicking Back button on export.php)
+ if (isset($_POST['db_select'])) {
+ $_POST['db_select'] = urldecode($_POST['db_select']);
+ $_POST['db_select'] = explode(",", $_POST['db_select']);
+ }
+
+ $databases = [];
+ foreach ($GLOBALS['dblist']->databases as $currentDb) {
+ if ($GLOBALS['dbi']->isSystemSchema($currentDb, true)) {
+ continue;
+ }
+ $isSelected = false;
+ if (isset($_POST['db_select'])) {
+ if (in_array($currentDb, $_POST['db_select'])) {
+ $isSelected = true;
+ }
+ } elseif (! empty($tmpSelect)) {
+ if (mb_strpos(
+ ' ' . $tmpSelect,
+ '|' . $currentDb . '|'
+ )) {
+ $isSelected = true;
+ }
+ } else {
+ $isSelected = true;
+ }
+ $databases[] = [
+ 'name' => $currentDb,
+ 'is_selected' => $isSelected,
+ ];
+ }
+
+ return $this->template->render('display/export/select_options', [
+ 'databases' => $databases,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Hidden Input
+ *
+ * @param string $exportType Selected Export Type
+ * @param string $db Selected DB
+ * @param string $table Selected Table
+ * @param string $singleTable Single Table
+ * @param string $sqlQuery SQL Query
+ *
+ * @return string
+ */
+ public function getHtmlForHiddenInputs(
+ $exportType,
+ $db,
+ $table,
+ $singleTable,
+ $sqlQuery
+ ) {
+ global $cfg;
+
+ // If the export method was not set, the default is quick
+ if (isset($_POST['export_method'])) {
+ $cfg['Export']['method'] = $_POST['export_method'];
+ } elseif (! isset($cfg['Export']['method'])) {
+ $cfg['Export']['method'] = 'quick';
+ }
+
+ if (empty($sqlQuery) && isset($_POST['sql_query'])) {
+ $sqlQuery = $_POST['sql_query'];
+ }
+
+ return $this->template->render('display/export/hidden_inputs', [
+ 'db' => $db,
+ 'table' => $table,
+ 'export_type' => $exportType,
+ 'export_method' => $cfg['Export']['method'],
+ 'single_table' => $singleTable,
+ 'sql_query' => $sqlQuery,
+ 'template_id' => isset($_POST['template_id']) ? $_POST['template_id'] : '',
+ ]);
+ }
+
+ /**
+ * Returns HTML for the options in template dropdown
+ *
+ * @param string $exportType export type - server, database, or table
+ *
+ * @return string HTML for the options in teplate dropdown
+ */
+ private function getOptionsForTemplates($exportType)
+ {
+ // Get the relation settings
+ $cfgRelation = $this->relation->getRelationsParam();
+
+ $query = "SELECT `id`, `template_name` FROM "
+ . Util::backquote($cfgRelation['db']) . '.'
+ . Util::backquote($cfgRelation['export_templates'])
+ . " WHERE `username` = "
+ . "'" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user'])
+ . "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($exportType) . "'"
+ . " ORDER BY `template_name`;";
+
+ $result = $this->relation->queryAsControlUser($query);
+
+ $templates = [];
+ if ($result !== false) {
+ while ($row = $GLOBALS['dbi']->fetchAssoc($result, DatabaseInterface::CONNECT_CONTROL)) {
+ $templates[] = [
+ 'name' => $row['template_name'],
+ 'id' => $row['id'],
+ ];
+ }
+ }
+
+ return $this->template->render('display/export/template_options', [
+ 'templates' => $templates,
+ 'selected_template' => ! empty($_POST['template_id']) ? $_POST['template_id'] : null,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Method
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsMethod()
+ {
+ global $cfg;
+ if (isset($_POST['quick_or_custom'])) {
+ $exportMethod = $_POST['quick_or_custom'];
+ } else {
+ $exportMethod = $cfg['Export']['method'];
+ }
+
+ return $this->template->render('display/export/method', [
+ 'export_method' => $exportMethod,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Selection
+ *
+ * @param string $exportType Selected Export Type
+ * @param string $multiValues Export Options
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsSelection($exportType, $multiValues)
+ {
+ return $this->template->render('display/export/selection', [
+ 'export_type' => $exportType,
+ 'multi_values' => $multiValues,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Format dropdown
+ *
+ * @param ExportPlugin[] $exportList Export List
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsFormatDropdown($exportList)
+ {
+ $dropdown = Plugins::getChoice('Export', 'what', $exportList, 'format');
+ return $this->template->render('display/export/format_dropdown', [
+ 'dropdown' => $dropdown,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Format-specific options
+ *
+ * @param ExportPlugin[] $exportList Export List
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsFormat($exportList)
+ {
+ global $cfg;
+ $options = Plugins::getOptions('Export', $exportList);
+
+ return $this->template->render('display/export/options_format', [
+ 'options' => $options,
+ 'can_convert_kanji' => Encoding::canConvertKanji(),
+ 'exec_time_limit' => $cfg['ExecTimeLimit'],
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Rows
+ *
+ * @param string $db Selected DB
+ * @param string $table Selected Table
+ * @param string $unlimNumRows Num of Rows
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsRows($db, $table, $unlimNumRows)
+ {
+ $tableObject = new Table($table, $db);
+ $numberOfRows = $tableObject->countRecords();
+
+ return $this->template->render('display/export/options_rows', [
+ 'allrows' => isset($_POST['allrows']) ? $_POST['allrows'] : null,
+ 'limit_to' => isset($_POST['limit_to']) ? $_POST['limit_to'] : null,
+ 'limit_from' => isset($_POST['limit_from']) ? $_POST['limit_from'] : null,
+ 'unlim_num_rows' => $unlimNumRows,
+ 'number_of_rows' => $numberOfRows,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Quick Export
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsQuickExport()
+ {
+ global $cfg;
+ $saveDir = Util::userDir($cfg['SaveDir']);
+ $exportIsChecked = $this->checkboxCheck(
+ 'quick_export_onserver'
+ );
+ $exportOverwriteIsChecked = $this->checkboxCheck(
+ 'quick_export_onserver_overwrite'
+ );
+
+ return $this->template->render('display/export/options_quick_export', [
+ 'save_dir' => $saveDir,
+ 'export_is_checked' => $exportIsChecked,
+ 'export_overwrite_is_checked' => $exportOverwriteIsChecked,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Save Dir
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputSaveDir()
+ {
+ global $cfg;
+ $saveDir = Util::userDir($cfg['SaveDir']);
+ $exportIsChecked = $this->checkboxCheck(
+ 'onserver'
+ );
+ $exportOverwriteIsChecked = $this->checkboxCheck(
+ 'onserver_overwrite'
+ );
+
+ return $this->template->render('display/export/options_output_save_dir', [
+ 'save_dir' => $saveDir,
+ 'export_is_checked' => $exportIsChecked,
+ 'export_overwrite_is_checked' => $exportOverwriteIsChecked,
+ ]);
+ }
+
+
+ /**
+ * Prints Html For Export Options
+ *
+ * @param string $exportType Selected Export Type
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputFormat($exportType)
+ {
+ $trans = new Message();
+ $trans->addText(__('@SERVER@ will become the server name'));
+ if ($exportType == 'database' || $exportType == 'table') {
+ $trans->addText(__(', @DATABASE@ will become the database name'));
+ if ($exportType == 'table') {
+ $trans->addText(__(', @TABLE@ will become the table name'));
+ }
+ }
+
+ $msg = new Message(
+ __(
+ 'This value is interpreted using %1$sstrftime%2$s, '
+ . 'so you can use time formatting strings. '
+ . 'Additionally the following transformations will happen: %3$s. '
+ . 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'
+ )
+ );
+ $msg->addParamHtml(
+ '<a href="' . Core::linkURL(Core::getPHPDocLink('function.strftime.php'))
+ . '" target="documentation" title="' . __('Documentation') . '">'
+ );
+ $msg->addParamHtml('</a>');
+ $msg->addParam($trans);
+ $docUrl = Util::getDocuLink('faq', 'faq6-27');
+ $msg->addParamHtml(
+ '<a href="' . $docUrl . '" target="documentation">'
+ );
+ $msg->addParamHtml('</a>');
+
+ if (isset($_POST['filename_template'])) {
+ $filenameTemplate = $_POST['filename_template'];
+ } else {
+ if ($exportType == 'database') {
+ $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
+ 'pma_db_filename_template',
+ $GLOBALS['cfg']['Export']['file_template_database']
+ );
+ } elseif ($exportType == 'table') {
+ $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
+ 'pma_table_filename_template',
+ $GLOBALS['cfg']['Export']['file_template_table']
+ );
+ } else {
+ $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
+ 'pma_server_filename_template',
+ $GLOBALS['cfg']['Export']['file_template_server']
+ );
+ }
+ }
+
+ return $this->template->render('display/export/options_output_format', [
+ 'message' => $msg->getMessage(),
+ 'filename_template' => $filenameTemplate,
+ 'is_checked' => $this->checkboxCheck('remember_file_template'),
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Charset
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputCharset()
+ {
+ global $cfg;
+
+ return $this->template->render('display/export/options_output_charset', [
+ 'encodings' => Encoding::listEncodings(),
+ 'export_charset' => $cfg['Export']['charset'],
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Compression
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputCompression()
+ {
+ global $cfg;
+ if (isset($_POST['compression'])) {
+ $selectedCompression = $_POST['compression'];
+ } elseif (isset($cfg['Export']['compression'])) {
+ $selectedCompression = $cfg['Export']['compression'];
+ } else {
+ $selectedCompression = 'none';
+ }
+
+ // Since separate files export works with ZIP only
+ if (isset($cfg['Export']['as_separate_files'])
+ && $cfg['Export']['as_separate_files']
+ ) {
+ $selectedCompression = 'zip';
+ }
+
+ // zip and gzip encode features
+ $isZip = ($cfg['ZipDump'] && function_exists('gzcompress'));
+ $isGzip = ($cfg['GZipDump'] && function_exists('gzencode'));
+
+ return $this->template->render('display/export/options_output_compression', [
+ 'is_zip' => $isZip,
+ 'is_gzip' => $isGzip,
+ 'selected_compression' => $selectedCompression,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Radio
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputRadio()
+ {
+ return $this->template->render('display/export/options_output_radio', [
+ 'has_repopulate' => isset($_POST['repopulate']),
+ 'export_asfile' => $GLOBALS['cfg']['Export']['asfile'],
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options Checkbox - Separate files
+ *
+ * @param string $exportType Selected Export Type
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutputSeparateFiles($exportType)
+ {
+ $isChecked = $this->checkboxCheck('as_separate_files');
+
+ return $this->template->render('display/export/options_output_separate_files', [
+ 'is_checked' => $isChecked,
+ 'export_type' => $exportType,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options
+ *
+ * @param string $exportType Selected Export Type
+ *
+ * @return string
+ */
+ private function getHtmlForOptionsOutput($exportType)
+ {
+ global $cfg;
+
+ $hasAliases = isset($_SESSION['tmpval']['aliases'])
+ && ! Core::emptyRecursive($_SESSION['tmpval']['aliases']);
+ unset($_SESSION['tmpval']['aliases']);
+
+ $isCheckedLockTables = $this->checkboxCheck('lock_tables');
+ $isCheckedAsfile = $this->checkboxCheck('asfile');
+
+ $optionsOutputSaveDir = '';
+ if (isset($cfg['SaveDir']) && ! empty($cfg['SaveDir'])) {
+ $optionsOutputSaveDir = $this->getHtmlForOptionsOutputSaveDir();
+ }
+ $optionsOutputFormat = $this->getHtmlForOptionsOutputFormat($exportType);
+ $optionsOutputCharset = '';
+ if (Encoding::isSupported()) {
+ $optionsOutputCharset = $this->getHtmlForOptionsOutputCharset();
+ }
+ $optionsOutputCompression = $this->getHtmlForOptionsOutputCompression();
+ $optionsOutputSeparateFiles = '';
+ if ($exportType == 'server' || $exportType == 'database') {
+ $optionsOutputSeparateFiles = $this->getHtmlForOptionsOutputSeparateFiles(
+ $exportType
+ );
+ }
+ $optionsOutputRadio = $this->getHtmlForOptionsOutputRadio();
+
+ return $this->template->render('display/export/options_output', [
+ 'has_aliases' => $hasAliases,
+ 'export_type' => $exportType,
+ 'is_checked_lock_tables' => $isCheckedLockTables,
+ 'is_checked_asfile' => $isCheckedAsfile,
+ 'repopulate' => isset($_POST['repopulate']),
+ 'lock_tables' => isset($_POST['lock_tables']),
+ 'save_dir' => isset($cfg['SaveDir']) ? $cfg['SaveDir'] : null,
+ 'is_encoding_supported' => Encoding::isSupported(),
+ 'options_output_save_dir' => $optionsOutputSaveDir,
+ 'options_output_format' => $optionsOutputFormat,
+ 'options_output_charset' => $optionsOutputCharset,
+ 'options_output_compression' => $optionsOutputCompression,
+ 'options_output_separate_files' => $optionsOutputSeparateFiles,
+ 'options_output_radio' => $optionsOutputRadio,
+ ]);
+ }
+
+ /**
+ * Prints Html For Export Options
+ *
+ * @param string $exportType Selected Export Type
+ * @param string $db Selected DB
+ * @param string $table Selected Table
+ * @param string $multiValues Export selection
+ * @param string $numTables number of tables
+ * @param ExportPlugin[] $exportList Export List
+ * @param string $unlimNumRows Number of Rows
+ *
+ * @return string
+ */
+ public function getHtmlForOptions(
+ $exportType,
+ $db,
+ $table,
+ $multiValues,
+ $numTables,
+ $exportList,
+ $unlimNumRows
+ ) {
+ global $cfg;
+ $html = $this->getHtmlForOptionsMethod();
+ $html .= $this->getHtmlForOptionsFormatDropdown($exportList);
+ $html .= $this->getHtmlForOptionsSelection($exportType, $multiValues);
+
+ $tableObject = new Table($table, $db);
+ if (strlen($table) > 0 && empty($numTables) && ! $tableObject->isMerge()) {
+ $html .= $this->getHtmlForOptionsRows($db, $table, $unlimNumRows);
+ }
+
+ if (isset($cfg['SaveDir']) && ! empty($cfg['SaveDir'])) {
+ $html .= $this->getHtmlForOptionsQuickExport();
+ }
+
+ $html .= $this->getHtmlForAliasModalDialog();
+ $html .= $this->getHtmlForOptionsOutput($exportType);
+ $html .= $this->getHtmlForOptionsFormat($exportList);
+ return $html;
+ }
+
+ /**
+ * Generate Html For currently defined aliases
+ *
+ * @return string
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ private function getHtmlForCurrentAlias()
+ {
+ $result = '<table id="alias_data"><thead><tr><th colspan="4">'
+ . __('Defined aliases')
+ . '</th></tr></thead><tbody>';
+
+ $template = $this->template->load('export/alias_item');
+ if (isset($_SESSION['tmpval']['aliases'])) {
+ foreach ($_SESSION['tmpval']['aliases'] as $db => $dbData) {
+ if (isset($dbData['alias'])) {
+ $result .= $template->render([
+ 'type' => _pgettext('Alias', 'Database'),
+ 'name' => $db,
+ 'field' => 'aliases[' . $db . '][alias]',
+ 'value' => $dbData['alias'],
+ ]);
+ }
+ if (! isset($dbData['tables'])) {
+ continue;
+ }
+ foreach ($dbData['tables'] as $table => $tableData) {
+ if (isset($tableData['alias'])) {
+ $result .= $template->render([
+ 'type' => _pgettext('Alias', 'Table'),
+ 'name' => $db . '.' . $table,
+ 'field' => 'aliases[' . $db . '][tables][' . $table . '][alias]',
+ 'value' => $tableData['alias'],
+ ]);
+ }
+ if (! isset($tableData['columns'])) {
+ continue;
+ }
+ foreach ($tableData['columns'] as $column => $columnName) {
+ $result .= $template->render([
+ 'type' => _pgettext('Alias', 'Column'),
+ 'name' => $db . '.' . $table . '.' . $column,
+ 'field' => 'aliases[' . $db . '][tables][' . $table . '][colums][' . $column . ']',
+ 'value' => $columnName,
+ ]);
+ }
+ }
+ }
+ }
+
+ // Empty row for javascript manipulations
+ $result .= '</tbody><tfoot class="hide">' . $template->render([
+ 'type' => '',
+ 'name' => '',
+ 'field' => 'aliases_new',
+ 'value' => '',
+ ]) . '</tfoot>';
+
+ return $result . '</table>';
+ }