<?php
  class Pages extends Controller {
    public function __construct(){
     
    }
    
    public function index(){
      if(isLoggedIn()){
        redirect('users/login');
      }
      $data = [
        'title' => 'SharePosts',
        'description' => 'Simple social network built on the Emmizy MVC framework',
        'info' => 'You can contact me with the following details below if you like my program and willing to offer me a contract and work on your project',
        'name' => 'Omonzebaguan Emmanuel',
        'location' => 'Nigeria, Edo State',
        'contact' => '+2348147534847',
        'mail' => 'emmizy2015@gmail.com'
      ];
     
      $this->view('pages/index', $data);
    }

    public function about(){
      $data = [
        'title' => 'About Us',
        'description' => 'App to share posts with other users'
      ];

      $this->view('pages/about', $data);
    }

    public function errores(){
    if(isset($_SESSION['error'])){
        $data = [
        'errores' => $_SESSION['error'],
        'description' => 'App to share posts with other users'
      ];
      unset($_SESSION['error']);
    }else{
    redirect('educadores');
    }
    $loader = new \Twig\Loader\FilesystemLoader('../app/views');
    $twig = new \Twig\Environment($loader, ['cache' => '../app/cache','auto_reload' => true,'debug' => true,]);
    $twig->addGlobal('names',$_SESSION['name']);
    $layout = $twig->load('inc/base.html.twig');
    echo $twig->render('pages/error.html.twig', ['datos' => $data]);

    }

    public function contact(){
      $datos = [
          'title' => 'Contact Us',
          'description' => 'You can contact us through this medium',
          'info' => 'You can contact me with the following details below if you like my program and willing to offer me a contract and work on your project',
          'name' => 'Omonzebaguan Emmanuel',
          'location' => 'Nigeria, Edo State',
          'contact' => '+2348147534847',
          'mail' => 'emmizy2015@gmail.com'
      ];

//      $this->view('pages/contact', $data);
$loader = new \Twig\Loader\FilesystemLoader('../app/views');
$twig = new \Twig\Environment($loader, [
    'cache' => '../app/cache','auto_reload' => true,'debug' => true,
]);
      echo $twig->render('pages/contacto.html.twig', ['datos' => $datos]);
    }
  }