Fixes for userguide, added url_resolve to Table()

This commit is contained in:
Deon George 2013-11-08 22:26:58 +11:00
parent 45cadf0945
commit c014a4cec8
3 changed files with 23 additions and 6 deletions

View File

@ -62,18 +62,18 @@ abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Templa
* @uses meta * @uses meta
*/ */
public function before() { 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 // 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()) 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.')); throw HTTP_Exception::factory(412,_('Unable to fulfil request.'));
parent::before(); parent::before();
// Do not template media files
if ($this->request->action() === 'media') {
$this->auto_render = FALSE;
return;
}
// Check user auth and role // Check user auth and role
if ($this->_auth_required()) { if ($this->_auth_required()) {
if (PHP_SAPI === 'cli') if (PHP_SAPI === 'cli')

View File

@ -97,5 +97,9 @@ abstract class lnApp_Form extends Kohana_Form {
return sprintf(static::_controlgroup($name,$attributes),parent::textarea($name,$body,$attributes,$double_encode)); 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;
}
} }
?> ?>

View File

@ -80,6 +80,19 @@ abstract class lnApp_Table {
case 'url': $x = HTML::anchor($data.$x,$x); case 'url': $x = HTML::anchor($data.$x,$x);
break; 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));
} }
} }
} }