예제 #1
0
/**
 * retrieves table info and stores it in $GLOBALS['PMD']
 *
 * @return array with table info
 */
function get_tables_info()
{
    $retval = array();
    $GLOBALS['PMD']['TABLE_NAME'] = array();
    // that foreach no error
    $GLOBALS['PMD']['OWNER'] = array();
    $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
    $tables = PMA_DBI_get_tables_full($GLOBALS['db']);
    // seems to be needed later
    PMA_DBI_select_db($GLOBALS['db']);
    $i = 0;
    foreach ($tables as $one_table) {
        $GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
        $GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db'];
        $GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME'];
        $GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($GLOBALS['db'] . "." . $one_table['TABLE_NAME']);
        $GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($GLOBALS['db']);
        $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']);
        $GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES);
        $GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($GLOBALS['db'], ENT_QUOTES);
        $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES);
        $GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
        $DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
        if ($DF != '') {
            $retval[$GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]] = urlencode($DF);
        }
        $i++;
    }
    return $retval;
}
/**
 * retrieves table info and stores it in $GLOBALS['PMD']
 *
 * @uses    $GLOBALS['script_display_field']
 * @uses    $GLOBALS['PMD'] to fill it
 * @uses    $GLOBALS['db']
 * @uses    PMA_DBI_get_tables_full()
 * @uses    PMA_DBI_select_db()
 * @uses    PMA_getDisplayField()
 * @uses    urlencode()
 * @uses    htmlspecialchars()
 * @uses    strtoupper()
 * @uses    urlencode()
 */
function get_tabs()
{
    $GLOBALS['PMD']['TABLE_NAME'] = array();
    // that foreach no error
    $GLOBALS['PMD']['OWNER'] = array();
    $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
    $tables = PMA_DBI_get_tables_full($GLOBALS['db']);
    // seems to be needed later
    PMA_DBI_select_db($GLOBALS['db']);
    $i = 0;
    foreach ($tables as $one_table) {
        $GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
        $GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db'];
        $GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME'];
        $GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($GLOBALS['db'] . "." . $one_table['TABLE_NAME']);
        $GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($GLOBALS['db']);
        $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']);
        $GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES);
        $GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($GLOBALS['db'], ENT_QUOTES);
        $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES);
        $GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
        $DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
        if ($DF != '') {
            $GLOBALS['script_display_field'] .= "  display_field['" . $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . "'] = '" . urlencode($DF) . "';\n";
        }
        $i++;
    }
    $GLOBALS['script_display_field'] .= '// ]]>' . "\n" . '</script>' . "\n";
    //  return $GLOBALS['PMD'];       // many bases // not use ??????
}
 /**
  * Set the value of $map array for linking foreign key related tables
  *
  * @param array &$map the list of relations
  *
  * @return  void
  *
  * @access  private
  *
  * @see      getTable()
  */
 private function _setParamForLinkForiegnKeyRelatedTables(&$map)
 {
     // To be able to later display a link to the related table,
     // we verify both types of relations: either those that are
     // native foreign keys or those defined in the phpMyAdmin
     // configuration storage. If no PMA storage, we won't be able
     // to use the "column to display" notion (for example show
     // the name related to a numeric id).
     $exist_rel = PMA_getForeigners($this->__get('_db'), $this->__get('_table'), '', self::POSITION_BOTH);
     if ($exist_rel) {
         foreach ($exist_rel as $master_field => $rel) {
             $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
             $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
         }
         // end while
     }
     // end if
 }
예제 #4
0
/**
 * Function to get html for display field infos
 *
 * @param string $db       current database
 * @param string $table    current table
 * @param array  $save_row save row
 *
 * @return string
 */
function PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row)
{
    $disp = PMA_getDisplayField($db, $table);
    $html_output = '<fieldset>' . '<label>' . __('Choose column to display:') . '</label>' . '<select name="display_field">' . '<option value="">---</option>';
    foreach ($save_row as $row) {
        $html_output .= '<option value="' . htmlspecialchars($row['Field']) . '"';
        if (isset($disp) && $row['Field'] == $disp) {
            $html_output .= ' selected="selected"';
        }
        $html_output .= '>' . htmlspecialchars($row['Field']) . '</option>' . "\n";
    }
    // end while
    $html_output .= '</select>' . '</fieldset>';
    return $html_output;
}
예제 #5
0
 /**
  * Set the value of $map array for linking foreign key related tables
  *
  * @param array &$map the list of relations
  *
  * @return  void
  *
  * @access  private
  *
  * @see      getTable()
  */
 private function _setParamForLinkForeignKeyRelatedTables(&$map)
 {
     // To be able to later display a link to the related table,
     // we verify both types of relations: either those that are
     // native foreign keys or those defined in the phpMyAdmin
     // configuration storage. If no PMA storage, we won't be able
     // to use the "column to display" notion (for example show
     // the name related to a numeric id).
     $exist_rel = PMA_getForeigners($this->__get('db'), $this->__get('table'), '', self::POSITION_BOTH);
     if ($exist_rel) {
         foreach ($exist_rel as $master_field => $rel) {
             if ($master_field != 'foreign_keys_data') {
                 $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                 $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
             } else {
                 foreach ($rel as $key => $one_key) {
                     foreach ($one_key['index_list'] as $index => $one_field) {
                         $display_field = PMA_getDisplayField(isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $GLOBALS['db'], $one_key['ref_table_name']);
                         $map[$one_field] = array($one_key['ref_table_name'], $one_key['ref_index_list'][$index], $display_field, isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $GLOBALS['db']);
                     }
                 }
             }
         }
         // end while
     }
     // end if
 }
예제 #6
0
/**
 * Displays a table of results returned by a SQL query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @uses    $_SESSION['tmp_user_values']['pos']
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  string   $goto              the URL to go back in case of errors
 * @global  string   $sql_query         the current SQL query
 * @global  integer  $num_rows          the total number of rows returned by the
 *                                      SQL query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      SQL query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  array    $fields_meta       the list of fields properties
 * @global  integer  $fields_cnt        the total number of fields returned by
 *                                      the SQL query
 * @global  array    $vertical_display  informations used with vertical display
 *                                      mode
 * @global  array    $highlight_columns column names to highlight
 * @global  array    $cfgRelation       the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $db, $table, $goto;
    global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
    global $vertical_display, $highlight_columns;
    global $cfgRelation;
    global $showtable;
    // why was this called here? (already called from sql.php)
    //PMA_displayTable_checkConfigParams();
    /**
     * @todo move this to a central place
     * @todo for other future table types
     */
    $is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB';
    if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) {
        // "j u s t   b r o w s i n g"
        $pre_count = '~';
        $after_count = PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount']), true);
    } else {
        $pre_count = '';
        $after_count = '';
    }
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if ($_SESSION['tmp_user_values']['max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'];
            $pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Find the sort expression
    // we need $sort_expression and $sort_expression_nodirection
    // even if there are many table references
    if (!empty($analyzed_sql[0]['order_by_clause'])) {
        $sort_expression = trim(str_replace('  ', ' ', $analyzed_sql[0]['order_by_clause']));
        /**
         * Get rid of ASC|DESC
         */
        preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
        $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
        $sort_direction = isset($matches[2]) ? trim($matches[2]) : '';
        unset($matches);
    } else {
        $sort_expression = $sort_expression_nodirection = $sort_direction = '';
    }
    // 1.4 Prepares display of first and last value of the sorted column
    if (!empty($sort_expression_nodirection)) {
        list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
        $sort_table = PMA_unQuote($sort_table);
        $sort_column = PMA_unQuote($sort_column);
        // find the sorted column index in row result
        // (this might be a multi-table query)
        $sorted_column_index = false;
        foreach ($fields_meta as $key => $meta) {
            if ($meta->table == $sort_table && $meta->name == $sort_column) {
                $sorted_column_index = $key;
                break;
            }
        }
        if ($sorted_column_index !== false) {
            // fetch first row of the result set
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // fetch last row of the result set
            PMA_DBI_data_seek($dt_result, $num_rows - 1);
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // reset to first row for the loop in PMA_displayTableBody()
            PMA_DBI_data_seek($dt_result, 0);
            // we could also use here $sort_expression_nodirection
            $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
            unset($row, $column_for_first_row, $column_for_last_row);
        }
        unset($sorted_column_index, $sort_table, $sort_column);
    }
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
            $message = PMA_Message::notice('strViewHasAtLeast');
            $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
            $message->addParam('[/a]');
            $message_view_warning = PMA_showHint($message);
        } else {
            $message_view_warning = false;
        }
        $message = PMA_Message::success('strShowingRecords');
        $message->addMessage($_SESSION['tmp_user_values']['pos']);
        if ($message_view_warning) {
            $message->addMessage('...', ' - ');
            $message->addMessage($message_view_warning);
            $message->addMessage('(');
        } else {
            $message->addMessage($last_shown_rec, ' - ');
            $message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' (');
            $message->addString('strTotal');
            $message->addMessage($selectstring, '');
            $message->addMessage(', ', '');
        }
        $messagge_qt = PMA_Message::notice('strQueryTime');
        $messagge_qt->addParam($GLOBALS['querytime']);
        $message->addMessage($messagge_qt, '');
        $message->addMessage(')', '');
        $message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', '');
        PMA_showMessage($message, $sql_query, 'success');
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
    }
    // 2.3 Displays the navigation bars
    if (!strlen($table)) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
            // table does not always contain a real table name,
            // for example in MySQL 5.0.x, the query SHOW STATUS
            // returns STATUS as a table name
            $table = $fields_meta[0]->table;
        } else {
            $table = '';
        }
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'top_direction_dropdown');
        echo "\n";
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' configuration variable)
    // loic1, 2002-03-02: extended to php3
    // initialize map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (!strlen($table)) {
            $exist_rel = false;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction);
    $url_query = '';
    echo '<tbody>' . "\n";
    $clause_is_unique = PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    // vertical output case
    if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    echo '</tbody>' . "\n";
    ?>
