/**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     /**
      * Does the common work
      */
     include_once 'libraries/server_common.inc.php';
     $this->response->addHTML(PMA_getHtmlForSubPageHeader('collations'));
     $this->response->addHTML($this->_getHtmlForCharsets(Charsets::getMySQLCharsets(), Charsets::getMySQLCollations(), Charsets::getMySQLCharsetsDescriptions(), Charsets::getMySQLCollationsDefault()));
 }
 /**
  * Displays the list of tables
  *
  * @return void
  */
 protected function displayTableList()
 {
     // table form
     $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
     $i = $sum_entries = 0;
     $overhead_check = '';
     $create_time_all = '';
     $update_time_all = '';
     $check_time_all = '';
     $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
     $row_count = 0;
     $sum_size = 0;
     $overhead_size = 0;
     $hidden_fields = array();
     $overall_approx_rows = false;
     foreach ($this->_tables as $keyname => $current_table) {
         // Get valid statistics whatever is the table type
         $drop_query = '';
         $drop_message = '';
         $overhead = '';
         $table_is_view = false;
         $table_encoded = urlencode($current_table['TABLE_NAME']);
         // Sets parameters for links
         $tbl_url_query = $this->_url_query . '&table=' . $table_encoded;
         // do not list the previous table's size info for a view
         list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
         $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
         if (!$curTable->isMerge()) {
             $sum_entries += $current_table['TABLE_ROWS'];
         }
         if (isset($current_table['Collation'])) {
             $collation = '<dfn title="' . Charsets::getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
         } else {
             $collation = '---';
         }
         if ($this->_is_show_stats) {
             if ($formatted_overhead != '') {
                 $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>&nbsp;' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
                 $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
             } else {
                 $overhead = '-';
             }
         }
         // end if
         if ($GLOBALS['cfg']['ShowDbStructureCharset']) {
             if (isset($current_table['Collation'])) {
                 $charset = mb_substr($collation, 0, mb_strpos($collation, "_"));
             } else {
                 $charset = '';
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
             $create_time = isset($current_table['Create_time']) ? $current_table['Create_time'] : '';
             if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
                 $create_time_all = $create_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
             $update_time = isset($current_table['Update_time']) ? $current_table['Update_time'] : '';
             if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
                 $update_time_all = $update_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
             $check_time = isset($current_table['Check_time']) ? $current_table['Check_time'] : '';
             if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
                 $check_time_all = $check_time;
             }
         }
         $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $truename = str_replace(' ', '&nbsp;', $truename);
         $i++;
         $row_count++;
         if ($table_is_view) {
             $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
         }
         /*
          * Always activate links for Browse, Search and Empty, even if
          * the icons are greyed, because
          * 1. for views, we don't know the number of rows at this point
          * 2. for tables, another source could have populated them since the
          *    page was generated
          *
          * I could have used the PHP ternary conditional operator but I find
          * the code easier to read without this operator.
          */
         $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
         $titles = Util::buildActionTitles();
         $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
         $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
         $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
         $empty_table = '';
         if (!$this->_db_is_system_schema) {
             $empty_table = '&nbsp;';
             if (!$table_is_view) {
                 $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
             }
             $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote($current_table['TABLE_NAME']));
             $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', '&nbsp;', htmlspecialchars($current_table['TABLE_NAME'])));
         }
         if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) {
             $row_count = 1;
             $this->response->addHTML('</tr></tbody></table></form>');
             $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
         }
         list($approx_rows, $show_superscript) = $this->isRowCountApproximated($current_table, $table_is_view);
         list($do, $ignored) = $this->getReplicationStatus($truename);
         $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $this->getTrackingIcon($truename), 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'charset' => isset($charset) ? $charset : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME']))));
         $overall_approx_rows = $overall_approx_rows || $approx_rows;
     }
     // end foreach
     $this->response->addHTML('</tbody>');
     $db_collation = $this->dbi->getDbCollation($this->db);
     $db_charset = mb_substr($db_collation, 0, mb_strpos($db_collation, "_"));
     // Show Summary
     $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'db_charset' => $db_charset, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows)));
     $this->response->addHTML('</table>');
     //check all
     $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields)));
     $this->response->addHTML('</form>');
     //end of form
 }
