clase para la vista
Código PHP:
<?php
class View {
private $menu;
private $rutaview,$rutafooter;
private $defaultem;
private $indexs;
private $main;
private $layout;
private $path,$pathimg,$jscript,$contenido;
private $vars=array(),$vistaW=array();
public function __construct(){
$this->defaultem="default";
}
public function set($name,$value) {
$this->vars[$name] = $value;
}
public function show($view,$noLayout = false)
{
$this->rutaview= ROOT."templates".DS.$this->defaultem.DS.'index'.".php";
$this->rutafooter=$this->load(ROOT."templates".DS.$this->defaultem.DS."footer".".php");
$this->menu=$this->load(ROOT."templates".DS.$this->defaultem.DS.'menu'.".php");
$this->path=BASE_URL.DS.'templates'.DS. $this->defaultem . DS.'css';
$this->pathimg=BASE_URL.DS.'templates'.DS.$this->defaultem . DS.'img';
$this->jscript=BASE_URL.DS.'js';
foreach($this->vars as $key => $value) {
$$key = $value;
}
$this->vistaW["vistas"]=ROOT.'vista' . DS . $view. '.php';
if(is_readable($this->vistaW["vistas"]))
{
$this->set('contenido',$this->vistaW["vistas"]);
}
else {
throw new Exception('View issues');
}
$this->loadview($this->rutaview);
}
public function load($var){
if (file_exists($var)){
ob_start();
require_once $var;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
else {
return 'Template no encontrado';
}
}
public function loadview($views)
{
include_once($views);
}
}
?>
controlador
Código PHP:
<?php
class controlador extends controladores {
var $consulta,$paginacion,$pag,$rutas,$data,$mensaje;
public function __construct() {
parent::__construct();
$this->loadmodel("modelo");
$this->consulta =new auth;
$this->loadlibrary("paginador");
$this->pag = new Paginador();
$this->login();
}
public function principal(){
$this->data=$this->consulta->users();
$pg=$this->pag->paginas($this->data,$page,$limites);
$datas=$pg;
$this->view->set("datas",$datas);
$this->view->show("centro".DS."tabla");
exit;
}
}
?>
Código PHP:
<?php abstract class controladores {
public function __construct(){
$this->view=new View();
}?>
agradeceria su ayuda !! gracias de antemano