</table>

    <?php 
    // 4. ----- Displays the link for multi-fields edit and delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $_url_params = array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'goto' => $goto);
        $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params);
        $_url_params['checkall'] = '1';
        $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params);
        if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
            $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
            $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
        } else {
            $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
            $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
        }
        $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
        $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
        if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') {
            echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />';
        }
        echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
        PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
        if ($analyzed_sql[0]['querytype'] == 'SELECT') {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
        }
        echo "\n";
        echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '<input type="hidden" name="clause_is_unique"' . ' value="' . $clause_is_unique . '" />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown');
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 6. ----- Displays "Query results operations"
    if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
    }
}
예제 #7
0
/**
 * Saves the display field for a table.
 *
 * @param string $db    database name
 * @param string $table table name
 * @param string $field display field name
 *
 * @return boolean
 */
function PMA_saveDisplayField($db, $table, $field)
{
    $cfgRelation = PMA_getRelationsParam();
    if (!$cfgRelation['displaywork']) {
        return false;
    }
    $disp = PMA_getDisplayField($db, $table);
    if ($disp && $disp === $field) {
        $field = '';
    }
    $upd_query = new PMA_Table($table, $db, $GLOBALS['dbi']);
    $upd_query->updateDisplayField($disp, $field, $cfgRelation);
    return true;
}
예제 #8
0
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     switch ($this->_searchType) {
         case 'replace':
             if (isset($_POST['find'])) {
                 $this->findAction();
                 return;
             }
             $this->response->getHeader()->getScripts()->addFile('tbl_find_replace.js');
             if (isset($_POST['replace'])) {
                 $this->replaceAction();
             }
             // Displays the find and replace form
             $this->displaySelectionFormAction();
             break;
         case 'normal':
             $this->response->getHeader()->getScripts()->addFiles(array('makegrid.js', 'sql.js', 'tbl_select.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js', 'jquery/jquery.uitablefilter.js', 'gis_data_editor.js'));
             if (isset($_REQUEST['range_search'])) {
                 $this->rangeSearchAction();
                 return;
             }
             /**
              * No selection criteria received -> display the selection form
              */
             if (!isset($_POST['columnsToDisplay']) && !isset($_POST['displayAllColumns'])) {
                 $this->displaySelectionFormAction();
             } else {
                 $this->doSelectionAction();
             }
             break;
         case 'zoom':
             $this->response->getHeader()->getScripts()->addFiles(array('makegrid.js', 'sql.js', 'jqplot/jquery.jqplot.js', 'jqplot/plugins/jqplot.canvasTextRenderer.js', 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js', 'jqplot/plugins/jqplot.dateAxisRenderer.js', 'jqplot/plugins/jqplot.highlighter.js', 'jqplot/plugins/jqplot.cursor.js', 'jquery/jquery-ui-timepicker-addon.js', 'tbl_zoom_plot_jqplot.js', 'tbl_change.js'));
             /**
              * Handle AJAX request for data row on point select
              *
              * @var boolean Object containing parameters for the POST request
              */
             if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
                 $this->getDataRowAction();
                 return;
             }
             /**
              * Handle AJAX request for changing field information
              * (value,collation,operators,field values) in input form
              *
              * @var boolean Object containing parameters for the POST request
              */
             if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
                 $this->changeTableInfoAction();
                 return;
             }
             // Gets tables information
             include_once './libraries/tbl_info.inc.php';
             //Set default datalabel if not selected
             if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
                 $dataLabel = PMA_getDisplayField($this->db, $this->table);
             } else {
                 $dataLabel = $_POST['dataLabel'];
             }
             // Displays the zoom search form
             $this->displaySelectionFormAction($dataLabel);
             /*
              * Handle the input criteria and generate the query result
              * Form for displaying query results
              */
             if (isset($_POST['zoom_submit']) && $_POST['criteriaColumnNames'][0] != 'pma_null' && $_POST['criteriaColumnNames'][1] != 'pma_null' && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]) {
                 if (!isset($goto)) {
                     $goto = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
                 }
                 $this->zoomSubmitAction($dataLabel, $goto);
             }
             break;
     }
 }
