5 * @package phpMyAdmin-setup
6 * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
11 * Displays top part of the form
13 * @param string $action default: $_SERVER['REQUEST_URI']
14 * @param string $method 'post' or 'get'
15 * @param array $hidden_fields array of form hidden fields (key: field name)
17 function display_form_top($action = null, $method = 'post', $hidden_fields = null)
19 static $has_check_page_refresh = false;
21 if ($action === null) {
22 $action = $_SERVER['REQUEST_URI'];
24 if ($method != 'post') {
28 <form method
="<?php echo $method ?>" action
="<?php echo htmlspecialchars($action) ?>">
30 // we do validation on page refresh when browser remembers field values,
31 // add a field with known value which will be used for checks
32 if (!$has_check_page_refresh) {
33 $has_check_page_refresh = true;
34 echo '<input type="hidden" name="check_page_refresh" id="check_page_refresh"'
35 . ' value="" />' . "\n";
37 echo PMA_generate_common_hidden_inputs() . "\n";
38 echo PMA_getHiddenFields((array)$hidden_fields);
42 * Displays form tabs which are given by an array indexed by fieldset id
43 * ({@link display_fieldset_top}), with values being tab titles.
47 function display_tabs_top($tabs) {
50 <?php
foreach ($tabs as $tab_id => $tab_name): ?
>
51 <li
><a href
="#<?php echo $tab_id ?>"><?php
echo $tab_name ?
></a
></li
>
55 <div
class="tabs_contents">
61 * Displays top part of a fieldset
63 * @param string $title
64 * @param string $description
65 * @param array $errors
66 * @param array $attributes
68 function display_fieldset_top($title = '', $description = '', $errors = null, $attributes = array())
70 $attributes = array_merge(array('class' => 'optbox'), $attributes);
71 foreach ($attributes as $k => &$attr) {
72 $attr = $k . '="' . htmlspecialchars($attr) . '"';
75 echo '<fieldset ' . implode(' ', $attributes) . '>';
76 echo '<legend>' . $title . '</legend>';
77 if (!empty($description)) {
78 echo '<p>' . $description . '</p>';
80 // this must match with displayErrors() in scripts.js
81 if (is_array($errors) && count($errors) > 0) {
82 echo '<dl class="errors">';
83 foreach ($errors as $error) {
84 echo '<dd>' . $error . '</dd>';
89 <table width
="100%" cellspacing
="0">
94 * Displays input field
97 * o doc - (string) documentation link
98 * o errors - error array
99 * o setvalue - (string) shows button allowing to set poredefined value
100 * o show_restore_default - (boolean) whether show "restore default" button
101 * o values - key - value paris for <select> fields
102 * o values_escaped - (boolean) tells whether values array is already escaped (defaults to false)
103 * o values_disabled - (array)list of disabled values (keys from values)
104 * o wiki - (string) wiki link
106 * @param string $path
107 * @param string $name
108 * @param string $description
109 * @param string $type
110 * @param mixed $value
111 * @param bool $value_is_default
114 function display_input($path, $name, $description = '', $type, $value, $value_is_default = true, $opts = null)
116 $field_class = $value_is_default ?
'' : ' class="custom"';
117 $name_id = 'name="' . $path . '" id="' . $path . '"';
121 <label
for="<?php echo htmlspecialchars($path) ?>"><?php
echo $name ?
></label
>
122 <?php
if (!empty($opts['doc']) ||
!empty($opts['wiki'])): ?
>
124 <?php
if (!empty($opts['doc'])) { ?
><a href
="<?php echo $opts['doc'] ?>" target
="documentation"><img
class="icon" src
="../<?php echo $GLOBALS['cfg']['ThemePath'] ?>/original/img/b_help.png" width
="11" height
="11" alt
="Doc" title
="<?php echo $GLOBALS['strDocu'] ?>" /></a
><?php
} ?
>
125 <?php
if (!empty($opts['wiki'])){ ?
><a href
="<?php echo $opts['wiki'] ?>" target
="wiki"><img
class="icon" src
="../<?php echo $GLOBALS['cfg']['ThemePath'] ?>/original/img/b_info.png" width
="11" height
="11" alt
="Wiki" title
="Wiki" /></a
><?php
} ?
>
128 <?php
if (!empty($description)) { ?
><small
><?php
echo $description ?
></small
><?php
} ?
>
135 echo '<input type="text" size="50" ' . $name_id . $field_class
136 . ' value="' . htmlspecialchars($value) . '" />';
139 echo '<span class="checkbox' . ($value_is_default ?
'' : ' custom')
140 . '"><input type="checkbox" ' . $name_id
141 . ($value ?
' checked="checked"' : '') . ' /></span>';
144 echo '<select ' . $name_id . $field_class . '>';
145 $escape = !(isset($opts['values_escaped']) && $opts['values_escaped']);
146 $values_disabled = isset($opts['values_disabled'])
147 ?
array_flip($opts['values_disabled']) : array();
148 foreach ($opts['values'] as $opt_value => $opt_name) {
149 // set names for boolean values
150 if (is_bool($opt_name)) {
151 $opt_name = $GLOBALS['strSetup' . ($opt_value ?
'True' : 'False')];
153 // cast boolean values to integers
154 $display_value = is_bool($opt_value) ?
(int) $opt_value : $opt_value;
155 // escape if necessary
157 $display = htmlspecialchars($opt_name);
158 $display_value = htmlspecialchars($display_value);
160 $display = $opt_name;
162 // compare with selected value
163 // boolean values are cast to integers when used as array keys
164 $selected = is_bool($value)
165 ?
(int) $value === $opt_value
166 : $opt_value === $value;
167 echo '<option value="' . $display_value . '"'
168 . ($selected ?
' selected="selected"' : '')
169 . (isset($values_disabled[$opt_value]) ?
' disabled="disabled"' : '')
170 . '>' . $display . '</option>';
175 echo '<textarea cols="40" rows="5" ' . $name_id . $field_class . '>'
176 . htmlspecialchars(implode("\n", $value))
180 if (isset($opts['setvalue']) && $opts['setvalue']) {
182 <a
class="set-value" href
="#<?php echo "$path={$opts['setvalue']}" ?>" title
="<?php echo sprintf($GLOBALS['strSetupSetValue'], htmlspecialchars($opts['setvalue'])) ?>" style
="display:none"><img alt
="set-value" src
="../<?php echo $GLOBALS['cfg']['ThemePath'] ?>/original/img/b_edit.png" width
="16" height
="16" /></a
>
185 if (isset($opts['show_restore_default']) && $opts['show_restore_default']) {
187 <a
class="restore-default" href
="#<?php echo $path ?>" title
="<?php echo $GLOBALS['strSetupRestoreDefaultValue'] ?>" style
="display:none"><img alt
="restore-default" src
="../<?php echo $GLOBALS['cfg']['ThemePath'] ?>/original/img/s_reload.png" width
="16" height
="16" /></a
>
190 // this must match with displayErrors() in scripts.js
191 if (isset($opts['errors']) && !empty($opts['errors'])) {
192 echo "\n <dl class=\"inline_errors\">";
193 foreach ($opts['errors'] as $error) {
194 echo '<dd>' . htmlspecialchars($error) . '</dd>';
206 * Displays bottom part of a fieldset
208 * @param array $js_array
210 function display_fieldset_bottom()
214 <td colspan
="2" class="lastrow">
215 <input type
="submit" name
="submit_save" value
="<?php echo $GLOBALS['strSave'] ?>" class="green" />
216 <input type
="button" name
="submit_reset" value
="<?php echo $GLOBALS['strReset'] ?>" />
226 * Displays simple bottom part of a fieldset (without submit buttons)
228 function display_fieldset_bottom_simple()
240 function display_tabs_bottom() {
245 * Displays bottom part of the form
247 function display_form_bottom()
253 * Appends JS validation code to $js_array
255 * @param string $field_id
256 * @param string $validator
257 * @param array $js_array
259 function js_validate($field_id, $validator, &$js_array) {
260 $js_array[] = "validateField('$field_id', '$validator', true)";
264 * Displays JavaScript code
266 * @param array $js_array
268 function display_js($js_array) {
269 if (empty($js_array)) {
273 <script type
="text/javascript">
274 <?php
echo implode(";\n", $js_array) . ";\n" ?
>
280 * Displays error list
282 * @param string $name
283 * @param array $error_list
285 function display_errors($name, $error_list) {
287 echo '<dt>' . htmlspecialchars($name) . '</dt>';
288 foreach ($error_list as $error) {
289 echo '<dd>' . htmlspecialchars($error) . '</dd>';