Modules
Controller_Welcome
extends Controller_Template
extends Kohana_Controller_Template
extends Controller
extends Kohana_Controller
Abstract controller class for automatic templating.
Class declared in APPPATH/classes/controller/welcome.php on line 3.
Constants
- None
Properties
Properties
public
boolean$auto_renderauto render template
public
Request$requestRequest that created the controller
public
$templatepublic
$widgets
Methods
public __construct( Request $request ) (defined in Kohana_Controller)
Creates a new controller instance. Each controller must be constructed with the request object that created it.
Parameters
-
Request$request required - Request that created the controller
Return Values
void
Source Code
public function __construct(Request $request)
{
// Assign the request to the controller
$this->request = $request;
}
public action_form( ) (defined in Controller_Welcome)
Source Code
public function action_form()
{
$last_input = array();
$errors = array();
if (Arr::get($_POST, 'hidden') == 'form_sent')
{
$keys = array ('text','pass','area','chck','radio','sel');
$last_input = Arr::extract($_POST, $keys, NULL);
$valid = Validate::factory($last_input)
->filter('text','trim')
->filter('pass','trim')
->filter('area','trim')
->rules('text',array('not_empty'=>NULL,'alpha_numeric'=>array(TRUE),'max_length'=>array(10)))
->rules('pass',array('alpha_numeric'=>array(TRUE),'max_length'=>array(10)))
->rule('radio','not_empty');
if ( ! $valid->check())
{
$errors = $valid->errors();
}
}
$this->template->title = 'Form page';
$this->template->content = View::factory('elements/form')
->set('last_input', $last_input)
->set('errors', $errors);
$this->template->navigation = $this->_simple_nav();
$this->widgets[] = Request::factory('widget_date/show/hour-min')->execute();
}
public action_index( ) (defined in Controller_Welcome)
Source Code
public function action_index()
his->template->title = 'Main page';
$this->template->content = View::factory('elements/content')
->bind('p1',$par1)
->bind('p2',$par2);
$par1 = 'news 1';
$par2 = 'news 2';
$this->template->navigation = $this->_simple_nav();
public action_page1( ) (defined in Controller_Welcome)
Source Code
public function action_page1()
{
$out = Request::factory('psy/nice')->execute();
$this->template->title = 'Page 1';
$this->template->content = 'hello, world<br />page 1!<br />'.$out;
$this->template->navigation = $this->_simple_nav();
}
public action_page2( ) (defined in Controller_Welcome)
Source Code
public function action_page2()
{
$out = Request::factory('psy/intellectual')->execute();
$this->template->title = 'Page 2';
$this->template->content = 'hello, world<br />page 2!<br />'.$out;
$this->template->navigation = $this->_simple_nav();
}
public after( ) (defined in Kohana_Controller_Template)
Assigns the template View as the request response.
Source Code
public function after()
{
if ($this->auto_render === TRUE)
{
$this->request->response = $this->template;
}
return parent::after();
}
public before( ) (defined in Controller_Welcome)
Loads the template View object.
Source Code
public function before()
{
parent::before();
$this->template->bind('widgets', $this->widgets);
// attach "anywhere presented" widget
$this->widgets[] = Request::factory('widget_date/show/year-day')->execute();
$this->widgets[] = Request::factory('widget_cdate/show/page')->execute();
}
protected _simple_nav( ) (defined in Controller_Welcome)
Source Code
protected function _simple_nav()
{
$class = new ReflectionClass('Controller_Welcome');
$methods = $class->getMethods();
$slugs = array();
foreach ($methods as $method_object)
{
$pos = strpos($method_object->name, 'action_');
if ($pos !== 0)
{
continue;
}
$slug = substr_replace($method_object->name, '', 0, 7);
if ($slug === '')
{
continue;
}
$m = new ReflectionMethod('Controller_Welcome',$method_object->name);
if ($m->isPublic())
{
$slugs[] = HTML::anchor($slug, url::title($slug));
}
}
//$view = new View('elements/navigation');
//$view->items = $slugs;
$view = View::factory('elements/navigation')
->set('items',$slugs);
return $view;
}