/**
 * Displays a table of results returned by a sql query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @global  string   the current language
 * @global  integer  the server to use (refers to the number in the
 *                   configuration file)
 * @global  array    the current server config
 * @global  string   the database name
 * @global  string   the table name
 * @global  string   the url to go back in case of errors
 * @global  string   the current sql query
 * @global  integer  the total number of rows returned by the sql query
 * @global  integer  the total number of rows returned by the sql query
 *                   without any programmatically appended "LIMIT" clause
 * @global  integer  the current postion of the first record to be
 *                   displayed
 * @global  array    the list of fields properties
 * @global  integer  the total number of fields returned by the sql query
 * @global  array    informations used with vertical display mode
 * @global  string   the display mode (horizontal/vertical/horizontalflipped)
 * @global  integer  the number of row to display between two table headers
 * @global  boolean  whether to limit the number of displayed characters of
 *                   text type fields or not
 * @global  array    the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $lang, $server, $cfg, $db, $table;
    global $goto, $text_url;
    global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    global $dontlimitchars;
    global $cfgRelation;
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionnalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    if ($total == '') {
        unset($total);
    }
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if (!isset($pos)) {
            $pos = 0;
        }
        if ($GLOBALS['session_max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
            $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Urlencodes the query to use in input form fields
    $encoded_sql_query = urlencode($sql_query);
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $GLOBALS['session_max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        PMA_showMessage($GLOBALS['strShowingRecords'] . " {$pos} - {$last_shown_rec} ({$total} " . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            PMA_showMessage($GLOBALS['strSQLQuery']);
        }
    }
    // 2.3 Displays the navigation bars
    if (!isset($table) || strlen(trim($table)) == 0) {
        $table = $fields_meta[0]->table;
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
        echo "\n";
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            echo "\n" . '<br /><br />' . "\n";
        }
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' config variable)
    // loic1, 2002-03-02: extended to php3
    // init map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (empty($table)) {
            $exist_rel = FALSE;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
    $url_query = '';
    PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    // vertical output case
    if ($disp_direction == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    ?>
</table>
    <?php 
    echo "\n";
    // 4. ----- Displays the link for multi-fields delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $propicon = (string) $GLOBALS['cfg']['PropertiesIconic'];
        ?>
        &nbsp;&nbsp;<img src="<?php 
        echo $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png';
        ?>
" border="0" width="38" height="22" alt="<?php 
        echo $GLOBALS['strWithChecked'];
        ?>
" />
        <a href="<?php 
        echo $text_url . '&amp;checkall=1';
        ?>
" onclick="setCheckboxesRange('rowsDeleteForm', true, 'id_rows_to_delete', 0, '<?php 
        echo $num_rows;
        ?>
'); return false;">
            <?php 
        echo $GLOBALS['strCheckAll'];
        ?>
</a>
        &nbsp;/&nbsp;
        <a href="<?php 
        echo $text_url;
        ?>
" onclick="setCheckboxesRange('rowsDeleteForm', false, 'id_rows_to_delete', 0, '<?php 
        echo $num_rows;
        ?>
'); return false;">
            <?php 
        echo $GLOBALS['strUncheckAll'];
        ?>
</a>
<?php 
        echo '&nbsp;&nbsp;<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        if ($cfg['PropertiesIconic']) {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
            }
            echo "\n";
        } else {
            echo '                    <input type="submit" name="submit_mult" value="' . htmlspecialchars($GLOBALS['strEdit']) . '" title="' . $GLOBALS['strEdit'] . '" />' . "\n";
            echo '&nbsp;<input type="submit" name="submit_mult" value="' . htmlspecialchars($delete_text) . '" title="' . $delete_text . '" />' . "\n";
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                echo '&nbsp;<input type="submit" name="submit_mult" value="' . htmlspecialchars($GLOBALS['strExport']) . '" title="' . $GLOBALS['strExport'] . '" />' . "\n";
            }
        }
        echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
        echo '<input type="hidden" name="url_query" value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '<br />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            echo "\n" . '<br /><br />' . "\n";
        }
    }
}
예제 #10
0
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     switch ($this->_searchType) {
         case 'replace':
             if (isset($_POST['find'])) {
                 $this->findAction();
                 return;
             }
             $this->response->getHeader()->getScripts()->addFile('tbl_find_replace.js');
             // Show secondary level of tabs
             $this->response->addHTML(Template::get('secondary_tabs')->render(array('url_params' => array('db' => $this->db, 'table' => $this->table), 'sub_tabs' => $this->_getSubTabs())));
             if (isset($_POST['replace'])) {
                 $this->replaceAction();
             }
             if (!isset($goto)) {
                 $goto = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
             }
             // Defines the url to return to in case of error in the next sql
             // statement
             $params = array('db' => $this->db, 'table' => $this->table);
             $err_url = $goto . '?' . PMA_URL_getCommon($params);
             // Displays the find and replace form
             $this->response->addHTML(Template::get('table/search/selection_form')->render(array('searchType' => $this->_searchType, 'db' => $this->db, 'table' => $this->table, 'goto' => $goto, 'self' => $this, 'geomColumnFlag' => $this->_geomColumnFlag, 'columnNames' => $this->_columnNames, 'columnTypes' => $this->_columnTypes, 'columnCollations' => $this->_columnCollations, 'dataLabel' => null)));
             break;
         case 'normal':
             $this->response->getHeader()->getScripts()->addFiles(array('makegrid.js', 'sql.js', 'tbl_select.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js', 'jquery/jquery.uitablefilter.js', 'gis_data_editor.js'));
             if (isset($_REQUEST['range_search'])) {
                 $this->rangeSearchAction();
                 return;
             }
             /**
              * No selection criteria received -> display the selection form
              */
             if (!isset($_POST['columnsToDisplay']) && !isset($_POST['displayAllColumns'])) {
                 $this->displaySelectionFormAction();
             } else {
                 $this->doSelectionAction();
             }
             break;
         case 'zoom':
             $this->response->getHeader()->getScripts()->addFiles(array('makegrid.js', 'sql.js', 'jqplot/jquery.jqplot.js', 'jqplot/plugins/jqplot.canvasTextRenderer.js', 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js', 'jqplot/plugins/jqplot.dateAxisRenderer.js', 'jqplot/plugins/jqplot.highlighter.js', 'jqplot/plugins/jqplot.cursor.js', 'canvg/canvg.js', 'jquery/jquery-ui-timepicker-addon.js', 'tbl_zoom_plot_jqplot.js', 'tbl_change.js'));
             /**
              * Handle AJAX request for data row on point select
              *
              * @var boolean Object containing parameters for the POST request
              */
             if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
                 $this->getDataRowAction();
                 return;
             }
             /**
              * Handle AJAX request for changing field information
              * (value,collation,operators,field values) in input form
              *
              * @var boolean Object containing parameters for the POST request
              */
             if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
                 $this->changeTableInfoAction();
                 return;
             }
             $this->url_query .= '&amp;goto=tbl_select.php&amp;back=tbl_select.php';
             // Gets tables information
             include_once './libraries/tbl_info.inc.php';
             if (!isset($goto)) {
                 $goto = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
             }
             // Defines the url to return to in case of error in the next sql
             // statement
             $err_url = $goto . PMA_URL_getCommon(array('db' => $this->db, 'table' => $this->table));
             //Set default datalabel if not selected
             if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
                 $dataLabel = PMA_getDisplayField($this->db, $this->table);
             } else {
                 $dataLabel = $_POST['dataLabel'];
             }
             // Displays the zoom search form
             $this->response->addHTML(Template::get('secondary_tabs')->render(array('url_params' => array('db' => $this->db, 'table' => $this->table), 'sub_tabs' => $this->_getSubTabs())));
             $this->response->addHTML(Template::get('table/search/selection_form')->render(array('searchType' => $this->_searchType, 'db' => $this->db, 'table' => $this->table, 'goto' => $goto, 'self' => $this, 'geomColumnFlag' => $this->_geomColumnFlag, 'columnNames' => $this->_columnNames, 'columnTypes' => $this->_columnTypes, 'columnCollations' => $this->_columnCollations, 'dataLabel' => $dataLabel)));
             /*
              * Handle the input criteria and generate the query result
              * Form for displaying query results
              */
             if (isset($_POST['zoom_submit']) && $_POST['criteriaColumnNames'][0] != 'pma_null' && $_POST['criteriaColumnNames'][1] != 'pma_null' && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]) {
                 $this->zoomSubmitAction($dataLabel, $goto);
             }
             break;
     }
 }
 /**
  * Test for PMA_relationsCleanupColumn
  *
  * @return void
  * @group medium
  */
 public function testPMARelationsCleanupColumn()
 {
     $db = "PMA";
     $table = "PMA_bookmark";
     $column = "name";
     $this->redefineRelation();
     //the $cfgRelation value before cleanup column
     $cfgRelation = PMA_checkRelationsParam();
     $this->assertEquals(true, $cfgRelation['commwork']);
     //validate PMA_getDbComments when commwork = true
     $db_comments = PMA_getDbComments();
     $this->assertEquals(array('db_name0' => 'comment0', 'db_name1' => 'comment1'), $db_comments);
     $this->assertEquals(true, $cfgRelation['displaywork']);
     //validate PMA_getDisplayField when displaywork = true
     $display_field = PMA_getDisplayField($db, $table);
     $this->assertEquals('PMA_display_field', $display_field);
     $this->assertEquals(true, $cfgRelation['relwork']);
     $this->assertEquals('column_info', $cfgRelation['column_info']);
     $this->assertEquals('table_info', $cfgRelation['table_info']);
     $this->assertEquals('relation', $cfgRelation['relation']);
     //cleanup
     PMA_relationsCleanupColumn($db, $table, $column);
     //the $cfgRelation value after cleanup column
     $cfgRelation = PMA_checkRelationsParam();
     $is_defined_column_info = isset($cfgRelation['column_info']) ? $cfgRelation['column_info'] : null;
     $is_defined_table_info = isset($cfgRelation['table_info']) ? $cfgRelation['table_info'] : null;
     $is_defined_relation = isset($cfgRelation['relation']) ? $cfgRelation['relation'] : null;
     $this->assertEquals(null, $is_defined_column_info);
     $this->assertEquals(null, $is_defined_table_info);
     $this->assertEquals(null, $is_defined_relation);
 }
