getRadioFields() public static method

Generates a set of radio HTML fields
public static getRadioFields ( string $html_field_name, array $choices, string $checked_choice = '', boolean $line_break = true, boolean $escape_label = true, string $class = '', string $id_prefix = '' ) : string
$html_field_name string the radio HTML field
$choices array the choices values and labels
$checked_choice string the choice to check by default
$line_break boolean whether to add HTML line break after a choice
$escape_label boolean whether to use htmlspecialchars() on label
$class string enclose each choice with a div of this class
$id_prefix string prefix for the id attribute, name will be used if this is not supplied
return string set of html radio fiels
/**
 * Get HTML snippet for partition maintenance
 *
 * @param array $partition_names array of partition names for a specific db/table
 * @param array $url_params      url parameters
 *
 * @return string $html_output
 */
function PMA_getHtmlForPartitionMaintenance($partition_names, $url_params)
{
    $choices = array('ANALYZE' => __('Analyze'), 'CHECK' => __('Check'), 'OPTIMIZE' => __('Optimize'), 'REBUILD' => __('Rebuild'), 'REPAIR' => __('Repair'), 'TRUNCATE' => __('Truncate'));
    $partition_method = Partition::getPartitionMethod($GLOBALS['db'], $GLOBALS['table']);
    // add COALESCE or DROP option to choices array depeding on Partition method
    if ($partition_method == 'RANGE' || $partition_method == 'LIST') {
        $choices['DROP'] = __('Drop');
    } else {
        $choices['COALESCE'] = __('Coalesce');
    }
    $html_output = '<div class="operations_half_width">' . '<form id="partitionsForm" class="ajax" ' . 'method="post" action="tbl_operations.php" >' . PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . '<fieldset>' . '<legend>' . __('Partition maintenance') . PMA\libraries\Util::showMySQLDocu('partitioning_maintenance') . '</legend>';
    $html_select = '<select id="partition_name" name="partition_name[]"' . ' multiple="multiple" required="required">' . "\n";
    $first = true;
    foreach ($partition_names as $one_partition) {
        $one_partition = htmlspecialchars($one_partition);
        $html_select .= '<option value="' . $one_partition . '"';
        if ($first) {
            $html_select .= ' selected="selected"';
            $first = false;
        }
        $html_select .= '>' . $one_partition . '</option>' . "\n";
    }
    $html_select .= '</select>' . "\n";
    $html_output .= sprintf(__('Partition %s'), $html_select);
    $html_output .= '<div class="clearfloat" />';
    $html_output .= PMA\libraries\Util::getRadioFields('partition_operation', $choices, 'ANALYZE', false, true, 'floatleft');
    $this_url_params = array_merge($url_params, array('sql_query' => 'ALTER TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;'));
    $html_output .= '<div class="clearfloat" /><br />';
    $html_output .= '<a href="sql.php' . PMA_URL_getCommon($this_url_params) . '">' . __('Remove partitioning') . '</a>';
    $html_output .= '</fieldset>' . '<fieldset class="tblFooters">' . '<input type="hidden" name="submit_partition" value="1">' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</form>' . '</div>';
    return $html_output;
}
Esempio n. 2
0
 /**
  * Prepare option fields block
  *
  * @return  string  $options_html   html content
  *
  * @access  private
  *
  * @see     _getTableHeaders()
  */
 private function _getOptionsBlock()
 {
     $options_html = '';
     $options_html .= '<form method="post" action="sql.php" ' . 'name="displayOptionsForm"';
     $options_html .= ' class="ajax print_ignore" ';
     $options_html .= '>';
     $url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'sql_query' => $this->__get('sql_query'), 'goto' => $this->__get('goto'), 'display_options_form' => 1);
     $options_html .= PMA_URL_getHiddenInputs($url_params) . '<br />' . Util::getDivForSliderEffect('', __('Options')) . '<fieldset>';
     $options_html .= '<div class="formelement">';
     $choices = array('P' => __('Partial texts'), 'F' => __('Full texts'));
     // pftext means "partial or full texts" (done to reduce line lengths)
     $options_html .= Util::getRadioFields('pftext', $choices, $_SESSION['tmpval']['pftext'], true, true, '', 'pftext_' . $this->__get('unique_id')) . '</div>';
     if ($GLOBALS['cfgRelation']['relwork'] && $GLOBALS['cfgRelation']['displaywork']) {
         $options_html .= '<div class="formelement">';
         $choices = array('K' => __('Relational key'), 'D' => __('Display column for relations'));
         $options_html .= Util::getRadioFields('relational_display', $choices, $_SESSION['tmpval']['relational_display'], true, true, '', 'relational_display_' . $this->__get('unique_id')) . '</div>';
     }
     $options_html .= '<div class="formelement">' . Util::getCheckbox('display_binary', __('Show binary contents'), !empty($_SESSION['tmpval']['display_binary']), false, 'display_binary_' . $this->__get('unique_id')) . '<br />' . Util::getCheckbox('display_blob', __('Show BLOB contents'), !empty($_SESSION['tmpval']['display_blob']), false, 'display_blob_' . $this->__get('unique_id')) . '</div>';
     // I would have preferred to name this "display_transformation".
     // This is the only way I found to be able to keep this setting sticky
     // per SQL query, and at the same time have a default that displays
     // the transformations.
     $options_html .= '<div class="formelement">' . Util::getCheckbox('hide_transformation', __('Hide browser transformation'), !empty($_SESSION['tmpval']['hide_transformation']), false, 'hide_transformation_' . $this->__get('unique_id')) . '</div>';
     $options_html .= '<div class="formelement">';
     $choices = array('GEOM' => __('Geometry'), 'WKT' => __('Well Known Text'), 'WKB' => __('Well Known Binary'));
     $options_html .= Util::getRadioFields('geoOption', $choices, $_SESSION['tmpval']['geoOption'], true, true, '', 'geoOption_' . $this->__get('unique_id'));
     $options_html .= '</div>';
     $options_html .= '<div class="clearfloat"></div>' . '</fieldset>';
     $options_html .= '<fieldset class="tblFooters">' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</div>' . '</form>';
     return $options_html;
 }
