daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jan 3rd, 2012 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class LibraryRenderer{
  4.  
  5.         public $menu;
  6.         public $movies;
  7.         private $library;
  8.        
  9.         public function __construct($library){
  10.        
  11.                 $this->library = $library;
  12.        
  13.         }
  14.  
  15.         public function render(){
  16.        
  17.                 $html[] = "<!doctype html>";
  18.                 $html[] = "<html>";
  19.                
  20.                 $html[] = $this->getHead();
  21.                
  22.                 $html[] = $this->getBody();
  23.                
  24.                 $html[] = "</html>";
  25.                
  26.                 return $this->getHtmlString($html);
  27.        
  28.         }
  29.        
  30.         private function getHead(){
  31.        
  32.                 $head[] = "<head>";
  33.                
  34.                         $head[] = "<title>Library</title>";
  35.                        
  36.                         foreach ($this->library->css as $css){
  37.                                 $head[] = '<link rel="stylesheet" type="text/css" href="'.$css.'">';
  38.                         }
  39.                        
  40.                         foreach ($this->library->javascript as $javascript){
  41.                                 $head[] = '<script type="text/javascript" src="'.$javascript.'"></script>';
  42.                         }
  43.                
  44.                
  45.                 $head[] = "</head>";
  46.                
  47.                 return $head;
  48.        
  49.         }
  50.        
  51.         private function getBody(){
  52.        
  53.                 $body[] = "<body>";
  54.                
  55.                         $body[] = '<nav id="main-nav">';
  56.                         foreach($this->menu as $menu){
  57.                                 $body[] = '<a href="?folder='.$menu.'">'.$menu.'</a>';
  58.                         }
  59.                         $body[] = "</nav>";
  60.                        
  61.                         $body[] = "<section>";
  62.                         foreach($this->movies as $movie){
  63.                                 $body[] = '<article class="movie"><img src="'.$movie['img'].'"><h3>'.$movie['name'].'</h3></article>';
  64.                         }
  65.                         $body[] = "</section>";
  66.                
  67.                 $body[] = "</body>";
  68.                
  69.                 return $body;
  70.        
  71.         }
  72.        
  73.         private function getHtmlString($array){
  74.        
  75.                 foreach($array as $html){
  76.                         if(is_array($html)){
  77.                                 $string .= $this->getHtmlString($html);
  78.                         }else{
  79.                                 $string .= $html;
  80.                         }
  81.                 }
  82.                 return $string;
  83.        
  84.         }
  85.        
  86. }
  87.  
  88. ?>
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top