Exemplo n.º 1
0
 public static function index()
 {
     print_r('testing inputs: ');
     print_r(self::input('get', 'foo'));
     $test = kos::model('test')->test_method('abc');
     echo $test;
 }
Exemplo n.º 2
0
 public static function bootstrap()
 {
     if (!empty($_GET['kos_path'])) {
         // TODO: This needs escaping
         $path = explode('/', $_GET['kos_path']);
         unset($_GET['kos_path']);
     } else {
         $path = array();
     }
     // Set the controller
     if (count($path) > 0) {
         self::$controller = array_shift($path);
     }
     // Set the method
     if (count($path) > 0) {
         self::$method = array_shift($path);
     }
     // Set the method parameters
     while (count($path) > 0) {
         $param_key = array_shift($path);
         if (!($param_value = array_shift($path))) {
             $param_value = true;
         }
         self::$method_parameters[$param_key] = $param_value;
     }
     // Set the include dir
     self::$include_dir = './';
     // Include the required core classes, but don't instantiate them
     self::include_class('kos/config');
     self::include_class('kos/model');
     self::include_class('kos/controller');
     // Controller init
     if (method_exists('controller', 'init')) {
         controller::init();
     }
     // Load up the controller class and call the correct method
     if (!self::controller(self::$controller)) {
         self::fatal_error('Error loading the controller');
     }
     $controller_class = self::$controller . '_controller';
     $method = self::$method;
     // Call the controller's init method
     if (method_exists($controller_class, 'init')) {
         $controller_class::init();
     }
     // Call the controller method that was requested (or index)
     if (method_exists($controller_class, $method)) {
         $controller_class::$method();
     } else {
         self::fatal_error('Error loading class method');
     }
 }