<?php

class ControllerCommonDesenvolvimento extends Controller
{
    public function index()
    {

        if (!$this->config->get('config_habilita_linkproducao')) {

            $this->load->type('tipocomum');
            $this->load->helper('ftr_geral');

            $route = '';

            if (isset($this->request->get['route']) || isset($this->request->get['_route_'])) {

                $part = (isset($this->request->get['route'])) ? explode('/', $this->request->get['route']) : explode('/', $this->request->get['_route_']);

                if (isset($part[0])) {
                    $route .= $part[0];
                }

                if ($route == Type_DefaultValues::Tp_UrlLiberada) {
                    return false;
                }

                $route2 = (isset($this->request->get['route'])) ? $this->request->get['route'] : $this->request->get['_route_'];

                if ($this->ftrgeralregistry->getUrlRelease($route2)) {
                    return false;
                }

            }

            // Show site if logged in as admin
            $this->load->library('user');

            $this->user = new User($this->registry);

            if (($route != 'payment') && !$this->user->isLogged() && !$this->config->get('lojaEmProducao')) {
                return $this->forward('common/desenvolvimento/info');
            }
        }
    }

    public function info()
    {
        $this->language->load('common/desenvolvimento');
        $this->load->model('localisation/language');
        $this->load->type('tipocomum');
        $this->load->helper('ftr_geral');

        $this->document->setTitle($this->language->get('heading_title'));

        $this->data['heading_title'] = $this->language->get('heading_title');

        $server = $this->url->link('', '', 'SSL', false);


        if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
            $this->data['logo'] = $server . 'image/' . $this->config->get('config_logo');
        } else {
            $this->data['logo'] = '';
        }

        if ($this->config->get('config_name')) {
            $this->data['name'] = $this->config->get('config_name');
        } else {
            $this->data['name'] = '';
        }

        $config_telephone = $this->config->get('config_telephone');
        if ($config_telephone) {
            $config = array();
            foreach (array_reverse($config_telephone) as $telefone) {
                if ($telefone['display']) {
                    $config[$telefone['type']][] = $telefone['numero'];
                }
            }
            $config_telephone = $config;
        }

        $this->data['config_telephone'] = $config_telephone;

        $message = $this->language->get('text_message');

        $this->data['message'] = $message;
        $this->data['text_redes'] = $this->language->get('text_redes');
        $this->data['text_phone'] = $this->language->get('text_phone');
        $this->data['text_email'] = $this->language->get('text_email');

        $this->response->setOutput($this->render('common/desenvolvimento'));

    }
}
