daily pastebin goal
47%
SHARE
TWEET

Untitled

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