예제 #12
0
  * transformed fields, if they were edited. After that, output the correct
  * link/transformed value and exit
  *
  * Logic taken from libraries/display_tbl.lib.php
  */
 if (isset($_REQUEST['rel_fields_list']) && $_REQUEST['rel_fields_list'] != '') {
     //handle relations work here for updated row.
     include_once './libraries/relation.lib.php';
     $map = PMA_getForeigners($db, $table, '', 'both');
     $rel_fields = array();
     parse_str($_REQUEST['rel_fields_list'], $rel_fields);
     // loop for each relation cell
     foreach ($rel_fields as $cell_index => $curr_cell_rel_field) {
         foreach ($curr_cell_rel_field as $rel_field => $rel_field_value) {
             $where_comparison = "='" . $rel_field_value . "'";
             $display_field = PMA_getDisplayField($map[$rel_field]['foreign_db'], $map[$rel_field]['foreign_table']);
             // Field to display from the foreign table?
             if (isset($display_field) && strlen($display_field)) {
                 $dispsql = 'SELECT ' . PMA_backquote($display_field) . ' FROM ' . PMA_backquote($map[$rel_field]['foreign_db']) . '.' . PMA_backquote($map[$rel_field]['foreign_table']) . ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field']) . $where_comparison;
                 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
                 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
                     list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
                 } else {
                     //$dispval = __('Link not found');
                 }
                 @PMA_DBI_free_result($dispresult);
             } else {
                 $dispval = '';
             }
             // end if... else...
             if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
예제 #13
0
$foreign_link = false;
if ($foreigners && isset($foreigners[$field])) {
    $foreigner = $foreigners[$field];
    $foreign_db = $foreigner['foreign_db'];
    $foreign_table = $foreigner['foreign_table'];
    $foreign_field = $foreigner['foreign_field'];
    // Count number of rows in the foreign table. Currently we do
    // not use a drop-down if more than 200 rows in the foreign table,
    // for speed reasons and because we need a better interface for this.
    //
    // We could also do the SELECT anyway, with a LIMIT, and ensure that
    // the current value of the field is one of the choices.
    $the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
    if (isset($override_total) && $override_total == true || $the_total < 200) {
        // foreign_display can be FALSE if no display field defined:
        $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
        $dispsql = 'SELECT ' . PMA_backquote($foreign_field) . ($foreign_display == FALSE ? '' : ', ' . PMA_backquote($foreign_display)) . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table) . ($foreign_display == FALSE ? '' : ' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display)) . (isset($foreign_limit) ? $foreign_limit : '');
        $disp = PMA_DBI_query($dispsql);
        if ($disp) {
            // garvin: If a resultset has been created, pre-cache it in the $disp_row array
            // This helps us from not needing to use mysql_data_seek by accessing a pre-cached
            // PHP array. Usually those resultsets are not that big, so a performance hit should
            // not be expected.
            $disp_row = array();
            while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
                $disp_row[] = $single_disp_row;
            }
            @PMA_DBI_free_result($disp);
        }
    } else {
        unset($disp_row);
 /**
 * The "PMA_RT_Table" constructor
 *
 * @param string $ The table name
 * @param integer $ The font size
 * @param integer $ The max. with among tables
 * @global object    The current PDF document
 * @global integer   The current page number (from the
 *                     $cfg['Servers'][$i]['table_coords'] table)
 * @global array     The relations settings
 * @global string    The current db name
 * @access private
 * @see PMA_PDF, PMA_RT_Table::PMA_RT_Table_setWidth,
      PMA_RT_Table::PMA_RT_Table_setHeight
 */
 function __construct($table_name, $ff, &$same_wide_width, $show_keys)
 {
     global $pdf, $pdf_page_number, $cfgRelation, $db;
     $this->table_name = $table_name;
     $sql = 'DESCRIBE ' . PMA_backquote($table_name);
     $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
     if (!$result || !PMA_DBI_num_rows($result)) {
         $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
     }
     // load fields
     //check to see if it will load all fields or only the foreign keys
     if ($show_keys) {
         $indexes = PMA_Index::getFromTable($this->table_name, $db);
         $all_columns = array();
         foreach ($indexes as $index) {
             $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
         }
         $this->fields = array_keys($all_columns);
     } else {
         while ($row = PMA_DBI_fetch_row($result)) {
             $this->fields[] = $row[0];
         }
     }
     // height and width
     $this->PMA_RT_Table_setWidth($ff);
     $this->PMA_RT_Table_setHeight();
     if ($same_wide_width < $this->width) {
         $same_wide_width = $this->width;
     }
     // x and y
     $sql = 'SELECT x, y FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND   table_name = \'' . PMA_sqlAddslashes($table_name) . '\'' . ' AND   pdf_page_number = ' . $pdf_page_number;
     $result = PMA_query_as_cu($sql, false, PMA_DBI_QUERY_STORE);
     if (!$result || !PMA_DBI_num_rows($result)) {
         $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
     }
     list($this->x, $this->y) = PMA_DBI_fetch_row($result);
     $this->x = (double) $this->x;
     $this->y = (double) $this->y;
     // displayfield
     $this->displayfield = PMA_getDisplayField($db, $table_name);
     // index
     $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table_name) . ';', null, PMA_DBI_QUERY_STORE);
     if (PMA_DBI_num_rows($result) > 0) {
         while ($row = PMA_DBI_fetch_assoc($result)) {
             if ($row['Key_name'] == 'PRIMARY') {
                 $this->primary[] = $row['Column_name'];
             }
         }
     }
     // end if
 }
예제 #15
0
/**
 * Column to display from the foreign table?
 *
 * @param string $where_comparison     string that contain relation field value
 * @param string $relation_field_value relation field value
 * @param array  $map                  all Relations to foreign tables for a given
 *                                     table or optionally a given column in a table
 * @param string $relation_field       relation field
 *
 * @return string $dispval display value from the foriegn table
 */
function PMA_getDisplayValueForForeignTableColumn($where_comparison, $relation_field_value, $map, $relation_field)
{
    $display_field = PMA_getDisplayField($map[$relation_field]['foreign_db'], $map[$relation_field]['foreign_table']);
    // Field to display from the foreign table?
    if (isset($display_field) && strlen($display_field)) {
        $dispsql = 'SELECT ' . PMA_Util::backquote($display_field) . ' FROM ' . PMA_Util::backquote($map[$relation_field]['foreign_db']) . '.' . PMA_Util::backquote($map[$relation_field]['foreign_table']) . ' WHERE ' . PMA_Util::backquote($map[$relation_field]['foreign_field']) . $where_comparison;
        $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
        if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
            list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
        }
        @PMA_DBI_free_result($dispresult);
        return $dispval;
    }
    return '';
}
예제 #16
0
/**
 * During grid edit, if we have a relational field, show the dropdown for it
 *
 * Logic taken from libraries/display_tbl_lib.php
 *
 * This doesn't seem to be the right place to do this, but I can't think of any
 * better place either.
 */
if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) {
    include_once 'libraries/relation.lib.php';

    $column = $_REQUEST['column'];
    $foreigners = PMA_getForeigners($db, $table, $column);

    $display_field = PMA_getDisplayField($foreigners[$column]['foreign_db'], $foreigners[$column]['foreign_table']);

    $foreignData = PMA_getForeignData($foreigners, $column, false, '', '');

    if ($_SESSION['tmp_user_values']['relational_display'] == 'D'
        && isset($display_field)
        && strlen($display_field)
        && isset($_REQUEST['relation_key_or_display_column'])
        && $_REQUEST['relation_key_or_display_column']
    ) {
            $curr_value = $_REQUEST['relation_key_or_display_column'];
    } else {
        $curr_value = $_REQUEST['curr_value'];
    }
    if ($foreignData['disp_row'] == null) {
        //Handle the case when number of values is more than $cfg['ForeignKeyMaxLimit']
예제 #17
0
 /**
  * The "Table_Stats" constructor
  *
  * @param string  $tableName      The table name
  * @param integer $fontSize       The font size
  * @param integer $pageNumber     The current page number (from the
  *                                $cfg['Servers'][$i]['table_coords'] table)
  * @param integer &$sameWideWidth The max. with among tables
  * @param boolean $showKeys       Whether to display keys or not
  * @param boolean $showInfo       Whether to display table position or not
  *
  * @global object    The current PDF document
  * @global array     The relations settings
  * @global string    The current db name
  *
  * @return void
  *
  * @see PMA_Schema_PDF, Table_Stats::Table_Stats_setWidth,
  *     Table_Stats::Table_Stats_setHeight
  */
 function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth, $showKeys = false, $showInfo = false)
 {
     global $pdf, $cfgRelation, $db;
     $this->_tableName = $tableName;
     $sql = 'DESCRIBE ' . PMA_backquote($tableName);
     $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
     if (!$result || !PMA_DBI_num_rows($result)) {
         $pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName));
     }
     // load fields
     //check to see if it will load all fields or only the foreign keys
     if ($showKeys) {
         $indexes = PMA_Index::getFromTable($this->_tableName, $db);
         $all_columns = array();
         foreach ($indexes as $index) {
             $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
         }
         $this->fields = array_keys($all_columns);
     } else {
         while ($row = PMA_DBI_fetch_row($result)) {
             $this->fields[] = $row[0];
         }
     }
     $this->_showInfo = $showInfo;
     $this->_setHeight();
     /*
      * setWidth must me after setHeight, because title
      * can include table height which changes table width
      */
     $this->_setWidth($fontSize);
     if ($sameWideWidth < $this->width) {
         $sameWideWidth = $this->width;
     }
     $sql = 'SELECT x, y FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND   table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' . ' AND   pdf_page_number = ' . $pageNumber;
     $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
     if (!$result || !PMA_DBI_num_rows($result)) {
         $pdf->Error(sprintf(__('Please configure the coordinates for table %s'), $tableName));
     }
     list($this->x, $this->y) = PMA_DBI_fetch_row($result);
     $this->x = (double) $this->x;
     $this->y = (double) $this->y;
     /*
      * displayfield
      */
     $this->displayfield = PMA_getDisplayField($db, $tableName);
     /*
      * index
      */
     $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
     if (PMA_DBI_num_rows($result) > 0) {
         while ($row = PMA_DBI_fetch_assoc($result)) {
             if ($row['Key_name'] == 'PRIMARY') {
                 $this->primary[] = $row['Column_name'];
             }
         }
     }
 }
