Add files via upload
This commit is contained in:
		
							
								
								
									
										68
									
								
								showtimes/includes/loadFilms.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								showtimes/includes/loadFilms.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | |||||||
|  | <?php | ||||||
|  |     require_once($prefix.'panel_admin/includes/film_dao.php'); | ||||||
|  |  | ||||||
|  |     // ESTA CLASE SE HA CREADO PARA PODER INSTANCIAR ATRIBUTOS DE LA TABLA PELÍCULAS,  | ||||||
|  |     // SEGÚN VAYAN SIENDO RELEVANTES PARA MOSTRAR EN FUNCIÓN DE LA PÁGINA QUE LLAME A ESTA CLASE. | ||||||
|  |     // NO TODAS LAS PÁGINAS DEL CINE NECESITAN CARGAR TODOS LOS ATRIBUTOS POR COMPLETO DE LA TABLA PELÍCULAS | ||||||
|  |     // Y HEMOS CREIDO, QUE EN ESE CASO, MÁS EFICIENTE HACERLO A PETICIÓN. | ||||||
|  |     class loadFilms { | ||||||
|  |  | ||||||
|  |         //Atributes: | ||||||
|  |         private $films;         //Array of movie titles. | ||||||
|  |         private $descriptions;  //Array of movie descriptions. | ||||||
|  |  | ||||||
|  |         //Constructor: | ||||||
|  |         public function __construct() { | ||||||
|  |             $this->load(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Methods: | ||||||
|  |         //Returns an array with the titles of the available movies. | ||||||
|  |         public function getFilms(){ | ||||||
|  |             return $this->films; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Returns an array with the descriptions of the available movies. | ||||||
|  |         public function getDescription(){ | ||||||
|  |             $this->loadDescriptions(); | ||||||
|  |             return $this->descriptions; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Load the list of tittles of the movies. | ||||||
|  |         private function load(){ | ||||||
|  |             $this->films = array(); | ||||||
|  |             $tittles = new Film_DAO("complucine"); | ||||||
|  |             $reply = $tittles->tittleFilmData(); | ||||||
|  |  | ||||||
|  |             if($reply && $reply->num_rows>0){ | ||||||
|  |                 $i = 0; | ||||||
|  |                 while ($row = $reply->fetch_assoc()){ | ||||||
|  |                     foreach($row as $key => $value){ | ||||||
|  |                         $this->films[$i] = $value; | ||||||
|  |                     }  | ||||||
|  |                     $i++; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             $reply->free(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private function loadDescriptions(){ | ||||||
|  |             $this->descriptions = array(); | ||||||
|  |             $desc = new Film_DAO("complucine"); | ||||||
|  |             $reply = $desc->descriptionFilmData(); | ||||||
|  |  | ||||||
|  |             if($reply && $reply->num_rows>0){ | ||||||
|  |                 $i = 0; | ||||||
|  |                 while ($row = $reply->fetch_assoc()){ | ||||||
|  |                     foreach($row as $key => $value){ | ||||||
|  |                         $this->descriptions[$i] = $value; | ||||||
|  |                     }  | ||||||
|  |                     $i++; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             $reply->free(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | ?> | ||||||
| @@ -2,23 +2,17 @@ | |||||||
| <?php  | <?php  | ||||||
|     session_start(); |     session_start(); | ||||||
|  |  | ||||||
|  |     //HTML template: | ||||||
|     require_once('../assets/php/template.php'); |     require_once('../assets/php/template.php'); | ||||||
|     $template = new Template(); |     $template = new Template(); | ||||||
|     $prefix = $template->get_prefix(); |     $prefix = $template->get_prefix(); | ||||||
|  |  | ||||||
|     // BORRAR CUANDO TENGAMOS BBDD: |     //List of the tittles and descriptions of the movies: | ||||||
|     $films = array( |     require_once('includes/loadFilms.php'); | ||||||
|         "iron_man", |     $loadFilms = new loadFilms(); | ||||||
|         "iron_man_2", |     $films = $loadFilms->getFilms(); | ||||||
|         "iron_man_3", |     $descriptions = $loadFilms->getDescription(); | ||||||
|         "capitan_america_el_primer_vengador", |      | ||||||
|         "capitan_america_el_soldado_de_invierno", |  | ||||||
|         "capitan_america_civil_war", |  | ||||||
|         "marvel_avengers", |  | ||||||
|         "avengers_age_of_ultron", |  | ||||||
|         "avengers_inifinity_war", |  | ||||||
|         "avengers_end_game" |  | ||||||
|     ); |  | ||||||
| ?> | ?> | ||||||
| <!-- | <!-- | ||||||
|     Práctica 2 - Sistemas Web | Grupo D |     Práctica 2 - Sistemas Web | Grupo D | ||||||
| @@ -46,6 +40,7 @@ | |||||||
|             <?php |             <?php | ||||||
|             for($i = 0; $i < count($films); $i++){ |             for($i = 0; $i < count($films); $i++){ | ||||||
|                 $title = str_replace('_', ' ', $films[$i]); |                 $title = str_replace('_', ' ', $films[$i]); | ||||||
|  |                 $description = $descriptions[$i]; | ||||||
|                 if($i%2 === 0){ |                 if($i%2 === 0){ | ||||||
|                     if($i != 0) echo "</div> |                     if($i != 0) echo "</div> | ||||||
|                 "; |                 "; | ||||||
| @@ -60,9 +55,13 @@ | |||||||
|                 } |                 } | ||||||
|                 echo "<section id='".$films[$i]."'> |                 echo "<section id='".$films[$i]."'> | ||||||
|                         <div class='zoom'> |                         <div class='zoom'> | ||||||
|                             <div class='code'> |                             <div class='code showtimes'> | ||||||
|                                 <div class='image'><img src='".$prefix."img/".$films[$i].".jpg' alt='".$films[$i]."' /></div> |                                 <div class='image'><img src='".$prefix."img/".$films[$i].".jpg' alt='".$films[$i]."' /></div> | ||||||
|                                 <h2>".$title."</h2> |                                 <h2>".$title."</h2> | ||||||
|  |                                 <hr /> | ||||||
|  |                                 <div class='blockquote'> | ||||||
|  |                                     <p>".$description."</p> | ||||||
|  |                                 </div> | ||||||
|                             </div> |                             </div> | ||||||
|                         </div> |                         </div> | ||||||
|                     </section> |                     </section> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user