/** * Returns the html for the sub-page heading * * @param string $type Sub page type * @param string $link Link to the official MySQL documentation * @param bool $is_image Display image or icon, true: image, false: icon * * @return string */ function PMA_getHtmlForSubPageHeader($type, $link = '', $is_image = true) { //array contains Sub page icon and text $header = array(); $header['variables']['image'] = 's_vars.png'; $header['variables']['text'] = __('Server variables and settings'); $header['engines']['image'] = 'b_engine.png'; $header['engines']['text'] = __('Storage Engines'); $header['plugins']['image'] = 'b_engine.png'; $header['plugins']['text'] = __('Plugins'); $header['binlog']['image'] = 's_tbl.png'; $header['binlog']['text'] = __('Binary log'); $header['collations']['image'] = 's_asci.png'; $header['collations']['text'] = __('Character Sets and Collations'); $header['replication']['image'] = 's_replication.png'; $header['replication']['text'] = __('Replication'); $header['database_statistics']['image'] = 's_db.png'; $header['database_statistics']['text'] = __('Databases statistics'); $header['databases']['image'] = 's_db.png'; $header['databases']['text'] = __('Databases'); $header['privileges']['image'] = 'b_usrlist.png'; $header['privileges']['text'] = __('Privileges'); if ($is_image) { $html = '<h2>' . "\n" . PMA\libraries\Util::getImage($header[$type]['image']) . ' ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n"; } else { $html = '<h2>' . "\n" . PMA\libraries\Util::getIcon($header[$type]['image']) . ' ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n"; } return $html; }
/** * Test for PMA_getHtmlForCreateTable * * @return void */ public function testPMAGetHtmlForCreateTable() { $db = "pma_db"; //Call the test function $html = PMA_getHtmlForCreateTable($db); //getImage $this->assertContains(PMA\libraries\Util::getImage('b_table_add.png'), $html); //__('Create table') $this->assertContains(__('Create table'), $html); //PMA_URL_getHiddenInputs $this->assertContains(PMA_URL_getHiddenInputs($db), $html); //label $this->assertContains(__('Name'), $html); $this->assertContains(__('Number of columns'), $html); //button $this->assertContains(__('Go'), $html); }
/** * setup HTML for a given Storage Engine * * @return string */ function PMA_getHtmlForSpecifiedServerEngines() { /** * Displays details about a given Storage Engine */ $html = ''; $engine_plugin = StorageEngine::getEngine($_REQUEST['engine']); $html .= '<h2>' . "\n" . PMA\libraries\Util::getImage('b_engine.png') . ' ' . htmlspecialchars($engine_plugin->getTitle()) . "\n" . ' ' . PMA\libraries\Util::showMySQLDocu($engine_plugin->getMysqlHelpPage()) . "\n" . '</h2>' . "\n\n"; $html .= '<p>' . "\n" . ' <em>' . "\n" . ' ' . htmlspecialchars($engine_plugin->getComment()) . "\n" . ' </em>' . "\n" . '</p>' . "\n\n"; $infoPages = $engine_plugin->getInfoPages(); if (!empty($infoPages) && is_array($infoPages)) { $html .= '<p>' . "\n" . ' <strong>[</strong>' . "\n"; if (empty($_REQUEST['page'])) { $html .= ' <strong>' . __('Variables') . '</strong>' . "\n"; } else { $html .= ' <a href="server_engines.php' . PMA_URL_getCommon(array('engine' => $_REQUEST['engine'])) . '">' . __('Variables') . '</a>' . "\n"; } foreach ($infoPages as $current => $label) { $html .= ' <strong>|</strong>' . "\n"; if (isset($_REQUEST['page']) && $_REQUEST['page'] == $current) { $html .= ' <strong>' . $label . '</strong>' . "\n"; } else { $html .= ' <a href="server_engines.php' . PMA_URL_getCommon(array('engine' => $_REQUEST['engine'], 'page' => $current)) . '">' . htmlspecialchars($label) . '</a>' . "\n"; } } unset($current, $label); $html .= ' <strong>]</strong>' . "\n" . '</p>' . "\n\n"; } unset($infoPages, $page_output); if (!empty($_REQUEST['page'])) { $page_output = $engine_plugin->getPage($_REQUEST['page']); } if (!empty($page_output)) { $html .= $page_output; } else { $html .= '<p> ' . $engine_plugin->getSupportInformationMessage() . "\n" . '</p>' . "\n" . $engine_plugin->getHtmlVariables(); } return $html; }
echo '</li>'; } // ThemeManager if available if ($GLOBALS['cfg']['ThemeManager']) { echo '<li id="li_select_theme" class="no_bullets">'; echo PMA\libraries\Util::getImage('s_theme.png'), " ", $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox(); echo '</li>'; } echo '<li id="li_select_fontsize">'; echo PMA\libraries\Config::getFontsizeForm(); echo '</li>'; echo '</ul>'; // User preferences if ($server > 0) { echo '<ul>'; PMA_printListItem(PMA\libraries\Util::getImage('b_tblops.png') . " " . __('More settings'), 'li_user_preferences', 'prefs_manage.php' . $common_url_query, null, null, null, "no_bullets"); echo '</ul>'; } echo '</div>'; echo '</div>'; echo '<div id="main_pane_right">'; if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { echo '<div class="group">'; echo '<h2>', __('Database server'), '</h2>'; echo '<ul>', "\n"; PMA_printListItem(__('Server:') . ' ' . $server_info, 'li_server_info'); PMA_printListItem(__('Server type:') . ' ' . PMA\libraries\Util::getServerType(), 'li_server_type'); PMA_printListItem(__('Server version:') . ' ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, 'li_server_version'); PMA_printListItem(__('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(), 'li_mysql_proto'); PMA_printListItem(__('User:'******' ' . htmlspecialchars($mysql_cur_user_and_host), 'li_user_info'); echo ' <li id="li_select_mysql_charset">';
/** * Prints Html For Display Export options * * @param String $import_type Import type: server, database, table * @param String $db Selected DB * @param String $table Selected Table * * @return string */ function PMA_getHtmlForImportOptions($import_type, $db, $table) { $html = ' <div class="exportoptions" id="header">'; $html .= ' <h2>'; $html .= PMA\libraries\Util::getImage('b_import.png', __('Import')); if ($import_type == 'server') { $html .= __('Importing into the current server'); } elseif ($import_type == 'database') { $import_str = sprintf(__('Importing into the database "%s"'), htmlspecialchars($db)); $html .= $import_str; } else { $import_str = sprintf(__('Importing into the table "%s"'), htmlspecialchars($table)); $html .= $import_str; } $html .= ' </h2>'; $html .= ' </div>'; return $html; }
/** * Prints Html For Export Options Header * * @param String $export_type Selected Export Type * @param String $db Selected DB * @param String $table Selected Table * * @return string */ function PMA_getHtmlForExportOptionHeader($export_type, $db, $table) { $html = '<div class="exportoptions" id="header">'; $html .= '<h2>'; $html .= PMA\libraries\Util::getImage('b_export.png', __('Export')); if ($export_type == 'server') { $html .= __('Exporting databases from the current server'); } elseif ($export_type == 'database') { $html .= sprintf(__('Exporting tables from "%s" database'), htmlspecialchars($db)); } else { $html .= sprintf(__('Exporting rows from "%s" table'), htmlspecialchars($table)); } $html .= '</h2>'; $html .= '</div>'; return $html; }
/** * Function to get html for field * * @param int $index index * @param array $field field * @param string $style style * * @return string */ function PMA_getHtmlForField($index, $field, $style) { $html = '<tr class="noclick ' . $style . '">'; $html .= '<td>' . $index . '</td>'; $html .= '<td><b>' . htmlspecialchars($field['Field']); if ($field['Key'] == 'PRI') { $html .= ' ' . PMA\libraries\Util::getImage('b_primary.png', __('Primary')); } elseif (!empty($field['Key'])) { $html .= ' ' . PMA\libraries\Util::getImage('bd_primary.png', __('Index')); } $html .= '</b></td>'; $html .= "\n"; $html .= '<td>' . htmlspecialchars($field['Type']) . '</td>'; $html .= '<td>' . htmlspecialchars($field['Collation']) . '</td>'; $html .= '<td>' . ($field['Null'] == 'YES' ? __('Yes') : __('No')) . '</td>'; $html .= '<td>'; if (isset($field['Default'])) { $extracted_columnspec = PMA\libraries\Util::extractColumnSpec($field['Type']); if ($extracted_columnspec['type'] == 'bit') { // here, $field['Default'] contains something like b'010' $html .= PMA\libraries\Util::convertBitDefaultValue($field['Default']); } else { $html .= htmlspecialchars($field['Default']); } } else { if ($field['Null'] == 'YES') { $html .= '<i>NULL</i>'; } else { $html .= '<i>' . _pgettext('None for default', 'None') . '</i>'; } } $html .= '</td>'; $html .= '<td>' . htmlspecialchars($field['Extra']) . '</td>'; $html .= '<td>' . htmlspecialchars($field['Comment']) . '</td>'; $html .= '</tr>'; return $html; }
/** * Prints link templates * * @return string */ function PMA_getHtmlForLinkTemplates() { $url = 'server_variables.php' . PMA_URL_getCommon(); $output = '<a style="display: none;" href="' . $url . '" class="ajax saveLink">'; $output .= PMA\libraries\Util::getIcon('b_save.png', __('Save')) . '</a> '; $output .= '<a style="display: none;" href="#" class="cancelLink">'; $output .= PMA\libraries\Util::getIcon('b_close.png', __('Cancel')) . '</a> '; $output .= PMA\libraries\Util::getImage('b_help.png', __('Documentation'), array('style' => 'display:none', 'id' => 'docImage')); return $output; }
/** * Sanitizes $message, taking into account our special codes * for formatting. * * If you want to include result in element attribute, you should escape it. * * Examples: * * <p><?php echo PMA_sanitize($foo); ?></p> * * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a> * * @param string $message the message * @param boolean $escape whether to escape html in result * @param boolean $safe whether string is safe (can keep < and > chars) * * @return string the sanitized message */ function PMA_sanitize($message, $escape = false, $safe = false) { if (!$safe) { $message = strtr($message, array('<' => '<', '>' => '>')); } /* Interpret bb code */ $replace_pairs = array('[em]' => '<em>', '[/em]' => '</em>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[/doc]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>', '[conferr]' => '<iframe src="show_config_errors.php" />', '[dochelpicon]' => PMA\libraries\Util::getImage('b_help.png', __('Documentation'))); $message = strtr($message, $replace_pairs); /* Match links in bb code ([a@url@target], where @target is options) */ $pattern = '/\\[a@([^]"@]*)(@([^]"]*))?\\]/'; /* Find and replace all links */ $message = preg_replace_callback($pattern, 'PMA_replaceBBLink', $message); /* Replace documentation links */ $message = preg_replace_callback('/\\[doc@([a-zA-Z0-9_-]+)(@([a-zA-Z0-9_-]*))?\\]/', 'PMA_replaceDocLink', $message); /* Possibly escape result */ if ($escape) { $message = htmlspecialchars($message); } return $message; }
/** * Returns the html for Column Order with Sort * * @param bool $is_superuser User status * @param bool $is_allowUserDropDb Allow user drop database * @param Array $_url_params Url params * @param string $sort_by sort column name * @param string $sort_order order * @param array $column_order column order * @param array $first_database database to show * * @return string */ function PMA_getHtmlForColumnOrderWithSort($is_superuser, $is_allowUserDropDb, $_url_params, $sort_by, $sort_order, $column_order, $first_database) { $html = ($is_superuser || $is_allowUserDropDb ? ' <th></th>' . "\n" : '') . ' <th><a href="server_databases.php' . PMA_URL_getCommon($_url_params) . '">' . "\n" . ' ' . __('Database') . "\n" . ($sort_by == 'SCHEMA_NAME' ? ' ' . PMA\libraries\Util::getImage('s_' . $sort_order . '.png', $sort_order == 'asc' ? __('Ascending') : __('Descending')) . "\n" : '') . ' </a></th>' . "\n"; $table_columns = 3; foreach ($column_order as $stat_name => $stat) { if (!array_key_exists($stat_name, $first_database)) { continue; } if ($stat['format'] === 'byte') { $table_columns += 2; $colspan = ' colspan="2"'; } else { $table_columns++; $colspan = ''; } $_url_params['sort_by'] = $stat_name; $_url_params['sort_order'] = $sort_by == $stat_name && $sort_order == 'desc' ? 'asc' : 'desc'; $html .= ' <th' . $colspan . '>' . '<a href="server_databases.php' . PMA_URL_getCommon($_url_params) . '">' . "\n" . ' ' . $stat['disp_name'] . "\n" . ($sort_by == $stat_name ? ' ' . PMA\libraries\Util::getImage('s_' . $sort_order . '.png', $sort_order == 'asc' ? __('Ascending') : __('Descending')) . "\n" : '') . ' </a></th>' . "\n"; } return $html; }
* * @package PhpMyAdmin */ if (!defined('PHPMYADMIN')) { exit; } /** * */ require_once './libraries/check_user_privileges.lib.php'; if ($is_create_db_priv) { // The user is allowed to create a db $html .= '<form method="post" action="db_create.php"' . ' id="create_database_form" class="ajax"><strong>'; $html .= '<label for="text_create_db">' . PMA\libraries\Util::getImage('b_newdb.png') . " " . __('Create database') . '</label> ' . PMA\libraries\Util::showMySQLDocu('CREATE_DATABASE'); $html .= '</strong><br />'; $html .= PMA_URL_getHiddenInputs('', '', 5); $html .= '<input type="hidden" name="reload" value="1" />'; $html .= '<input type="text" name="new_db" value="' . $db_to_create . '" maxlength="64" class="textfield" id="text_create_db" ' . 'required placeholder="' . __('Database name') . '"/>'; include_once './libraries/mysql_charsets.inc.php'; $html .= PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, true); if (!empty($dbstats)) { $html .= '<input type="hidden" name="dbstats" value="1" />'; } $html .= '<input type="submit" value="' . __('Create') . '" id="buttonGo" />'; $html .= '</form>'; } else { $html .= '<!-- db creation no privileges message -->'; $html .= '<strong>' . __('Create database:') . ' ' . PMA\libraries\Util::showMySQLDocu('CREATE_DATABASE') . '</strong><br />'; $html .= '<span class="noPrivileges">' . PMA\libraries\Util::getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle')) . '' . __('No Privileges') . '</span>'; } // end create db form or message