示例#3
0
/**
 * Get HTML fieldset for Table option, it contains HTML table for options
 *
 * @param Table   $pma_table          Table object
 * @param string  $comment            Comment
 * @param array   $tbl_collation      table collation
 * @param string  $tbl_storage_engine table storage engine
 * @param string  $pack_keys          pack keys
 * @param string  $delay_key_write    delay key write
 * @param string  $auto_increment     value of auto increment
 * @param string  $transactional      value of transactional
 * @param string  $page_checksum      value of page checksum
 * @param string  $checksum           the checksum
 *
 * @return string $html_output
 */
function PMA_getTableOptionFieldset($pma_table, $comment, $tbl_collation, $tbl_storage_engine, $pack_keys, $delay_key_write, $auto_increment, $transactional, $page_checksum, $checksum)
{
    $html_output = '<fieldset>' . '<legend>' . __('Table options') . '</legend>';
    $html_output .= '<table>';
    $html_output .= PMA_getHtmlForRenameTable();
    $html_output .= PMA_getHtmlForTableComments($comment);
    //Storage engine
    $html_output .= '<tr><td class="vmiddle">' . __('Storage Engine') . '&nbsp;' . Util::showMySQLDocu('Storage_engines') . '</td>' . '<td>' . StorageEngine::getHtmlSelect('new_tbl_storage_engine', null, $tbl_storage_engine) . '</td>' . '</tr>';
    //Table character set
    $html_output .= '<tr><td class="vmiddle">' . __('Collation') . '</td>' . '<td>' . Charsets::getCollationDropdownBox('tbl_collation', null, $tbl_collation, false) . '</td>' . '</tr>';
    // Change all Column collations
    $html_output .= '<tr><td></td><td>' . '<input type="checkbox" name="change_all_collations" value="1" ' . 'id="checkbox_change_all_collations" />' . '<label for="checkbox_change_all_collations">' . __('Change all column collations') . '</label>' . '</td></tr>';
    if ($pma_table->isEngine(array('MYISAM', 'ARIA', 'ISAM'))) {
        $html_output .= PMA_getHtmlForPackKeys($pack_keys);
    }
    // end if (MYISAM|ISAM)
    if ($pma_table->isEngine(array('MYISAM', 'ARIA'))) {
        $html_output .= PMA_getHtmlForTableRow('new_checksum', 'CHECKSUM', $checksum);
        $html_output .= PMA_getHtmlForTableRow('new_delay_key_write', 'DELAY_KEY_WRITE', $delay_key_write);
    }
    // end if (MYISAM)
    if ($pma_table->isEngine('ARIA')) {
        $html_output .= PMA_getHtmlForTableRow('new_transactional', 'TRANSACTIONAL', $transactional);
        $html_output .= PMA_getHtmlForTableRow('new_page_checksum', 'PAGE_CHECKSUM', $page_checksum);
    }
    // end if (ARIA)
    if (strlen($auto_increment) > 0 && $pma_table->isEngine(array('MYISAM', 'ARIA', 'INNODB', 'PBXT'))) {
        $html_output .= '<tr><td class="vmiddle">' . '<label for="auto_increment_opt">AUTO_INCREMENT</label></td>' . '<td><input type="number" name="new_auto_increment" ' . 'id="auto_increment_opt"' . 'value="' . $auto_increment . '" /></td>' . '</tr> ';
    }
    // end if (MYISAM|INNODB)
    $possible_row_formats = PMA_getPossibleRowFormat();
    // for MYISAM there is also COMPRESSED but it can be set only by the
    // myisampack utility, so don't offer here the choice because if we
    // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
    // does not return a warning
    // (if the table was compressed, it can be seen on the Structure page)
    if (isset($possible_row_formats[$tbl_storage_engine])) {
        $current_row_format = mb_strtoupper($GLOBALS['showtable']['Row_format']);
        $html_output .= '<tr><td class="vmiddle">' . '<label for="new_row_format">ROW_FORMAT</label></td>' . '<td>';
        $html_output .= Util::getDropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format');
        $html_output .= '</td></tr>';
    }
    $html_output .= '</table>' . '</fieldset>';
    return $html_output;
}
/**
 * Prints Html For Display Import charset
 *
 * @return string
 */