예제 #18
0
/**
 * Get HTML to display tables on designer page
 *
 * @param array $tab_pos                  tables positions
 * @param int   $display_page             page number of the selected page
 * @param array $tab_column               table column info
 * @param array $tables_all_keys          all indices
 * @param array $tables_pk_or_unique_keys unique or primary indices
 *
 * @return string html
 */
function PMA_getDatabaseTables($tab_pos, $display_page, $tab_column, $tables_all_keys, $tables_pk_or_unique_keys)
{
    $html = '';
    for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
        $t_n = $GLOBALS['PMD']["TABLE_NAME"][$i];
        $t_n_url = $GLOBALS['PMD_URL']["TABLE_NAME"][$i];
        $html .= '<input name="t_x[' . $t_n_url . ']" type="hidden" id="t_x_' . $t_n_url . '_" />';
        $html .= '<input name="t_y[' . $t_n_url . ']" type="hidden" id="t_y_' . $t_n_url . '_" />';
        $html .= '<input name="t_v[' . $t_n_url . ']" type="hidden" id="t_v_' . $t_n_url . '_" />';
        $html .= '<input name="t_h[' . $t_n_url . ']" type="hidden" id="t_h_' . $t_n_url . '_" />';
        $html .= '<table id="' . $t_n_url . '" cellpadding="0" cellspacing="0" ';
        $html .= 'class="pmd_tab" style="position:absolute;';
        $html .= 'left:';
        $html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["X"] : rand(20, 700)) . 'px;';
        $html .= 'top:';
        $html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["Y"] : rand(20, 550)) . 'px;';
        $html .= 'display:';
        $html .= isset($tab_pos[$t_n]) || $display_page == -1 ? 'block;' : 'none;';
        $html .= 'z-index: 1;">';
        $html .= '<thead>';
        $html .= '<tr class="header">';
        if (isset($_REQUEST['query'])) {
            $html .= '<td class="select_all">';
            $html .= '<input class="select_all_1" type="checkbox" ' . 'style="margin: 0px;" ';
            $html .= 'value="select_all_' . htmlspecialchars($t_n_url) . '" ';
            $html .= 'id="select_all_' . htmlspecialchars($t_n_url) . '" ';
            $html .= 'title="select all" pmd_url_table_name="' . htmlspecialchars($t_n_url) . '" ';
            $html .= 'pmd_out_owner="' . htmlspecialchars($GLOBALS['PMD_OUT']['OWNER'][$i]) . '">';
            $html .= '</td>';
        }
        $html .= '<td class="small_tab" ';
        $html .= 'id="id_hide_tbody_' . $t_n_url . '" ';
        $html .= 'table_name="' . htmlspecialchars($t_n_url) . '" onmouseover="this.className=\'small_tab2\';" ';
        $html .= 'onmouseout="this.className=\'small_tab\';" ';
        $html .= '>';
        // no space allowed here, between tags and content !!!
        // JavaScript function does require this
        if (!isset($tab_pos[$t_n]) || !empty($tab_pos[$t_n]["V"])) {
            $html .= 'v';
        } else {
            $html .= '&gt;';
        }
        $html .= '</td>';
        $html .= '<td class="small_tab_pref small_tab_pref_1" ';
        $html .= 'table_name_small="' . $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '" onmouseover="this.className=' . '\'small_tab_pref2 small_tab_pref_1\';" ';
        $html .= 'onmouseout="this.className=\'small_tab_pref small_tab_pref_1\';" ';
        $html .= '>';
        $html .= '<img alt="" ';
        $html .= 'src="' . $_SESSION['PMA_Theme']->getImgPath('pmd/exec_small.png') . '" />';
        $html .= '</td>';
        $html .= '<td id="id_zag_' . htmlspecialchars($t_n_url) . '" class="tab_zag nowrap tab_zag_noquery" ';
        $html .= 'onmousedown="cur_click=document.getElementById(\'' . $t_n_url . '\');" ';
        $html .= 'table_name="' . htmlspecialchars($t_n_url) . '' . '" query_set="' . (isset($_REQUEST['query']) ? 1 : 0) . '" ';
        $html .= '>';
        $html .= '<span class="owner">';
        $html .= $GLOBALS['PMD_OUT']["OWNER"][$i] . '.';
        $html .= '</span>';
        $html .= $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i];
        $html .= '</td>';
        if (isset($_REQUEST['query'])) {
            $html .= '<td class="tab_zag tab_zag_query" ';
            $html .= 'id="id_zag_' . htmlspecialchars($t_n_url) . '_2" ';
            $html .= 'table_name="' . htmlspecialchars($t_n_url) . '" ';
            $html .= 'onmousedown="cur_click=document.getElementById(\'' . htmlspecialchars($t_n_url) . '\');" ';
            $html .= '>';
        }
        $html .= '</tr>';
        $html .= '</thead>';
        $html .= '<tbody id="id_tbody_' . $t_n_url . '" ';
        if (isset($tab_pos[$t_n]) && empty($tab_pos[$t_n]["V"])) {
            $html .= 'style="display: none;"';
        }
        $html .= '>';
        $display_field = PMA_getDisplayField($_GET['db'], $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
        for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) {
            $html .= '<tr id="id_tr_' . $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '.' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '" ';
            if ($display_field == $tab_column[$t_n]["COLUMN_NAME"][$j]) {
                $html .= 'class="tab_field_3" ';
            } else {
                $html .= 'class="tab_field" ';
            }
            $html .= 'onmouseover="old_class = this.className; ';
            $html .= 'this.className = \'tab_field_2\';" ';
            $html .= 'onmouseout="this.className = old_class;" ';
            $html .= 'click_field_param="';
            $html .= $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . ',';
            $html .= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . ',';
            $tmpColumn = $t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j];
            if (!PMA_Util::isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
                $html .= isset($tables_pk_or_unique_keys[$tmpColumn]) ? 1 : 0;
            } else {
                // if foreign keys are supported, it's not necessary that the
                // index is a primary key
                $html .= isset($tables_all_keys[$tmpColumn]) ? 1 : 0;
            }
            $html .= '"';
            $html .= '>';
            if (isset($_REQUEST['query'])) {
                $html .= '<td class="select_all">';
                $html .= '<input class="select_all_store_col" value="' . htmlspecialchars($t_n_url) . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '"';
                $html .= 'type="checkbox" id="select_' . htmlspecialchars($t_n_url) . '._' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '" ';
                $html .= 'style="margin: 0px;" title="select_' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '" ';
                $html .= 'store_column_param="' . urlencode($GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i]) . ',' . htmlspecialchars($GLOBALS['PMD_OUT']["OWNER"][$i]) . ',' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '"></td>';
            }
            $html .= '<td width="10px" colspan="3"';
            $html .= 'id="' . $t_n_url . '.' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) . '">';
            $html .= '<div class="nowrap">';
            if (isset($tables_pk_or_unique_keys[$t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j]])) {
                $html .= '<img src="' . $_SESSION['PMA_Theme']->getImgPath('pmd/FieldKey_small.png') . '" alt="*" />';
            } else {
                $image = 'pmd/Field_small';
                if (strstr($tab_column[$t_n]["TYPE"][$j], 'char') || strstr($tab_column[$t_n]["TYPE"][$j], 'text')) {
                    $image .= '_char';
                } elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'int') || strstr($tab_column[$t_n]["TYPE"][$j], 'float') || strstr($tab_column[$t_n]["TYPE"][$j], 'double') || strstr($tab_column[$t_n]["TYPE"][$j], 'decimal')) {
                    $image .= '_int';
                } elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'date') || strstr($tab_column[$t_n]["TYPE"][$j], 'time') || strstr($tab_column[$t_n]["TYPE"][$j], 'year')) {
                    $image .= '_date';
                }
                $image .= '.png';
                $html .= '<img src="' . $_SESSION['PMA_Theme']->getImgPath($image) . '" alt="*" />';
            }
            $html .= htmlspecialchars($tab_column[$t_n]["COLUMN_NAME"][$j] . " : " . $tab_column[$t_n]["TYPE"][$j], ENT_QUOTES);
            $html .= "</div>\n</td>\n";
            if (isset($_REQUEST['query'])) {
                $html .= '<td class="small_tab_pref small_tab_pref_click_opt" ';
                $html .= 'onmouseover="this.className=' . '\'small_tab_pref2 small_tab_pref_click_opt\';" ';
                $html .= 'onmouseout="this.className=' . '\'small_tab_pref small_tab_pref_click_opt\';" ';
                $html .= 'Click_option_param="pmd_optionse,' . urlencode($tab_column[$t_n]['COLUMN_NAME'][$j]) . ',' . $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] . '" >';
                $html .= '<img src="' . $_SESSION['PMA_Theme']->getImgPath('pmd/exec_small.png') . '" title="options" alt="" /></td> ';
            }
            $html .= "</tr>";
        }
        $html .= "</tbody>";
        $html .= "</table>";
    }
    return $html;
}
예제 #19
0
/**
 * Column to display from the foreign table?
 *
 * @param string $where_comparison string that contain relation field value
 * @param array  $map              all Relations to foreign tables for a given
 *                                 table or optionally a given column in a table
 * @param string $relation_field   relation field
 *
 * @return string $dispval display value from the foreign table
 */
