<?php
namespace admin\controls;

class LayoutManager {

  public function getContent()
  {
    global $sys;

    $rw = $sys -> formGet( 'rw' );

    if ( $rw == 'edit' )
    {
      $id = $sys -> formGetInt( 'id' );
      return \admin\view\LayoutManager::edit( $id );
    }
    else if ( $rw == 'add' )
    {
      return \admin\view\LayoutManager::add();
    }
    else
    {
      if ( $rw == 'save_new' )
      {
        $name     = $sys -> formGet( 'name' );
        $enabled  = $sys -> formGet( 'enabled' );
        $html     = $sys -> formGet( 'html' );
        $css      = $sys -> formGet( 'css' );
        $js       = $sys -> formGet( 'js' );
        $time		= $sys -> formGetHash( 'time' );
		$pages		= \System::formGet( 'pages' );
        \admin\factory\LayoutManager::saveNew( $name , $enabled , $html , $css , $js , $time , $pages );
      }
      else if ( $rw == 'save' )
      {
        $id       = $sys -> formGetInt( 'id' );
        $name     = $sys -> formGet( 'name' );
        $enabled  = $sys -> formGet( 'enabled' );
        $html     = $sys -> formGet( 'html' );
        $css      = $sys -> formGet( 'css' );
        $js       = $sys -> formGet( 'js' );
		$pages		= \System::formGet( 'pages' );
        \admin\factory\LayoutManager::save( $id , $name , $enabled , $html , $css , $js , false , $pages );
      }
      else if ( $rw == 'del' )
      {
        $id = $sys -> formGetInt( 'id' );
        \admin\factory\LayoutManager::delete( $id );
      }
      return \admin\view\LayoutManager::show();
    }
  }
}
?>