updated plugins and version; added table filter

This commit is contained in:
Pau Capó 2018-02-17 16:12:52 +01:00
parent b92f7a0a63
commit 8c7fe51582
9 changed files with 1153 additions and 1107 deletions

View file

@ -2,17 +2,17 @@
/** Select foreign key in edit form
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, http://www.vrana.cz/
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerEditForeign {
var $_limit;
function __construct($limit = 0) {
$this->_limit = $limit;
}
function editInput($table, $field, $attrs, $value) {
static $foreignTables = array();
static $values = array();
@ -39,5 +39,5 @@ class AdminerEditForeign {
}
}
}
}
}

View file

@ -2,26 +2,29 @@
/** Use <select><option> for enum edit instead of <input type="radio">
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, http://www.vrana.cz/
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerEnumOption {
function editInput($table, $field, $attrs, $value) {
if ($field["type"] == "enum") {
$options = array("" => array());
$options = array();
$selected = $value;
if (isset($_GET["select"])) {
$options[""][-1] = lang('original');
$options[-1] = lang('original');
if ($selected === null) {
$selected = -1;
}
}
if ($field["null"]) {
$options[""][""] = "NULL";
$options[""] = "NULL";
if ($value === null && !isset($_GET["select"])) {
$selected = "";
}
}
$options[""][0] = lang('empty');
$options[0] = lang('empty');
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
@ -33,5 +36,5 @@ class AdminerEnumOption {
return "<select$attrs>" . optionlist($options, (string) $selected, 1) . "</select>"; // 1 - use keys
}
}
}

View file

@ -2,9 +2,9 @@
/** Allow using Adminer inside a frame (disables ClickJacking protection)
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, http://www.vrana.cz/
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerFrames {
/** @access protected */
@ -20,9 +20,9 @@ class AdminerFrames {
function headers() {
if ($this->sameOrigin) {
header("X-Frame-Options: SameOrigin");
} elseif (function_exists('header_remove')) {
header_remove("X-Frame-Options");
}
header("X-XSS-Protection: 0");
return false;
}
}
}

View file

@ -2,10 +2,10 @@
/** Display JSON values as table in edit
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, http://www.vrana.cz/
* @author Jakub Vrana, https://www.vrana.cz/
* @author Martin Zeman (Zemistr), http://www.zemistr.eu/
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerJsonColumn {
private function _testJson($value) {

View file

@ -1,138 +0,0 @@
<?php
/**
* Displays only one prefered action in table list.
*
* Get rid of schizophrenic decisions between selecting data and showing table structure.
* Optimize your workflow!
*
* @author Peter Knut
* @copyright 2014-2015 Pematon, s.r.o. (http://www.pematon.com/)
*/
class AdminerSimpleMenu
{
/** @var bool */
private $preferSelect;
/** @var bool */
private $reorderLinks;
/**
* @param bool $preferSelect Whether to prefer table selection before editing structure.
* @param bool $reorderLinks Whether links above data table will be reordered to reflect workflow priority.
*/
public function AdminerSimpleMenu($preferSelect = true, $reorderLinks = true)
{
$this->preferSelect = $preferSelect;
$this->reorderLinks = $reorderLinks;
}
/**
* Prints HTML code inside <head>.
*/
public function head()
{
?>
<style>
#tables {
margin: 0;
padding: 0.8em 1em;
border-bottom: 1px solid #ccc;
list-style: none;
}
</style>
<?php
}
/**
* Prints table list in menu.
*
* @param array $tables Table list.
* @return bool|null
*/
public function tablesPrint($tables)
{
if (defined("PMTN_ADMINER_THEME")) {
echo "<ul id='tables' class='simple'>\n";
} else {
echo "<ul id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);' class='simple'>\n";
}
foreach ($tables as $table => $status) {
$name = Adminer::tableName($status);
$active = in_array($table, array($_GET["select"], $_GET["edit"], $_GET["table"], $_GET["create"], $_GET["indexes"], $_GET["foreign"], $_GET["trigger"]));
if ($this->preferSelect) {
$action = "select";
$title = "Select data";
} else {
$action = "table";
$title = "Show structure";
}
echo "<li>";
if ($this->preferSelect || support("table") || support("indexes")) {
echo '<a href="' . h(ME) . $action . '=' . urlencode($table) . '"' . bold($active, (is_view($status) ? "view" : "")) . " title='" . lang($title) . "'>$name</a>";
} else {
echo "<span>$name</span>";
}
echo "</li>\n";
}
echo "</ul>\n";
return true;
}
/*
* Prints links after select heading.
*
* @param array $tableStatus Result of SHOW TABLE STATUS.
* @param string $set New item options, NULL for no new item.
*
* @return bool|null
*/
public function selectLinks($tableStatus, $set = "")
{
if (!$this->reorderLinks) {
return null; // null has to be returned to force Adminer print original links.
}
echo '<p class="links">';
$links = array();
if ($this->preferSelect) {
$links["select"] = lang('Select data');
}
if (support("table") || support("indexes")) {
$links["table"] = lang('Show structure');
}
if (!$this->preferSelect) {
$links["select"] = lang('Select data');
}
if (support("table")) {
if (is_view($tableStatus)) {
$links["view"] = lang('Alter view');
} else {
$links["create"] = lang('Alter table');
}
}
if ($set !== null) {
$links["edit"] = lang('New item');
}
foreach ($links as $key => $val) {
echo " <a href='" . h(ME) . "$key=" . urlencode($tableStatus["Name"]) . ($key == "edit" ? $set : "") . "'" . bold(isset($_GET[$key])) . ">$val</a>";
}
echo "\n";
return true;
}
}

