page = new MM_Page($this); } // -------------------------------------------------------------------------- /** * Function for loading a model into the current class * * @param string $file * @param array $args * @return void */ public function load_model($file, $args=array()) { $path = ""; // The module is the lower of the class name // need to figure out a way to allow multiple controllers // in one module $module = strtolower(get_class($this)); $not_modules = array('miniMVC', 'page', 'db', 'output'); // If it's a module, look in the module view folder if( ! in_array($module, $not_modules)) { $path = MM_MOD_PATH . "{$module}/models/{$file}.php"; } if(is_file($path)) { require_once($path); } if( ! empty($args)) { $this->$file = new $file($args); } else { $this->$file = new $file; } } // -------------------------------------------------------------------------- /** * Function for loading a view * * @param string $file * @param array $data * @param bool $return * @return mixed */ public function load_view($file, array $data=array(), $return=FALSE) { $path = ""; // The module is the lower of the class name // need to figure out a way to allow multiple controllers // in one module $module = strtolower(get_class($this)); $not_modules = array('miniMVC', 'page', 'db', 'output'); // If it's a module, look in the module view folder if( ! in_array($module, $not_modules)) { $path = MM_MOD_PATH . "{$module}/views/{$file}.php"; } // If it's not a module, or doesn't exist in the module view folder // look in the app view folder if( ! is_file($path)) { $path = MM_APP_PATH . "views/{$file}.php"; } // Contain the content for buffering ob_start(); // Extract the data array extract($data); // Include the file include($path); $buffer = ob_get_contents(); ob_end_clean(); if($return == TRUE) { return $buffer; } else { $this->output->append_output($buffer); } } } // End of controller.php