public function login($email = false, $passwd = false)
 {
     $email || ($email = $this->getPost('email'));
     $passwd || ($passwd = $this->getPost('passwd'));
     $orbit = new Orbit();
     $client = $orbit->get('client/login', 1, 1, array('email' => $email, 'passwd' => $passwd));
     if ($client['status'] == 200) {
         $phones = $orbit->get('client/phones/' . $client['uid']['id']);
         UID::set($client['uid']);
         UID::set('phones', $phones['phones']);
         $orbit = new Orbit();
         $favRequest = $orbit->get('client/countfav', 1, 1, array('id' => UID::get('id')));
         $favs = $favRequest['fav'];
         $cartRequest = $orbit->get('client/countcart', 1, 1, array('id' => UID::get('id')));
         $carts = $cartRequest['cart'];
         $this->commitReplace($carts, '#cartitems');
         $this->commitReplace($favs, '#favitems');
         $product_id = $this->getQueryString('product_id');
         if ($product_id) {
             $productPage = Services::get('products');
             $productPage->setId($product_id);
             $productPage->viewProduct();
             return;
         }
         $home = Services::get('home');
         $home->homePage();
         return;
     }
     $this->commitReplace('O e-mail e senha não foram encontrados', '#loginmsg');
     $this->commitShow('#loginmsg');
 }
 public function indexAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $defaultItems = array($this->view->serverUrl() . BASEDIR => '1.00000', $this->view->serverUrl() . BASEDIR . '/fale-conosco' => '0.80000', $this->view->serverUrl() . BASEDIR . '/quem-somos' => '0.80000', $this->view->serverUrl() . BASEDIR . '/imoveis/listagem?oportunidades=Sim&e=oportunidades' => '0.80000', $this->view->serverUrl() . BASEDIR . 'imoveis/listagem?lancamento=Sim&e=lancamentos' => '0.80000', $this->view->serverUrl() . BASEDIR . 'bairros/listagem' => '0.80000');
     $xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
     foreach ($defaultItems as $urlItem => $priority) {
         $url = $xml->addChild('url');
         $url->addChild('loc', htmlentities($urlItem));
         $url->addChild('lastmod', date('Y-m-dTh:i:s+00:00'));
         $url->addChild('changefreq', 'monthly');
         $url->addChild('priority', $priority);
     }
     $vista = Services::get('vista_rest');
     $totalPages = 2;
     for ($page = 1; $page < $totalPages; $page++) {
         $vista->setPaginationParam($page, 50);
         $vista->buscaImoveis(array());
         $totalPages = intval($vista->getTotalPages());
         $result = $vista->getResult();
         foreach ($result as $row) {
             $url = $xml->addChild('url');
             $url->addChild('loc', $this->view->serverUrl() . BASEDIR . '/imoveis/detalhes/codigo/' . $row['Codigo'] . '/' . $row['Categoria'] . '/' . $row['Bairro'] . (intval($row['Dormitorios']) > 0 ? '-' . $row['Dormitorios'] : '') . '/Zona+Sul-Porto+Alegre');
             $url->addChild('lastmod', date('Y-m-dTh:i:s+00:00'));
             $url->addChild('changefreq', 'monthly');
             $url->addChild('priority', '0.90000');
         }
     }
     file_put_contents(APPLICATION_PATH . '/../public/sitemap.xml', $xml->asXML());
 }
 public function indexAction()
 {
     $this->view->bodyClass = 'pg-interna';
     $vista = Services::get('vista_rest');
     $this->view->listas = $vista->getListasBusca();
     $form = new Site_Form_FaleConoscoForm();
     $this->view->form = $form;
     $params = $this->_request->getParams();
     $this->view->headScript()->appendFile($this->view->serverUrl() . BASEDIR . '/res/js/quem-somos.js');
     $vista = Services::get('vista_rest');
     $users = $vista->getDadosUsuarios();
     $grouped = array();
     $groups = array();
     array_walk($users, function ($user) use(&$grouped, &$groups) {
         $group = String::RemoveIndex($user['Equipesite']);
         $groups[] = strtolower($group);
         $grouped[$group][] = $user;
     });
     $title = 'Equipe AG3 Imóveis';
     $filterGroup = $this->getRequest()->getParam('t');
     if (in_array($filterGroup, $groups)) {
         $title = ucwords($filterGroup);
         $grouped = array($title => $grouped[$title]);
     }
     $this->view->showGroups = !in_array($filterGroup, $groups);
     $this->view->title = $title;
     $this->view->users = $grouped;
 }
 public function indexAction()
 {
     $form = new Application_Form_FaleConoscoForm();
     $this->view->form = $form;
     $params = $this->_request->getParams();
     if ($this->_request->isPost() && $form->isValid($params)) {
         try {
             $vista = Services::get('vista_rest');
             $vista->getAuthEmail();
             $smtpData = $vista->getResult();
             $config = array('auth' => 'login', 'username' => $smtpData['user'], 'password' => $smtpData['pass'], 'port' => $smtpData['port']);
             $transport = new Zend_Mail_Transport_Smtp($smtpData['smtp'], $config);
             Zend_Mail::setDefaultTransport($transport);
             $html = new Zend_View();
             $html->setScriptPath(APPLICATION_PATH . '/views/scripts/fale-conosco/');
             $html->data = $params;
             $emailBody = $html->render('email-body.phtml');
             $mail = new Zend_Mail();
             $mail->setBodyHtml($emailBody);
             $mail->setFrom('*****@*****.**', $params['nome']);
             $mail->addTo('*****@*****.**', 'Esselence');
             $mail->setSubject("Contato pelo Site {$params['nome']}");
             $mail->send();
             $this->view->success = true;
         } catch (Exception $e) {
             print_r($e->getMessage());
             exit;
         }
     }
 }
 public function listagemAction()
 {
     $this->view->bodyClass = 'pg-interna';
     $vista = Services::get('vista_rest');
     $this->view->listas = $vista->getListasBusca();
     $bairros = Gravi_Service_ImochatService::getBairros();
     $this->view->bairros = $bairros['hoods'];
 }
