Support for customizing foreign-key dropdown, take #2, now very customizable,
incl max item limit.
This commit is contained in:
@@ -266,7 +266,13 @@ $cfg['CharEditing'] = 'input';
|
|||||||
// input - allows limiting of input length
|
// input - allows limiting of input length
|
||||||
// textarea - allows newlines in fields
|
// textarea - allows newlines in fields
|
||||||
$cfg['InsertRows'] = 2; // How many rows can be inserted at one time
|
$cfg['InsertRows'] = 2; // How many rows can be inserted at one time
|
||||||
$cfg['InsertDropdownOrder'] = FALSE; // Ordering for elements in dropdown.
|
$cfg['ForeignKeyDropdownOrder'] = array(
|
||||||
|
'content-id'
|
||||||
|
//,
|
||||||
|
//'id-content'
|
||||||
|
); // Sort order for items in a foreign-key dropdown box.
|
||||||
|
$cfg['ForeignKeyMaxLimit'] = 100; // If less items than this exist, a dropdown will be used.
|
||||||
|
|
||||||
|
|
||||||
// For the export features...
|
// For the export features...
|
||||||
$cfg['ZipDump'] = TRUE; // Allow the use of zip/gzip/bzip
|
$cfg['ZipDump'] = TRUE; // Allow the use of zip/gzip/bzip
|
||||||
|
@@ -27,7 +27,7 @@ if ($foreigners && isset($foreigners[$field])) {
|
|||||||
|
|
||||||
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
|
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
|
||||||
|
|
||||||
if ((isset($override_total) && $override_total == true) || $the_total < 200) {
|
if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) {
|
||||||
// foreign_display can be FALSE if no display field defined:
|
// foreign_display can be FALSE if no display field defined:
|
||||||
|
|
||||||
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
|
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
|
||||||
|
@@ -793,7 +793,7 @@ function PMA_purgeHistory($username) {
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $max = 100) {
|
function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $max) {
|
||||||
global $cfg;
|
global $cfg;
|
||||||
|
|
||||||
$ret = '<option value=""></option>' . "\n";
|
$ret = '<option value=""></option>' . "\n";
|
||||||
@@ -836,22 +836,27 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma
|
|||||||
asort($reloptions['content-id']);
|
asort($reloptions['content-id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cfg['InsertDropdownOrder']) {
|
$c = count($cfg['ForeignKeyDropdownOrder']);
|
||||||
$top = $reloptions['content-id'];
|
if($c == 2) {
|
||||||
$bot = $reloptions['id-content'];
|
$top = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
|
||||||
|
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]];
|
||||||
|
} elseif($c == 1) {
|
||||||
|
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
|
||||||
|
$top = NULL;
|
||||||
} else {
|
} else {
|
||||||
$top = $reloptions['id-content'];
|
$top = $reloptions['id-content'];
|
||||||
$bot = $reloptions['content-id'];
|
$bot = $reloptions['content-id'];
|
||||||
}
|
}
|
||||||
$str_top = implode('', $top);
|
|
||||||
$str_bot = implode('', $bot);
|
$str_bot = implode('', $bot);
|
||||||
|
if($top !== NULL) {
|
||||||
$top_count = count($top);
|
$str_top = implode('', $top);
|
||||||
if ($max == -1 || $top_count < $max) {
|
$top_count = count($top);
|
||||||
$ret .= $str_top;
|
if ($max == -1 || $top_count < $max) {
|
||||||
if ($top_count > 0) {
|
$ret .= $str_top;
|
||||||
$ret .= '<option value=""></option>' . "\n";
|
if ($top_count > 0) {
|
||||||
$ret .= '<option value=""></option>' . "\n";
|
$ret .= '<option value=""></option>' . "\n";
|
||||||
|
$ret .= '<option value=""></option>' . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ret .= $str_bot;
|
$ret .= $str_bot;
|
||||||
|
@@ -550,7 +550,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
|
|||||||
<input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
|
<input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
|
||||||
<input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $idindex; ?>_1" />
|
<input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $idindex; ?>_1" />
|
||||||
<select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3">
|
<select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="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); ?>
|
<?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
@@ -286,7 +286,7 @@ function PMA_tbl_select_operator(f, index, multiple) {
|
|||||||
// here, the 4th parameter is empty because there is no current
|
// here, the 4th parameter is empty because there is no current
|
||||||
// value of data for the dropdown (the search page initial values
|
// value of data for the dropdown (the search page initial values
|
||||||
// are displayed empty)
|
// are displayed empty)
|
||||||
echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, '', 100);
|
echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, '', $cfg['ForeignKeyMaxLimit']);
|
||||||
echo ' </select>' . "\n";
|
echo ' </select>' . "\n";
|
||||||
} else if (isset($foreign_link) && $foreign_link == true) {
|
} else if (isset($foreign_link) && $foreign_link == true) {
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user