View file

@ -0,0 +1,87 @@
<?php
/**
* Faster tables filter plugin
* ===========================
* Useful when there's way too many tables than it shoud be and Adminer Tables Filter is slow
*
* @author Martin Macko, https://github.com/linkedlist
* @license http://http://opensource.org/licenses/MIT, The MIT License (MIT)
*
* Modified 201802 - updated for Adminer 4.6.0 compatibility
*/
class FasterTablesFilter {
function tablesPrint($tables) { ?>
<p class="jsonly"><input id="filter-field">
<style>
.select-text {
margin-right: 5px;
}
</style>
<p id='tables'></p>
<script<?php echo nonce(); ?>>
function readCookie(name) {
name = name.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
var regex = new RegExp('(?:^|;)\\s?' + name + '=(.*?)(?:;|$)','i'),
match = document.cookie.match(regex);
return match && unescape(match[1]);
}
var filterf = function () {
var liProto = document.createElement('li');
var space = document.createTextNode('\u00A0')
var aProto = document.createElement('a');
var tableList = document.getElementById("tables");
function appendTables() {
var fragment = document.createDocumentFragment();
var item;
for (var i = 0, len = tempTables.length; i < len; i++) {
item = tempTables[i];
var li = liProto.cloneNode();
var aSelect = aProto.cloneNode();
aSelect.href = hMe+"select="+item;
aSelect.text = langSelect;
aSelect.className = "select";
var aName = aProto.cloneNode();
aName.href = hMe+"table="+item;
aName.text = item;
li.appendChild(aSelect);
li.appendChild(space.cloneNode());
li.appendChild(aName);
fragment.appendChild(li);
}
tableList.appendChild(fragment);
}
var tables = [<?php foreach($tables as $table => $type) { echo "'".urlencode($table) ."'". ",";}?>];
var tempTables = tables;
var hMe = "<?php echo h(ME) ?>";
hMe = hMe.replace(/&amp;/g, '&');
var langSelect = "<?php echo lang('select');?>";
var filterCookie = readCookie('tableFilter');
var filter = document.getElementById("filter-field");
if(filterCookie!='') {
filter.value=filterCookie;
}
function filterTableList() {
document.cookie = "tableFilter="+filter.value
while(tableList.firstChild) {
tableList.removeChild(tableList.firstChild);
}
tempTables = [];
var value = filter.value.toLowerCase();
var item;
for (var i = 0, len = tables.length; i < len; i++) {
item = tables[i];
if(item.toLowerCase().indexOf(value) > -1) {
tempTables.push(item);
}
}
appendTables();
};
filter.onkeyup = function(event) {
filterTableList();
}
filterTableList();
}
window.onload=filterf;
</script>
<?php return true;}} ?>