Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/07/2010, 14:06
Avatar de syntex
syntex
 
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 6 meses
Puntos: 4
Mvc (Modelo Vista Controlador)

hola gente,

Estoy desarrollando un Modelo Vista Controlador y bueno he comenzado ahora hacer este modelo y me gustaria que me pudiesen orientar con lo expuesto aqui.
GLOBALES:

Código PHP:
<?php
    define
('RUTA_controllers''app/controllers/');
    
define('RUTA_models''app/models/');
    
define('RUTA_views''app/views/');
    
define('RUTA_lib''app/lib/');
    
define('RUTA_layouts''app/views/layouts/');
?>
CLASE PADRE PREPARADA

Código PHP:
<?php
class User_Base{
    function 
__construct(){
        global 
$Bd;
        
$this->Bd $Bd;
    }
}
?>
CONTROLLERS

Código PHP:
<?php
/**
* Controller
**/
class Usuarios_controller extends User_Base{
private 
$userid;
private 
$user;
public 
$texto_user_no;
    function 
__construct(){
        
parent::__construct();    
    }
     public function 
login$user ,$password) {
        require_once(
RUTA_models."portada/portada.php");
        
$user = new usuarios($_POST[user],$_POST[password]);
        
$userid $user->validateUser();
        if(
$userid == ){
                  
//******************************************
                 
if ((empty($_POST[user]) or empty($_POST[password])) and $_POST[xs] !=""){
                    
ob_start();        
                      require_once(
RUTA_layouts."portada/portada.php");
                    
$this->texto_user_no ob_get_clean();
                }
                
//******************************************
               
require_once(RUTA_views."portada/sin_loginear.php");
          }else{ 
             require_once(
RUTA_views."portada/logineado.php");
          }
     }
}    
?>
MODELS

Código PHP:
<?php
/**
* Model
**/
class usuarios extends User_Base{
    public 
$user;
    private 
$password;
    private 
$userid;
    function 
__construct$user$password ) {
        
$this->user $user;
        
$this->password $password;
        
parent::__construct();
    }
   public function 
validateUser( ) {
        
$R $this->Bd->consultar("email,password","usuarios","WHERE (email = '".$_POST[user]."' and password = '".md5($_POST[password])."')","");
        
$this->dato $this->Bd->num_rows($R);
        
$this->Bd->limpiaconsulta($R);
       if( 
$this->dato !=  )  {
           return 
$this->dato;
       } else {
          return 
0;
       }
   }
}  
?>
VIEWS
SIN LOGINEARSE


Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<?= $this->texto_user_no; ?>
<form action="index.php" method="post">
	<input type="text" name="user" value="<?= $_POST[user]; ?>" />
    <input type="text" name="password" value="<?= $_POST[password]; ?>" />
    <input type="submit" name="xs" value="enviar" />
</form>
</body>
</html> 
LOGINEADO

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<p>El usuario <?= $user->user; ?> existe
</body>
</html> 
layouts

Código HTML:
<h1>Usuario inválido</h1>
<span>Introduzca correctamente la cuenta de usuario.</span> 
Espero que me puedan ayudar y mejorar todo lo reportado aqui

Gracias.
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------