Skip to content

Commit

Permalink
Switch Adminer-Theme to submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Ko committed Jan 22, 2018
1 parent 00680f6 commit 4ef7376
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 362 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contrib/adminer-theme"]
path = contrib/adminer-theme
url = https://github.com/pematon/adminer-theme
12 changes: 12 additions & 0 deletions bin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ if [ -s $new ]; then
### Move the just downloaded file to its correct name
mv $new $path/adminer.php
fi

### Update sub modules
git submodule update

### Update adminer-theme
p=$path/contrib/adminer-theme/lib

ln -sf $p/css $path/public/css
ln -sf $p/fonts $path/public/fonts
ln -sf $p/images $path/public/images

ln -sf $p/plugins/AdminerTheme.php $path/plugins/AdminerTheme.php
1 change: 1 addition & 0 deletions contrib/adminer-theme
Submodule adminer-theme added at 087ef8
94 changes: 0 additions & 94 deletions plugins/AdminerTheme.php

This file was deleted.

82 changes: 82 additions & 0 deletions plugins/adminer-tables-history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

/**
* Show the history of the latest selected tables. Cookies based.
* Set the js variable history_length to define the history length.
* Works only with current browsers.
* @link http://www.adminer.org/plugins/#use
* @author Ale Rimoldi, http://www.ideale.ch/
* @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)
*/
class AdminerTablesHistory {

function tablesPrint($tables) {
?>
<script type="text/javascript">

history_length = 5;

function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}

function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
return "";
}

function addToHistory(table) {
// alert(table)
var history_array = [];
var history_cookie = getCookie('adminer_tables_history');
if (history_cookie != '') {
history_array = JSON && JSON.parse(history_cookie)
}
if (history_array.indexOf(table) == -1) {
if (history_array.length >= history_length) {
history_array.splice(0, 1);
}
history_array.push(table)
setCookie('adminer_tables_history', JSON.stringify(history_array), 10)
}
}

// $(document).ready "equivalent" without jQuery. should work with current browsers
document.addEventListener('DOMContentLoaded',function(){
// alert('chuila');
var tables = document.getElementById('tables').getElementsByTagName('a');
for (var i = 0; i < tables.length; i = i + 2) {
var a = tables[i + 1];
var text = a.innerText || a.textContent;
a.setAttribute('onclick', 'addToHistory("'+text+'")');
var a = tables[i];
a.setAttribute('onclick', 'addToHistory("'+text+'")');
}
})
</script>
<?php if (array_key_exists('adminer_tables_history', $_COOKIE)) : ?>
<p onmouseover="menuOver(this, event);" onmouseout="menuOut(this);" style="white-space:nowrap;overflow:auto;text-overflow:ellipsis;"><?php
// print_r($_COOKIE['adminer_tables_history']);
foreach (array_reverse(json_decode($_COOKIE['adminer_tables_history'])) as $table) {
echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table) . ">" . lang('select') . "</a>&nbsp;";
echo '<a href="' . h(ME) . 'table=' . urlencode($table) . '"' . bold($_GET["table"] == $table) . ">" . h($table) . "</a><br>\n";
}
?></p>
<?php endif; ?>
<?php
return null;
}

}
26 changes: 26 additions & 0 deletions plugins/floatThead.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

class AdminerFloatThead {

private $pathToJquery;
private $pathToFloatThead;

/**
* @param string $pathToJquery Path to jquery js library. Can be url, filesystem relative path related to the adminer directory or null (if jquery is provided by another plugin).
* @param string $pathToFloatThead Path to floatThead js library. Can be url or filesystem relative path related to the adminer directory.
*/
public function __construct($pathToJquery='https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js',
$pathToFloatThead='https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.0.3/jquery.floatThead.min.js') {
$this->pathToJquery = $pathToJquery;
$this->pathToFloatThead = $pathToFloatThead;
}

public function head() {
if ($this->pathToJquery) {
echo '<script src="'.h($this->pathToJquery).'"></script>';
}
echo '<script src="'.h($this->pathToFloatThead).'"></script>';
echo '<script>$(document).ready(function() { $(\'#content table\').first().floatThead(); });</script>';
echo '<style type="text/css">.floatThead-container { overflow: visible !important; }</style>';
}
}
1 change: 0 additions & 1 deletion public/css/default-blue.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/default-green.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/default-orange.css

This file was deleted.

Binary file removed public/fonts/entypo.eot
Binary file not shown.
Loading

0 comments on commit 4ef7376

Please sign in to comment.