echo $field_name_appendix_md5;
            ?>
"
                <?php 
            echo $unnullify_trigger;
            ?>
                tabindex="<?php 
            echo $tabindex + $tabindex_for_value;
            ?>
"
                id="field_<?php 
            echo $idindex;
            ?>
_3">
                <?php 
            echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']);
            ?>
            </select>
            <?php 
            // still needed? :
            unset($foreignData['disp_row']);
        } elseif ($cfg['LongtextDoubleTextarea'] && strstr($field['pma_type'], 'longtext')) {
            ?>
            &nbsp;</td>
        </tr>
        <tr class="<?php 
            echo $odd_row ? 'odd' : 'even';
            ?>
">
            <td colspan="5" align="right">
                <?php 
Exemplo n.º 2
0
    /**
     * Provides html elements for search criteria inputbox
     * in case the column is a Foreign Key
     *
     * @param array  $foreignData         Foreign keys data
     * @param string $column_name         Column name
     * @param int    $column_index        Column index
     * @param array  $titles              Selected title
     * @param int    $foreignMaxLimit     Max limit of displaying foreign elements
     * @param array  $criteriaValues      Array of search criteria inputs
     * @param string $column_id           Column's inputbox's id
     * @param bool   $in_zoom_search_edit Whether we are in zoom search edit
     *
     * @return string HTML elements.
     */
    private function _getForeignKeyInputBox($foreignData, $column_name, $column_index, $titles, $foreignMaxLimit, $criteriaValues, $column_id, $in_zoom_search_edit = false)
    {
        $html_output = '';
        if (is_array($foreignData['disp_row'])) {
            $html_output .= '<select name="criteriaValues[' . $column_index . ']"' . ' id="' . $column_id . $column_index . '">';
            $html_output .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $foreignMaxLimit);
            $html_output .= '</select>';
        } elseif ($foreignData['foreign_link'] == true) {
            $html_output .= '<input type="text" id="' . $column_id . $column_index . '"' . ' name="criteriaValues[' . $column_index . ']" id="field_' . md5($column_name) . '[' . $column_index . ']" class="textfield"' . (isset($criteriaValues[$column_index]) && is_string($criteriaValues[$column_index]) ? ' value="' . $criteriaValues[$column_index] . '"' : '') . ' />';
            $html_output .= <<<EOT
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
EOT;
            $html_output .= '' . PMA_URL_getCommon($this->_db, $this->_table) . '&amp;field=' . urlencode($column_name) . '&amp;fieldkey=' . $column_index . '&amp;fromsearch=1"';
            if ($in_zoom_search_edit) {
                $html_output .= ' class="browse_foreign"';
            }
            $html_output .= '>' . str_replace("'", "\\'", $titles['Browse']) . '</a>';
        }
        return $html_output;
    }
Exemplo n.º 3
0
/**
 * 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);
    $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) . '"' . 'class="ajax 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;
}
Exemplo n.º 4
0
    } else {
        $curr_value = $_REQUEST['curr_value'];
    }
    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_generate_common_url($_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, $cfg['ForeignKeyMaxLimit']);
        $dropdown = '<select>' . $dropdown . '</select>';
    }

    $extra_data['dropdown'] = $dropdown;
    PMA_ajaxResponse(null, true, $extra_data);
}

/**
 * Just like above, find possible values for enum fields during grid edit.
 *
 * Logic taken from libraries/display_tbl_lib.php
 */
