<?php
namespace front\view;

class Banners
{  
  public static function banners( $banners )
  {
    $tpl = new \Tpl;
    $tpl -> banners = $banners;
    return $tpl -> render( 'banner/banners' );
  }
  
  public static function main_banner( $banner )
  {
    if ( file_exists( 'templates/banner/draw.php' ) and !file_exists( 'templates/banner/main-banner.php' ) )
      copy( 'templates/banner/draw.php', 'templates/banner/main-banner.php' );
    
    if ( file_exists( 'templates/banner/draw.php' ) and file_exists( 'templates/banner/main-banner.php' ) )
      unlink( 'templates/banner/draw.php' );
    
    if ( file_exists( 'templates_user/banner/draw.php' ) and !file_exists( 'templates_user/banner/main-banner.php' ) )
      copy( 'templates_user/banner/draw.php', 'templates_user/banner/main-banner.php' );
    
    if ( file_exists( 'templates_user/banner/draw.php' ) and file_exists( 'templates_user/banner/main-banner.php' ) )
      unlink( 'templates_user/banner/draw.php' );
    
    
    if ( !\S::get_session( 'banner_close' ) && is_array( $banner ) )
    {
      $tpl = new \Tpl;
      $tpl -> banner = $banner;
      return $tpl -> render( 'banner/main-banner' );
    }
  }
}
