Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/12/2012, 20:54
underwebinfo
 
Fecha de Ingreso: septiembre-2012
Ubicación: Buenos aires
Mensajes: 110
Antigüedad: 11 años, 7 meses
Puntos: 9
Pregunta Class var en eval

Hola estoy haciendo va, termine una clase en php para la paginacion de articulos o lo que se quiera, el unico inconveniente es el de pasar 1 sola variable, mostrare a continuacion el script y luego podre hablar más claro.


Código PHP:
Ver original
  1. # --------------- CLASE PAGINACION -------------
  2. class Cm_Paginador{
  3.    
  4.     # --- Configuracion
  5.     var $Posicion,$Botones,$Base,$Article,$Order,$Mysql,$Query,$Exect,$Cant,$Paginas,$Comming,$Consulta,$Estructura;
  6.    
  7.     # --- Mysql
  8.     public function _Mysql($Mysql,$base,$article,$orden,$Posicion){
  9.        
  10.         # --- Mysql
  11.         $this->Base  = $base;
  12.         $this->Order = $orden;
  13.         $this->Article = $article;
  14.         $this->Mysql    = $Mysql;
  15.         $this->Posicion = $Posicion;
  16.         $this->Mysql->Conectar();
  17.         $this->Query = "SELECT * FROM ".($this->Base);
  18.         $this->Exect = $this->Mysql->Consulta($this->Query);
  19.        
  20.         # --- Condicionales
  21.         $this->Cant     = $this->Mysql->Reg_Num($this->Exect);
  22.         $this->Paginas  = ceil($this->Cant/$this->Article);
  23.         $this->Comming  = $this->Article*$this->Posicion;
  24.         $Desde          = $this->Posicion*$this->Paginas;
  25.    
  26.         # --- Consulta
  27.         $this->Consulta = $this->Mysql->Consulta($this->Query.' ORDER BY id '.$orden.' LIMIT '.$Desde.' , '.$this->Cant);
  28.    
  29.     }
  30.    
  31.     # --- Estructura
  32.     public function _Estructure($estructure){
  33.        
  34.         $this->Estructura = $estructure;
  35.        
  36.     }
  37.    
  38.     # --- Devolucion
  39.     public function _Devolucion(){
  40.        
  41.         while($Campo = $this->Mysql->Assoc($this->Consulta)){
  42.            
  43.             echo $this->Estructura;
  44.            
  45.         }
  46.  
  47.     }
  48.    
  49.     # --- Navegacion
  50.     public function _Navegacion($botones){
  51.        
  52.         # Vars
  53.         $this->Botones = $botones;
  54.        
  55.         if(($this->Botones)>=3){
  56.            
  57.             // next
  58.             if(($this->Posicion)>1 && ($this->Paginas)>1){
  59.                
  60.                 echo '<input type="button" onClick="Paginacion('.(($this-Posicion)-1).')" value="next">';
  61.                
  62.             }
  63.            
  64.             // numbers
  65.             for($i = 0;$i<$this->Botones;$i++){
  66.            
  67.                 if($i<$this->Paginas){
  68.                    
  69.                     echo '<input type="button" value="'.$i.'" onClick="Paginacion('.$i.')">';
  70.                        
  71.                 }
  72.            
  73.             }
  74.            
  75.             // prev
  76.             if(($this->Posicion)<($this->Paginas)){
  77.                
  78.                 echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+1).')" value="prev">';
  79.                
  80.             }
  81.    
  82.         }
  83.        
  84.         if(($this->Botones)<=2){
  85.        
  86.                    
  87.             // next
  88.             if(($this->Posicion)>1 && ($this->Paginas)>1){
  89.                
  90.                 echo '<input type="button" onClick="Paginacion('.(($this->Posicion)-1).')" value="next">';
  91.                    
  92.             }
  93.    
  94.             // prev
  95.             if(($this->Posicion)<($this->Paginas)){
  96.                    
  97.                 echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+1).')" value="prev">';
  98.                    
  99.             }
  100.                            
  101.         }
  102.        
  103.     }
  104.    
  105. }
  106.  
  107.  
  108.  
  109. # --------------- USO DE PAGINACION -------------
  110.  
  111. # --- Framework
  112.     include("../../Include/Cm_Framework.php");
  113.  
  114.     # --- Posicion
  115.     if(isset($_POST['Page']) && $_POST['Page']==''){
  116.        
  117.         $Posicion = intval($_POST['Page']);
  118.    
  119.     }else{
  120.        
  121.         $Posicion = 1;
  122.  
  123.     }
  124.  
  125.     # --- Configuracion
  126.     $Paginador  = new Cm_Paginador;
  127.     $Paginador->_Mysql(new Cm_mysql,'Album',5,'DESC',1);
  128.  
  129.     # --- Estructura
  130.     $Estructure = '<li><article class="Info"><h1><img src="Content/Albums/$Campo["Slug"]/$Campo["Caratula"]">$Campo["Titulo"]</h1><p>$Campo["Pie"]</p></article><article class="Multimedia" id="Album_$Campo["id"]"><a href="http://Naylafernandez.com.ar/Album/$Campo["Slug"]/" target="new" class="Ver" title="Ver Album"></a> <input type="button" title="Agregar Fotos" class="Agregar"> <input type="button" title="Editar Album" class="Editar"> <input type="button" title="Eliminar Album" class="Eliminar"></article></li>';
  131.     $Paginador->_Estructure($Estructure);
  132.      
  133.     # --- Devolucion
  134.     $Paginador->_Devolucion();
  135.    
  136.     # --- Paginacion
  137.     $Paginador->_Navegacion(5);

El problema es que cuando llamo a $Paginador->_Devolucion();
me entrega toda la estructura html pasada pero las variables como string y no como variables de datos... me dijeron que con eval se podia acá

http://www.forosdelweb.com/f18/callback-bucle-while-1028736/

pero no comprendo a eval(); -.- y un include no quiero usar, alguna otra sugerencia? seria de mucha utilidad para mi