<?php
namespace article;

class VArticle
{
  public function drawArticleListStatic( $id )
  {
    $tpl = new \Savant3;
    $tpl -> _id       = $id;
    $tpl -> _site     = new \site\Site( $id );
    $tpl -> _articles = \article\FArticle::getArticles( 0, $id );
    return $tpl -> fetch( 'articles/articles-list-static' );
  }
  
  public function drawListArticles( $articles )
  {
    $tpl = new \Savant3;
    $tpl -> _articles = $articles;
    return $tpl -> fetch( 'articles/articles-list' );
  }

  public function drawMiniatureArticles( $articles )
  {
    $tpl = new \Savant3;
    $tpl -> _articles = $articles;
    return $tpl -> fetch( 'articles/articles-miniature' );
  }
  
  public function drawSlider( $article_id, $images ) 
  {
    $tpl = new \Savant3;
    $tpl -> _article_id = $article_id;
    $tpl -> _images     = $images;
    return $tpl -> fetch( 'articles/article-slider' );
  }

  public function draw( $id )
  {
    global $user;
    
    if ( \article\FArticle::isArticleOnlyForLogged( $id ) && !$user )
      return \user\VUser::drawLoginForm();
      
    $article = \article\FArticle::loadArticle( $id );
    
    if ( !$article -> _values['enabled'] || $article -> _values['archive'] )
      return false;
    
    $tpl = new \Savant3;
    $tpl -> _article = $article;
    return $tpl -> fetch( 'articles/article-draw' );
  }

  public function drawEntryArticles( $articles )
  {
    $tpl = new \Savant3;
    $tpl -> _articles = $articles;
    return $tpl -> fetch( 'articles/articles-entry' );
  }

  public function drawGallery( $id, $images ) 
  {
    $tpl = new \Savant3;
    $tpl -> _id     = $id;
    $tpl -> _images = $images;
    return $tpl -> fetch( 'articles/article-gallery' );
  }

  public static function drawFullArticles( $articles )
  {
    $tpl = new \Savant3;
    $tpl -> _articles = $articles;
    return $tpl -> fetch( 'articles/articles-full' );
  }
}
?>