if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) {
    $field_info_query = PMA_DBI_get_columns_sql($db, $table, $_REQUEST['column']);
Exemplo n.º 5
0
/**
 * Get HTML to display foreign data
 *
 * @param string  $backup_field         hidden input field
 * @param string  $column_name_appendix the name attribute
 * @param string  $onChangeClause       onchange clause for fields
 * @param integer $tabindex             tab index
 * @param integer $tabindex_for_value   offset for the values tabindex
 * @param integer $idindex              id index
 * @param string  $data                 data to edit
 * @param array   $foreignData          data about the foreign keys
 *
 * @return string                       an html snippet
 */
function PMA_dispRowForeignData($backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $foreignData)
{
    $html_output = '';
    $html_output .= $backup_field . "\n";
    $html_output .= '<input type="hidden"' . ' name="fields_type' . $column_name_appendix . '"' . ' value="foreign" />';
    $html_output .= '<select name="fields' . $column_name_appendix . '"' . ' ' . $onChangeClause . ' class="textfield"' . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ' id="field_' . $idindex . '_3">';
    $html_output .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $GLOBALS['cfg']['ForeignKeyMaxLimit']);
    $html_output .= '</select>';
    return $html_output;
}
Exemplo n.º 6
0
/**
 * Creates the HTML content for:
 * 1) Browsing foreign data for a field.
 * 2) Creating elements for search criteria input on fields.
 *
 * @param array  $foreigners      Array of foreign keys
 * @param array  $foreignData     Foreign keys data
 * @param string $field           Column name
 * @param string $tbl_fields_type Column type
 * @param int    $i               Column index
 * @param string $db              Selected database
 * @param string $table           Selected table
 * @param array  $titles          Selected title
 * @param int    $foreignMaxLimit Max limit of displaying foreign elements
 * @param array  $fields          Array of search criteria inputs
 * @param bool   $in_fbs          Whether we are in 'function based search'
 * @param bool   $in_zoom_search_edit  Whether we are in zoom search edit 
 *
 * @return string HTML content for viewing foreing data and elements
 * for search criteria input.
 */
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false, $in_zoom_search_edit = false)
{
    $str = '';
    if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
        // f o r e i g n    k e y s
        $str .= '<select name="fields[' . $i . ']" id="fieldID_' . $i . '">' . "\n";
        // go back to first row
        // here, the 4th parameter is empty because there is no current
        // value of data for the dropdown (the search page initial values
        // are displayed empty)
        $str .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $foreignMaxLimit);
        $str .= '</select>' . "\n";
    } elseif ($foreignData['foreign_link'] == true) {
        if (isset($fields[$i]) && is_string($fields[$i])) {
            $str .= '<input type="text" id="fieldID_' . $i . '" name="fields[' . $i . ']" value="' . $fields[$i] . '" id="field_' . md5($field) . '[' . $i . ']" class="textfield" />';
        } else {
            $str .= '<input type="text" id="fieldID_' . $i . '" name="fields[' . $i . ']" id="field_' . md5($field) . '[' . $i . ']" class="textfield" />';
        }
        $str .= <<<EOT
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
EOT;
        $str .= '' . PMA_generate_common_url($db, $table) . '&amp;field=' . urlencode($field) . '&amp;fieldkey=' . $i . '"';
        if ($in_zoom_search_edit) {
            $str .= ' class="browse_foreign"';
        }
        $str .= '>' . str_replace("'", "\\'", $titles['Browse']) . '</a>';
    } elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) {
        // g e o m e t r y
        $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="textfield" id="field_' . $i . '" />' . "\n";
        if ($in_fbs) {
            $edit_url = 'gis_data_editor.php?' . PMA_generate_common_url();
            $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
            $str .= '<span class="open_search_gis_editor">';
            $str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank');
            $str .= '</span>';
        }
    } elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0 || strncasecmp($tbl_fields_type[$i], 'set', 3) == 0 && $in_zoom_search_edit) {
        // e n u m s   a n d   s e t s
        // Enum in edit mode   --> dropdown
        // Enum in search mode --> multiselect
        // Set in edit mode    --> multiselect
        // Set in search mode  --> input (skipped here, so the 'else'
        //                                 section would handle it)
        $value = explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)));
        $cnt_value = count($value);
        if (strncasecmp($tbl_fields_type[$i], 'enum', 4) && !$in_zoom_search_edit || strncasecmp($tbl_fields_type[$i], 'set', 3) && $in_zoom_search_edit) {
            $str .= '<select name="fields[' . $i . '][]" id="fieldID_' . $i . '">' . "\n";
        } else {
            $str .= '<select name="fields[' . $i . '][]" id="fieldID_' . $i . '"' . ' multiple="multiple" size="' . min(3, $cnt_value) . '">' . "\n";
        }
        for ($j = 0; $j < $cnt_value; $j++) {
            if (isset($fields[$i]) && is_array($fields[$i]) && in_array($value[$j], $fields[$i])) {
                $str .= '<option value="' . $value[$j] . '" Selected>' . $value[$j] . '</option>';
            } else {
                $str .= '<option value="' . $value[$j] . '">' . $value[$j] . '</option>';
            }
        }
        // end for
        $str .= '</select>' . "\n";
    } else {
        // o t h e r   c a s e s
        $the_class = 'textfield';
        $type = $tbl_fields_type[$i];
        if ($type == 'date') {
            $the_class .= ' datefield';
        } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
            $the_class .= ' datetimefield';
        } elseif (substr($type, 0, 3) == 'bit') {
            $the_class .= ' bit';
        }
        if (isset($fields[$i]) && is_string($fields[$i])) {
            $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="' . $the_class . '" id="fieldID_' . $i . '" value = "' . $fields[$i] . '"/>' . "\n";
        } else {
            $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="' . $the_class . '" id="fieldID_' . $i . '" />' . "\n";
        }
    }
    return $str;
}
Exemplo n.º 7
0
/**
 * Get HTML to display foreign data
 *
 * @param string  $backup_field         hidden input field
 * @param string  $column_name_appendix the name attribute
 * @param string  $onChangeClause       onchange clause for fields
 * @param integer $tabindex             tab index
 * @param integer $tabindex_for_value   offset for the values tabindex
 * @param integer $idindex              id index
 * @param string  $data                 data to edit
 * @param array   $foreignData          data about the foreign keys
 * @param boolean $readOnly             is display read only or not
 *
 * @return string                       an html snippet
 */
