PMA\libraries\Charsets::getCharsetDropdownBox PHP Method

getCharsetDropdownBox() public static method

Generate charset dropdown box
public static getCharsetDropdownBox ( string $name = null, string $id = null, null | string $default = null, boolean $label = true, boolean $submitOnChange = false ) : string
$name string Element name
$id string Element id
$default null | string Default value
$label boolean Label
$submitOnChange boolean Submit on change
return string
    public static function getCharsetDropdownBox($name = null, $id = null, $default = null, $label = true, $submitOnChange = false)
    {
        self::loadCharsets();
        if (empty($name)) {
            $name = 'character_set';
        }
        $return_str = '<select lang="en" dir="ltr" name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . ($submitOnChange ? ' class="autosubmit"' : '') . '>' . "\n";
        if ($label) {
            $return_str .= '<option value="">' . __('Charset') . '</option>' . "\n";
        }
        $return_str .= '<option value=""></option>' . "\n";
        foreach (self::$_charsets as $current_charset) {
            $current_cs_descr = empty(self::$_charsets_descriptions[$current_charset]) ? $current_charset : self::$_charsets_descriptions[$current_charset];
            $return_str .= '<option value="' . $current_charset . '" title="' . $current_cs_descr . '"' . ($default == $current_charset ? ' selected="selected"' : '') . '>' . $current_charset . '</option>' . "\n";
        }
        $return_str .= '</select>' . "\n";
        return $return_str;
    }

Usage Example

/**
 * 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;
}
All Usage Examples Of PMA\libraries\Charsets::getCharsetDropdownBox