/** * Displays top part of the form * * @uses PMA_generate_common_hidden_inputs() * @uses PMA_getHiddenFields() * @param string $action default: $_SERVER['REQUEST_URI'] * @param string $method 'post' or 'get' * @param array $hidden_fields array of form hidden fields (key: field name) */ function display_form_top($action = null, $method = 'post', $hidden_fields = null) { static $has_check_page_refresh = false; if ($action === null) { $action = $_SERVER['REQUEST_URI']; } if ($method != 'post') { $method = 'get'; } ?> <form method="<?php echo $method; ?> " action="<?php echo htmlspecialchars($action); ?> " class="config-form"> <input type="hidden" name="tab_hash" value="" /> <?php // we do validation on page refresh when browser remembers field values, // add a field with known value which will be used for checks if (!$has_check_page_refresh) { $has_check_page_refresh = true; echo '<input type="hidden" name="check_page_refresh" id="check_page_refresh"' . ' value="" />' . "\n"; } echo PMA_generate_common_hidden_inputs('', '', 0, 'server') . "\n"; echo PMA_getHiddenFields((array) $hidden_fields); }
/** * Displays top part of the form * * @param string $action default: $_SERVER['REQUEST_URI'] * @param string $method 'post' or 'get' * @param array $hidden_fields array of form hidden fields (key: field name) * * @return void */ function PMA_displayFormTop($action = null, $method = 'post', $hidden_fields = null) { static $has_check_page_refresh = false; if ($action === null) { $action = $_SERVER['REQUEST_URI']; } if ($method != 'post') { $method = 'get'; } echo '<form method="' . $method . '" action="' . htmlspecialchars($action) . '" class="config-form disableAjax">'; echo '<input type="hidden" name="tab_hash" value="" />'; // we do validation on page refresh when browser remembers field values, // add a field with known value which will be used for checks if (!$has_check_page_refresh) { $has_check_page_refresh = true; echo '<input type="hidden" name="check_page_refresh" ' . ' id="check_page_refresh" value="" />' . "\n"; } echo PMA_URL_getHiddenInputs('', '', 0, 'server') . "\n"; echo PMA_getHiddenFields((array) $hidden_fields); }
/** * generates the error report form to collect user description and preview the * report before being sent * * @return String the form */ function PMA_getErrorReportForm() { $html = ""; $html .= '<form action="error_report.php" method="post" name="report_frm"' . ' id="report_frm" class="ajax">' . '<fieldset style="padding-top:0px">'; $html .= '<p>' . __('phpMyAdmin has encountered an error. We have collected data about' . ' this error as well as information about relevant configuration' . ' settings to send to the phpMyAdmin team to help us in' . ' debugging the problem.') . '</p>'; $html .= '<div class="label"><label><p>' . __('You may examine the data in the error report:') . '</p></label></div>' . '<pre class="report-data">' . htmlspecialchars(PMA_getPrettyReportData()) . '</pre>'; $html .= '<div class="label"><label><p>' . __('Please explain the steps that lead to the error:') . '</p></label></div>' . '<textarea class="report-description" name="description"' . 'id="report_description"></textarea>'; $html .= '<input type="checkbox" name="always_send"' . ' id="always_send_checkbox"/>' . '<label for="always_send_checkbox">' . __('Automatically send report next time') . '</label>'; $html .= '</fieldset>'; $html .= PMA_URL_getHiddenInputs(); $reportData = PMA_getReportData(); if (!empty($reportData)) { $html .= PMA_getHiddenFields($reportData); } $html .= '</form>'; return $html; }
/** * Prepare sort by key dropdown - html code segment * * @param Index[] $indexes the indexes of the table for sort criteria * @param string $sort_expression the sort expression * @param string $unsorted_sql_query the unsorted sql query * * @return string $drop_down_html html content * * @access private * * @see _getTableHeaders() */ private function _getSortByKeyDropDown($indexes, $sort_expression, $unsorted_sql_query) { $drop_down_html = ''; $drop_down_html .= '<form action="sql.php" method="post" ' . 'class="print_ignore">' . "\n" . PMA_URL_getHiddenInputs($this->__get('db'), $this->__get('table')) . PMA_getHiddenFields(array('sort_by_key' => '1')) . __('Sort by key') . ': <select name="sql_query" class="autosubmit">' . "\n"; $used_index = false; $local_order = isset($sort_expression) ? $sort_expression : ''; foreach ($indexes as $index) { $asc_sort = '`' . implode('` ASC, `', array_keys($index->getColumns())) . '` ASC'; $desc_sort = '`' . implode('` DESC, `', array_keys($index->getColumns())) . '` DESC'; $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort; if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|' . 'FOR UPDATE|LOCK IN SHARE MODE))@is', $unsorted_sql_query, $my_reg)) { $unsorted_sql_query_first_part = $my_reg[1]; $unsorted_sql_query_second_part = $my_reg[2]; } else { $unsorted_sql_query_first_part = $unsorted_sql_query; $unsorted_sql_query_second_part = ''; } $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query_first_part . "\n" . ' ORDER BY ' . $asc_sort . $unsorted_sql_query_second_part) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($index->getName()) . ' (ASC)</option>'; $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query_first_part . "\n" . ' ORDER BY ' . $desc_sort . $unsorted_sql_query_second_part) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($index->getName()) . ' (DESC)</option>'; } $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . __('None') . '</option>' . '</select>' . "\n" . '</form>' . "\n"; return $drop_down_html; }
/** * create hidden form fields from array with name => value * * <code> * $values = array( * 'aaa' => aaa, * 'bbb' => array( * 'bbb_0', * 'bbb_1', * ), * 'ccc' => array( * 'a' => 'ccc_a', * 'b' => 'ccc_b', * ), * ); * echo PMA_getHiddenFields($values); * * // produces: * <input type="hidden" name="aaa" Value="aaa" /> * <input type="hidden" name="bbb[0]" Value="bbb_0" /> * <input type="hidden" name="bbb[1]" Value="bbb_1" /> * <input type="hidden" name="ccc[a]" Value="ccc_a" /> * <input type="hidden" name="ccc[b]" Value="ccc_b" /> * </code> * * @param array $values hidden values * @param string $pre prefix * * @return string form fields of type hidden */ function PMA_getHiddenFields($values, $pre = '') { $fields = ''; foreach ($values as $name => $value) { if (!empty($pre)) { $name = $pre . '[' . $name . ']'; } if (is_array($value)) { $fields .= PMA_getHiddenFields($value, $name); } else { // do not generate an ending "\n" because // PMA_URL_getHiddenInputs() is sometimes called // from a JS document.write() $fields .= '<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />'; } } return $fields; }
/** * Generates the HTML code for displaying the fast filter for tables * * @param Node $node The node for which to generate the fast filter html * * @return string LI element used for the fast filter */ private function _fastFilterHtml($node) { $retval = ''; $filter_db_min = (int) $GLOBALS['cfg']['NavigationTreeDisplayDbFilterMinimum']; $filter_item_min = (int) $GLOBALS['cfg']['NavigationTreeDisplayItemFilterMinimum']; if ($node === $this->_tree && $this->_tree->getPresence() >= $filter_db_min) { $url_params = array('pos' => 0); $retval .= '<li class="fast_filter db_fast_filter">'; $retval .= '<form class="ajax fast_filter">'; $retval .= PMA_getHiddenFields($url_params); $retval .= '<input class="searchClause" type="text"'; $retval .= ' name="searchClause" accesskey="q"'; // allow html5 placeholder attribute $placeholder_key = 'value'; if (PMA_USR_BROWSER_AGENT !== 'IE' || PMA_USR_BROWSER_VER > 9) { $placeholder_key = 'placeholder'; } $retval .= " {$placeholder_key}='" . __('Filter databases by name or regex'); $retval .= "' />"; $retval .= '<span title="' . __('Clear fast filter') . '">X</span>'; $retval .= "</form>"; $retval .= "</li>"; } else { if ($node->type == Node::CONTAINER && ($node->real_name == 'tables' || $node->real_name == 'views' || $node->real_name == 'functions' || $node->real_name == 'procedures' || $node->real_name == 'events') && method_exists($node->realParent(), 'getPresence') && $node->realParent()->getPresence($node->real_name) >= $filter_item_min) { $paths = $node->getPaths(); $url_params = array('pos' => $this->_pos, 'aPath' => $paths['aPath'], 'vPath' => $paths['vPath'], 'pos2_name' => $node->real_name, 'pos2_value' => 0); $retval .= "<li class='fast_filter'>"; $retval .= "<form class='ajax fast_filter'>"; $retval .= PMA_getHiddenFields($url_params); $retval .= "<input class='searchClause' type='text'"; $retval .= " name='searchClause2'"; // allow html5 placeholder attribute $placeholder_key = 'value'; if (PMA_USR_BROWSER_AGENT !== 'IE' || PMA_USR_BROWSER_VER > 9) { $placeholder_key = 'placeholder'; } $retval .= " {$placeholder_key}='" . __('Filter by name or regex') . "' />"; $retval .= "<span title='" . __('Clear fast filter') . "'>X</span>"; $retval .= "</form>"; $retval .= "</li>"; } } return $retval; }
/** * Generates the HTML code for displaying the fast filter for tables * * @param Node $node The node for which to generate the fast filter html * * @return string LI element used for the fast filter */ private function _fastFilterHtml($node) { $retval = ''; if ($node === $this->_tree && $this->_tree->getPresence() >= (int) $GLOBALS['cfg']['NavigationTreeDisplayDbFilterMinimum']) { $url_params = array('pos' => 0); $retval .= "<ul>"; $retval .= "<li class='fast_filter db_fast_filter'>"; $retval .= "<form class='ajax fast_filter'>"; $retval .= PMA_getHiddenFields($url_params); $retval .= "<input class='searchClause' name='searchClause'"; $retval .= " value='" . __('filter databases by name') . "' />"; $retval .= "<span title='" . __('Clear Fast Filter') . "'>X</span>"; $retval .= "</form>"; $retval .= "</li>"; $retval .= "</ul>"; } else { if ($node->type == Node::CONTAINER && ($node->real_name == 'tables' || $node->real_name == 'views' || $node->real_name == 'functions' || $node->real_name == 'procedures' || $node->real_name == 'events') && $node->realParent()->getPresence($node->real_name) >= (int) $GLOBALS['cfg']['NavigationTreeDisplayItemFilterMinimum']) { $paths = $node->getPaths(); $url_params = array('pos' => $this->_pos, 'aPath' => $paths['aPath'], 'vPath' => $paths['vPath'], 'pos2_name' => $node->real_name, 'pos2_value' => 0); $retval .= "<li class='fast_filter'>"; $retval .= "<form class='ajax fast_filter'>"; $retval .= PMA_getHiddenFields($url_params); $retval .= "<input class='searchClause' name='searchClause2'"; $retval .= " value='" . __('filter items by name') . "' />"; $retval .= "<span title='" . __('Clear Fast Filter') . "'>X</span>"; $retval .= "</form>"; $retval .= "</li>"; } } return $retval; }
/** * generates the error report form to collect user description and preview the * report before being sent * * @return String the form */ function PMA_getErrorReportForm() { $datas = array('report_data' => PMA_getPrettyReportData(), 'hidden_inputs' => PMA_URL_getHiddenInputs(), 'hidden_fields' => null); $reportData = PMA_getReportData(); if (!empty($reportData)) { $datas['hidden_fields'] = PMA_getHiddenFields($reportData); } return PMA\libraries\Template::get('error/report_form')->render($datas); }
/** * Renders the server selection in list or selectbox form, or option tags only * * @param boolean $not_only_options whether to include form tags or not * @param boolean $omit_fieldset whether to omit fieldset tag or not * * @return string */ function PMA_selectServer($not_only_options, $omit_fieldset) { $retval = ''; // Show as list? if ($not_only_options) { $list = $GLOBALS['cfg']['DisplayServersList']; $not_only_options = !$list; } else { $list = false; } if ($not_only_options) { $retval .= '<form method="post" action="' . $GLOBALS['cfg']['DefaultTabServer'] . '" class="disableAjax">'; $retval .= PMA_getHiddenFields(array('token' => $_SESSION[' PMA_token '])); if (!$omit_fieldset) { $retval .= '<fieldset>'; } $retval .= '<label for="select_server">' . __('Current Server:') . '</label> '; $retval .= '<select name="server" id="select_server" class="autosubmit">'; $retval .= '<option value="">(' . __('Servers') . ') ...</option>' . "\n"; } elseif ($list) { $retval .= __('Current Server:') . '<br />'; $retval .= '<ul id="list_server">'; } foreach ($GLOBALS['cfg']['Servers'] as $key => $server) { if (empty($server['host'])) { continue; } if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) { $selected = 1; } else { $selected = 0; } if (!empty($server['verbose'])) { $label = $server['verbose']; } else { $label = $server['host']; if (!empty($server['port'])) { $label .= ':' . $server['port']; } } if (!empty($server['only_db'])) { if (!is_array($server['only_db'])) { $label .= ' - ' . $server['only_db']; // try to avoid displaying a too wide selector } elseif (count($server['only_db']) < 4) { $label .= ' - ' . implode(', ', $server['only_db']); } } if (!empty($server['user']) && $server['auth_type'] == 'config') { $label .= ' (' . $server['user'] . ')'; } if ($list) { $retval .= '<li>'; if ($selected) { $retval .= '<strong>' . htmlspecialchars($label) . '</strong>'; } else { $retval .= '<a class="disableAjax item" href="' . $GLOBALS['cfg']['DefaultTabServer'] . PMA_URL_getCommon(array('server' => $key)) . '" >' . htmlspecialchars($label) . '</a>'; } $retval .= '</li>'; } else { $retval .= '<option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n"; } } // end while if ($not_only_options) { $retval .= '</select>'; if (!$omit_fieldset) { $retval .= '</fieldset>'; } $retval .= '</form>'; } elseif ($list) { $retval .= '</ul>'; } return $retval; }