Remove more table actions dropdown

Add spatial index action icons
This commit is contained in:
2025-04-21 00:26:28 -07:00
parent 083031170c
commit fa1b8d5c94
7 changed files with 66 additions and 257 deletions

View File

@@ -147,36 +147,18 @@ $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
/**
* prepare table infos
*/
// action titles (image or string)
$titles = array();
$titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
$titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
$titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
$titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
$titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
$titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
$titles['Spatial'] = PMA_getIcon('b_ftext.png', __('Spatial'), true);
$titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
$titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
$titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
$titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
$titles['NoSpatial'] = PMA_getIcon('bd_ftext.png', __('Spatial'), true);
$titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
$titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
// hidden action titles (image and string)
$hidden_titles = array();
$hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
$hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Add primary key'), false, true);
$hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), false, true);
$hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), false, true);
$hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), false, true);
$hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), false, true);
$hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), false, true);
$hidden_titles['Spatial'] = PMA_getIcon('b_ftext.png', __('Add SPATIAL index'), false, true);
$hidden_titles['NoSpatial'] = PMA_getIcon('bd_ftext.png', __('Add SPATIAL index'), false, true);
$hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), false, true);
$hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), false, true);
// action icons
$titles = [
'Change' => PMA_getOnlyIcon('b_edit.png', __('Change')),
'Drop' => PMA_getOnlyIcon('b_drop.png', __('Drop')),
'NoDrop' => PMA_getOnlyIcon('b_drop.png', __('Drop')),
'Primary' => PMA_getOnlyIcon('b_primary.png', __('Primary')),
'Index' => PMA_getOnlyIcon('b_index.png', __('Index')),
'Unique' => PMA_getOnlyIcon('b_unique.png', __('Unique')),
'Spatial' => PMA_getOnlyIcon('bd_spatial.png', __('Spatial')),
'IdxFulltext' => PMA_getOnlyIcon('b_ftext.png', __('Fulltext')),
'BrowseDistinctValues' => PMA_getOnlyIcon('b_browse.png', __('Browse distinct values'))
];
/**
* Displays the table structure ('show table' works correct since 3.23.03)
@@ -211,7 +193,7 @@ $i = 0;
<?php if ($db_is_information_schema || $tbl_is_view) { ?>
<th id="th<?php echo ++$i; ?>" class="view"><?php echo __('View'); ?></th>
<?php } else { ?>
<th colspan="7" id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
<th colspan="8" id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
<?php } ?>
</tr>
</thead>
@@ -411,169 +393,66 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
<td align="center" class="primary">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
echo $titles['NoPrimary'] . "\n";
$primary_enabled = false;
} else {
echo "\n";
?>
<a class="add_primary_key_anchor" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Primary']; ?></a>
<?php $primary_enabled = true;
$primary_enabled = true;
}
echo "\n";
?>
?>
<a class="add_primary_key_anchor<?php echo $primary_enabled ? '' : ' disabled' ?>" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Primary']; ?></a>
</td>
<td align="center" class="unique">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
echo $titles['NoUnique'] . "\n";
$unique_enabled = false;
} else {
echo "\n";
?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Unique']; ?></a>
<?php $unique_enabled = true;
$unique_enabled = true;
}
echo "\n";
?>
?>
<a <?php echo $unique_enabled ? '' : ' class="disabled"'; ?>href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Unique']; ?></a>
</td>
<td align="center" class="index">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
echo $titles['NoIndex'] . "\n";
$index_enabled = false;
} else {
echo "\n";
?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Index']; ?></a>
<?php
$index_enabled = true;
}
echo "\n";
?>
<a <?php echo $index_enabled ? '' : ' class="disabled"'; ?>href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Index']; ?></a>
</td>
<td align="center" class="index">
<td align="center" class="spatial">
<?php
$spatial_types = array(
'geometry', 'point', 'linestring', 'polygon', 'multipoint',
'multilinestring', 'multipolygon', 'geomtrycollection'
);
if (! in_array($type, $spatial_types) || 'MYISAM' != $tbl_type) {
echo $titles['NoSpatial'] . "\n";
$spatial_enabled = false;
} else {
echo "\n";
?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>"></a>
<?php echo $titles['Spatial']; ?></a>
<?php
$spatial_enabled = true;
}
echo "\n";
?>
<a <?php echo $spatial_enabled ? '' : ' class="disabled"'; ?>href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Spatial']; ?></a>
</td>
<?php
<td align="center" nowrap="nowrap" class="fulltext">
<?php
if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')
// FULLTEXT is possible on TEXT, CHAR and VARCHAR
&& (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
echo "\n";
?>
<td align="center" nowrap="nowrap" class="fulltext">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['IdxFulltext']; ?></a>
<?php $fulltext_enabled = true; ?>
</td>
<?php
$fulltext_enabled = true;
} else {
echo "\n";
$fulltext_enabled = false;
}
?>
<td align="center" nowrap="nowrap" class="fulltext">
<?php echo $titles['NoIdxFulltext'] . "\n"; ?>
<?php $fulltext_enabled = false; ?>
<a <?php echo $fulltext_enabled ? '' : ' class="disabled"' ?>href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['IdxFulltext']; ?></a>
</td>
<?php
} // end if... else...
echo "\n";
?>
<td class="more_opts" id="more_opts<?php echo $rownum; ?>">
<?php echo __('More'); ?> <img src="<?php echo $pmaThemeImage . 'more.png'; ?>" alt="<?php echo __('Show more actions'); ?>" />
<div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
<div class="action_browse">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
<?php echo $hidden_titles['BrowseDistinctValues']; ?>
</a>
</div>
<div <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="action_primary"' : ''); ?>>
<?php
if(isset($primary_enabled)) {
if($primary_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Primary']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoPrimary'];
}
} ?>
</div>
<div class="action_unique">
<?php
if(isset($unique_enabled)) {
if($unique_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Unique']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoUnique'];
}
} ?>
</div>
<div class="action_index">
<?php
if(isset($index_enabled)) {
if($index_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Index']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIndex'];
}
} ?>
</div>
<div class="action_spatial">
<?php
if(isset($spatial_enabled)) {
if($spatial_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Spatial']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoSpatial'];
}
} ?>
</div>
<div class="action_fulltext">
<?php
if(isset($fulltext_enabled)) {
if($fulltext_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['IdxFulltext']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIdxFulltext'];
}
} ?>
</div>
</div>
</td>
<?php
} // end if (! $tbl_is_view && ! $db_is_information_schema)
?>
</tr>
@@ -612,7 +491,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) {
}
if (! empty($tbl_type) && $tbl_type == 'MYISAM') {
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_spatial', __('Spatial'), 'b_ftext.png', 'spatial');
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_spatial', __('Spatial'), 'b_spatial.png', 'spatial');
}
if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')) {
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png', 'ftext');
@@ -701,7 +580,6 @@ if (! $tbl_is_view && ! $db_is_information_schema) {
?>
<input type="submit" value="<?php echo __('Go'); ?>" />
</form>
<iframe class="IE_hack" scrolling="no"></iframe>
<hr />
<?php
}