From c014a4cec843a37c14cb77b2d453909b8ca6494e Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 8 Nov 2013 22:26:58 +1100 Subject: [PATCH] Fixes for userguide, added url_resolve to Table() --- classes/lnApp/Controller/TemplateDefault.php | 12 ++++++------ classes/lnApp/Form.php | 4 ++++ classes/lnApp/Table.php | 13 +++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/classes/lnApp/Controller/TemplateDefault.php b/classes/lnApp/Controller/TemplateDefault.php index 186a954..28774ea 100644 --- a/classes/lnApp/Controller/TemplateDefault.php +++ b/classes/lnApp/Controller/TemplateDefault.php @@ -62,18 +62,18 @@ abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Templa * @uses meta */ public function before() { - // Do not template media files - if ($this->request->action() === 'media') { - $this->auto_render = FALSE; - return; - } - // Actions that start with ajax, should only be ajax if (! Kohana::$config->load('debug')->ajax AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax()) throw HTTP_Exception::factory(412,_('Unable to fulfil request.')); parent::before(); + // Do not template media files + if ($this->request->action() === 'media') { + $this->auto_render = FALSE; + return; + } + // Check user auth and role if ($this->_auth_required()) { if (PHP_SAPI === 'cli') diff --git a/classes/lnApp/Form.php b/classes/lnApp/Form.php index c81e872..84a17ef 100644 --- a/classes/lnApp/Form.php +++ b/classes/lnApp/Form.php @@ -97,5 +97,9 @@ abstract class lnApp_Form extends Kohana_Form { return sprintf(static::_controlgroup($name,$attributes),parent::textarea($name,$body,$attributes,$double_encode)); } + + public static function textarea_rows($textarea,$min=10,$char="\n") { + return ($x=count(explode($char,$textarea))) < $min ? $min : $x; + } } ?> diff --git a/classes/lnApp/Table.php b/classes/lnApp/Table.php index 1557cb0..087c0ce 100644 --- a/classes/lnApp/Table.php +++ b/classes/lnApp/Table.php @@ -80,6 +80,19 @@ abstract class lnApp_Table { case 'url': $x = HTML::anchor($data.$x,$x); break; + + case 'url_resolve': + $filtermatchall = array(); + preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$data,$filtermatchall); + + foreach ($filtermatchall[1] as $id=>$key) + $data = str_replace($filtermatchall[0][$id],$d->display($key),$data); + + $x = HTML::anchor($data,$x); + break; + + default: + throw HTTP_Exception::factory(501,'Unknown action :action',array(':action'=>$act)); } } }