<?php
namespace admin\view;

class SContainers {
  
  public function editContainer( $id = '' )
  {
    $id ? $value = 'Zapisz' : $value = 'Dodaj';
    
		$out = \admin\view\PagePanel::show( false, $value, true, 'Zawartość statyczna' );
    
    $tpl = new \Savant3;
    if ( $id )
      $tpl -> _container  = \admin\factory\SContainers::getContainer( $id );
    $tpl -> _languages    = \admin\factory\SContainers::getContainerParamLanguage( $id );
    $out .= $tpl -> fetch( 'scontainers/edit-container' );
    return $out;
  }

  public function showContainerList()
  {    
		$out = \admin\view\PagePanel::show( true, false, false, 'Zawartość statyczna' );

		$dbrowse = new \DataBrowse( 'pp_static_container' );
		$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
		$dbrowse -> addPosition( 'id', 'Użycie', '', "SELECT id, CONCAT( '[KONTENER:', id, ']' ) FROM pp_static_container", '', 'name' );
		$dbrowse -> addPosition( 'enabled', 'Aktywne', '', \System::getComboYesNo() );
		$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
		$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
		$dbrowse -> setParam( 'id' );
		$dbrowse -> addSort( 'name ASC' );
		$dbrowse -> addLp();
		$out .= $dbrowse -> draw();

		return $out;
  }
}
