Skip to content

Commit

Permalink
Create templates for structure.lib.php
Browse files Browse the repository at this point in the history
Signed-off-by: Jason <jason.daurus@gmail.com>
  • Loading branch information
gzzhanghao committed Jul 26, 2015
1 parent 94d08aa commit 15c8cb4
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 418 deletions.
489 changes: 71 additions & 418 deletions libraries/structure.lib.php

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions templates/structure/add_column.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<form method="post" action="tbl_addfield.php" id="addColumns" name="addColumns" onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
<?php echo PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
<?php if (PMA_Util::showIcons('ActionLinksMode')): ?>
<?php echo PMA_Util::getImage('b_insrow.png', __('Add column')); ?>&nbsp;
<?php endif; ?>
<input type="number" name="num_fields" value="1" onfocus="this.select()" min="1" required />
<?php echo printf(__('Add %s column(s)'), $num_fields); ?>
<input type="hidden" name="field_where" value="after"/>&nbsp;
<!-- I tried displaying the drop-down inside the label but with Firefox the drop-down was blinking -->
<select name="after_field" onchange="checkFirst()">
<option value="first" data-pos = "first">
<?php echo __('at beginning of table'); ?>
</option>
<?php $cols_count = count($columns_list);
foreach ($columns_list as $one_column_name): ?>
<?php if (--$cols_count == 0): ?>
<option value="<?php echo htmlspecialchars($one_column_name); ?>" selected="selected">
<?php else: ?>
<option value="<?php echo htmlspecialchars($one_column_name); ?>">
<?php endif; ?>
<?php echo printf(__('after %s'), htmlspecialchars($one_column_name)); ?>
</option>
<? endforeach; ?>
</select>
<input type="submit" value="<?php echo __('Go'); ?>" />
</form>
84 changes: 84 additions & 0 deletions templates/structure/body_for_table_summary.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<tbody id="tbl_summary_row">
<tr>
<th class="print_ignore"></th>
<th class="tbl_num nowrap">
<?php
printf(_ngettext('%s table', '%s tables', $num_tables),
PMA_Util::formatNumber($num_tables, 0)); ?>
</th>
<?php if ($server_slave_status): ?>
<th> <?php echo __('Replication'); ?> </th>
<?php endif; ?>
<?php
$sum_colspan = ($db_is_system_schema ? 4 : 7);
if ($GLOBALS['cfg']['NumFavoriteTables'] == 0) {
$sum_colspan--;
} ?>
<th colspan="<?php echo $sum_colspan; ?>" class="print_ignore" ><?php echo __('Sum'); ?></th>
<?php
$row_count_sum = PMA_Util::formatNumber($sum_entries, 0);
// If a table shows approximate rows count, display update-all-real-count anchor.
$row_sum_url = array();
if (isset($approx_rows)) {
$row_sum_url = array(
'ajax_request' => true,
'db' => $GLOBALS['db'],
'real_row_count' => 'true',
'real_row_count_all' => 'true'
);
}
$cell_text = ($approx_rows)
? '<a href="db_structure.php' . PMA_URL_getCommon($row_sum_url)
. '" class="ajax row_count_sum">' . '~' . $row_count_sum . '</a>'
: $row_count_sum;
?>
<th class="value tbl_rows"><?php echo $cell_text; ?></th>
<?php if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)): ?>
<?php $default_engine = $GLOBALS['dbi']->fetchValue(
'SHOW VARIABLES LIKE \'storage_engine\';',
0,
1
); ?>
<th class="center">
<dfn title="<?php printf(__('%s is the default storage engine on this MySQL server.'),
$default_engine); ?>"><?php echo $default_engine; ?></dfn>
</th>
<th>
<?php if (! empty($db_collation)): ?>
<dfn title="<?php echo PMA_getCollationDescr($db_collation) . ' (' . __('Default'). ')'; ?>"></dfn>
<?php endif; ?>
</th>
<?php endif; ?>
<?php if ($is_show_stats): ?>
<?php
list($sum_formatted, $unit) = PMA_Util::formatByteDown(
$sum_size, 3, 1
);
list($overhead_formatted, $overhead_unit)
= PMA_Util::formatByteDown($overhead_size, 3, 1);
?>
<th class="value tbl_size"><?php echo $sum_formatted . ' ' . $unit; ?></th>
<th class="value tbl_overhead"><?php $overhead_formatted . ' ' . $overhead_unit; ?></th>
<?php endif; ?>
<?php if ($GLOBALS['cfg']['ShowDbStructureComment']): ?>
<th></th>
<?php endif; ?>
<?php if ($GLOBALS['cfg']['ShowDbStructureCreation']): ?>
<th class="value tbl_creation">
<?php echo ($create_time_all
? PMA_Util::localisedDate(strtotime($create_time_all))
: '-'); ?>
</th>
<?php endif; ?>
<?php if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']): ?>
<th class="value tbl_last_update"><?php echo ($update_time_all
? PMA_Util::localisedDate(strtotime($update_time_all))
: '-'); ?></th>
<?php endif; ?>
<?php if ($GLOBALS['cfg']['ShowDbStructureLastCheck']): ?>
<th class="value tbl_last_check"><?php echo ($check_time_all
? PMA_Util::localisedDate(strtotime($check_time_all))
: '-');?></th>
<?php endif; ?>
</tr>
</tbody>
43 changes: 43 additions & 0 deletions templates/structure/check_all_tables.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="clearfloat print_ignore">
<img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>" width="38" height="22" alt="<?php __('With selected:'); ?>" />
<input type="checkbox" id="tablesForm_checkall" class="checkall_box" title="<?php echo __('Check All'); ?>" />
<label for="tablesForm_checkall"><?php echo __('Check All'); ?></label>
<?php if ($overhead_check != ''): ?>
/ <a href="#" onclick="unMarkAllRows('tablesForm')<?php echo $overhead_check; ?> return false;"><?php echo __('Check tables having overhead'); ?></a>
<?php endif; ?>
<select name="submit_mult" class="autosubmit" style="margin: 0 3em 0 3em;">
<option value="<?php echo __('With selected:'); ?>" selected="selected"><?php echo __('With selected:'); ?></option>
<option value="show_create" ><?php echo __('Show create'); ?></option>
<option value="export" ><?php echo __('Export'); ?></option>
<?php if (!$db_is_system_schema
&& !$GLOBALS['cfg']['DisableMultiTableMaintenance']): ?>
<optgroup label="<?php echo __('Delete data or table'); ?>">
<option value="empty_tbl" ><?php echo __('Empty'); ?></option>
<option value="drop_tbl" ><?php echo __('Drop'); ?></option>
</optgroup>
<optgroup label="<?php echo __('Table maintenance'); ?>">
<option value="analyze_tbl" ><?php echo __('Analyze table'); ?></option>
<option value="check_tbl" ><?php echo __('Check table'); ?></option>
<?php if (!PMA_DRIZZLE): ?>
<option value="checksum_tbl" ><?php echo __('Checksum table'); ?></option>
<option value="optimize_tbl" ><?php echo __('Optimize table'); ?></option>
<option value="repair_tbl" ><?php echo __('Repair table'); ?></option>
<?php endif; ?>
</optgroup>
<optgroup label="<?php echo __('Prefix'); ?>">
<option value="add_prefix_tbl" ><?php echo __('Add prefix to table'); ?></option>
<option value="replace_prefix_tbl" ><?php echo __('Replace table prefix'); ?></option>
<option value="copy_tbl_change_prefix" ><?php echo __('Copy table with prefix'); ?></option>
</optgroup>
<?php endif; ?>
<?php if (isset($GLOBALS['cfgRelation']['centralcolumnswork'])
&& $GLOBALS['cfgRelation']['centralcolumnswork']): ?>
<optgroup label="<?php echo __('Central columns'); ?>">
<option value="sync_unique_columns_central_list" ><?php echo __('Add columns to central list'); ?></option>
<option value="delete_unique_columns_central_list" ><?php echo __('Remove columns from central list'); ?></option>
<option value="make_consistent_with_central_list" ><?php echo __('Make consistent with central list'); ?></option>
</optgroup>
<?php endif; ?>
</select>
<?php echo implode("\n", $hidden_fields); ?>
</div>
12 changes: 12 additions & 0 deletions templates/structure/insert_empty_drop_action_links.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<td class="insert_table center print_ignore">
<a href="tbl_change.php<?php echo $tbl_url_query; ?>"><?php echo $titles['Insert']; ?></a>
</td>
<td class="center print_ignore"><?php echo $empty_table; ?></td>
<td class="center print_ignore">
<a class="ajax drop_table_anchor
<?php if ($table_is_view || $current_table['ENGINE'] == null): ?>
<?php echo ' view'; ?>
<?php endif; ?>" href="sql.php<?php echo $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php echo urlencode($drop_query); ?>&amp;message_to_show=<?php echo urlencode($drop_message); ?>" >
<?php echo $titles['Drop']; ?>
</a>
</td>
32 changes: 32 additions & 0 deletions templates/structure/optional_action_links.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<a href="#" id="printView"><?php echo PMA_Util::getIcon('b_print.png', __('Print view'), true); ?></a>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<?php if (!PMA_DRIZZLE): ?>
<a href="sql.php<?php echo $url_query; ?>&amp;session_max_rows=all&amp;sql_query=' . <?php echo urlencode(
'SELECT * FROM ' . PMA_Util::backquote($GLOBALS['table'])
. ' PROCEDURE ANALYSE()'
); ?>"><?php echo PMA_Util::getIcon(
'b_tblanalyse.png',
__('Propose table structure'),
true
); ?>
</a>
<?php echo PMA_Util::showMySQLDocu('procedure_analyse'); ?>
<?php endif; ?>
<?php if (PMA_Tracker::isActive()): ?>
<a href="tbl_tracking.php<?php echo $url_query; ?>">
<?php echo PMA_Util::getIcon('eye.png', __('Track table'), true); ?>
</a>
<?php endif; ?>
<a href="#" id="move_columns_anchor">
<?php echo PMA_Util::getIcon('b_move.png', __('Move columns'), true); ?>
</a>
<a href="normalization.php<?php echo $url_query; ?>">
<?php echo PMA_Util::getIcon('normalize.png', __('Improve table structure'), true); ?>
</a>
<?php endif; ?>
<?php if ($tbl_is_view && ! $db_is_system_schema): ?>
<?php if (PMA_Tracker::isActive()): ?>
<a href="tbl_tracking.php<?php echo $url_query; ?>">
<?php echo PMA_Util::getIcon('eye.png', __('Track view'), true); ?>
</a>
<?php endif; ?>
26 changes: 26 additions & 0 deletions templates/structure/table_structure_header.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<thead>
<tr>
<th class="print_ignore"></th>
<th>#</th>
<th><?php echo __('Name'); ?></th>
<th><?php echo __('Type'); ?></th>
<th><?php echo __('Collation'); ?></th>
<th><?php echo __('Attributes'); ?></th>
<th><?php echo __('Null'); ?></th>
<th><?php echo __('Default'); ?></th>
<th><?php echo __('Extra'); ?></th>
<!-- see tbl_structure.js, function moreOptsMenuResize() -->
<?php if (! $db_is_system_schema && ! $tbl_is_view): ?>
<?php
$colspan = 9;
if (PMA_DRIZZLE) {
$colspan -= 2;
}
if (PMA_Util::showIcons('ActionLinksMode')) {
$colspan--;
}
?>
<th colspan="<?php echo $colspan; ?>" class="action print_ignore"><?php echo __('Action'); ?></th>
<?php endif; ?>
</tr>
</thead>
44 changes: 44 additions & 0 deletions templates/structure/table_structure_row.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<td class="center print_ignore">
<input type="checkbox" class="checkall" name="selected_fld[]" value="<?php htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>"/>
</td>
<td class="right"><?php echo $rownum; ?></td>
<th class="nowrap">
<label for="checkbox_row_<?php echo $rownum; ?>"><?php echo preg_replace(/[\x00-\x1F]/', '&#x2051;', $displayed_field_name); ?>
</label>
</th>
<td <?php echo $type_nowrap; ?>>
<bdo dir="ltr" lang="en"><?php echo $extracted_columnspec['displayed_type'] . $type_mime; ?></bdo>
</td>
<td>
<?php if (! empty($field_charset)): ?>
<dfn title="<?php echo PMA_getCollationDescr($field_charset); ?>"><?php echo $field_charset; ?></dfn>
<?php endif; ?>
</td>
<td class="column_attribute nowrap"><?php echo $attribute; ?></td>
<td><?php echo (($row['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
<td class="nowrap">
<?php if (isset($row['Default'])): ?>
<?php if ($extracted_columnspec['type'] == 'bit'): ?>
<?php echo PMA_Util::convertBitDefaultValue($row['Default']); ?>
<?php else: ?>
<?php echo $row['Default']; ?>
<?php endif;?>
<?php else: ?>
<i><?php echo _pgettext('None for default', 'None'); ?></i>
<?php endif; ?>
</td>
<td class="nowrap"><?php echo /*overload*/mb_strtoupper($row['Extra']); ?></td>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<td class="edit center print_ignore">
<a class="change_column_anchor ajax" href="tbl_structure.php<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>&amp;change_column=1">
<?php echo $titles['Change']; ?>
</a>
</td>
<td class="drop center print_ignore">
<a class="drop_column_anchor ajax" href="sql.php<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode(
'ALTER TABLE ' . PMA_Util::backquote($table)
. ' DROP ' . PMA_Util::backquote($row['Field']) . ';'); ?>&amp;dropped_column=&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped.'), htmlspecialchars($row['Field']))) ?>" >
<?php echo $titles['Drop']; ?>
</a>
</td>
<?php endif; ?>

0 comments on commit 15c8cb4

Please sign in to comment.