function PMA_getDisplayValueForForeignTableColumn($where_comparison, $map, $relation_field)
{
    $foreigner = PMA_searchColumnInForeigners($map, $relation_field);
    $display_field = PMA_getDisplayField($foreigner['foreign_db'], $foreigner['foreign_table']);
    // Field to display from the foreign table?
    if (isset($display_field) && mb_strlen($display_field)) {
        $dispsql = 'SELECT ' . PMA_Util::backquote($display_field) . ' FROM ' . PMA_Util::backquote($foreigner['foreign_db']) . '.' . PMA_Util::backquote($foreigner['foreign_table']) . ' WHERE ' . PMA_Util::backquote($foreigner['foreign_field']) . $where_comparison;
        $dispresult = $GLOBALS['dbi']->tryQuery($dispsql, null, PMA_DatabaseInterface::QUERY_STORE);
        if ($dispresult && $GLOBALS['dbi']->numRows($dispresult) > 0) {
            list($dispval) = $GLOBALS['dbi']->fetchRow($dispresult, 0);
        } else {
            $dispval = '';
        }
        @$GLOBALS['dbi']->freeResult($dispresult);
        return $dispval;
    }
    return '';
}
 /**
  * Index
  *
  * @return void
  */
 public function indexAction()
 {
     // Send table of column names to populate corresponding dropdowns depending
     // on the current selection
     if (isset($_REQUEST['getDropdownValues']) && $_REQUEST['getDropdownValues'] === 'true') {
         // if both db and table are selected
         if (isset($_REQUEST['foreignTable'])) {
             $this->getDropdownValueForTableAction();
         } else {
             // if only the db is selected
             $this->getDropdownValueForDbAction();
         }
         return;
     }
     $this->response->getHeader()->getScripts()->addFiles(array('tbl_relation.js', 'indexes.js'));
     // Gets tables information
     include_once 'libraries/tbl_info.inc.php';
     // updates for Internal relations
     if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) {
         $this->updateForInternalRelationAction();
     }
     // updates for foreign keys
     if (isset($_POST['destination_foreign_db'])) {
         $this->updateForForeignKeysAction();
     }
     // Updates for display field
     if ($this->cfgRelation['displaywork'] && isset($_POST['display_field'])) {
         $this->updateForDisplayField();
     }
     // If we did an update, refresh our data
     if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) {
         $this->existrel = PMA_getForeigners($this->db, $this->table, '', 'internal');
     }
     if (isset($_POST['destination_foreign_db']) && PMA_Util::isForeignKeySupported($this->tbl_storage_engine)) {
         $this->existrel_foreign = PMA_getForeigners($this->db, $this->table, '', 'foreign');
     }
     if ($this->cfgRelation['displaywork']) {
         $this->disp = PMA_getDisplayField($this->db, $this->table);
     }
     // display secondary level tabs if necessary
     $engine = $this->dbi->getTable($this->db, $this->table)->sGetStatusInfo('ENGINE');
     $this->response->addHTML(Template::get('structure/secondary_tabs')->render(array('url_params' => array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']), 'engine' => $engine)));
     $this->response->addHTML('<div id="structure_content">');
     /**
      * Dialog
      */
     // Now find out the columns of our $table
     // need to use PMA_DatabaseInterface::QUERY_STORE with $this->dbi->numRows()
     // in mysqli
     $columns = $this->dbi->getColumns($this->db, $this->table);
     // common form
     $this->response->addHTML(Template::get('tbl_relation/common_form')->render(array('db' => $this->db, 'table' => $this->table, 'columns' => $columns, 'cfgRelation' => $this->cfgRelation, 'tbl_storage_engine' => $this->tbl_storage_engine, 'existrel' => isset($this->existrel) ? $this->existrel : array(), 'existrel_foreign' => isset($this->existrel_foreign) ? $this->existrel_foreign['foreign_keys_data'] : array(), 'options_array' => $this->options_array)));
     if (PMA_Util::isForeignKeySupported($this->tbl_storage_engine)) {
         $this->response->addHTML(PMA_getHtmlForDisplayIndexes());
     }
     $this->response->addHTML('</div>');
 }
예제 #21
0
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * @author  Ivan A Kirillov (Ivan.A.Kirillov@gmail.com)
 * @version $Id$
 * @package phpMyAdmin-Designer
 */
/**
 *
 */
include_once 'pmd_common.php';
require_once './libraries/relation.lib.php';
$table = $T;
$display_field = $F;
if ($cfgRelation['displaywork']) {
    $disp = PMA_getDisplayField($db, $table);
    if ($disp) {
        if ($display_field != $disp) {
            $upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\'' . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        } else {
            $upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        }
    } elseif ($display_field != '') {
        $upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '(db_name, table_name, display_field) ' . ' VALUES(' . '\'' . PMA_sqlAddslashes($db) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($display_field) . '\')';
    }
    if (isset($upd_query)) {
        $upd_rs = PMA_query_as_controluser($upd_query);
    }
}
// end if
header("Content-Type: text/xml; charset=utf-8");
예제 #22
0
use PMA_Util;
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/TableRelationController.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/Util.class.php';
$container = DI\Container::getDefaultContainer();
$container->factory('PMA\\Controllers\\Table\\TableRelationController');
$container->alias('TableRelationController', 'PMA\\Controllers\\Table\\TableRelationController');
/* Define dependencies for the concerned controller */
$db = $container->get('db');
$table = $container->get('table');
$dbi = $container->get('dbi');
$options_array = array('CASCADE' => 'CASCADE', 'SET_NULL' => 'SET NULL', 'NO_ACTION' => 'NO ACTION', 'RESTRICT' => 'RESTRICT');
$cfgRelation = PMA_getRelationsParam();
$tbl_storage_engine = mb_strtoupper(PMA_Table::sGetStatusInfo($db, $table, 'Engine'));
$upd_query = new PMA_Table($table, $db, $dbi);
$dependency_definitions = array("options_array" => $options_array, "cfgRelation" => $cfgRelation, "tbl_storage_engine" => $tbl_storage_engine, "upd_query" => $upd_query);
if ($cfgRelation['relwork']) {
    $dependency_definitions['existrel'] = PMA_getForeigners($db, $table, '', 'internal');
}
if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
    $dependency_definitions['existrel_foreign'] = PMA_getForeigners($db, $table, '', 'foreign');
}
if ($cfgRelation['displaywork']) {
    $dependency_definitions['disp'] = PMA_getDisplayField($db, $table);
} else {
    $dependency_definitions['disp'] = 'asas';
}
/** @var Controllers\Table\TableRelationController $controller */
$controller = $container->get('TableRelationController', $dependency_definitions);
$controller->indexAction();
예제 #23
0
 /**
  * The "PMA_RT_Table" constructor
  *
  * @param   string    The table name
  * @param   integer   The font size
  * @param   integer   The max. with among tables
  *
  * @global  object    The current PDF document
  * @global  integer   The current page number (from the
  *                    $cfg['Servers'][$i]['table_coords'] table)
  * @global  array     The relations settings
  * @global  string    The current db name
  *
  * @access  private
  *
  * @see     PMA_PDF, PMA_RT_Table::PMA_RT_Table_setWidth,
  *          PMA_RT_Table::PMA_RT_Table_setHeight
  */
 function PMA_RT_Table($table_name, $ff, &$same_wide_width)
 {
     global $pdf, $pdf_page_number, $cfgRelation, $db;
     $this->table_name = $table_name;
     $sql = 'DESCRIBE ' . PMA_backquote($table_name);
     $result = PMA_mysql_query($sql);
     if (!$result || !mysql_num_rows($result)) {
         $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
     }
     // load fields
     while ($row = PMA_mysql_fetch_array($result)) {
         $this->fields[] = $row[0];
     }
     //height and width
     $this->PMA_RT_Table_setWidth($ff);
     $this->PMA_RT_Table_setHeight();
     if ($same_wide_width < $this->width) {
         $same_wide_width = $this->width;
     }
     //x and y
     $sql = 'SELECT x, y FROM ' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND   table_name = \'' . PMA_sqlAddslashes($table_name) . '\'' . ' AND   pdf_page_number = ' . $pdf_page_number;
     $result = PMA_query_as_cu($sql);
     if (!$result || !mysql_num_rows($result)) {
         $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
     }
     list($this->x, $this->y) = PMA_mysql_fetch_array($result);
     $this->x = (double) $this->x;
     $this->y = (double) $this->y;
     // displayfield
     $this->displayfield = PMA_getDisplayField($db, $table_name);
     // index
     $sql = 'SHOW index FROM ' . PMA_backquote($table_name);
     $result = PMA_mysql_query($sql);
     if ($result && mysql_num_rows($result) > 0) {
         while ($row = PMA_mysql_fetch_array($result)) {
             if ($row['Key_name'] == 'PRIMARY') {
                 $this->primary[] = $row['Column_name'];
             }
         }
     }
     // end if
 }
예제 #24
0
    ?>
</td>
</tr>
</thead>
<tbody id="id_tbody_<?php 
    echo $t_n_url;
    ?>
"
    <?php 
    if (!isset($tab_pos[$t_n])) {
        echo 'style="display: none;"';
    }
    ?>
>
    <?php 
    $display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
    for ($j = 0; $j < count($tab_column[$t_n]["COLUMN_ID"]); $j++) {
        ?>
<tr id="id_tr_<?php 
        echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '.' . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]);
        ?>
