<?php

include_once 'application/core/AdminController.php';
include_once 'application/core/AdminGodController.php'; 

class SiteController extends CI_Controller {
  public function __construct () {
    parent::__construct();

    $this->load->model('CompanyInformationModel');
    $this->data['companyInformations'] = $this->CompanyInformationModel->getLast();

    $this->load->model('socialMediaModel');
    $this->data['socialMedias'] = $this->socialMediaModel->getAll();

    $this->load->vars($this->data);
  }

  protected function getMetatags ($page) {
    $this->load->model('MetatagModel');
    return $this->MetatagModel->getRowWhere(['slug' => $page]);
  }

  protected function goToPreviousPage () {
    $this->load->library('user_agent');
    redirect($this->agent->referrer());
  }

  protected function response (array $response) {
    echo json_encode($response);
    return array_key_exists('success', $response) ? $response['success'] : false;
  }
}