function PMA_dispRowForeignData($backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $foreignData, $readOnly)
{
    $html_output = '';
    $html_output .= $backup_field . "\n";
    $html_output .= '<input type="hidden"' . ' name="fields_type' . $column_name_appendix . '"' . ' value="foreign" />';
    $html_output .= '<select name="fields' . $column_name_appendix . '"' . ' ' . $onChangeClause . ' class="textfield"' . ($readOnly ? ' disabled' : '') . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ' id="field_' . $idindex . '_3">';
    $html_output .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $GLOBALS['cfg']['ForeignKeyMaxLimit']);
    $html_output .= '</select>';
    //Add hidden input, as disabled <select> input does not included in POST.
    if ($readOnly) {
        $html_output .= '<input name="fields' . $column_name_appendix . '"' . ' type="hidden" value="' . htmlspecialchars($data) . '">';
    }
    return $html_output;
}
Exemplo n.º 8
0
                ?>
="return unNullify('<?php 
                echo urlencode($field);
                ?>
', '<?php 
                echo $jsvkey;
                ?>
')" tabindex="<?php 
                echo $tabindex + $tabindex_for_value;
                ?>
" id="field_<?php 
                echo $idindex;
                ?>
_3">
                <?php 
                echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, 100);
                ?>
            </select>
            </td>
            <?php 
                unset($disp_row);
            } else {
                if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
                    ?>
            <td bgcolor="<?php 
                    echo $bgcolor;
                    ?>
">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4" align="right" bgcolor="<?php 
Exemplo n.º 9
0
                </select>
            </td>
            <td>
        <?php 
        // <*****@*****.**>
        $field = $fields_list[$i];
        $foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
        if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
            // f o r e i g n    k e y s
            echo '            <select name="fields[' . $i . ']">' . "\n";
            // go back to first row
            // here, the 4th parameter is empty because there is no current
            // value of data for the dropdown (the search page initial values
            // are displayed empty)
            echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $GLOBALS['cfg']['ForeignKeyMaxLimit']);
            echo '            </select>' . "\n";
        } elseif ($foreignData['foreign_link'] == true) {
            ?>
            <input type="text" name="fields[<?php 
            echo $i;
            ?>
]"
                id="field_<?php 
            echo md5($field);
            ?>
