diff --git a/classes/lnApp/Controller/Default.php b/classes/lnApp/Controller/Default.php index d988e65..3f29a25 100644 --- a/classes/lnApp/Controller/Default.php +++ b/classes/lnApp/Controller/Default.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Deon George * @license http://dev.leenooks.net/license.html */ -abstract class lnApp_Controller_Default extends Controller { +abstract class lnApp_Controller_Default extends Kohana_Controller { /** * The variable that our output is stored in */ diff --git a/classes/lnApp/Controller/TemplateDefault.php b/classes/lnApp/Controller/TemplateDefault.php index cb9eefe..87fd109 100644 --- a/classes/lnApp/Controller/TemplateDefault.php +++ b/classes/lnApp/Controller/TemplateDefault.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Deon George * @license http://dev.leenooks.net/license.html */ -abstract class lnApp_Controller_TemplateDefault extends Controller_Template { +abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Template { /** * @var object meta object information as per [meta] */ @@ -76,7 +76,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { // Check user auth and role if ($this->_auth_required()) { - if (Kohana::$is_cli) + if (PHP_SAPI === 'cli') throw new Kohana_Exception('Cant run :method, authentication not possible',array(':method'=>$this->request->action())); // If auth is required and the user is logged in, then they dont have access. diff --git a/classes/lnApp/Form.php b/classes/lnApp/Form.php index f36316e..d2b50a2 100644 --- a/classes/lnApp/Form.php +++ b/classes/lnApp/Form.php @@ -48,6 +48,10 @@ abstract class lnApp_Form extends Kohana_Form { return $output; } + public static function button($name,$body,array $attributes=NULL) { + return sprintf(static::_controlgroup($name,$attributes),parent::button($name,$body,$attributes)); + } + /** * Wrap our Form() functions with boostrap HTML * diff --git a/classes/lnApp/HTMLRender.php b/classes/lnApp/HTMLRender.php index 54b5eb9..b624582 100644 --- a/classes/lnApp/HTMLRender.php +++ b/classes/lnApp/HTMLRender.php @@ -102,7 +102,7 @@ abstract class lnApp_HTMLRender { throw new Kohana_Exception('Missing key :key for image',array(':key'=>$key)); // Check for unique keys - if (static::$_unique_vals) + if (isset(static::$_unique_vals) AND static::$_unique_vals) foreach (static::$_unique_vals as $v=>$u) foreach (static::$_data as $d) if (isset($d[$u]) && $d['data'] == $item['data']) diff --git a/classes/lnApp/Table.php b/classes/lnApp/Table.php index 3de5ad9..4f57d4d 100644 --- a/classes/lnApp/Table.php +++ b/classes/lnApp/Table.php @@ -12,6 +12,8 @@ abstract class lnApp_Table { private $data = NULL; private $columns = array(); // Our columns that we need to display + private $filters = array(); // Our datafomrating that we need to use + private $filters_added = FALSE; private $jssort = FALSE; // Use the JS pager and sorter private $other = ''; // If we are only listing x items, this will be the other summary line private $other_col = NULL; // If we are only listing x items, this will be the other summary line @@ -19,6 +21,8 @@ abstract class lnApp_Table { private $page = FALSE; // If we should page the results private $page_rows = 0; // Number of rows per page private $prepend = array(); // Our datafomrating that we need to use + private $prepend_vals = array(); // Our datafomrating that we need to use + private $select = array(); // Our select form details public function __toString() { return (string) $this->render(); @@ -37,6 +41,12 @@ abstract class lnApp_Table { } private function evaluate($d,$key) { + if (count($this->filters) AND ! $this->filters_added) { + $d->display_filters($this->filters); + // So we dont keep extending our display_filters + $this->filters_added = TRUE; + } + if (is_array($d) AND isset($d[$key])) $x = $d[$key]; @@ -53,8 +63,18 @@ abstract class lnApp_Table { if (isset($this->prepend[$key])) { foreach ($this->prepend[$key] as $act => $data) { switch ($act) { + case 'checkbox': $x = sprintf('',Form::checkbox($data,$x,FALSE,array('nocg'=>TRUE)),$x); // @todo Check those not yet checked + break; + + case 'input': + if (preg_match('/__VALUE__/',$data['key'])) + $data['key'] = preg_replace('/__VALUE__/',$x,$data['key']); + + $x = Form::input($data['key'],isset($data['values'][$x]) ? $data['values'][$x] : '',array('placeholder'=>$x,'label'=>$x)); + break; + case 'url': $x = HTML::anchor($data.$x,$x); - break; + break; } } } @@ -66,8 +86,17 @@ abstract class lnApp_Table { return new Table; } - public function jssort($bool) { - $this->jssort = $bool; + /** + * Apply additional display filters to the results + */ + public function filters($cols) { + $this->filters = $cols; + + return $this; + } + + public function jssort($table) { + $this->jssort = $table; return $this; } @@ -92,6 +121,8 @@ abstract class lnApp_Table { foreach ($this->data as $o) { $row++; $c = 0; + // So our filters are added for this record. + $this->filters_added = FALSE; // If we are HTML paging if ($this->page) { @@ -103,7 +134,7 @@ abstract class lnApp_Table { // If we are just listing page_rows items and a summary line as a result of exceeding that if ($this->other_col AND $row>$this->page_rows) { - $this->other += Table::resolve($o,$this->other_col); + $this->other += $this->evaluate($o,$this->other_col); // Otherwise rendering our rows } else { @@ -118,7 +149,7 @@ abstract class lnApp_Table { return $result; } - public function render() { + private function render() { $output = ''; // If we need to page the results @@ -132,8 +163,11 @@ abstract class lnApp_Table { } + if ($this->select) + $output .= Form::open($this->select['form']); + $output .= View::factory('table') - ->set('jssort',$this->jssort AND ! $this->page) + ->set('jssort',($this->jssort AND ! $this->page) ? $this->jssort : FALSE) ->set('other',$this->other) ->set('th',$this->columns) ->set('td',$this->process()); @@ -162,7 +196,7 @@ $(document).ready(function() { odd : "" // even row zebra striping }); - $("#list-table").tablesorter({ + $("#list-table'.($this->jssort ? '-'.$this->jssort : '').'").tablesorter({ theme: "bootstrap", widthFixed : true, headerTemplate : "{content} {icon}", // Add icon for jui theme; new in v2.7! @@ -170,7 +204,7 @@ $(document).ready(function() { }).tablesorterPager({ // target the pager markup - see the HTML block below - container : $(".pager"), + container : $(".pager'.($this->jssort ? '-'.$this->jssort : '').'"), output : "{startRow} - {endRow} / {filteredRows} ({totalRows})", fixedHeight: true, removeRows : false, @@ -200,10 +234,27 @@ $(document).ready(function() { ->data('media/vendor/mottie-tablesorter/css/jquery.tablesorter.pager.css'); } + if ($this->select) { + $output .= Form::button('submit','Submit',array('class'=>'btn btn-primary','value'=>$this->select['submit'])); + + foreach ($this->select['hidden'] as $k=>$v) + $output .= Form::hidden($k,$v); + + $output .= Form::close(); + } + return $output; } -//ZZ + public function select($form,$submit='',array $hidden=array()) { + $this->select['form'] = $form; + $this->select['submit'] = $submit; + $this->select['hidden'] = $hidden; + + return $this; + } + + // @deprecated public static function display($data,$rows,array $cols,array $option) { $prepend = $headers = array(); @@ -222,11 +273,6 @@ $(document).ready(function() { ->prepend($prepend); /* - if (! empty($option['button'])) - $button = implode('',$option['button']); - else - $button = Form::button('Submit','View/Edit',array('class'=>'form_button','type'=>'submit')); - // This JS is failing, any pressing of select all, unselect all, toggle is propaging up and submitting the form Script::factory() diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 0000000..8062cdc --- /dev/null +++ b/config/cache.php @@ -0,0 +1,31 @@ + array( + 'driver' => 'apc', + 'default_expire' => 3600, + ), + + 'file' => array( + 'driver' => 'file', + 'cache_dir' => Kohana::$cache_dir ? Kohana::$cache_dir : APPPATH.'cache/', + 'default_expire' => 3600, + 'ignore_on_delete' => array( + '.gitignore', + '.git', + '.htaccess', + '.svn' + ) + ), +); +?> diff --git a/config/userguide.php b/config/userguide.php new file mode 100644 index 0000000..4dc0f18 --- /dev/null +++ b/config/userguide.php @@ -0,0 +1,56 @@ + TRUE, + + // Enable these packages in the API browser. TRUE for all packages, or a string of comma seperated packages, using 'None' for a class with no @package + // Example: 'api_packages' => 'Kohana,Kohana/Database,Kohana/ORM,None', + 'api_packages' => TRUE, + + // Enables Disqus comments on the API and User Guide pages + 'show_comments' => Kohana::$environment === Kohana::PRODUCTION, + + // Leave this alone + 'modules' => array( + + 'kohana' => array('enabled'=>FALSE), + 'auth' => array('enabled'=>FALSE), + 'cache' => array('enabled'=>FALSE), + 'database' => array('enabled'=>TRUE), + 'minion' => array('enabled'=>FALSE), + 'orm' => array('enabled'=>FALSE), + 'pagination' => array('enabled'=>FALSE), + // This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename' + 'userguide' => array( + + // Whether this modules userguide pages should be shown + 'enabled' => TRUE, + + // The name that should show up on the userguide index page + 'name' => 'Userguide', + + // A short description of this module, shown on the index page + 'description' => 'Documentation viewer and api generation.', + + // Copyright message, shown in the footer for this module + 'copyright' => '© 2008–2012 Kohana Team', + ) + ), + + // Set transparent class name segments + 'transparent_prefixes' => array( + 'Kohana' => TRUE, + ) +); diff --git a/views/table.php b/views/table.php index b9ca09b..68ebed4 100644 --- a/views/table.php +++ b/views/table.php @@ -1,4 +1,4 @@ - +
@@ -11,7 +11,7 @@
',$th); ?>
-
+
Page: diff --git a/views/theme/baseadmin/page.php b/views/theme/baseadmin/page.php index 045a4a2..e85c5ef 100644 --- a/views/theme/baseadmin/page.php +++ b/views/theme/baseadmin/page.php @@ -14,7 +14,7 @@ = Kohana::TESTING) { + if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) { echo HTML::style('media/theme/bootstrap/css/bootstrap.min.css'); echo HTML::style('media/theme/bootstrap/css/bootstrap-responsive.min.css'); echo HTML::style('media/vendor/font-awesome/css/font-awesome.min.css'); @@ -97,7 +97,7 @@
= Kohana::TESTING) { + if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) { echo HTML::script('media/js/jquery/jquery-1.9.1.min.js'); echo HTML::script('media/theme/bootstrap/js/bootstrap.min.js'); // @todo Work out how to delay this loading until required