Fixed table presentations with new bootstrap, added HTML::abbr(), added public access to Database::config(), enabled DB compression to be disabled in database.php

This commit is contained in:
Deon George 2016-05-03 11:01:28 +10:00
parent 113597f9eb
commit 8f659c50c6
13 changed files with 126 additions and 226 deletions

View File

@ -12,7 +12,14 @@
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Database extends Kohana_Database {
public function caching() {
return $this->_config['caching'];
/**
* Return a database configuration setting
*
* @param string Configuration value to return
* @return string|NULL Value of setting or NULL if it doesnt exist
*/
public function config($key) {
return isset($this->_config[$key]) ? $this->_config[$key] : NULL;
}
}
?>

View File

@ -27,11 +27,11 @@ abstract class lnApp_Form extends Kohana_Form {
$output = '';
$output .= '<div class="form-group">';
$output .= '<div class="input-group">';
// Only need col-md for horizonal forms?
if (isset($attributes['label'])) {
$output .= Form::label($name,$attributes['label'],array('class'=>'col-md-2 control-label'));
$output .= Form::label($name,$attributes['label'],array('class'=>'control-label'));
unset($attributes['label']);
}

View File

@ -12,6 +12,26 @@
abstract class lnApp_HTML extends Kohana_HTML {
public static $windowed_urls = TRUE;
/**
* Limit the number of characters that some text takes up.
* If the Text is smaller than the number of characters to display, then it is
* displayed normally.
*
* @param string Text to re-format
* @param int Number of characters to display
*/
public static function abbr($string,$chars=0) {
if (! $chars OR strlen($string)<=$chars)
return $string;
return sprintf('<abbr title="%s">%s</abbr>',$string,Text::limit_chars($string,$chars));
}
/**
* If the string is blank, then return &ampnbsp;
*
* @param string Text to print.
*/
public static function nbsp($string) {
if (strlen((string)$string))
return $string;

View File

@ -95,10 +95,11 @@ abstract class lnApp_ORM extends Kohana_ORM {
/**
* Retrieve and Store DB BLOB data in compressed format.
* Compression can be disabled by setting dbcompress in the database config to FALSE
*/
private function _blob($data,$set=FALSE) {
try {
return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data));
return $set ? ($this->_db->config('compress') ? gzcompress($this->_serialize($data,$set)) : $this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {

View File

@ -309,138 +309,6 @@ $(document).ready(function() {
return $this;
}
// @deprecated
public static function display($data,$rows,array $cols,array $option) {
$prepend = $headers = array();
foreach ($cols as $k=>$v) {
if (isset($v['label']))
$headers[$k] = $v['label'];
if (isset($v['url']))
$prepend[$k] = array('url'=>$v['url']);
}
return self::factory()
->data($data)
->jssort(TRUE)
->page_items($rows)
->columns($headers)
->prepend($prepend);
/*
// This JS is failing, any pressing of select all, unselect all, toggle is propaging up and submitting the form
Script::factory()
->type('stdin')
->data('
(function($) {
// Enable Range Selection
$.fn.enableCheckboxRangeSelection = function() {
var lastCheckbox = null;
var followOn = 0;
var $spec = this;
$spec.bind("click", function(e) {
if (lastCheckbox != null && e.shiftKey) {
x = y = 0;
if (followOn != 0) {
if ($spec.index(lastCheckbox) < $spec.index(e.target)) {
x = 1 - ((followOn == 1) ? 1 : 0);
} else {
y = 1 - ((followOn == -1) ? 1 : 0);
}
}
$spec.slice(
Math.min($spec.index(lastCheckbox) - x, $spec.index(e.target)) + 1,
Math.max($spec.index(lastCheckbox), $spec.index(e.target)) + y
).attr("checked",function() { return ! this.checked; })
.parent().parent().toggleClass("selected");
followOn = ($spec.index(lastCheckbox) < $spec.index(e.target)) ? 1 : -1;
} else {
followOn = 0;
}
lastCheckbox = e.target;
});
return $spec;
};
// Enable Toggle, (De)Select All
$.fn.check = function(mode) {
// if mode is undefined, use "on" as default
var mode = mode || "on";
switch(mode) {
case "on":
$("#select-table tr:not(.head)")
.filter(":has(:checkbox:not(checked))")
.toggleClass("selected")
break;
case "off":
$("#select-table tr:not(.head)")
.filter(":has(:checkbox:checked)")
.toggleClass("selected")
break;
case "toggle":
$("#select-table tr:not(.head)")
.toggleClass("selected");
break;
}
return this.each(function(e) {
switch(mode) {
case "on":
this.checked = true;
break;
case "off":
this.checked = false;
break;
case "toggle":
this.checked = !this.checked;
break;
}
});
};
})(jQuery);
// Bind our actions
$(document).ready(function() {
$("#select-table :checkbox").enableCheckboxRangeSelection();
$("#select-menu > #toggle").bind("click",function() {
$("#select-table :checkbox").check("toggle");
});
$("#select-menu > #all_on").bind("click",function() {
$("#select-table :checkbox").check("on");
});
$("#select-menu > #all_off").bind("click",function() {
$("#select-table :checkbox").check("off");
});
// Click to select Row
$("#select-table tr:not(.head)")
.filter(":has(:checkbox:checked)")
.addClass("selected")
.end()
.click(function(e) {
$(this).toggleClass("selected");
if (e.target.type !== "checkbox") {
$(":checkbox", this).attr("checked", function() {
return !this.checked;
});
}
});
// Double click to select a row
$("#select-table tr:not(.head)")
.dblclick(function(e) {
window.location = $("a", this).attr("href");
});
});
');
*/
}
// This enables us to page through many selected items
// @todo This is currently not usable, since our JS above needs to be fixed to work with tablesorter
public static function page($key) {

View File

@ -26,7 +26,7 @@ var search = _.debounce(function(url,query,process){
cache : false,
beforeSend : function() {
if (c++ == 0)
$('img[name=searching]').css('visibility', 'visible');
$('i[name=searching]').removeClass("hidden");
},
success : function(data) {
// if json is null, means no match, won't do again.
@ -47,7 +47,7 @@ var search = _.debounce(function(url,query,process){
},
complete : function() {
if (--c == 0)
$('img[name=searching]').css('visibility', 'hidden');
$('i[name=searching]').addClass("hidden");
}
})
}, 500);

View File

@ -1218,27 +1218,6 @@ a.list-group-item.active > .badge,
/*------------------------------------------------------------------
[ Pagination / .pagination ]
*/
ul.pagination li a {
padding: 0 10px;
margin-right: .25em;
margin-left: .25em;
color: #444;
line-height: 32px;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
ul.pagination li.active a {
font-weight: 600;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
background-color: #F90;
border-color: #F90;
}
ul.pagination li.active a:hover {
background-color: #F90;
border-color: #F90;
}
.pager li {
margin-right: .25em;
margin-left: .25em;

View File

@ -82,18 +82,24 @@ table .text-right {
font-weight: normal;
color: #000;
}
.form-group [class*=" fa-spin"] {
margin-left: -35px;
position: relative;
margin-top: 10px;
}
.navbar .navbar-form .navbar-search-addon [class*=" fa-spin"] {
padding: 10px 10px;
pointer-events: none;
right: 0px;
margin-top: 0px;
visibility: visible;
}
.navbar .navbar-form .navbar-search-addon i {
position: absolute;
padding: 10px 10px;
pointer-events: none;
}
.navbar .navbar-form .navbar-search-addon img {
position: absolute;
padding: 6px 10px;
pointer-events: none;
right: 0px;
visibility: hidden;
}
.form-group {
margin-bottom: 25px;
@ -102,3 +108,13 @@ table .text-right {
ul.typeahead.dropdown-menu {
min-width: 560px;
}
legend [class^="fa-"],
legend [class*=" fa-"] {
display: inline-block;
margin-top: -3px;
width: 25px;
font-size: 16px;
color: #555;
vertical-align: middle;
}

View File

@ -1,26 +1,28 @@
<div class="pager pagination-centered">
<ul>
<li class="<?php echo $x=($page->first_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->first_page())) ?>" rel="first"><?php echo __('First') ?></a>
</li>
<li class="<?php echo $x=($page->previous_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->previous_page())) ?>" rel="prev"><?php echo __('Previous') ?></a>
</li>
<?php for ($i = 1; $i <= $page->total_pages(); $i++): ?>
<li class="<?php echo $x=($page->current_page() == $i) ? 'active disabled' : '' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($i)) ?>"><?php echo $i ?></a>
</li>
<?php endfor ?>
<li class="<?php echo $x=($page->next_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->next_page())) ?>" rel="next"><?php echo __('Next') ?></a>
</li>
<li class="<?php echo $x=($page->last_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->last_page())) ?>" rel="last"><?php echo __('Last') ?></a>
</li>
</ul>
</div>
<nav>
<div class="text-center">
<ul class="pagination">
<li class="<?php echo $x=($page->first_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->first_page())) ?>" rel="first"><?php echo __('First') ?></a>
</li>
<li class="<?php echo $x=($page->previous_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->previous_page())) ?>" rel="prev"><?php echo __('Previous') ?></a>
</li>
<?php for ($i = 1; $i <= $page->total_pages(); $i++): ?>
<li class="<?php echo $x=($page->current_page() == $i) ? 'active disabled' : '' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($i)) ?>"><?php echo $i ?></a>
</li>
<?php endfor ?>
<li class="<?php echo $x=($page->next_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->next_page())) ?>" rel="next"><?php echo __('Next') ?></a>
</li>
<li class="<?php echo $x=($page->last_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->last_page())) ?>" rel="last"><?php echo __('Last') ?></a>
</li>
</ul>
</div>
</nav>

View File

@ -48,29 +48,31 @@ if ($use_n6)
for ($i = $n7; $i <= $n8; $i++)
$links[$i] = $i;
?>
<div class="pagination pagination-centered">
<ul>
<li class="<?php echo $x=($page->first_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->first_page())) ?>" rel="first"><?php echo __('First') ?></a>
</li>
<li class="<?php echo $x=($page->previous_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->previous_page())) ?>" rel="prev"><?php echo __('Previous') ?></a>
</li>
<?php foreach ($links as $number => $content): ?>
<li class="<?php echo $x=($page->current_page() == $number) ? 'active disabled' : '' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($number)) ?>"><?php echo $content ?></a>
</li>
<?php endforeach ?>
<li class="<?php echo $x=($page->next_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->next_page())) ?>" rel="next"><?php echo __('Next') ?></a>
</li>
<li class="<?php echo $x=($page->last_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->last_page())) ?>" rel="last"><?php echo __('Last') ?></a>
</li>
</ul>
</div>
<nav>
<div class="text-center">
<ul class="pagination">
<li class="<?php echo $x=($page->first_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->first_page())) ?>" rel="first"><?php echo __('First') ?></a>
</li>
<li class="<?php echo $x=($page->previous_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' :HTML::chars($page->url($page->previous_page())) ?>" rel="prev"><?php echo __('Previous') ?></a>
</li>
<?php foreach ($links as $number => $content): ?>
<li class="<?php echo $x=($page->current_page() == $number) ? 'active disabled' : '' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($number)) ?>"><?php echo $content ?></a>
</li>
<?php endforeach ?>
<li class="<?php echo $x=($page->next_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->next_page())) ?>" rel="next"><?php echo __('Next') ?></a>
</li>
<li class="<?php echo $x=($page->last_page() !== FALSE) ? '' : 'disabled' ?>">
<a href="<?php echo $x ? '#' : HTML::chars($page->url($page->last_page())) ?>" rel="last"><?php echo __('Last') ?></a>
</li>
</ul>
</div>
</nav>

View File

@ -1,11 +1,15 @@
<table class="table table-striped table-condensed table-hover" id="list-table<?php echo $jssort ? '-'.$jssort : ''; ?>">
<thead><tr><th><?php echo implode('</th><th>',$th); ?></th></tr></thead>
<tbody>
<?php foreach ($td as $details) : ?>
<tr><td><?php echo implode('</td><td>',$details['val']); ?></td></tr>
<?php endforeach ?>
<?php if ($other) : ?>
<tr><td>Other</td><td colspan="<?php #echo count($data)-1; ?>"><?php #printf('(%s) %s',$count,$other); ?></td></tr>
<?php if ($td) : ?>
<?php foreach ($td as $details) : ?>
<tr><td><?php echo implode('</td><td>',$details['val']); ?></td></tr>
<?php endforeach ?>
<?php if ($other) : ?>
<tr><td>Other</td><td colspan="<?php #echo count($data)-1; ?>"><?php #printf('(%s) %s',$count,$other); ?></td></tr>
<?php endif ?>
<?php else : ?>
<tr><td colspan="<?php echo count($th); ?>">NO records.</td></tr>
<?php endif ?>
</tbody>
</table>

View File

@ -2,7 +2,7 @@
<html>
<head>
<title><?php echo Site::Appname(); ?></title>
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/media/img/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="<?php echo $meta->language; ?>" />
@ -51,6 +51,7 @@
<div class="navbar-search-addon form-group">
<i class="fa fa-search"></i>
<input type="text" autocomplete="off" name="search-query" class="form-control input-sm search-query" placeholder="Search" data-provide="typeahead">
<i class="fa fa-spinner fa-spin hidden" name="searching"></i>
</div>
</form>
<?php endif ?>

View File

@ -2,7 +2,7 @@
<html>
<head>
<title><?php echo Site::Appname(); ?></title>
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/media/img/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="<?php echo $meta->language; ?>" />