[<?php 
            echo $i;
            ?>
]"
                class="textfield" />
Exemplo n.º 10
0
            <td>
        <?php 
        // <*****@*****.**>
        $field = $fields_list[$i];
        // do not use require_once here
        require './libraries/get_foreign.lib.php';
        // we got a bug report: in some cases, even if $disp is true,
        // there are no rows, so we add a fetch_array
        if ($foreigners && isset($foreigners[$field]) && isset($disp_row) && is_array($disp_row)) {
            // f o r e i g n    k e y s
            echo '            <select name="fields[' . $i . ']">' . "\n";
            // go back to first row
            // here, the 4th parameter is empty because there is no current
            // value of data for the dropdown (the search page initial values
            // are displayed empty)
            echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, '', $GLOBALS['cfg']['ForeignKeyMaxLimit']);
            echo '            </select>' . "\n";
        } elseif (isset($foreign_link) && $foreign_link == true) {
            ?>
            <input type="text" name="fields[<?php 
            echo $i;
            ?>
]"
                id="field_<?php 
            echo md5($field);
            ?>
[<?php 
            echo $i;
            ?>
]"
                class="textfield" />
Exemplo n.º 11
0
                ?>
="return unNullify('<?php 
                echo urlencode($field);
                ?>
', '<?php 
                echo $jsvkey;
                ?>
')" tabindex="<?php 
                echo $tabindex + $tabindex_for_value;
                ?>
" id="field_<?php 
                echo $idindex;
                ?>
_3">
                <?php 
                echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']);
                ?>
            </select>
            </td>
            <?php 
                unset($disp_row);
            } else {
                if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
                    ?>
            <td bgcolor="<?php 
                    echo $bgcolor;
                    ?>
">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4" align="right" bgcolor="<?php 
Exemplo n.º 12
0
 /**
  * Provides html elements for search criteria inputbox
  * in case the column is a Foreign Key
  *
  * @param array  $foreignData     Foreign keys data
  * @param string $column_name     Column name
  * @param int    $column_index    Column index
  * @param array  $titles          Selected title
  * @param int    $foreignMaxLimit Max limit of displaying foreign elements
  * @param array  $criteriaValues  Array of search criteria inputs
  * @param string $column_id       Column's inputbox's id
  *
  * @return string HTML elements.
  */
 private function _getForeignKeyInputBox($foreignData, $column_name, $column_index, $titles, $foreignMaxLimit, $criteriaValues, $column_id)
 {
     $html_output = '';
     if (is_array($foreignData['disp_row'])) {
         $html_output .= '<select name="criteriaValues[' . $column_index . ']"' . ' id="' . $column_id . $column_index . '">';
         $html_output .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $foreignMaxLimit);
         $html_output .= '</select>';
     } elseif ($foreignData['foreign_link'] == true) {
         $html_output .= '<input type="text" id="' . $column_id . $column_index . '"' . ' name="criteriaValues[' . $column_index . ']" id="field_' . md5($column_name) . '[' . $column_index . ']" class="textfield"' . (isset($criteriaValues[$column_index]) && is_string($criteriaValues[$column_index]) ? ' value="' . $criteriaValues[$column_index] . '"' : '') . ' />';
         $html_output .= '<a class="ajax browse_foreign" href="' . 'browse_foreigners.php' . PMA_URL_getCommon(array('db' => $this->_db, 'table' => $this->_table)) . '&amp;field=' . urlencode($column_name) . '&amp;fieldkey=' . $column_index . '&amp;fromsearch=1"';
         $html_output .= '>' . str_replace("'", "\\'", $titles['Browse']) . '</a>';
     }
     return $html_output;
 }