function PMA_getHtmlForImportCharset()
{
    global $cfg;
    $html = '       <div class="formelementrow" id="charaset_of_file">';
    // charset of file
    if (Encoding::isSupported()) {
        $html .= '<label for="charset_of_file">' . __('Character set of the file:') . '</label>';
        $html .= '<select id="charset_of_file" name="charset_of_file" size="1">';
        foreach ($cfg['AvailableCharsets'] as $temp_charset) {
            $html .= '<option value="' . htmlentities($temp_charset) . '"';
            if (empty($cfg['Import']['charset']) && $temp_charset == 'utf-8' || $temp_charset == $cfg['Import']['charset']) {
                $html .= ' selected="selected"';
            }
            $html .= '>' . htmlentities($temp_charset) . '</option>';
        }
        $html .= ' </select><br />';
    } else {
        $html .= '<label for="charset_of_file">' . __('Character set of the file:') . '</label>' . "\n";
        $html .= Charsets::getCharsetDropdownBox('charset_of_file', 'charset_of_file', 'utf8', false);
    }
    // end if (recoding)
    $html .= '        </div>';
    return $html;
}
/**
 * build html for adding a new user defined column to central list
 *
 * @param string $db current database
 *
 * @return string html of the form to let user add a new user defined column to the
 *                list
 */
