<?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->data['wg24_facebook_url'] = $this->config->get('wg24_facebook_url');
        $this->data['wg24_twitter_url'] = $this->config->get('wg24_twitter_url');
        $this->data['wg24_google_url'] = $this->config->get('wg24_google_url');
        $this->data['wg24_rss_url'] = $this->config->get('wg24_rss_url');
        $this->data['wg24_pinterest_url'] = $this->config->get('wg24_pinterest_url');
        $this->data['wg24_linking_url'] = $this->config->get('wg24_linking_url');
        $this->data['wg24_youtub_url'] = $this->config->get('wg24_youtub_url');
        $this->data['wg24_instagram_url'] = $this->config->get('wg24_instagram_url');
        $this->data['wg24_twitter_id'] = $this->config->get('wg24_twitter_id');
        $this->data['wg24_blogger_url'] = $this->config->get('wg24_blogger_url');
        $this->data['config_email'] = $this->config->get('config_email');
        
        $this->response->setOutput($this->render('common/desenvolvimento'));

    }
}
