Skip to content

Commit

Permalink
Update PHP versions, DB explorer, remove Testing and JSON parser
Browse files Browse the repository at this point in the history
  • Loading branch information
awps committed Mar 13, 2022
1 parent 87b530c commit 76c9d6f
Show file tree
Hide file tree
Showing 22 changed files with 941 additions and 1,472 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
/vendor/
mix-manifest.json
mix.js.map

.srv
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "fastdev",
"version": "1.7.3",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/awps/fastdev.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/awps/fastdev/issues"
},
"homepage": "https://github.com/awps/fastdev#readme",
"devDependencies": {
"replace-in-file": "^6.3.2"
}
}
109 changes: 109 additions & 0 deletions src/app/DB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace Fastdev;

class DB extends Tab
{

public function settings()
{
return [
'label' => __('DB', 'fastdev'),
];
}

public function page()
{
$this->pageContent();
}

public function pageContent()
{
global $wpdb;

$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
$list = wp_list_pluck($tables, 0);
?>
<div class="fd-db-table-view">
<div>
<?php $this->tables($list); ?>
</div>
<div style="width: 100%; overflow-x: auto">
<?php if ( ! empty($_GET['fd-table']) && in_array($_GET['fd-table'], $list)) : ?>
<?php
$tableName = esc_sql($_GET['fd-table']);
$columns = wp_list_pluck($wpdb->get_results("SHOW COLUMNS FROM $tableName", ARRAY_A), 'Field');
$firstColumn = $columns[0];

$results = $wpdb->get_results("SELECT * FROM $tableName ORDER BY $firstColumn DESC LIMIT 0, 300",
ARRAY_A);

$tableWidth = count($columns) / 5 * 100;
?>
<div class="posts-table fd-db-table" style="width: <?php echo $tableWidth ?>%;">
<div class="wp-table">
<table class="wp-list-table widefat fixed striped table-view-list"
style="table-layout: auto !important;">
<thead>
<tr>
<?php
foreach ($columns as $column) {
?>
<th scope="col" class="manage-column"
style="width: auto; max-width: 800px;"><?php echo $column; ?></th>
<?php
}
?>
</tr>
</thead>
<tbody id="the-list">
<?php
foreach ($results as $result) {
?>
<tr><?php
foreach ($columns as $column) {
?>
<td style="width: auto; max-width: 800px;"><?php echo esc_html($result[$column]); ?></td>
<?php
}
?></tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<?php
foreach ($columns as $column) {
?>
<th scope="col" class="manage-column"
style="width: auto; max-width: 800px;"><?php echo $column; ?></th>
<?php
}
?>
</tr>
</tfoot>
</table>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php
}

public function tables($list)
{
$output = '<div class="fd-key-val-table">';
foreach ($list as $value) {
$output .= '<div class="fd-kv-row col-100">';
$output .= '<div class="filter-this"><div class="fd-kv-code"><a href="' . add_query_arg([
'fd-table' => $value,
]) . '" class="'. (! empty($_GET['fd-table']) && $_GET['fd-table'] === $value ? 'selected-table' : '') .'">' . $value . '</a></div></div>';
$output .= '</div>';
}
$output .= '</div>';
echo $output;
}

}
110 changes: 0 additions & 110 deletions src/app/JsonParse.php

This file was deleted.

Loading

0 comments on commit 76c9d6f

Please sign in to comment.