Esempio n. 3
0
/**
 * get html for options to normalize table
 *
 * @return string HTML
 */
function PMA_getHtmlForNormalizetable()
{
    $html_output = '<form method="post" action="normalization.php" ' . 'name="normalize" ' . 'id="normalizeTable" ' . '>' . PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . '<input type="hidden" name="step1" value="1">';
    $html_output .= '<fieldset>';
    $html_output .= '<legend>' . __('Improve table structure (Normalization):') . '</legend>';
    $html_output .= '<h3>' . __('Select up to what step you want to normalize') . '</h3>';
    $choices = array('1nf' => __('First step of normalization (1NF)'), '2nf' => __('Second step of normalization (1NF+2NF)'), '3nf' => __('Third step of normalization (1NF+2NF+3NF)'));
    $html_output .= Util::getRadioFields('normalizeTo', $choices, '1nf', true);
    $html_output .= '</fieldset><fieldset class="tblFooters">' . "<span class='floatleft'>" . __('Hint: Please follow the procedure carefully in order ' . 'to obtain correct normalization') . "</span>" . '<input type="submit" name="submit_normalize" value="' . __('Go') . '" />' . '</fieldset>' . '</form>' . '</div>';
    return $html_output;
}
/**
 * Get the HTML snippet for change user login information
 *
 * @param string $username username
 * @param string $hostname host name
 *
 * @return string HTML snippet
 */