"
        <?php 
        if ($display_field == $tab_column[$t_n]["COLUMN_NAME"][$j]) {
            echo ' class="tab_field_3" ';
        } else {
            echo ' class="tab_field" ';
        }
        ?>
    onmouseover="old_class = this.className; this.className = 'tab_field_2';"
    onmouseout="this.className = old_class;"
예제 #25
0
/**
 * Displays a table of results returned by a sql query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  string   $goto              the url to go back in case of errors
 * @global  boolean  $dontlimitchars    whether to limit the number of displayed
 *                                      characters of text type fields or not
 * @global  string   $sql_query         the current sql query
 * @global  integer  $num_rows          the total number of rows returned by the
 *                                      sql query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      sql query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  integer  $pos               the current postion of the first record
 *                                      to be displayed
 * @global  array    $fields_meta       the list of fields properties
 * @global  integer  $fields_cnt        the total number of fields returned by
 *                                      the sql query
 * @global  array    $vertical_display  informations used with vertical display
 *                                      mode
 * @global  string   $disp_direction    the display mode
 *                                      (horizontal/vertical/horizontalflipped)
 * @global  integer  $repeat_cells      the number of row to display between two
 *                                      table headers
 * @global  array    $highlight_columns collumn names to highlight
 * @global  array    $cfgRelation       the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $db, $table, $goto, $dontlimitchars;
    global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    global $cfgRelation;
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionnalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    if ($total == '') {
        unset($total);
    }
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if (!isset($pos)) {
            $pos = 0;
        }
        if ($GLOBALS['session_max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
            $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Urlencodes the query to use in input form fields
    $encoded_sql_query = urlencode($sql_query);
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $GLOBALS['session_max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        PMA_showMessage($GLOBALS['strShowingRecords'] . " {$pos} - {$last_shown_rec} (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
        if (isset($table) && PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
            echo '<div class="notice">' . "\n";
            echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
            echo '</div>' . "\n";
        }
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_showMessage($GLOBALS['strSQLQuery']);
    }
    // 2.3 Displays the navigation bars
    if (!isset($table) || strlen(trim($table)) == 0) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
            // table does not always contain a real table name,
            // for example in MySQL 5.0.x, the query SHOW STATUS
            // returns STATUS as a table name
            $table = $fields_meta[0]->table;
        } else {
            $table = '';
        }
    }
    if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
        echo "\n";
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' config variable)
    // loic1, 2002-03-02: extended to php3
    // init map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (!isset($table) || !strlen($table)) {
            $exist_rel = false;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
    $url_query = '';
    echo '<tbody>' . "\n";
    PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    echo '</tbody>' . "\n";
    // vertical output case
    if ($disp_direction == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    ?>
</table>

    <?php 
    // 4. ----- Displays the link for multi-fields delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $uncheckall_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($sql_query) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $GLOBALS['session_max_rows'] . '&amp;pos=' . $pos . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;goto=' . $goto . '&amp;dontlimitchars=' . $dontlimitchars;
        $checkall_url = $uncheckall_url . '&amp;checkall=1';
        if ($disp_direction == 'vertical') {
            $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
            $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
        } else {
            $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
            $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
        }
        $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
        $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
        if ($disp_direction != 'vertical') {
            echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />';
        }
        echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        if ($GLOBALS['cfg']['PropertiesIconic']) {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
            }
            echo "\n";
        } else {
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"' . ' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($delete_text) . '"' . ' title="' . $delete_text . '" />' . "\n";
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strExport']) . '"' . ' title="' . $GLOBALS['strExport'] . '" />' . "\n";
            }
        }
        echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
        echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
}
예제 #26
0
 /**
  * Loads the table's display field
  *
  * @return void
  */
 protected function loadDisplayField()
 {
     $this->displayfield = PMA_getDisplayField($this->db, $this->tableName);
 }
예제 #27
0
/**
 * Gets foreign keys in preparation for a drop-down selector
 *
 * @param array|boolean $foreigners     array of the foreign keys
 * @param string        $field          the foreign field name
 * @param bool          $override_total whether to override the total
 * @param string        $foreign_filter a possible filter
 * @param string        $foreign_limit  a possible LIMIT clause
 *
 * @return array    data about the foreign keys
 *
 * @access  public
 */
