<?
/* 2011-09-26 - dodanie typu strony LINK */

namespace site;

class Site {
  
  public $_values;
  
  public function __construct( $id = '' )
  {
    global $db;
    
    if ( !$id ) 
      $id = \site\FSite::getMainSiteId();
    
    $current_lang = \System::getSessionVar( 'current_lang' );
    
    $query = $db -> prepare( 'SELECT * FROM pp_pages WHERE id = :id' );
    $query -> bindValue( ':id', $id, \PDO::PARAM_INT );
    $query -> execute();
    if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
    {
      foreach ( $row as $key => $val )
        $this -> _values[$key] = $val;
    }
    $query -> closeCursor();
    
    $query = $db -> prepare( 'SELECT *, "' . $id . '" AS id FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
    $query -> bindValue( ':page_id' , $id           , \PDO::PARAM_INT );
    $query -> bindValue( ':lang_id' , $current_lang , \PDO::PARAM_STR );
    $query -> execute();
    if ( $query -> rowCount() ) while ( $row = $query -> fetch() ) 
    {
      foreach ( $row as $key => $val )
        $this -> _values[$key] = $val;
    }
    $query -> closeCursor();

    return true;
  }
}
?>
