<?php
namespace admin\controls;

class ArticleManager
{
	public function getContent()
	{
		$rw = \System::formGet( 'rw' );

    if ( \System::formGet( 'act' ) ) 
    {
      \System::setSessionVar( 'act'     , \System::formGet( 'act' ) );
      \System::setSessionVar( 'art_id'  , \System::formGet( 'id' ) );
    }
    
    $act = \System::getSessionVar( 'act' );
    if ( $act == 'show_versions' ) 
    {
      if ( $rw == 'show' )
        return \admin\view\ArticleManager::drawArticle( \System::formGetInt( 'id' ) );
      if ( $rw == 'restore' )
        \admin\factory\ArticleManager::restoreArticleVersion( \System::formGetInt( 'id' ) );
      return \admin\view\ArticleManager::showVersions( \System::getSessionVar( 'art_id' ) );
    } 
    else 
    {
      \admin\factory\ArticleManager::deleteNonAssignImages();
      
      if ( $rw == 'edit' )
        return \admin\view\ArticleManager::edit( \System::formGetInt( 'id' ) );
      if ( $rw == 'add' )
        return \admin\view\ArticleManager::Add();
      if ( $rw == 'del' )
        \admin\factory\ArticleManager::setAsArchive( \System::formGetInt( 'id' ) );
      if ( $rw == 'save' )
        \admin\factory\ArticleManager::save();
      if ( $rw == 'add_new' )
        \admin\factory\ArticleManager::saveNew();
      return \admin\view\ArticleManager::show();
    }
	}
}
?>