<?php
namespace view;

class Page 
{
  public static function unlogged()
  {
    $tpl = new \Tpl;
    return $tpl -> render( 'page/unlogged-layout' );
  }

  public function show()
  {
    global $user;
    
    if ( !\S::get_session( 'user' ) and \S::get( 'p' ) != 'cron'  )
      return \view\Page::unlogged();
    
    $tpl = new \Savant3;
    $tpl -> _content  = \controls\Page::getContent();
    $tpl -> _alert    = \S::get_session( 'alert' );
    $tpl -> _messages = \view\Messages::drawMessages();
    $tpl -> _user     = $user;
    
    if ( $user['type'] == 'client' or $user['type'] == 'worker' )
      return $tpl -> fetch( 'client/main-layout' );
    if ( $user['type'] == 'reseller' )
      return $tpl -> fetch( 'reseller/main-layout' );
    else
      return $tpl -> fetch( 'page/main-layout' );
  }
}
?>
