<?php
$loader = $this->registry->get('load');
$loader->controller('api/controllerapi');

class ControllerApiConfiguracoes extends ControllerApi{

  public function menulateral(){
    parent::validaAutenticacao();

    if(parent::haserror()){
       $retorno = parent::geterror();
    }else{

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

      $retorno = array();

      foreach (Type_ApiLinksLateral::getEnumList() as $key => $value) {
          if ($key == Type_ApiLinksLateral::TpApil_Carrinho){
            $retorno['cart'][] = array(
              'codigo'     => $key,
              'link'       => ($value['route'] == '') ? '' : str_replace('&amp;', '&',$this->url->link($value['route'], $value['param'], 'SSL')),
              'titulo'     => $value['titulo'],
              'qtdProduto' => $this->cart->countProducts()
            );
          }else{
            $retorno['links'][] = array(
              'codigo' => $key,
              'link'   => ($value['route'] == '') ? '' :  str_replace('&amp;', '&',$this->url->link($value['route'], $value['param'], 'SSL')),
              'titulo' => $value['titulo']
            );
          }
      }

      $this->load->model('catalog/information');

      foreach ($this->model_catalog_information->getInformations() as $result) {
        if($result['displayapp'] == Type_DsimDnao::Tp_Sim)
    			$retorno['informacoes'][] = array(
                    'titulo' => str_replace('&amp;', '&', $result['title']),
    				'link'   => str_replace('&amp;', '&', $this->url->link('information/information', 'information_id=' . $result['information_id']))
    			);
      }
      


    }

    $this->response->setOutputJson($retorno);
  }

  public function infoLogin(){

     parent::validaAutenticacao();

     if(parent::haserror()){
        $retorno = parent::geterror();
     }else{

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

      $retorno = array();      

      $this->load->model('catalog/information');

      foreach ($this->model_catalog_information->getInformations() as $result) {
        if($result['displayapp'] == Type_DsimDnao::Tp_Sim)
    			$retorno['informacoes'][] = array(
                    'titulo' => str_replace('&amp;', '&', $result['title']),
    				'link'   => str_replace('&amp;', '&', $this->url->link('information/information', 'information_id=' . $result['information_id']))
    			);
      }
      $retorno['informacoes'][] = array(
        'titulo' => 'Contate-nos',
        'link'   => str_replace('&amp;', '&', $this->url->link('information/contact'))
      );

      if($this->config->get('loginredesociais_facebook_status')==Type_StatusEn::Tp_Enable){
        $retorno['redesociais']['facebook'] = array(
          'id_applicativo'   => $this->config->get('loginredesociais_facebook_id')
        );        
      }

      if($this->config->get('loginredesociais_google_status')==Type_StatusEn::Tp_Enable){
        $retorno['redesociais']['google'] = array(
          'id_applicativo'   => $this->config->get('loginredesociais_google_id')
        );        
      }      

    }

    $this->response->setOutputJson($retorno);

  }


}
