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) {