Exemple #6
0
 /**
  * Constructor
  *
  * Sets up the client
  */
 public function __construct()
 {
     $this->restClient = Services::get('restclient');
     $this->restClient->addHeader('Accept', 'application/json');
     $this->restClient->setFormat('json');
     $this->loadConfig();
     $this->restClient->setUrl($this->getURL());
     $this->restClient->addParam('key', $this->getConfig('key'));
 }
 /**
  * Löst die Facade gegen die eigentliche Implementierung auf.
  * Hierbei ist zu beachten, dass eine Facade-Instanz als Accessor
  * auch direkt eine Klasse zurückgeben kann!
  *
  * @param $name
  * @return mixed
  */
 protected static function resolveFacadeInstance($name)
 {
     if (is_object($name)) {
         return $name;
     }
     if (isset(static::$resolvedInstances[$name])) {
         return static::$resolvedInstances[$name];
     }
     return static::$resolvedInstances[$name] = Services::get($name);
 }
 public function detalhesAction()
 {
     $this->view->headScript()->appendFile($this->view->serverUrl() . BASEDIR . '/res/js/detalhes.js');
     $imoCodigo = $this->_request->getParam('codigo');
     if (empty($imoCodigo)) {
         //TODO -- Criar tela de imovel não encontrado
     }
     $vista = Services::get('vista_rest');
     $vista->getDadosImovel($imoCodigo);
     $dadosImovel = $vista->getResult();
     if (empty($dadosImovel)) {
         //TODO -- Criar tela de imovel não encontrado
     }
     $form = new Application_Form_FaleConoscoForm();
     $this->view->form = $form;
     $this->view->imovel = $dadosImovel;
 }