function PMA_getHTMLforAddNewColumn($db)
{
    $addNewColumn = '<div id="add_col_div"><a href="#">' . '<span>+</span> ' . __('Add new column') . '</a>' . '<form id="add_new" style="min-width:100%;display:none" ' . 'method="post" action="db_central_columns.php">' . URL::getHiddenInputs($db) . '<input type="hidden" name="add_new_column" value="add_new_column">' . '<table>';
    $addNewColumn .= PMA_getCentralColumnsTableHeader();
    $addNewColumn .= '<tr>' . '<td></td>' . '<td name="col_name" class="nowrap">' . PMA\libraries\Template::get('columns_definitions/column_name')->render(array('columnNumber' => 0, 'ci' => 0, 'ci_offset' => 0, 'columnMeta' => array(), 'cfgRelation' => array('centralcolumnswork' => false))) . '</td>' . '<td name = "col_type" class="nowrap">' . PMA\libraries\Template::get('columns_definitions/column_type')->render(array('columnNumber' => 0, 'ci' => 1, 'ci_offset' => 0, 'type_upper' => '', 'columnMeta' => array())) . '</td>' . '<td class="nowrap" name="col_length">' . PMA\libraries\Template::get('columns_definitions/column_length')->render(array('columnNumber' => 0, 'ci' => 2, 'ci_offset' => 0, 'length_values_input_size' => 8, 'length_to_display' => '')) . '</td>' . '<td class="nowrap" name="col_default">' . PMA\libraries\Template::get('columns_definitions/column_default')->render(array('columnNumber' => 0, 'ci' => 3, 'ci_offset' => 0, 'type_upper' => '', 'columnMeta' => array())) . '</td>' . '<td name="collation" class="nowrap">' . Charsets::getCollationDropdownBox('field_collation[0]', 'field_0_4', null, false) . '</td>' . '<td class="nowrap" name="col_attribute">' . PMA\libraries\Template::get('columns_definitions/column_attribute')->render(array('columnNumber' => 0, 'ci' => 5, 'ci_offset' => 0, 'extracted_columnspec' => array(), 'columnMeta' => array(), 'submit_attribute' => false)) . '</td>' . '<td class="nowrap" name="col_isNull">' . PMA\libraries\Template::get('columns_definitions/column_null')->render(array('columnNumber' => 0, 'ci' => 6, 'ci_offset' => 0, 'columnMeta' => array())) . '</td>' . '<td class="nowrap" name="col_extra">' . PMA\libraries\Template::get('columns_definitions/column_extra')->render(array('columnNumber' => 0, 'ci' => 7, 'ci_offset' => 0, 'columnMeta' => array())) . '</td>' . ' <td>' . '<input id="add_column_save" type="submit" ' . ' value="Save"/></td>' . '</tr>';
    $addNewColumn .= '</table></form></div>';
    return $addNewColumn;
}
示例#6
0
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">';
    echo '        ', __('Server charset:'), ' ' . '        <span lang="en" dir="ltr">';
    $unicode = Charsets::$mysql_charset_map['utf-8'];
    $charsets = Charsets::getMySQLCharsetsDescriptions();
    echo '           ', $charsets[$unicode], ' (' . $unicode, ')';
    echo '        </span>' . '    </li>' . '  </ul>' . ' </div>';
}
if ($GLOBALS['cfg']['ShowServerInfo']) {
    echo '<div class="group">';
    echo '<h2>', __('Web server'), '</h2>';
    echo '<ul>';
    if ($GLOBALS['cfg']['ShowServerInfo']) {
        PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
        if ($server > 0) {
            $client_version_str = $GLOBALS['dbi']->getClientInfo();
            if (preg_match('#\\d+\\.\\d+\\.\\d+#', $client_version_str)) {
                $client_version_str = 'libmysql - ' . $client_version_str;
            }
            PMA_printListItem(__('Database client version:') . ' ' . $client_version_str, 'li_mysql_client_version');
 /**
  * Handles creating a new database
  *
  * @return void
  */
 public function createDatabaseAction()
 {
     /**
      * Builds and executes the db creation sql query
      */
     $sql_query = 'CREATE DATABASE ' . Util::backquote($_POST['new_db']);
     if (!empty($_POST['db_collation'])) {
         list($db_charset) = explode('_', $_POST['db_collation']);
         $charsets = Charsets::getMySQLCharsets();
         $collations = Charsets::getMySQLCollations();
         if (in_array($db_charset, $charsets) && in_array($_POST['db_collation'], $collations[$db_charset])) {
             $sql_query .= ' DEFAULT' . Util::getCharsetQueryPart($_POST['db_collation']);
         }
     }
     $sql_query .= ';';
     $result = $GLOBALS['dbi']->tryQuery($sql_query);
     if (!$result) {
         // avoid displaying the not-created db name in header or navi panel
         $GLOBALS['db'] = '';
         $message = Message::rawError($GLOBALS['dbi']->getError());
         $this->response->setRequestStatus(false);
         $this->response->addJSON('message', $message);
     } else {
         $GLOBALS['db'] = $_POST['new_db'];
         $message = Message::success(__('Database %1$s has been created.'));
         $message->addParam($_POST['new_db']);
         $this->response->addJSON('message', $message);
         $this->response->addJSON('sql_query', Util::getMessage(null, $sql_query, 'success'));
         $url_query = URL::getCommon(array('db' => $_POST['new_db']));
         $this->response->addJSON('url_query', Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&amp;db=' . urlencode($_POST['new_db']));
     }
 }
示例#8
0
/**
 * Displays a form used to add/edit a routine
 *
 * @param string $mode      If the editor will be used to edit a routine
 *                          or add a new one: 'edit' or 'add'.
 * @param string $operation If the editor was previously invoked with
 *                          JS turned off, this will hold the name of
 *                          the current operation
 * @param array  $routine   Data for the routine returned by
 *                          PMA_RTN_getDataFromRequest() or
 *                          PMA_RTN_getDataFromName()
 *
 * @return string   HTML code for the editor.
 */
function PMA_RTN_getEditorForm($mode, $operation, $routine)
{
    global $db, $errors, $param_sqldataaccess, $param_opts_num;
    $response = Response::getInstance();
    // Escape special characters
    $need_escape = array('item_original_name', 'item_name', 'item_returnlength', 'item_definition', 'item_definer', 'item_comment');
    foreach ($need_escape as $key => $index) {
        $routine[$index] = htmlentities($routine[$index], ENT_QUOTES, 'UTF-8');
    }
    for ($i = 0; $i < $routine['item_num_params']; $i++) {
        $routine['item_param_name'][$i] = htmlentities($routine['item_param_name'][$i], ENT_QUOTES);
        $routine['item_param_length'][$i] = htmlentities($routine['item_param_length'][$i], ENT_QUOTES);
    }
    // Handle some logic first
    if ($operation == 'change') {
        if ($routine['item_type'] == 'PROCEDURE') {
            $routine['item_type'] = 'FUNCTION';
            $routine['item_type_toggle'] = 'PROCEDURE';
        } else {
            $routine['item_type'] = 'PROCEDURE';
            $routine['item_type_toggle'] = 'FUNCTION';
        }
    } else {
        if ($operation == 'add' || $routine['item_num_params'] == 0 && $mode == 'add' && !$errors) {
            $routine['item_param_dir'][] = '';
            $routine['item_param_name'][] = '';
            $routine['item_param_type'][] = '';
            $routine['item_param_length'][] = '';
            $routine['item_param_opts_num'][] = '';
            $routine['item_param_opts_text'][] = '';
            $routine['item_num_params']++;
        } else {
            if ($operation == 'remove') {
                unset($routine['item_param_dir'][$routine['item_num_params'] - 1]);
                unset($routine['item_param_name'][$routine['item_num_params'] - 1]);
                unset($routine['item_param_type'][$routine['item_num_params'] - 1]);
                unset($routine['item_param_length'][$routine['item_num_params'] - 1]);
                unset($routine['item_param_opts_num'][$routine['item_num_params'] - 1]);
                unset($routine['item_param_opts_text'][$routine['item_num_params'] - 1]);
                $routine['item_num_params']--;
            }
        }
    }
    $disableRemoveParam = '';
    if (!$routine['item_num_params']) {
        $disableRemoveParam = " color: gray;' disabled='disabled";
    }
    $original_routine = '';
    if ($mode == 'edit') {
        $original_routine = "<input name='item_original_name' " . "type='hidden' " . "value='{$routine['item_original_name']}'/>\n" . "<input name='item_original_type' " . "type='hidden' " . "value='{$routine['item_original_type']}'/>\n";
    }
    $isfunction_class = '';
    $isprocedure_class = '';
    $isfunction_select = '';
    $isprocedure_select = '';
    if ($routine['item_type'] == 'PROCEDURE') {
        $isfunction_class = ' hide';
        $isprocedure_select = " selected='selected'";
    } else {
        $isprocedure_class = ' hide';
        $isfunction_select = " selected='selected'";
    }
    // Create the output
    $retval = "";
    $retval .= "<!-- START " . mb_strtoupper($mode) . " ROUTINE FORM -->\n\n";
    $retval .= "<form class='rte_form' action='db_routines.php' method='post'>\n";
    $retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
    $retval .= $original_routine;
    $retval .= URL::getHiddenInputs($db) . "\n";
    $retval .= "<fieldset>\n";
    $retval .= "<legend>" . __('Details') . "</legend>\n";
    $retval .= "<table class='rte_table' style='width: 100%'>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td style='width: 20%;'>" . __('Routine name') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_name' maxlength='64'\n";
    $retval .= "               value='{$routine['item_name']}' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Type') . "</td>\n";
    $retval .= "    <td>\n";
    if ($response->isAjax()) {
        $retval .= "        <select name='item_type'>\n" . "<option value='PROCEDURE'{$isprocedure_select}>PROCEDURE</option>\n" . "<option value='FUNCTION'{$isfunction_select}>FUNCTION</option>\n" . "</select>\n";
    } else {
        $retval .= "<input name='item_type' type='hidden'" . " value='{$routine['item_type']}' />\n" . "<div class='floatleft' style='width: 49%; text-align: center;" . " font-weight: bold;'>\n" . $routine['item_type'] . "\n" . "</div>\n" . "<input style='width: 49%;' type='submit' name='routine_changetype'\n" . " value='" . sprintf(__('Change to %s'), $routine['item_type_toggle']) . "' />\n";
    }
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Parameters') . "</td>\n";
    $retval .= "    <td>\n";
    // parameter handling start
    $retval .= "        <table class='routine_params_table'>\n";
    $retval .= "        <thead>\n";
    $retval .= "        <tr>\n";
    $retval .= "            <td></td>\n";
    $retval .= "            <th class='routine_direction_cell{$isprocedure_class}'>" . __('Direction') . "</th>\n";
    $retval .= "            <th>" . __('Name') . "</th>\n";
    $retval .= "            <th>" . __('Type') . "</th>\n";
    $retval .= "            <th>" . __('Length/Values') . "</th>\n";
    $retval .= "            <th colspan='2'>" . __('Options') . "</th>\n";
    $retval .= "            <th class='routine_param_remove hide'>&nbsp;</th>\n";
    $retval .= "        </tr>";
    $retval .= "        </thead>\n";
    $retval .= "        <tbody>\n";
    for ($i = 0; $i < $routine['item_num_params']; $i++) {
        // each parameter
        $retval .= PMA_RTN_getParameterRow($routine, $i, $isprocedure_class);
    }
    $retval .= "        </tbody>\n";
    $retval .= "        </table>";
    $retval .= "    </td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>&nbsp;</td>";
    $retval .= "    <td>";
    $retval .= "        <input style='width: 49%;' type='button'";
    $retval .= "               name='routine_addparameter'";
    $retval .= "               value='" . __('Add parameter') . "' />";
    $retval .= "        <input style='width: 49%;" . $disableRemoveParam . "'";
    $retval .= "               type='submit' ";
    $retval .= "               name='routine_removeparameter'";
    $retval .= "               value='" . __('Remove last parameter') . "' />";
    $retval .= "    </td>";
    $retval .= "</tr>";
    // parameter handling end
    $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>";
    $retval .= "    <td>" . __('Return type') . "</td>";
    $retval .= "    <td><select name='item_returntype'>";
    $retval .= PMA\libraries\Util::getSupportedDatatypes(true, $routine['item_returntype']);
    $retval .= "    </select></td>";
    $retval .= "</tr>";
    $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>";
    $retval .= "    <td>" . __('Return length/values') . "</td>";
    $retval .= "    <td><input type='text' name='item_returnlength'";
    $retval .= "        value='" . $routine['item_returnlength'] . "' /></td>";
    $retval .= "    <td class='hide no_len'>---</td>";
    $retval .= "</tr>";
    $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>";
    $retval .= "    <td>" . __('Return options') . "</td>";
    $retval .= "    <td><div>";
    $retval .= Charsets::getCharsetDropdownBox("item_returnopts_text", null, $routine['item_returnopts_text']);
    $retval .= "    </div>";
    $retval .= "    <div><select name='item_returnopts_num'>";
    $retval .= "        <option value=''></option>";
    foreach ($param_opts_num as $key => $value) {
        $selected = "";
        if (!empty($routine['item_returnopts_num']) && $routine['item_returnopts_num'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "<option" . $selected . ">" . $value . "</option>";
    }
    $retval .= "    </select></div>";
    $retval .= "    <div class='hide no_opts'>---</div>";
    $retval .= "</td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>" . __('Definition') . "</td>";
    $retval .= "    <td><textarea name='item_definition' rows='15' cols='40'>";
    $retval .= $routine['item_definition'];
    $retval .= "</textarea></td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>" . __('Is deterministic') . "</td>";
    $retval .= "    <td><input type='checkbox' name='item_isdeterministic'" . $routine['item_isdeterministic'] . " /></td>";
    $retval .= "</tr>";
    if (isset($_REQUEST['edit_item']) && !empty($_REQUEST['edit_item'])) {
        $retval .= "<tr>";
        $retval .= "    <td>" . __('Adjust privileges');
        $retval .= PMA\libraries\Util::showDocu('faq', 'faq6-39');
        $retval .= "</td>";
        if ($GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv']) {
            $retval .= "    <td><input type='checkbox' " . "name='item_adjust_privileges' value='1' checked /></td>";
        } else {
            $retval .= "    <td><input type='checkbox' " . "name='item_adjust_privileges' value='1' title='" . __("You do not have sufficient privileges to perform this " . "operation; Please refer to the documentation for more " . "details") . "' disabled/></td>";
        }
        $retval .= "</tr>";
    }
    $retval .= "<tr>";
    $retval .= "    <td>" . __('Definer') . "</td>";
    $retval .= "    <td><input type='text' name='item_definer'";
    $retval .= "               value='" . $routine['item_definer'] . "' /></td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>" . __('Security type') . "</td>";
    $retval .= "    <td><select name='item_securitytype'>";
    $retval .= "        <option value='DEFINER'" . $routine['item_securitytype_definer'] . ">DEFINER</option>";
    $retval .= "        <option value='INVOKER'" . $routine['item_securitytype_invoker'] . ">INVOKER</option>";
    $retval .= "    </select></td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>" . __('SQL data access') . "</td>";
    $retval .= "    <td><select name='item_sqldataaccess'>";
    foreach ($param_sqldataaccess as $key => $value) {
        $selected = "";
        if ($routine['item_sqldataaccess'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "        <option" . $selected . ">" . $value . "</option>";
    }
    $retval .= "    </select></td>";
    $retval .= "</tr>";
    $retval .= "<tr>";
    $retval .= "    <td>" . __('Comment') . "</td>";
    $retval .= "    <td><input type='text' name='item_comment' maxlength='64'";
    $retval .= "    value='" . $routine['item_comment'] . "' /></td>";
    $retval .= "</tr>";
    $retval .= "</table>";
    $retval .= "</fieldset>";
    if ($response->isAjax()) {
        $retval .= "<input type='hidden' name='editor_process_" . $mode . "'";
        $retval .= "       value='true' />";
        $retval .= "<input type='hidden' name='ajax_request' value='true' />";
    } else {
        $retval .= "<fieldset class='tblFooters'>";
        $retval .= "    <input type='submit' name='editor_process_" . $mode . "'";
        $retval .= "           value='" . __('Go') . "' />";
        $retval .= "</fieldset>";
    }
    $retval .= "</form>";
    $retval .= "<!-- END " . mb_strtoupper($mode) . " ROUTINE FORM -->";
    return $retval;
}