<?php if ( ! defined('PATH')) exit('Acesso direto NEGADO');
/**
* Smvc - Simple MVC
* @package SMVC
* @author Paulo Rocha
* @copyright 2009 - 2009 Ahcor Design
* @license http://smvc.tk/manual/license.html
* @link http://smvc.tk
* @since Version 0.01
* @filesource http://smvc.tk/download
* @category Super Class
* @uses This is Base Class for all others class (others class extendes this!)
*/
class Smvc
{
public $db;
public $model;
public $views;
public $config;
function __construct()
{
//echo "smvc|";
$this->config=$GLOBALS['Smvc_config'];
$this->db=$GLOBALS['Smvc_db'];
}
function xxteste()
{
echo "TESTE";
}
function load_model($model)
{
if (file_exists(MODELS.$model.".php")){$this->model=new $model;}else{return false;}
}
function view($view)
{
if(file_exists($this->config->path.$this->config->path_views.$view.'.php')){require_once($this->config->path_views.$view.'.php');
}
else{require_once($smvc_config->path_views."off.php");}
}
/**
* Smvc - Simple MVC
* Função que carrega uma classe adicionada ao SMVC no caminho: 'site/_smvc/library/classe..php'
* O nome da classe pode ter caracteres em maiúsculo e minúsculo mas o arquivo deve sempre estar em caracteres minúsculos.
* A classe será instanciada com o nome fornecido em '$classe'. no arquivo a classe (cabeçalho) de ve ter o mesmo nome ou o sistema indicará erro.
* por exemplo: 'load_library('Mail')' -> carega o arquivo: mail.php -> A classe será chamada assim: '$this->Mail...'.
* @package SMVC
* @category Functions
* @uses Carrega outras CLASSES localizadas no diretório 'library' e disponibiliza para o controller.
* @param string Nome da classe (case sensitive). Será o nome de referencia para chamadas. O nome do arquivo tem que estar em minúsculo.
* @return bool False se o arquivo não existir.
*/
function load_library($classe)
{
$class=strtolower($classe);
if (file_exists(PATH."_smvc/library/".$class.".php"))
{
require_once(PATH."_smvc/library/".$class.".php");
$this->$classe=new $classe;
return true;
}else{return false;}
}
}
?>