Exemple #9
0
 function testRegisterService()
 {
     Services::unregisterAllServices();
     Services::registerServiceFactory("test/service", new CachedInstanceServiceFactory(new MyService()));
     $this->assertTrue(Services::is_registered("test/service"), "Il servizio non e' stato registrato!!");
     $this->assertTrue(Services::get("test/service") instanceof MyService, "Il servizio non corrisponde alla classe registrata!!");
     $all_services = Services::get_all_registered_services();
     $this->assertEqual(count($all_services), 1, "Il numero dei servizi registrati non corrisponde!!");
     $this->assertEqual($all_services[0], "test/service", "Il nome del servizio registrato non corrisponde!!");
     Services::registerServiceFactory("test/service2", new NewInstanceServiceFactory("MyService2"));
     $this->assertTrue(Services::is_registered("test/service2"), "Il servizio non e' stato registrato!!");
     $this->assertTrue(Services::get("test/service2") instanceof MyService2, "Il servizio non corrisponde alla classe registrata!!");
     $all_services = Services::get_all_registered_services();
     $this->assertEqual(count($all_services), 2, "Il numero dei servizi registrati non corrisponde!!");
     Services::unregisterAllServices();
     $all_services = Services::get_all_registered_services();
     $this->assertEqual(count($all_services), 0, "Il numero dei servizi registrati non corrisponde!!");
 }
Exemple #10
0
 public function respond()
 {
     header("Content-type: {$this->content_type}; charset={$this->charset}");
     http_response_code($this->status_code);
     if ($this->content_type === 'application/json') {
         return $this->encode_json($this->data);
     } else {
         if (substr($this->content_type, 0, 5) === 'image') {
             return file_get_contents($this->data);
         } else {
             if ($this->content_type === 'text/html') {
                 if (isset($this->view)) {
                     $te = Services::get('TemplateEngine');
                     return $te->display($this->view, $this->data);
                 } else {
                     return $this->data;
                 }
             } else {
                 return $this->data;
             }
         }
     }
 }
 public function indexAction()
 {
     $vista = Services::get('vista_rest');
     $vista->getListasBusca();
     $this->view->listas = $vista->getResult();
     $vista->reset();
     $filtroBanner = array('SuperDestaqueWeb' => 'Sim');
     $pagination = array('pagina' => 1, 'quantidade' => 5);
     $vista->buscaImoveis($filtroBanner, $pagination);
     $this->view->banners = $vista->getResult();
     $vista->reset();
     $filtroWidget1 = array('EmDestaque' => 'Sim');
     $vista->buscaImoveis($filtroWidget1);
     $this->view->widget1 = $vista->getResult();
     $this->view->widget1Title = 'Destaques';
     //        $vista->reset();
     //
     //        $filtroWidget2 = array(
     //            'Categoria'     => 'Casa'
     //        );
     //
     //        $vista->buscaImoveis($filtroWidget2);
     //        $this->view->widget2 = $vista->getResult();
 }