function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filter, $foreign_limit)
{
    // we always show the foreign field in the drop-down; if a display
    // field is defined, we show it besides the foreign field
    $foreign_link = false;
    do {
        if (!$foreigners) {
            break;
        }
        $foreigner = PMA_searchColumnInForeigners($foreigners, $field);
        if ($foreigner != false) {
            $foreign_db = $foreigner['foreign_db'];
            $foreign_table = $foreigner['foreign_table'];
            $foreign_field = $foreigner['foreign_field'];
        } else {
            break;
        }
        // Count number of rows in the foreign table. Currently we do
        // not use a drop-down if more than ForeignKeyMaxLimit rows in the
        // foreign table,
        // for speed reasons and because we need a better interface for this.
        //
        // We could also do the SELECT anyway, with a LIMIT, and ensure that
        // the current value of the field is one of the choices.
        $the_total = PMA_Table::countRecords($foreign_db, $foreign_table, true);
        if ($override_total == true || $the_total < $GLOBALS['cfg']['ForeignKeyMaxLimit']) {
            // foreign_display can be false if no display field defined:
            $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
            $f_query_main = 'SELECT ' . PMA_Util::backquote($foreign_field) . ($foreign_display == false ? '' : ', ' . PMA_Util::backquote($foreign_display));
            $f_query_from = ' FROM ' . PMA_Util::backquote($foreign_db) . '.' . PMA_Util::backquote($foreign_table);
            $f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . PMA_Util::backquote($foreign_field) . ' LIKE "%' . PMA_Util::sqlAddSlashes($foreign_filter, true) . '%"' . ($foreign_display == false ? '' : ' OR ' . PMA_Util::backquote($foreign_display) . ' LIKE "%' . PMA_Util::sqlAddSlashes($foreign_filter, true) . '%"');
            $f_query_order = $foreign_display == false ? '' : ' ORDER BY ' . PMA_Util::backquote($foreign_table) . '.' . PMA_Util::backquote($foreign_display);
            $f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
            if (!empty($foreign_filter)) {
                $the_total = $GLOBALS['dbi']->fetchValue('SELECT COUNT(*)' . $f_query_from . $f_query_filter);
                if ($the_total === false) {
                    $the_total = 0;
                }
            }
            $disp = $GLOBALS['dbi']->tryQuery($f_query_main . $f_query_from . $f_query_filter . $f_query_order . $f_query_limit);
            if ($disp && $GLOBALS['dbi']->numRows($disp) > 0) {
                // If a resultset has been created, pre-cache it in the $disp_row
                // array. This helps us from not needing to use mysql_data_seek by
                // accessing a pre-cached PHP array. Usually those resultsets are
                // not that big, so a performance hit should not be expected.
                $disp_row = array();
                while ($single_disp_row = @$GLOBALS['dbi']->fetchAssoc($disp)) {
                    $disp_row[] = $single_disp_row;
                }
                @$GLOBALS['dbi']->freeResult($disp);
            } else {
                // Either no data in the foreign table or
                // user does not have select permission to foreign table/field
                // Show an input field with a 'Browse foreign values' link
                $disp_row = null;
                $foreign_link = true;
            }
        } else {
            $disp_row = null;
            $foreign_link = true;
        }
    } while (false);
    $foreignData = array();
    $foreignData['foreign_link'] = $foreign_link;
    $foreignData['the_total'] = isset($the_total) ? $the_total : null;
    $foreignData['foreign_display'] = isset($foreign_display) ? $foreign_display : null;
    $foreignData['disp_row'] = isset($disp_row) ? $disp_row : null;
    $foreignData['foreign_field'] = isset($foreign_field) ? $foreign_field : null;
    return $foreignData;
}
예제 #28
0
/**
 * Gets foreign keys in preparation for a drop-down selector
 *
 * @param array  $foreigners     array of the foreign keys
 * @param string $field          the foreign field name
 * @param bool   $override_total whether to override the total
 * @param string $foreign_filter a possible filter
 * @param string $foreign_limit  a possible LIMIT clause
 *
 * @return  array    data about the foreign keys
 *
 * @access  public
 */
function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filter, $foreign_limit)
{
    // we always show the foreign field in the drop-down; if a display
    // field is defined, we show it besides the foreign field
    $foreign_link = false;
    if ($foreigners && isset($foreigners[$field])) {
        $foreigner = $foreigners[$field];
        $foreign_db = $foreigner['foreign_db'];
        $foreign_table = $foreigner['foreign_table'];
        $foreign_field = $foreigner['foreign_field'];
        // Count number of rows in the foreign table. Currently we do
        // not use a drop-down if more than 200 rows in the foreign table,
        // for speed reasons and because we need a better interface for this.
        //
        // We could also do the SELECT anyway, with a LIMIT, and ensure that
        // the current value of the field is one of the choices.
        $the_total = PMA_Table::countRecords($foreign_db, $foreign_table);
        if ($override_total == true || $the_total < $GLOBALS['cfg']['ForeignKeyMaxLimit']) {
            // foreign_display can be false if no display field defined:
            $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
            $f_query_main = 'SELECT ' . PMA_backquote($foreign_field) . ($foreign_display == false ? '' : ', ' . PMA_backquote($foreign_display));
            $f_query_from = ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
            $f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . PMA_backquote($foreign_field) . ' LIKE "%' . PMA_sqlAddSlashes($foreign_filter, true) . '%"' . ($foreign_display == false ? '' : ' OR ' . PMA_backquote($foreign_display) . ' LIKE "%' . PMA_sqlAddSlashes($foreign_filter, true) . '%"');
            $f_query_order = $foreign_display == false ? '' : ' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display);
            $f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
            if (!empty($foreign_filter)) {
                $res = PMA_DBI_query('SELECT COUNT(*)' . $f_query_from . $f_query_filter);
                if ($res) {
                    $the_total = PMA_DBI_fetch_value($res);
                    @PMA_DBI_free_result($res);
                } else {
                    $the_total = 0;
                }
            }
            $disp = PMA_DBI_query($f_query_main . $f_query_from . $f_query_filter . $f_query_order . $f_query_limit);
            if ($disp && PMA_DBI_num_rows($disp) > 0) {
                // If a resultset has been created, pre-cache it in the $disp_row array
                // This helps us from not needing to use mysql_data_seek by accessing a pre-cached
                // PHP array. Usually those resultsets are not that big, so a performance hit should
                // not be expected.
                $disp_row = array();
                while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
                    $disp_row[] = $single_disp_row;
                }
                @PMA_DBI_free_result($disp);
            }
        } else {
            $disp_row = null;
            $foreign_link = true;
        }
    }
    // end if $foreigners
    $foreignData['foreign_link'] = $foreign_link;
    $foreignData['the_total'] = isset($the_total) ? $the_total : null;
    $foreignData['foreign_display'] = isset($foreign_display) ? $foreign_display : null;
    $foreignData['disp_row'] = isset($disp_row) ? $disp_row : null;
    $foreignData['foreign_field'] = isset($foreign_field) ? $foreign_field : null;
    return $foreignData;
}
    $response->addJSON('field_value', $properties['value']);
    exit;
}
// Gets some core libraries
require_once './libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_select.php&amp;back=tbl_select.php';
// Gets tables informations
require_once './libraries/tbl_info.inc.php';
if (!isset($goto)) {
    $goto = $GLOBALS['cfg']['DefaultTabTable'];
}
// Defines the url to return to in case of error in the next sql statement
$err_url = $goto . PMA_URL_getCommon(array('db' => $db, 'table' => $table));
//Set default datalabel if not selected
if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
    $dataLabel = PMA_getDisplayField($db, $table);
} else {
    $dataLabel = $_POST['dataLabel'];
}
// Displays the zoom search form
$response->addHTML($table_search->getSecondaryTabs());
$response->addHTML($table_search->getSelectionForm($goto, $dataLabel));
/*
 * Handle the input criteria and generate the query result
 * Form for displaying query results
 */
if (isset($_POST['zoom_submit']) && $_POST['criteriaColumnNames'][0] != 'pma_null' && $_POST['criteriaColumnNames'][1] != 'pma_null' && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]) {
    //Query generation part
    $sql_query = $table_search->buildSqlQuery();
    $sql_query .= ' LIMIT ' . $_POST['maxPlotLimit'];
    //Query execution part
예제 #30
0
파일: sql.lib.php 프로젝트: yszar/linuxwp
/**
 * Get the HTML for relational column dropdown
 * During grid edit, if we have a relational field, returns the html for the
 * dropdown
 *
 * @param string $db         current database
 * @param string $table      current table
 * @param string $column     current column
 * @param string $curr_value current selected value
 *
 * @return string $dropdown html for the dropdown
 */
function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_value)
{
    $foreigners = PMA_getForeigners($db, $table, $column);
    $display_field = PMA_getDisplayField($foreigners[$column]['foreign_db'], $foreigners[$column]['foreign_table']);
    $foreignData = PMA_getForeignData($foreigners, $column, false, '', '');
    if ($foreignData['disp_row'] == null) {
        //Handle the case when number of values
        //is more than $cfg['ForeignKeyMaxLimit']
        $_url_params = array('db' => $db, 'table' => $table, 'field' => $column);
        $dropdown = '<span class="curr_value">' . htmlspecialchars($_REQUEST['curr_value']) . '</span>' . '<a href="browse_foreigners.php' . PMA_URL_getCommon($_url_params) . '"' . ' target="_blank" class="browse_foreign" ' . '>' . __('Browse foreign values') . '</a>';
    } else {
        $dropdown = PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $curr_value, $GLOBALS['cfg']['ForeignKeyMaxLimit']);
        $dropdown = '<select>' . $dropdown . '</select>';
    }
    return $dropdown;
}