function PMA_getChangeLoginInformationHtmlForm($username, $hostname)
{
    $choices = array('4' => __('… keep the old one.'), '1' => __('… delete the old one from the user tables.'), '2' => __('… revoke all active privileges from ' . 'the old one and delete it afterwards.'), '3' => __('… delete the old one from the user tables ' . 'and reload the privileges afterwards.'));
    $html_output = '<form action="server_privileges.php" ' . 'onsubmit="return checkAddUser(this);" ' . 'method="post" class="copyUserForm submenu-item">' . "\n" . PMA_URL_getHiddenInputs('', '') . '<input type="hidden" name="old_username" ' . 'value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="old_hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset id="fieldset_change_copy_user">' . "\n" . '<legend data-submenu-label="' . __('Login Information') . '">' . "\n" . __('Change login information / Copy user account') . '</legend>' . "\n" . PMA_getHtmlForLoginInformationFields('change', $username, $hostname);
    $html_output .= '<fieldset id="fieldset_mode">' . "\n" . ' <legend>' . __('Create a new user account with the same privileges and …') . '</legend>' . "\n";
    $html_output .= Util::getRadioFields('mode', $choices, '4', true);
    $html_output .= '</fieldset>' . "\n" . '</fieldset>' . "\n";
    $html_output .= '<fieldset id="fieldset_change_copy_user_footer" ' . 'class="tblFooters">' . "\n" . '<input type="hidden" name="change_copy" value="1" />' . "\n" . '<input type="submit" value="' . __('Go') . '" />' . "\n" . '</fieldset>' . "\n" . '</form>' . "\n";
    return $html_output;
}
Esempio n. 5
0
 /**
  * Provides the main search form's html
  *
  * @return string HTML for selection form
  */
 public function getSelectionForm()
 {
     $html_output = '<a id="db_search"></a>';
     $html_output .= '<form id="db_search_form"' . ' class="ajax lock-page"' . ' method="post" action="db_search.php" name="db_search">';
     $html_output .= URL::getHiddenInputs($GLOBALS['db']);
     $html_output .= '<fieldset>';
     // set legend caption
     $html_output .= '<legend>' . __('Search in database') . '</legend>';
     $html_output .= '<table class="formlayout">';
     // inputbox for search phrase
     $html_output .= '<tr>';
     $html_output .= '<td>' . __('Words or values to search for (wildcard: "%"):') . '</td>';
     $html_output .= '<td><input type="text"' . ' name="criteriaSearchString" size="60"' . ' value="' . htmlspecialchars($this->_criteriaSearchString) . '" />';
     $html_output .= '</td>';
     $html_output .= '</tr>';
     // choices for types of search
     $html_output .= '<tr>';
     $html_output .= '<td class="right vtop">' . __('Find:') . '</td>';
     $html_output .= '<td>';
     $choices = array('1' => __('at least one of the words') . Util::showHint(__('Words are separated by a space character (" ").')), '2' => __('all words') . Util::showHint(__('Words are separated by a space character (" ").')), '3' => __('the exact phrase'), '4' => __('as regular expression') . ' ' . Util::showMySQLDocu('Regexp'));
     // 4th parameter set to true to add line breaks
     // 5th parameter set to false to avoid htmlspecialchars() escaping
     // in the label since we have some HTML in some labels
     $html_output .= Util::getRadioFields('criteriaSearchType', $choices, $this->_criteriaSearchType, true, false);
     $html_output .= '</td></tr>';
     // displays table names as select options
     $html_output .= '<tr>';
     $html_output .= '<td class="right vtop">' . __('Inside tables:') . '</td>';
     $html_output .= '<td rowspan="2">';
     $html_output .= '<select name="criteriaTables[]" size="6"' . ' multiple="multiple">';
     foreach ($this->_tables_names_only as $each_table) {
         if (in_array($each_table, $this->_criteriaTables)) {
             $is_selected = ' selected="selected"';
         } else {
             $is_selected = '';
         }
         $html_output .= '<option value="' . htmlspecialchars($each_table) . '"' . $is_selected . '>' . str_replace(' ', '&nbsp;', htmlspecialchars($each_table)) . '</option>';
     }
     // end for
     $html_output .= '</select>';
     $html_output .= '</td></tr>';
     // Displays 'select all' and 'unselect all' links
     $alter_select = '<a href="#" ' . 'onclick="setSelectOptions(\'db_search\',' . ' \'criteriaTables[]\', true); return false;">' . __('Select all') . '</a> &nbsp;/&nbsp;';
     $alter_select .= '<a href="#" ' . 'onclick="setSelectOptions(\'db_search\',' . ' \'criteriaTables[]\', false); return false;">' . __('Unselect all') . '</a>';
     $html_output .= '<tr><td class="right vbottom">' . $alter_select . '</td></tr>';
     // Inputbox for column name entry
     $html_output .= '<tr>';
     $html_output .= '<td class="right">' . __('Inside column:') . '</td>';
     $html_output .= '<td><input type="text" name="criteriaColumnName" size="60"' . 'value="' . (!empty($this->_criteriaColumnName) ? htmlspecialchars($this->_criteriaColumnName) : '') . '" /></td>';
     $html_output .= '</tr>';
     $html_output .= '</table>';
     $html_output .= '</fieldset>';
     $html_output .= '<fieldset class="tblFooters">';
     $html_output .= '<input type="submit" name="submit_search" value="' . __('Go') . '" id="buttonGo" />';
     $html_output .= '</fieldset>';
     $html_output .= '</form>';
     $html_output .= '<div id="togglesearchformdiv">' . '<a id="togglesearchformlink"></a></div>';
     return $html_output;
 }