Exemple #12
0
 public function indexAction()
 {
     $this->view->headScript()->appendFile($this->view->serverUrl() . BASEDIR . '/res/js/imoveis.js');
     $this->view->headScript()->appendFile($this->view->serverUrl() . BASEDIR . '/res/js/index.js');
     $vista = Services::get('vista_rest');
     $this->view->listas = $vista->getListasBusca();
     $vista->reset();
     $pagination = array('pagina' => 1, 'quantidade' => 4);
     $banners = Gravi_Service_ImochatService::getBanners();
     $this->view->banners = $banners['banners'];
     $filtroWidget1 = array('Destinacao' => 'ALUGUEL', 'EmDestaque' => 'Sim');
     $order = array('DataCadastro' => 'desc');
     $vista->buscaImoveis($filtroWidget1, $pagination, $order);
     $this->view->widget1 = $vista->getResult();
     $vista->reset();
     $filtroWidget2 = array('Destinacao' => 'VENDA', 'EmDestaque' => 'Sim');
     $pagination = array('pagina' => 1, 'quantidade' => 4);
     $vista->buscaImoveis($filtroWidget2, $pagination, $order);
     $this->view->widget2 = $vista->getResult();
     $filtroWidget3 = array('Destinacao' => 'VENDA', 'Lancamento' => 'Sim');
     $pagination = array('pagina' => 1, 'quantidade' => 8);
     $vista->buscaImoveis($filtroWidget3, $pagination, $order);
     $this->view->widget3 = $vista->getResult();
 }
 public function addFavourite()
 {
     if (!UID::isLoggedIn()) {
         $client = Services::get('client');
         $client->register();
         return;
     }
     $orbit = new Orbit();
     $favs = $orbit->post('client/favourites/' . UID::get('id'), array('product_id' => $this->getQueryString('id')));
     #debug($favs);
     $favRequest = $orbit->get('client/countfav', 1, 1, array('id' => UID::get('id')));
     $countfavs = $favRequest['fav'];
     $this->commitReplace(intval($countfavs), '#favitems');
     $this->view()->loadTemplate('favlink');
     $this->commitReplace($this->view()->render(), '#addfav');
 }
 public function indexAction()
 {
     $this->view->bodyClass = 'pg-interna';
     $vista = Services::get('vista_rest');
     $this->view->listas = $vista->getListasBusca();
 }
 private function getSemelhantes($imovel)
 {
     $vista = Services::get('vista_rest');
     $vista->reset();
     $similarFields = array('Categoria', 'Bairro', 'Status');
     $filters = array();
     array_walk($similarFields, function ($item) use(&$filters, $imovel) {
         !isset($imovel[$item]) || ($filters[$item] = $imovel[$item]);
     });
     if ($imovel['Dormitorios'] > 0) {
         $filters['Dormitorios'] = array('>=', $imovel['Dormitorios']);
     }
     if ($imovel['Vagas'] > 0) {
         $filters['Vagas'] = array('>=', $imovel['Vagas']);
     }
     $min = intval($imovel['ValorVenda']) - intval($imovel['ValorVenda']) * 20 / 100;
     $max = intval($imovel['ValorVenda']) + intval($imovel['ValorVenda']) * 20 / 100;
     $filters['ValorVenda'] = array($min, $max);
     $filters['Codigo'] = array('!=', $imovel['Codigo']);
     $vista->setPaginationParam(1, 4);
     $vista->buscaImoveis($filters);
     $sem_filters = array('tipo' => $filters['Categoria'], 'bairros' => $filters['Bairro'], 'valor_min' => $filters['ValorVenda'][0], 'valor_max' => $filters['ValorVenda'][1], 'codigo' => $filters['Codigo']);
     !isset($filters['Dormitorios']) || ($sem_filters['dormitorios'] = $filters['Dormitorios']);
     !isset($filters['Vagas']) || ($sem_filters['vagas'] = $filters['Vagas']);
     $this->view->filter_semelhantes = $sem_filters;
     return $vista->getResult();
 }
 function test_class_methods_get()
 {
     $services = new Services();
     $services->register("DBHandler", "DBHandler");
     //print_r($services->_registeredServices);
     $this->assertTrue($services->start("DBHandler"));
     $this->assertTrue($services->running("DBHandler"));
     $this->assertTrue(is_object($services->get("DBHandler")));
     $this->assertEqual(get_class($services->get("DBHandler")), "dbhandler");
     $this->assertReference($services->get("DBHandler"), $services->_services['DBHandler']);
 }
 public function indexAction()
 {
     $vista = Services::get('vista_rest');
     $this->view->listas = $vista->getListasBusca();
     $form = new Site_Form_FaleConoscoForm();
     $this->view->form = $form;
     $this->view->bodyClass = 'pg-interna';
     $params = $this->_request->getParams();
     $this->view->headScript()->appendFile($this->view->serverUrl() . BASEDIR . '/res/js/faleconosco.js');
     $acao = $this->getRequest()->getParam('acao');
     $this->view->proposta = $acao == 'proposta';
     $this->view->subject = $this->getRequest()->getParam('s');
     if ($this->_request->isPost()) {
         try {
             $vista = Services::get('vista_rest');
             $vista->getAuthEmail();
             $smtpData = $vista->getResult();
             $config = array('auth' => 'login', 'username' => $smtpData['user'], 'password' => $smtpData['pass'], 'port' => $smtpData['port']);
             //                print_r($smtpData); exit;
             $transport = new Zend_Mail_Transport_Smtp($smtpData['smtp'], $config);
             Zend_Mail::setDefaultTransport($transport);
             $html = new Zend_View();
             $html->setScriptPath(APPLICATION_PATH . '/modules/site/views/scripts/fale-conosco/');
             $html->data = $params;
             $emailBody = $html->render('email-body.phtml');
             $mail = new Zend_Mail('UTF-8');
             $configData = Gravi_Service_ImochatService::getSiteConfig();
             $config = $configData['config'];
             $mail->setBodyHtml($emailBody);
             $mail->setFrom($config['contact_email'], $params['nome']);
             //              Teste Local
             //                $mail->addTo('*****@*****.**', 'AG3');
             $mail->addTo($config['contact_email'], 'AG3');
             $assunto = isset($params['assunto']) ? $params['assunto'] : '';
             $subjects = array('contato' => 'SITE AG3 - ' . $assunto . ' - CONTATO PELO SITE', 'interesse' => 'SITE AG3 - ' . $assunto . ' - INTERESSE EM IMÓVEL', 'ligamos' => 'SITE AG3 - ' . $assunto . ' - LIGAMOS PARA VOCÊ');
             $subject = 'contato';
             if (isset($params['subject']) && isset($subjects[$params['subject']])) {
                 $subject = $params['subject'];
             }
             if (isset($params['curriculo'])) {
                 $filename = $params['curriculo-name'];
                 $ext = pathinfo($filename, PATHINFO_EXTENSION);
                 $allowed = array('doc', 'docx', 'pdf', 'xls', 'xlsx', 'odt', 'zip', 'rar');
                 if (!in_array($ext, $allowed)) {
                     $this->_helper->layout()->disableLayout();
                     $this->_helper->viewRenderer->setNoRender(true);
                     echo 'O currículo enviado está em um formato não aceito!';
                     return;
                 }
                 $file = explode(',', $params['curriculo']);
                 $base64 = $file[1];
                 $data = explode(':', $file[0]);
                 $mime = str_replace(';base64', '', $data[1]);
                 $at = $mail->createAttachment(base64_decode($base64));
                 $at->type = $mime;
                 $at->disposition = Zend_Mime::DISPOSITION_INLINE;
                 $at->encoding = Zend_Mime::ENCODING_BASE64;
                 $at->filename = $filename;
             }
             $location = Gravi_Geolocation::getVisitorLocation();
             $contactData = array('client_name' => $params['nome'], 'email' => $params['email'], 'phone' => $params['fone'], 'message' => $params['mensagem']);
             foreach (array('city' => 'city', 'region' => 'region', 'lat' => 'lat', 'lon' => 'lng', 'isp' => 'isp', 'query' => 'ip') as $info => $dest) {
                 !isset($location[$info]) || ($contactData[$dest] = $location[$info]);
             }
             if (in_array($params['subject'], array('interesse', 'oferta'))) {
                 $contactData['property_id'] = $params['imovel'];
                 Gravi_Service_ImochatService::SaveSiteOffer($contactData);
             } else {
                 Gravi_Service_ImochatService::SaveSiteContact($contactData);
             }
             $mail->setSubject($subjects[$subject]);
             $mail->send();
             $this->view->success = true;
             if ($this->_request->isXmlHttpRequest()) {
                 $this->_helper->layout()->disableLayout();
                 $this->_helper->viewRenderer->setNoRender(true);
                 echo 'Sua mensagem foi enviada. Obrigado!';
                 return;
             }
         } catch (Exception $e) {
             print_r($e->getMessage());
             exit;
         }
     }
 }
 /**
  * When returning the home page, loads the inner content only
  *
  * You can always create a modulePage function that
  * is called when the module is called without an action.
  */
 public function homePage()
 {
     $products = Services::get('products');
     $blocks = array('slider' => $products->getSlider(), 'recent' => $products->getRecentProducts(), 'bestsellers' => $products->getBestSellers());
     $products->view()->loadTemplate('home');
     foreach ($blocks as $var => $block) {
         $products->view()->setVariable($var, $block);
     }
     $products->view()->appendJs('home');
     $products->commitReplace($products->view()->render(), '#content', true);
 }