New version submitted by TomB
[carbonphp.git] / Source / carbon / libraries / Controller.php
blob22e0a28de82b72b99b8dc7eaa29347379f40db6c
1 <?php
2 /*------------------------------------------------------------
3 * CarbonPHP framework (C) Tom Bell
4 * http://tombell.org.uk
5 *------------------------------------------------------------*/
7 if (!defined('CARBON_PATH'))
9 exit('Direct script access is not allowed.');
12 class Controller extends Carbon_Base
14 protected $scaffolding = false;
15 protected $scaff_table = false;
17 public function __construct()
19 parent::__construct();
20 $this->_initialise();
22 log_message('debug', 'Controller.php - Controller class initialised');
25 protected function _initialise()
27 $classes = array(
28 'config' => 'Config',
29 'input' => 'Input',
30 'benchmark' => 'Benchmark',
31 'uri' => 'Uri',
32 'lang' => 'Language',
33 'output' => 'Output'
36 foreach ($classes as $class => $class_name)
38 $this->$class =& load_class($class_name);
41 $this->load =& load_class('Loader');
42 $this->load->autoloader();
45 public function _scaffolding()
47 if ($this->scaffolding === false || $this->scaff_table === false)
49 display_not_found('Scaffolding is not available');
52 $method = (!in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), true)) ? 'view' : $this->uri->segment(3);
54 require_once(CARBON_PATH . 'scaffolding/Scaffolding' . FILE_EXT);
56 $scaffold = new Scaffolding($this->scaff_table);
57 $scaffold->$method();
60 public function set_scaffolding($scaffolding)
62 $this->scaffolding = $scaffolding;
65 public function set_scaff_table($scaff_table)
67 $this->scaff_table = $scaff_table;