<?php
namespace view;
class Site
{
  public static function show()
  {
		global $user;

    $class = '\controls\\';

    $results = explode( '_', \S::get( 'module' ) );
    if ( is_array( $results ) ) foreach ( $results as $row )
      $class .= ucfirst( $row );

    $action = \S::get( 'action' );

    $tpl = new \Tpl;
    $tpl -> content = \controls\Site::route();

    if ( $class == '\controls\Cron' and $action == 'main_view'
          or
            $class == '\controls\CronAllegro' and $action == 'main_view'
          or
            $class == '\controls\CronOlx' and $action == 'main_view'
        )
    return $tpl -> render( 'site/layout-cron' );

		if ( !$user )
      return $tpl -> render( 'site/layout-unlogged' );
    else
    {
      $tpl -> user = $user;
      if ( $alert = \S::get_session( 'alert' ) )
      {
        $tpl -> alert = $alert;
        unset( $_SESSION['alert'] );
      }
      return $tpl -> render( 'site/layout-logged' );
    }
  }
}
