<?php
namespace admin\controls;

class Page {

  public function checkUrlParams()
  {
    global $user;

    $rw = \System::formGet( 'rw' );

    switch ( $rw )
    {
      case 'user_logon':
        $user = \user\FUser::Login( \System::formGet( 'user_login' ) , \System::formGet( 'user_password' ) );
				\System::setSessionVar( 'user' , $user , true );
      break;

      case 'user_logout':
        \System::deleteSessionVar( 'user' , true );
      break;

      case 'db_edit_save':
        $db_edit_table 	= \System::getSessionVar( 'db_edit_table' );
        $db_edit_key    = \System::getSessionVar( 'db_edit_key' );
        $db_edit_val    = \System::getSessionVar( 'db_edit_val' );
        $db_edit_pols 	= \System::getSessionVar( 'db_edit_pols' );
        $db_edit_pass 	= \System::getSessionVar( 'db_edit_pass' );
        $db_edit_pols_t = \System::getSessionVar( 'db_edit_pols_type' );
        \DataBase::SaveData( $db_edit_table , $db_edit_key , $db_edit_val , $db_edit_pols , $db_edit_pass , $db_edit_pols_t );
      break;

      case 'db_edit_add_new':
        $db_edit_table        	= \System::getSessionVar( 'db_edit_table' );
        $db_edit_pols         	= \System::getSessionVar( 'db_edit_pols' );
        $db_edit_pass         	= \System::getSessionVar( 'db_edit_pass' );
        $db_edit_pols_hidden    = \System::getSessionVar( 'db_edit_pols_hidden' );
        $db_edit_pols_t       	= \System::getSessionVar( 'db_edit_pols_type' );
        $time                 	= \System::formGetHash( 'time' );
        \DataBase::AddData( $db_edit_table , $db_edit_pols , $db_edit_pols_hidden , $db_edit_pols_t , $time , $db_edit_pass );
      break;
    }
  }

	public function getContent()
	{
		global $user;

		if ( !$user || !$user -> get_admin() )
			return false;

		if ( \System::formGet( 'page_type' ) )
			\System::setSessionVar( 'page_type' , \System::formGet( 'page_type' ) );
		$page_type = \System::getSessionVar( 'page_type' );

		switch ( $page_type )
		{
      case 'adverts':
        return \admin\controls\Adverts::getContent();
      break;

      case 'page_article_sort':
        return \admin\controls\ArticleSort::getContent();
      break;

      case 'users':
        return \admin\controls\UsersManager::getContent();
      break;

      case 'change_log':
        return \site\VSite::drawChangeLog();
      break;

      case 'article_archive':
        return \admin\controls\ArticleArchiveManager::getContent();
      break;

			case 'menu_definition':
				return \admin\controls\MenuManager::getContent();
			break;

			case 'page_definition':
				return \admin\controls\PageManager::getContent();
			break;

			case 'page_articles':
      default;
				return \admin\controls\ArticleManager::getContent();
			break;

			case 'admins':
				return \admin\controls\AdminManager::getContent();
			break;

			case 'lang':
				return \admin\controls\LanguageManager::getContent();
			break;

			case 'translation':
				return \admin\controls\TranslationManager::getContent();
			break;

			case 'settings':
				return \admin\controls\SettingManager::getContent();
			break;

			case 'guest_book':
				return \admin\controls\GuestBookManager::getContent();
			break;

			case 'banner':
				return \admin\controls\BannerManager::getContent();
			break;

      case 'layout':
          return \admin\controls\LayoutManager::getContent();
      break;

      case 'banned_email':
          return \admin\controls\EmailRestriction::getContent();
      break;

      case 'banned_login':
          return \admin\controls\LoginRestriction::getContent();
      break;
		}
	}
}
?>
