Exception - sizeof(): Parameter must be an array or an object that implements Countable
sizeof(): Parameter must be an array or an object that implements Countable
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php(60) : eval()'d code (78)
#1Bootstrap->{closure}(2, sizeof(): Parameter must be an array or an object that implements Countable, /home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php(60) : eval()'d code, 78, Array(31))
#2sizeof(null)
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php(60) : eval()'d code (78)

( ! ) Warning: file(/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php(60) : eval()'d code): failed to open stream: No such file or directory in /home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/CoreException.php on line 277
Call Stack
#TimeMemoryFunctionLocation
10.0000394504{main}( ).../index.php:0
20.0029913232Bootstrap->run( ).../index.php:39
30.04771627976Cataya\Application\Frontcontroller\Frontcontroller->callController( ).../ABootstrap.php:72
40.23582555768controllers\main\ControllerDefault->postActionEvent( ).../AFrontcontroller.php:281
50.23622562904controllers\main\ControllerDefault->postActionEvent( ).../ControllerPagina.php:1047
60.23662562968Cataya\View\View->render( ).../AController.php:334
70.23662563568Cataya\View\View->compile( ).../AView.php:284
80.23672579976Cataya\View\View->run( ).../ATemplate.php:234
90.23692659744eval( '?>partial('main:head'); if ( $this->helper->isMobileRequest() ) { echo $this->partial('main:nav-mobile'); } else { echo $this->partial('main:nav'); } [ 'imovelId' => $imovelId, 'titulo' => $tituloImovel, 'codigo' => $codigoImovel, 'area' => $areaImovel, 'solo' => $solo, 'formacao' => $formacao, 'topografia' => $topografia, 'hidrografia' => $hidrografia, 'localizacao' => $localizacao, 'benfeitorias' => $benfeitorias, 'videothumb' => $videoThumb, 'estado' => [ 'estadoId' => $estadoId, 'estado' => $nomeEstado, 'sigla' => $siglaEstado ], 'cidade' => [ 'cidadeId' => $cidadeId, 'cidade' => $nomeCidade, ], 'tipo' => [ 'singular' => $nomeTipo ] ] = $this->imovel; [ 'galeria' => $galeria, 'pasta' => $pasta, 'arquivo' => $arquivo, 'extensao' => $extensao ] = $this->media; $urlEstado = strtolower($this->helper->url("imoveis/local/estado", $estadoId, $nomeEstado)); $urlCidade = strtolower($this->helper->url('imoveis/local/cidade', $estadoId, $cidadeId, $nomeCidade, $nomeEstado) ); $imgBaseUrl = $this->baseasset; $mainImgUrl = $this->destaque[0]['url']; $mainVideoUrl = $this->destaque[0]['url']; $videoId = $this->hutil->getYoutubeVideoId($mainVideoUrl); $videoParams = [ 'rel'=> 0, 'loop' => 1, 'showinfo' => 0, 'version' => 3, 'playlist' => $videoId ]; if ( empty( $videoThumb ) ) { $videoThumb = $this->hutil->getYoutubeUrlImage( $videoId ); } else { $videoThumb = "{$this->baseasset}images/media/videothumbs/{$imovelId}/{$videoThumb}"; } $property = $this->propertyField; $tipoImovel = $this->tipoImovel['singular']; ?>
destaque) > 0 ): ?> destaque[0]['type'] != 'video'): ?>

staticField['forsalein']} {$nomeCidade}-{$siglaEstado}"; ?>

  • staticField['details.access']; ?>:
  • staticField['details.area']; ?>: Alqueires
  • staticField['details.hydrography']; ?>:
  • staticField['details.topography']; ?>:
  • staticField['details.soilformation']; ?>:
  • staticField['details.soiltype']; ?>:
  • staticField['details.improvements']; ?>:

Código #

helper->isMobileRequest() ): ?>
partial('main:block/details/more-info', [ 'vars' => [ 'property' => $property ] ]); ?> partial('main:block/details/form', array('vars' => array( 'cod' => $codigoImovel, 'imovel' => $imovelId ))); ?>

staticField['details.relatedproperties']; ?>

partial('main:block/oportunities/card-description'); ?>
helper->isMobileRequest() ) { echo $this->partial('main:footer-mobile'); } else { echo $this->partial('main:footer-default'); } echo $this->partial('main:footer'); ?> '
)
.../ATemplate.php:60
100.23872656416sizeof ( ).../ATemplate.php(60) : eval()'d code:78
110.23872659528Bootstrap->{closure:/home/mercadodeterras/www/mercadodeterras.com.br/src/application/Bootstrap.php:52-55}( ).../ATemplate.php(60) : eval()'d code:78
120.23952669064Cataya\CoreException->handleError( ).../Bootstrap.php:54
130.24042660184Cataya\CoreException->_showTraceItem( ).../CoreException.php:458
140.24052660672file ( ).../CoreException.php:277

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/CoreException.php on line 286
Call Stack
#TimeMemoryFunctionLocation
10.0000394504{main}( ).../index.php:0
20.0029913232Bootstrap->run( ).../index.php:39
30.04771627976Cataya\Application\Frontcontroller\Frontcontroller->callController( ).../ABootstrap.php:72
40.23582555768controllers\main\ControllerDefault->postActionEvent( ).../AFrontcontroller.php:281
50.23622562904controllers\main\ControllerDefault->postActionEvent( ).../ControllerPagina.php:1047
60.23662562968Cataya\View\View->render( ).../AController.php:334
70.23662563568Cataya\View\View->compile( ).../AView.php:284
80.23672579976Cataya\View\View->run( ).../ATemplate.php:234
90.23692659744eval( '?>partial('main:head'); if ( $this->helper->isMobileRequest() ) { echo $this->partial('main:nav-mobile'); } else { echo $this->partial('main:nav'); } [ 'imovelId' => $imovelId, 'titulo' => $tituloImovel, 'codigo' => $codigoImovel, 'area' => $areaImovel, 'solo' => $solo, 'formacao' => $formacao, 'topografia' => $topografia, 'hidrografia' => $hidrografia, 'localizacao' => $localizacao, 'benfeitorias' => $benfeitorias, 'videothumb' => $videoThumb, 'estado' => [ 'estadoId' => $estadoId, 'estado' => $nomeEstado, 'sigla' => $siglaEstado ], 'cidade' => [ 'cidadeId' => $cidadeId, 'cidade' => $nomeCidade, ], 'tipo' => [ 'singular' => $nomeTipo ] ] = $this->imovel; [ 'galeria' => $galeria, 'pasta' => $pasta, 'arquivo' => $arquivo, 'extensao' => $extensao ] = $this->media; $urlEstado = strtolower($this->helper->url("imoveis/local/estado", $estadoId, $nomeEstado)); $urlCidade = strtolower($this->helper->url('imoveis/local/cidade', $estadoId, $cidadeId, $nomeCidade, $nomeEstado) ); $imgBaseUrl = $this->baseasset; $mainImgUrl = $this->destaque[0]['url']; $mainVideoUrl = $this->destaque[0]['url']; $videoId = $this->hutil->getYoutubeVideoId($mainVideoUrl); $videoParams = [ 'rel'=> 0, 'loop' => 1, 'showinfo' => 0, 'version' => 3, 'playlist' => $videoId ]; if ( empty( $videoThumb ) ) { $videoThumb = $this->hutil->getYoutubeUrlImage( $videoId ); } else { $videoThumb = "{$this->baseasset}images/media/videothumbs/{$imovelId}/{$videoThumb}"; } $property = $this->propertyField; $tipoImovel = $this->tipoImovel['singular']; ?>
destaque) > 0 ): ?> destaque[0]['type'] != 'video'): ?>

staticField['forsalein']} {$nomeCidade}-{$siglaEstado}"; ?>

  • staticField['details.access']; ?>:
  • staticField['details.area']; ?>: Alqueires
  • staticField['details.hydrography']; ?>:
  • staticField['details.topography']; ?>:
  • staticField['details.soilformation']; ?>:
  • staticField['details.soiltype']; ?>:
  • staticField['details.improvements']; ?>:

Código #

helper->isMobileRequest() ): ?>
partial('main:block/details/more-info', [ 'vars' => [ 'property' => $property ] ]); ?> partial('main:block/details/form', array('vars' => array( 'cod' => $codigoImovel, 'imovel' => $imovelId ))); ?>

staticField['details.relatedproperties']; ?>

partial('main:block/oportunities/card-description'); ?>
helper->isMobileRequest() ) { echo $this->partial('main:footer-mobile'); } else { echo $this->partial('main:footer-default'); } echo $this->partial('main:footer'); ?> '
)
.../ATemplate.php:60
100.23872656416sizeof ( ).../ATemplate.php(60) : eval()'d code:78
110.23872659528Bootstrap->{closure:/home/mercadodeterras/www/mercadodeterras.com.br/src/application/Bootstrap.php:52-55}( ).../ATemplate.php(60) : eval()'d code:78
120.23952669064Cataya\CoreException->handleError( ).../Bootstrap.php:54
130.24042660184Cataya\CoreException->_showTraceItem( ).../CoreException.php:458
140.24162672960count ( ).../CoreException.php:286
#3eval
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php (60)
<?php
 
namespace Cataya\Utilities\Template;
 
/**
 *
 * Abstract Class ATemplate
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1
 * @copyright  GPL © 2010, hugomastromauro.com.
 * @access public
 * @package Cataya
 * @subpackage lib
 *
 */
abstract class ATemplate 
  extends \Cataya\AObject {
  
  /**
   * 
   * @var string
   */
  private $token = '%%';
  
  /**
   * 
   * @var array
   */
  private $stack = array();
  
  /**
   * 
   * @param array $params
   */
  public function __construct( array $params = null ) {
    
    parent::__construct();
    
    if (is_array($params))
      $this->_data = $params;
  }
  
  /**
   * 
   * @param string $token
   */
  protected function setToken( $token ) {
    $this->token = $token;
  }
  
  /**
   * 
   * @param stream $template
   */
  private function run( $template ) {
      
    ob_start ();
        
    if ( eval( '?>' . $template ) === false && ( $error = error_get_last() ) ) {
      throw new Exception('Erro ao renderizar o layout!');
    }
    
    return ob_get_clean();
  }
  
  /**
   * 
   * @param string $element
   */
  protected function wrap( $element ) {
    
    $this->stack[] = $this->_data;
    
    foreach ($element as $k => $v) {
      $this->_data[$k] = $v;
    }
  }
  
  /**
   * 
   */
  protected function unwrap() {
    $this->_data = array_pop($this->stack);
    $this->stack = null;
  }
  
  /**
   * 
   * @param string $name
   */
  private function parse( $name ) {
    
    if (isset($this->_data[$name])) {
      echo $this->_data[$name];
    } else {
      echo $this->token[0] . $name . $this->token[1];
    }
  }
  
  /**
   * Método que compila o template antes de ser renderizado
   * @param string $template
   */
  protected function parseBehindTemplate( $template ) {
    
    $template = preg_replace('~\\' . $this->token[0] . '(\w+)\\' . $this->token[1] . '~', '<?php $this->parse(\'$1\'); ?>', $template);
    $template = preg_replace('~\\' . $this->token[0] . 'LOOP:(\w+)\\' . $this->token[1] . '~', '<?php foreach ($this->_data[\'$1\'] as $ELEMENT): $this->wrap($ELEMENT); ?>', $template);
    $template = preg_replace('~\\' . $this->token[0] . 'ENDLOOP:(\w+)\\' . $this->token[1] . '~', '<?php $this->unwrap(); endforeach; ?>', $template);
    
    return $template;
  }
  
  /**
   * Método que compila o template depois de ter renderizado
   * 
   * @param string $template
   * @param string $path
   * @return Ambigous <string, mixed, unknown>|Ambigous <>|Ambigous <mixed, unknown, string>|mixed
   */
  protected function parseAfterTemplate( $template, $path = null ) {
    
    $path = rtrim($path, '/') . '/';
    
    $_ = $this;
    $_data = $this->_data;
        
    $template = preg_replace_callback('/\\' . $this->token[0] . 'LOOP:(\w+)\\' . $this->token[1] . '(.*?)' . '\\' . $this->token[0] . 'ENDLOOP:(\w+)\\' . $this->token[1] . '/s', function ($match) use($_, $_data) {
        
      $html = '';
      
      if (isset($_data[$match[1]])) {
        foreach($_data[$match[1]] as $ELEMENT) {
          
          $_->wrap($ELEMENT);
          $html .= $_->parseAfterTemplate( $match[2] );
          $_->unwrap();
      
        }
      }
      return $html;
    
    }, $template);
    
    /*
     * 
     */
      $template = preg_replace_callback('/\\' . $this->token[0] . 'IF:(\w+)\\' . $this->token[1] . '(.*?)' . '\\' . $this->token[0] . 'ENDIF:(\w+)\\' . $this->token[1] . '/s', function ($match) use($_, $_data) {
 
          if (!isset($_data[$match[1]]) || $_data[$match[1]] == false) {
              return null;
          } else {
              return $_->parseBehindTemplate( $match[2] );
          }
              
      }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . '(\w+)\\' . $this->token[1] . '~', function ($match) use($_data) {
            
        if (isset($_data[$match[1]]))
                return $_data[$match[1]];
        
        return null;
      
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'PARTIAL:([\w -]+)\\' . $this->token[1] . '~', function ($match) use($_, $path) {
      
      $file = $path . 'content' . DIRECTORY_SEPARATOR . $match[1] . '.php';
      
      if ( is_file( $file ) )
        return $_->parseAfterTemplate( file_get_contents( $file ) );
          
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'PARTIAL:(\w+):([\w -]+)\\' . $this->token[1] . '~', function ($match) use($_, $path) {
      
      $path = trim(preg_replace('/\s*public\/(.*)/', '', $path));
      
      $file = $path . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . $match[1] . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $match[2] . '.php';
      
      if ( is_file( $file ) )
        return $_->parseAfterTemplate( file_get_contents( $file ) );
        
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'HELPER:(\w+)\[(.*)\]\\' . $this->token[1] . '~', function ($match) use($_) {
      
      $params = preg_replace('/\'/', '', $match[2]);
      $params = preg_replace('/\"/', '', $params);
      
      return $_->getHelper( 'helper' )->$match[1]($params); 
      
    }, $template);
  
    return $template;
  }
  
  /**
   * 
   * @param string $file
   * @param string $path
   * @param array $params
   * @throws Exception
   * @return string|Ambigous <\Cataya\Utilities\Template\Ambigous, mixed, string, unknown>
   */
  public function compile( $file, $path = null, array $params = null ) {
 
    try {
      $file = fopen ( $file, 'r' );
    } catch (Exception $e) {
      throw new Exception ( "Não foi possível abrir o arquivo template: {$file}" );
    }
  
    if ($file) {
      
      $template = '';
      while ( ! feof ( $file ) ) {
        $template .= fread ( $file, 65536 );
 
                /**
                 * Foi modificado por estar dando problemas com a compilação
                 */
//        flush ();
//              ob_end_flush();
                ob_flush();
      }
      fclose ( $file );
    }
    
    if (isset($params['compile']) && $params['compile'] === false) 
      return $this->run( $template );
    
    return $this->parseAfterTemplate( $this->run( $this->parseBehindTemplate( $template ) ), $path );
  }
  
  /**
   * 
   * @param string $string
   * @param string $path
   * @param array $params
   * @return string|Ambigous <\Cataya\Utilities\Template\Ambigous, mixed, string, unknown>
   */
  public function compileText( $string, $path = null, array $params = null ) {
    
    if ($params['compile'] === false)
      return $this->run( $string );
    
    return $this->parseAfterTemplate( $this->run( $this->parseBehindTemplate( $string ) ), $path );
  }
#4Cataya\Utilities\Template\ATemplate->run(<?php \n echo $this->partial('main:head'); \n\n if ( $this->helper->isMobileRequest() ) {\n echo $this->partial('main:nav-mobile');\n } else {\n echo $this->partial('main:nav');\n }\n\n [\n 'imovelId' => $imovelId,\n 'titulo' => $tituloImovel,\n 'codigo' => $codigoImovel,\n 'area' => $areaImovel,\n 'solo' => $solo,\n 'formacao' => $formacao,\n 'topografia' => $topografia,\n 'hidrografia' => $hidrografia,\n 'localizacao' => $localizacao,\n 'benfeitorias' => $benfeitorias,\n 'videothumb' => $videoThumb,\n\n 'estado' => [\n 'estadoId' => $estadoId,\n 'estado' => $nomeEstado,\n 'sigla' => $siglaEstado\n ],\n 'cidade' => [\n 'cidadeId' => $cidadeId,\n 'cidade' => $nomeCidade,\n ],\n 'tipo' => [\n 'singular' => $nomeTipo\n ]\n\n ] = $this->imovel;\n\n [\n 'galeria' => $galeria,\n 'pasta' => $pasta,\n 'arquivo' => $arquivo,\n 'extensao' => $extensao\n ] = $this->media;\n\n $urlEstado = strtolower($this->helper->url("imoveis/local/estado", $estadoId, $nomeEstado));\n $urlCidade = strtolower($this->helper->url('imoveis/local/cidade', $estadoId, $cidadeId, $nomeCidade, $nomeEstado) );\n\n $imgBaseUrl = $this->baseasset;\n $mainImgUrl = $this->destaque[0]['url'];\n $mainVideoUrl = $this->destaque[0]['url'];\n\n $videoId = $this->hutil->getYoutubeVideoId($mainVideoUrl);\n $videoParams = [\n 'rel'=> 0, \n 'loop' => 1, \n 'showinfo' => 0,\n 'version' => 3,\n 'playlist' => $videoId\n ];\n\n if ( empty( $videoThumb ) ) {\n $videoThumb = $this->hutil->getYoutubeUrlImage( $videoId );\n } else {\n $videoThumb = "{$this->baseasset}images/media/videothumbs/{$imovelId}/{$videoThumb}";\n }\n\n $property = $this->propertyField;\n\n $tipoImovel = $this->tipoImovel['singular'];\n\n?>\n\n<div class="details-body" ng-controller="ImovelCtrl">\n <section class="imoveldetalhes {{ stickyBarMode }}">\n <section class="detailsmain">\n <div class="detailsgallery-content">\n\n <?php if(sizeof($this->destaque) > 0 ): ?>\n\n <?php if( $this->destaque[0]['type'] != 'video'): ?>\n <button \n class="gallery-img gallery-imgmain <?php echo sizeof($this->destaque) <= 2 ? 'w-100' : ''; ?>" \n data-type="active-image" \n style="background-image: url('<?php echo $mainImgUrl; ?>')">\n\n <figure>\n <img class="invisible" src="<?php echo $mainImgUrl; ?>" alt="<?php echo $this->destaque[0]['title']; ?>">\n </figure>\n\n </button>\n <?php else: ?>\n <button \n class="gallery-img gallery-imgmain <?php echo sizeof($this->destaque) <= 2 ? 'w-100' : ''; ?>" \n data-type="active-image" \n style="background-image: url('<?php echo $videoThumb; ?>')"\n data-toggle="modal" data-target=".bd-example-modal-lg" ng-click="toggleModal">\n <div class="play"></div>\n </button>\n <?php endif; ?>\n\n <?php endif; ?>\n\n <div class="gallery-footer">\n <div class="gallery-thumbs<?php echo sizeof($this->destaque) <= 2 ? ' d-none' : ''; ?>">\n\n <?php $i = sizeof($this->destaque) > 3 ? 1 : 0; ?>\n\n <?php for ($i; $i < sizeof($this->destaque); $i++): ?>\n \n <?php echo $this->partial('main:block/details/thumb', [ \n 'vars' => [ \n 'destaques' => $this->destaque[$i], \n 'destaquesUrl' => $this->destaque[$i]['url'], \n 'videoUrl' => $mainVideoUrl, \n ]]); \n ?>\n\n <?php endfor; ?>\n \n </div>\n <div \n class="gallery-more" \n ng-click="openGallery();">\n <span>+</span>\n <span><?php echo $this->staticField['details.plus.images']; ?></span>\n </div>\n </div>\n </div>\n <div class="container">\n <div class="row">\n <div class="col-12 col-md-6">\n <div class="detailsmain-info">\n <nav class="detailsmain-breadcrumb">\n <ul class="detailsmain-breadcrumblist">\n <li class="detailsmain-breadcrumblistitem">\n <a href="<?php echo $this->baseurl; ?>" target="_self">Home</a>\n </li>\n <li class="detailsmain-breadcrumblistitem">\n <a href="<?php echo $urlEstado; ?>" target="_self"><?php echo $nomeEstado; ?></a>\n </li>\n <li class="detailsmain-breadcrumblistitem">\n <a href="<?php echo $urlCidade; ?>" target="_self"><?php echo $nomeCidade; ?></a>\n </li>\n <li class="detailsmain-breadcrumblistitem">\n <?php echo "{$tipoImovel} {$this->staticField['forsalein']} {$nomeCidade}-{$siglaEstado}"; ?>\n </li>\n </ul>\n </nav>\n \n <h3 class="details-title"><?php echo "{$tipoImovel} {$this->staticField['forsalein']} {$nomeCidade}-{$siglaEstado}"; ?></h3>\n \n <div class="detailsmain-content">\n <div class="row">\n <div class="col-8">\n <ul class="detailsmain-featureslist">\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.access']; ?>:\n </strong>\n <?php echo $property['localizacao']; ?>\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.area']; ?>:\n </strong>\n <?php echo $areaImovel; ?> Alqueires\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.hydrography']; ?>:\n </strong>\n <?php echo $property['hidrografia']; ?>\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.topography']; ?>:\n </strong>\n <?php echo $property['topografia']; ?>\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.soilformation']; ?>:\n </strong>\n <?php echo $property['formacao']; ?>\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.soiltype']; ?>:\n </strong>\n <?php echo $property['solo']; ?>\n </li>\n <li class="detailsmain-featureslistitem">\n <strong>\n <?php echo $this->staticField['details.improvements']; ?>:\n </strong>\n <?php echo $property['benfeitorias']; ?>\n </li>\n </ul>\n </div>\n <div class="col-4">\n <p class="detailsmain-code">Código #<?php echo $codigoImovel; ?></p>\n </div>\n </div>\n </div>\n\n <?php if ( $this->helper->isMobileRequest() ): ?>\n\n <div class="share-and-more">\n <div class="row">\n <div class="col-6">\n <?php echo $this->partial('main:block/details/share', [ 'vars' => [ 'imovel' => $this->imovel ] ]); ?>\n </div>\n <div class="col-6">\n <a href="javascript:;" ng-click="scrollPhotos(event);" class="landingmoreinfo-share">\n <?php echo $this->staticField['details.moreimages']; ?>\n </a>\n </div>\n </div>\n </div>\n\n <?php endif; ?>\n\n </div>\n </div>\n </div>\n </div>\n </section>\n </section>\n\n <section class="detailscontainer">\n <div class="container">\n <div class="row">\n <?php echo $this->partial('main:block/details/more-info', [ 'vars' => [ 'property' => $property ] ]); ?>\n <?php echo $this->partial('main:block/details/form', array('vars' => array( 'cod' => $codigoImovel, 'imovel' => $imovelId ))); ?>\n </div>\n </div>\n </section>\n <section class="detailspropertiesforsale">\n <div class="container">\n <p class="details-title"><?php echo $this->staticField['details.relatedproperties']; ?></p>\n <div class="row">\n <?php echo $this->partial('main:block/oportunities/card-description'); ?>\n </div>\n </div>\n </section>\n\n <a href="javascript:history.back()" ng-if="backBtn" class="btn-back"></a>\n</div>\n\n<?php \n if ( $this->helper->isMobileRequest() ) {\n echo $this->partial('main:footer-mobile');\n } else {\n echo $this->partial('main:footer-default');\n }\n echo $this->partial('main:footer'); \n?>\n\n<div class="modal fade bd-example-modal-lg video-modal" id="imovelVideo" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" ng-hide="toogleModal">\n <div class="modal-dialog modal-lg modal-dialog-centered video-container">\n <div class="modal-content content">\n <iframe width="560" height="315" src="<?php echo $this->hutil->getYoutubeUrlEmbed( $videoId, $videoParams ); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>\n </div>\n </div>\n</div> )
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Utilities/Template/ATemplate.php (234)
<?php
 
namespace Cataya\Utilities\Template;
 
/**
 *
 * Abstract Class ATemplate
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1
 * @copyright  GPL © 2010, hugomastromauro.com.
 * @access public
 * @package Cataya
 * @subpackage lib
 *
 */
abstract class ATemplate 
  extends \Cataya\AObject {
  
  /**
   * 
   * @var string
   */
  private $token = '%%';
  
  /**
   * 
   * @var array
   */
  private $stack = array();
  
  /**
   * 
   * @param array $params
   */
  public function __construct( array $params = null ) {
    
    parent::__construct();
    
    if (is_array($params))
      $this->_data = $params;
  }
  
  /**
   * 
   * @param string $token
   */
  protected function setToken( $token ) {
    $this->token = $token;
  }
  
  /**
   * 
   * @param stream $template
   */
  private function run( $template ) {
      
    ob_start ();
        
    if ( eval( '?>' . $template ) === false && ( $error = error_get_last() ) ) {
      throw new Exception('Erro ao renderizar o layout!');
    }
    
    return ob_get_clean();
  }
  
  /**
   * 
   * @param string $element
   */
  protected function wrap( $element ) {
    
    $this->stack[] = $this->_data;
    
    foreach ($element as $k => $v) {
      $this->_data[$k] = $v;
    }
  }
  
  /**
   * 
   */
  protected function unwrap() {
    $this->_data = array_pop($this->stack);
    $this->stack = null;
  }
  
  /**
   * 
   * @param string $name
   */
  private function parse( $name ) {
    
    if (isset($this->_data[$name])) {
      echo $this->_data[$name];
    } else {
      echo $this->token[0] . $name . $this->token[1];
    }
  }
  
  /**
   * Método que compila o template antes de ser renderizado
   * @param string $template
   */
  protected function parseBehindTemplate( $template ) {
    
    $template = preg_replace('~\\' . $this->token[0] . '(\w+)\\' . $this->token[1] . '~', '<?php $this->parse(\'$1\'); ?>', $template);
    $template = preg_replace('~\\' . $this->token[0] . 'LOOP:(\w+)\\' . $this->token[1] . '~', '<?php foreach ($this->_data[\'$1\'] as $ELEMENT): $this->wrap($ELEMENT); ?>', $template);
    $template = preg_replace('~\\' . $this->token[0] . 'ENDLOOP:(\w+)\\' . $this->token[1] . '~', '<?php $this->unwrap(); endforeach; ?>', $template);
    
    return $template;
  }
  
  /**
   * Método que compila o template depois de ter renderizado
   * 
   * @param string $template
   * @param string $path
   * @return Ambigous <string, mixed, unknown>|Ambigous <>|Ambigous <mixed, unknown, string>|mixed
   */
  protected function parseAfterTemplate( $template, $path = null ) {
    
    $path = rtrim($path, '/') . '/';
    
    $_ = $this;
    $_data = $this->_data;
        
    $template = preg_replace_callback('/\\' . $this->token[0] . 'LOOP:(\w+)\\' . $this->token[1] . '(.*?)' . '\\' . $this->token[0] . 'ENDLOOP:(\w+)\\' . $this->token[1] . '/s', function ($match) use($_, $_data) {
        
      $html = '';
      
      if (isset($_data[$match[1]])) {
        foreach($_data[$match[1]] as $ELEMENT) {
          
          $_->wrap($ELEMENT);
          $html .= $_->parseAfterTemplate( $match[2] );
          $_->unwrap();
      
        }
      }
      return $html;
    
    }, $template);
    
    /*
     * 
     */
      $template = preg_replace_callback('/\\' . $this->token[0] . 'IF:(\w+)\\' . $this->token[1] . '(.*?)' . '\\' . $this->token[0] . 'ENDIF:(\w+)\\' . $this->token[1] . '/s', function ($match) use($_, $_data) {
 
          if (!isset($_data[$match[1]]) || $_data[$match[1]] == false) {
              return null;
          } else {
              return $_->parseBehindTemplate( $match[2] );
          }
              
      }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . '(\w+)\\' . $this->token[1] . '~', function ($match) use($_data) {
            
        if (isset($_data[$match[1]]))
                return $_data[$match[1]];
        
        return null;
      
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'PARTIAL:([\w -]+)\\' . $this->token[1] . '~', function ($match) use($_, $path) {
      
      $file = $path . 'content' . DIRECTORY_SEPARATOR . $match[1] . '.php';
      
      if ( is_file( $file ) )
        return $_->parseAfterTemplate( file_get_contents( $file ) );
          
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'PARTIAL:(\w+):([\w -]+)\\' . $this->token[1] . '~', function ($match) use($_, $path) {
      
      $path = trim(preg_replace('/\s*public\/(.*)/', '', $path));
      
      $file = $path . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . $match[1] . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $match[2] . '.php';
      
      if ( is_file( $file ) )
        return $_->parseAfterTemplate( file_get_contents( $file ) );
        
    }, $template);
    
    $template = preg_replace_callback('~\\' . $this->token[0] . 'HELPER:(\w+)\[(.*)\]\\' . $this->token[1] . '~', function ($match) use($_) {
      
      $params = preg_replace('/\'/', '', $match[2]);
      $params = preg_replace('/\"/', '', $params);
      
      return $_->getHelper( 'helper' )->$match[1]($params); 
      
    }, $template);
  
    return $template;
  }
  
  /**
   * 
   * @param string $file
   * @param string $path
   * @param array $params
   * @throws Exception
   * @return string|Ambigous <\Cataya\Utilities\Template\Ambigous, mixed, string, unknown>
   */
  public function compile( $file, $path = null, array $params = null ) {
 
    try {
      $file = fopen ( $file, 'r' );
    } catch (Exception $e) {
      throw new Exception ( "Não foi possível abrir o arquivo template: {$file}" );
    }
  
    if ($file) {
      
      $template = '';
      while ( ! feof ( $file ) ) {
        $template .= fread ( $file, 65536 );
 
                /**
                 * Foi modificado por estar dando problemas com a compilação
                 */
//        flush ();
//              ob_end_flush();
                ob_flush();
      }
      fclose ( $file );
    }
    
    if (isset($params['compile']) && $params['compile'] === false) 
      return $this->run( $template );
    
    return $this->parseAfterTemplate( $this->run( $this->parseBehindTemplate( $template ) ), $path );
  }
  
  /**
   * 
   * @param string $string
   * @param string $path
   * @param array $params
   * @return string|Ambigous <\Cataya\Utilities\Template\Ambigous, mixed, string, unknown>
   */
  public function compileText( $string, $path = null, array $params = null ) {
    
    if ($params['compile'] === false)
      return $this->run( $string );
    
    return $this->parseAfterTemplate( $this->run( $this->parseBehindTemplate( $string ) ), $path );
  }
#5Cataya\Utilities\Template\ATemplate->compile(/home/mercadodeterras/www/mercadodeterras.com.br/src/public/main/, null)
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/View/AView.php (284)
<?php
 
namespace Cataya\View;
 
use Cataya\Utilities\File\Util;
 
/** 
 * 
 * Abstract Class AView
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1 
 * @copyright  GPL © 2010, hugomastromauro.com. 
 * @access public  
 * @package Cataya 
 * @subpackage lib
 *  
 */ 
abstract class AView
  extends \Cataya\Utilities\Template\ATemplate
    implements \Cataya\View\IView {
      
  /**
   * 
   * @var \Cataya\Application\Frontcontroller\Frontcontroller
   */
  protected $front;
    
  /**
   * 
   * @var array
   */
  protected $helpers = array();
  
  /**
   * 
   * @var string
   */
  private $_path;
    
  /**
   * 
   * @var array
   */
  private $_layout = array( 'key' => null, 'params' => null );
  
  /**
   * 
   * @var array
   */
  private $_partial = array();
  
  /**
   *
   * @var array
   */
  private $_extension = array();
  
  /**
   * 
   * @var array
   */
  private $_templates = array();
  
  /**
   * 
   * @var \Cataya\Utilities\Cache\ACache
   */
  private $_cache;
  
  /** 
     * Construtor da classe
     * @access public 
     * @param array $params   
     * @return void 
     */ 
  public function __construct( \Cataya\Application\Frontcontroller\Frontcontroller $front ) {
    
    parent::__construct();
    
    $this ->front = $front;
    $this->setToken( $front->getApp()->getConfig()->view->token );
  }
  
  /**
   * 
   * @param string $name
   * @param mixed $value
   */
  public function assign($name, $value) {
    
    $this->set($name, $value);  
  }
  
  /**
   * 
   * @param string $key
   * @param array $params
   * @param array $templates
   */  
  public function layout( $key, array $params = null, array $templates = null ) {
 
    $this->_layout['key'] = $key;
    $this->_layout['params'] = $params;
    
    $this->_templates = $templates;
  }
  
  /**
   * 
   * @param string $key
   * @param array $params
   */
  public function template( $key, array $params = null ) {
    
    if ( count( $this->_templates ) >= 1 ) {
      foreach( $this->_templates as $template ) {
        
        if ( $template['template'][$key] ) {
          
          $cparams = json_decode( $template['opcoes'] ); 
          
          if ( is_array( $cparams ) )
            $params = array_merge( $cparams, $params );
          
          $this->partial_javascript = $template['javascript'];
          $this->partial_css = $template['css'];
                  
          $this->render( $template['template'][$key], $params );
          
        }
      }
    }
  }
  
  /**
   * 
   * @param string $key
   * @param array $params
   */
  public function partial( $key, array $params = null ) {
  
    if ( is_null( $params ) ) {
      if ( isset( $this->_partial[$key] ) )
        $params = $this->_partial[$key];
    }
    
    if ( isset($params['vars']) && is_array($params['vars']) ) {
        foreach($params['vars'] as $name => $value) {
            $this->{$name} = $value;
        }
    }
    
    $this->render( $key, $params );
  }
  
  /**
   * 
   * @param string $key
   * @param array $params
   */
  public function extension( $key, array $params = null ) {
  
    if ( is_null( $params ) ) {
      if ( isset( $this->_extension[$key] ) )
        $params = $this->_extension[$key];
    }
  
    $this->render( $key, $params );
  }
  
  /**
   * 
   * @param string $key
   * @param array $params
   */
  public function setPartial( $key, array $params = null ) {
    $this->_partial[$key] = $params;
  } 
    
  /**
   * 
   * $params = array(
   *     'cache'   => [true/false],
   *     'lifetime'   => [integer],
   *     'type'    => [file],
   *     'compile'  => [true/false] optional,
   *     'devices'  => [phone/tablet/computer]
   * )
   * 
   * @param string $key
   * @param array $params
   * @throws Exception
   */
  public function render( $key = null, array $params = null ) {
 
    $type = 'content';
    
    $template =  $this ->front ->getApp() ->getConfig() ->template;
    $modulepath = $this ->front ->getApp() ->getConfig() ->controller ->module ->path;
    
    if ( $key == null && $params == null ) {
      $key = $this->_layout['key'];
      $params = $this->_layout['params'];
      $type = 'layout';
    }
 
    $type = isset( $params['type'] ) ? $params['type'] : $type;
    
    if ( isset( $params['devices'] ) && is_array( $params['devices'] ) ) {
      
      $detect = new \Cataya\Utilities\Device\MobileDetect();
      $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
      
      if (!in_array($deviceType, $params['devices']))
        return null;
    }
      
    $this->assignHelpers();
    
    if ( ! isset( $this-> _path ) ) $this -> _path = $modulepath;
    
    $test = preg_split('/:/', $key);    
    
    if ( count($test) > 1 ) {
      
        $module = $test[0] . DIRECTORY_SEPARATOR;
        $key = $test[1];
        
        if ( !is_dir( $this ->_path . Util::rslash( $module ) ) )
            $module = $this ->front ->getRouter() ->getModule();
      
    } else if ( isset( $params['module'] ) ) {
        
        $module = $params['module'] . DIRECTORY_SEPARATOR;
        
    } else {
        
      $module = $this ->front ->getRouter() ->getModule();
    }
    
    $path = $this ->_path . Util::rslash( $module );
 
    /*
     * Verifica se existe o arquivo no diretório principal
     * 
     */
    if ( $template && $module != 'admin\\' ) {
      
      $file = $this ->_path . $template . DIRECTORY_SEPARATOR . Util::rslash( $module ) . $type . DIRECTORY_SEPARATOR . $key . '.php';
      
      if ( !file_exists( $file ) )
        $file = $path . $type . DIRECTORY_SEPARATOR . $key . '.php';
 
    } else {
        
      $file = $path . $type . DIRECTORY_SEPARATOR . $key . '.php';
    }
    
    /*
     * Se não existir o arquivo, carrega vázio
     */
    if ( ! ( file_exists( $file ) ) )
      $file = $path . $type . DIRECTORY_SEPARATOR . 'empty.php';          
    
    if ( isset( $params['cache'] ) && 
        isset( $this->_cache ) ) {
      
      $lifetime = isset( $params['lifetime'] ) ? $params['lifetime'] : 200; 
            
      if ( $this->_cache->contains( $key ) === false )
        $this->_cache->save( $key, $this->compile( $file, $path, $params ), $lifetime );
    
      echo $this->_cache->fetch( $key );
 
      die;
 
     
    } else {
      
      /*
       * Compilar o layout com as variáveis vindas do bd
       */
      echo $this->compile( $file, $path, $params );
    }
  }
  
  /**
   * 
   * @param \Cataya\Utilities\Cache\ACache $cache
   * @throws Exception
   */
  public function setCache( $cache ) {
    
    if ( $cache instanceof \Cataya\Utilities\Cache\ACache ) {
      $this->_cache = $cache;
    } else {
      throw new Exception ( "Classe cache não extende classe base!" );  
    }
  }
  
  /**
   * 
   * @param string $key
   * @return boolean
   */
  public function isCached( $key ) {
    
    if ( isset($this->_cache ) )
      return $this->_cache->contains( $key );
      
    return false;
  }
  
  /**
   * 
   * @return \Cataya\Utilities\Cache\ACache
   */
  public function getCache() {
      return $this->_cache;
  }
    
  /**
   * 
   * @param string $path
   */
  public function setPath( $path ) {
    
    $this->_path = $path;
  }
  
  /**
   * 
   * @param string $name
   */
  public function getHelper( $name ) {
    return $this->helpers[$name];
  }
  
  /**
   * 
   * @return array
   */
  public function getHelpers() {
      return $this->helpers;
  }
    
  /**
   * 
   * @param string $name
   * @param \Cataya\View\Helper\AHelper $helper
   * @throws Exception
   */
  public function setHelper( $name, $helper ) {
    
    if ( $helper instanceof \Cataya\View\Helper\AHelper ) {
      $this->helpers[$name] = $helper;
    } else {
      throw new Exception ( "Helper não extende a classe AHelper!" );
    }
  }
  
  /**
   * 
   */
  public function assignHelpers( $helpers = null ) {
    
      if (is_array($helpers))
          $this->helpers = array_merge($this->helpers, $helpers);
      
    if (isset($this->helpers)) {
      foreach($this->helpers as $key => $value) {
        $this->$key = $value;  
      }
    }
  }
#6Cataya\View\AView->render()
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Controller/AController.php (334)
<?php
 
namespace Cataya\Controller;
 
use Cataya\Application\Frontcontroller\Plugins\Assets,
  Cataya\Utilities\File\Util;
 
/** 
 * 
 * Abstract Class AController
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1 
 * @copyright  GPL © 2010, hugomastromauro.com. 
 * @access public  
 * @package Cataya 
 * @subpackage lib
 *  
 */ 
abstract class AController 
  extends \Cataya\AObject 
    implements \Cataya\Controller\IController {    
  
  /**
   *
   * @var Cataya\Application\Frontcontroller
   */
  protected $front;
  
  /**
   *
   * @var Cataya\View\View
   */
  protected $view;
  
  /**
   *
   * @var Cataya\Application\Request\Request
   */
  protected $request;
  
  /**
   *
   * @var Cataya\Application
   */
  protected $app;
  
  /**
   *
   * @var Cataya\Router\Router
   */
  protected $router;
  
  /**
   *
   * @var Cataya\Utilities\Net\HTTPClient
   */
  protected $http;
  
  /**
   *
   * @var Doctrine\ORM\EntityManager
   */
  protected $entityManager;
  
  /**
   *
   * @var Doctrine\ODM\EntityManager
   */
  protected $documentManager;
  
  /**
   * 
   * @var \Predis\Client
   */
  protected $predis;
 
  /**
   * @var array
   */
  protected $meta = array();
 
  /**
   * @var string
   */
  protected $slash = ' :: ';
 
  /**
   *
   * @var \Cataya\Application\Frontcontroller\Assets
   */
  protected $assets;
 
  /**
     * Construtor da classe
     * @method __construct
     * @access public
     * @return void
     */
  public function __construct( \Cataya\Application\Frontcontroller\Frontcontroller $front ) {        
    
    /* FrontController */
    $this->front = $front;
    
    /* View */
    $this->view = $front->getView();
    
    /* Application */
    $this->app = $front->getApp();
    
    /* Router */
    $this->router = $front->getRouter();
    
    /* Request */
    $this->request = $front->getRequest();
    
    /* Entity (DBO) */
    $this->entityManager = $this->app->bootstrap()->stack('initDoctrine');
    
    /* Documents (ODM) */
        $this->predis = $this->app->bootstrap()->stack('initPredis');
 
    /* Configurando url */
    $this->configureView();
    
    /* Http client */
    $this->http = \Cataya\Loader\Loader::getInstance() 
            ->loadClass( 'Cataya\Utilities\Net\HTTPClient',
              array( array( 'baseurl' => $this->view->baseurl ) ) );
              
    parent::__construct();
  } 
  
  
  /**
   * 
   * Inicializando informações para a View
   * return void
   */
  protected function configureView() {
 
        $baseasset = $this->app->getConfig()->cdn ? $this->app->getConfig()->cdn : $this->app->getConfig()->baseurl;
 
        $this->view->baseurl = $this->app->isApache() && ($this->app->getConfig()->appmode == 'production' || $this->app->getConfig()->appmode == 'homologation') ?
            $this->app->getConfig()->baseurl . Util::rslash($this->router->getModule()) :
            $this->app->getConfig()->baseurl . 'index.php/' . Util::rslash($this->router->getModule());
 
        $this->view->base = $this->app->isApache() && ($this->app->getConfig()->appmode == 'production' || $this->app->getConfig()->appmode == 'homologation')  ?
            $this->app->getConfig()->baseurl :
            $this->app->getConfig()->baseurl . 'index.php/';
 
        $this->view->baseasset = $baseasset . 'public/' . Util::rslash( $this->router->getModule() ) . 'assets/';
 
        $path = $this->app->getConfig()->controller->module->path . Util::rslash( $this->router->getModule() ) . 'cache';
 
        $this->view->setCache( new \Cataya\Utilities\Cache\FileCache( array( 'path' => $path ) ) );
 
        /*
         *
         */
        $this->assets = new Assets( array(
 
            'baseasset'   => $this->view->baseasset,
            'baseurl'    => $this->view->baseurl,
            'base'        => $baseasset,
            'cachetime'   => $this->app->getConfig()->geral->cache
 
        ), $this->front );
 
        /*
         *
         */
        if ( $this->app->getConfig()->template ) {
 
            $this->view->baseasset = $baseasset . 'public/';
 
            if ( $this->router->getModule() != 'admin\\' ) {
 
                $this->view->baseasset .= $this->app->getConfig()->template . '/' .
                    Util::rslash( $this->router->getModule() ) . 'assets/';
 
            } else {
 
                $this->view->baseasset .= Util::rslash( $this->router->getModule() ) . 'assets/';
 
            }
        }
    }
      
  /**
   * 
   * @param string $name
   * @param mixed $value
   */
  public function setMetaCh($name, $value) {
 
    if(is_array($value))
      return $this->meta[$name] = implode($value, ', ');
 
    return $this->meta[$name] = $value;
  }
  
  /**
   * 
   * @param string $name
   */
  public function removeMetaCh($name) {
    unset($this->meta[$name]);
  }
  
  /**
   * 
   * Enter description here ...
   * @param string $value
   */
  public function setTitleCh( $value ) {
 
    if ( isset( $this->meta['title'] ) ) {
      $this->meta['title'] .= $this->slash . $value;
    }else{
      $this->meta['title'] = $value;
    }
    
    return $this->meta['title'];
  }
  
  /**
   * 
   * Enter description here ...
   * @param string $direction
   */
  public function setTitleDirectionCh( $direction = 'r' ) {
 
    $new = '';
    if ($direction == 'l') {
      $rows = preg_split("/\\{$this->slash}/", $this->meta['title']);
 
      for ($i = count($rows)-1; $i >= 0; $i--){
        $new .= $rows[$i];
        
        if ( ! ($i == 0) )
          $new .= $this->slash;
      }
    }
 
    if ($direction == 'r') {
      $rows = preg_split("/\\{$this->slash}/", $this->meta['title']);
      
      for ($i = 0; $i < count($rows); $i++){
        $new .= $rows[$i];
        
        if (! ($i == (count($rows)-1)) )
          $new .= $this->slash;
      }
    }
    
    $this->meta['title'] = $new;
  }
  
  /**
   * 
   * Enter description here ...
   * @param string $defaultSlash
   */
  public function formatTitleCh( $slash ) {
    
    $slash = trim($slash);
    $slashold = $this->slash; 
    $this->slash = str_pad($slash, strlen($slash) + 2, ' ', STR_PAD_BOTH);
    
    if (!empty($this->meta['title'])) {
      $this->meta['title'] = preg_replace("/{$slashold}/i", $this->slash, $this->meta['title']);
    }
  }
  
  /**
   * 
   * Enter description here ...
   */
  public function metaAssignCh() {
    $this->view->meta = $this->meta;
  }
  
  /**
   * 
   * Enter description here ...
   */
  public function assetsAssignCh() {
    $this->view->assets = $this->assets;
  }
  
    /**
   * (non-PHPdoc)
   * @see Cataya\Controller.IController::init()
   */
  public function init() {}
  
  /**
   * (non-PHPdoc)
   * @see Cataya\Controller.IController::preActionEvent()
   */
  public function preActionEvent( array $params ) {}
  
  /**
   * (non-PHPdoc)
   * @see Cataya\Controller.IController::indexAction()
   */
  public function indexAction( array $params ) {}
  
  /**
   * (non-PHPdoc)
   * @see Cataya\Controller.IController::postActionEvent()
   */
  public function postActionEvent( array $params ) {
    
    /**
     * Assign Meta
     */
    $this->metaAssign();
    
    /**
     * Assign assets
     */
    $this->assetsAssign();
    
    /**
     * Compile cache Asset
     */
    $this->assets->compile();
    
    /**
     * Render view
     */
    $this->view->render();
    
  }
  
  /**
   * 
   * Enter description here ...
   * @param array $params
   */
  public function errorAction( array $params ) {}
#7Cataya\Controller\AController->postActionEvent(Array(0 => imovel))
/home/mercadodeterras/www/mercadodeterras.com.br/src/application/lib/Application/Controller/ControllerPagina.php (1047)
<?php
 
namespace Application\Controller;
 
use Cataya\Utilities\Session\Session,
    Cataya\Utilities\Session\Cookie,
    Application\Utilities\ExtensoesObjetos,
    Application\Utilities\TranslateModel,
    models\Paginas;
 
/**
 *
 * Classe ControllerPagina
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1
 * @copyright  GPL © 2010, Hugo Mastromauro da Silva.
 * @access public
 * @package ELEVE
 * @subpackage controllers
 *
 */
class ControllerPagina
  extends \Cataya\Controller\AController {
  
  /**
   * 
   * @var \Cataya\Utilities\Session\Session
   */
  protected $session;
  
  /**
   * 
   * @var \Cataya\Utilities\Session\Cookie
   */
  protected $cookie;
  
  /**
   * 
   * @var string
   */
  protected $layout;
  
  /**
   * 
   * @var array
   */
  protected $params;
  
  /**
   * 
   * @var array
   */
  protected $plugins;
  
  /**
   * 
   * @var DateTime
   */
  public $limitDate;
 
  /**
   * Idioma padrão
   */
  public $defaultLocale = 'pt-br';
 
  /**
     * Construtor padrão do controller
     * @method init
     * @access public
     * @return void
     */
  public function init () {
 
    /*
     * Configuração da Sessão
     */
    $this->cookie = new Cookie( array( 'name' => $this->app->getConfig()->key, 'timeout' => '+12 month', 'path' => '/' ) );
    
    /*
     * Configuração da Sessão
     */
    $this->session = new Session( array( 'name' => $this->app->getConfig()->key, 'timeout' => $this->app->getConfig()->geral->sessao ) );
    
    /*
     * Configuração de idioma
     */
    if ($this->app->getConfig()->frontend->idiomas) {
        
      $idiomas = array_map(function($v) {
        return $v['nome'];
      }, json_decode($this->app->getConfig()->frontend->idiomas, true));
 
      $locales = json_decode($this->app->getConfig()->frontend->idiomas, true);
 
      if ( !empty($locales) ) {
 
        foreach( $locales as $locale ) {
  
          if ($locale['default']) {
            $this->defaultLocale = $locale['nome'];
          }
        }
      }
 
      if (in_array(stripslashes($this->router->getModule()), $idiomas)) {
        $this->app->getConfig()->language = stripslashes($this->router->getModule());
      }
    }
    
    $user = array(
        'nome'    => '',
        'avatar'  => 'default.png'
    );
    
    if ( isset($this->session->admin) ) {
        
        $user['nome'] = $this->session->admin['nome'];
        $user['avatar'] = isset($this->session->admin['avatar']) ? $this->session->admin['avatar'] : 'default.png';
    }
 
    $this->view->configuration = array_merge( $this->app->getConfig()->geral->toArray(),
      array( 
          'appmode'     => $this->app->getConfig()->appmode,
        'appname'     => $this->app->getConfig()->appname,
        'key'      => $this->app->getConfig()->key,
          'router'        => $this->router->getUri(),
          'user'          => $user,
      )
    );
    
    $this->view->urlrewrite = explode(',', $this->app->getConfig()->frontend->urlRewrite);
    
    /*
     * Setando helpers
     */
    $this->view->setHelper( 'helper', new \Cataya\View\Helper\Helper() );
    $this->view->setHelper( 'hcurrency', new \Cataya\View\Helper\Currency( Array(
        'locale' => $this->app->getConfig()->language
    )));
 
        $this->view->setHelper( 'hutil', new \Application\View\Helper\Util( $this->entityManager ) );
        $this->view->setHelper( 'hmedia', new \Application\View\Helper\Media( $this->entityManager ) );
        
    /*
     * Definindo e formatando o título
     */
    $this->setTitle( $this->app->getConfig()->geral->titulogeral );
 
    /*
     * Verificando token de acesso do cliente
     */
    if (isset($this->session->admin)) {
    
        $this->view->admin = $this->session->admin;
    
    } else if (!isset($this->session->admin) && isset($this->cookie->token) && !isset($this->request->redirect)) {
    
      $this->http->redirect('../clientes/token', array( 'redirect' => $this->router->getFullUrl() ) );
      
    }
    
    $this->limitDate = new \DateTime('2018-06-11 18:00:00');
    $this->view->limitDate = $this->limitDate;
 
    /*
     * Fingerprint para envio de formulário
     */
    $this->view->fingerprint = $this->http->getFingerprint();
 
    $this->loadStaticMessages();
  }
 
  /**
   * Renderizando dados das páginas
   * 
   * @param string $paginaUrl
   * @param string $idioma
   * @throws \Cataya\Controller\Exception
   * @return obj
   */
  protected function pagina( $paginaUrl, $idioma = 'pt-br' ) {
 
     if ( $this->app->getConfig()->frontend->active ) {
 
        /*
         * Verifica o cache em memcache da página
         */
      if ( $this->predis->exists( 'pagina_' . $paginaUrl ) ) {
 
        $pagina = $this->predis->jsonget( 'pagina_' . $paginaUrl );
        
      } else {
        
        $pagina = $this->entityManager->getRepository('models\Paginas')
                            ->selectByURLAndIdioma ( $paginaUrl, $idioma );
        
        if (!$pagina) {
          
          $pagina = $this->entityManager->getRepository('models\Paginas')
                         ->selectByURLAndIdioma ( '404', $this->app->getConfig()->language );
          
          if (!$pagina)
            throw new \Cataya\Controller\Exception('Página 404 não definda!');
          
          $this->http->setHeader('404');
        }
        
        $pagina['mediaDestaque'] = $this->entityManager->getRepository('models\PaginasMedia')
                                        ->selectByPaginaIdAndDestaque( $pagina['paginaId'] );
      }
      
      /*
       * Verifica e entrega a página cacheada em disco
       */
      if ( $pagina['cache'] && $pagina['cachetipo'] == 't' && $this->view->isCached( $paginaUrl ) === true ) {
      
          $this->view->render( $paginaUrl, array( 'cache' => true, 'lifetime' => $this->app->getConfig()->geral->cache, 'type' => 'layout' ) );
          die;
      }
      
      if (!empty($pagina['plugins']))
        $this->assets->loadPlugin( explode(',', $pagina['plugins']) );
 
      if (!empty($pagina['javascript'])) {
          
          $parts = explode(',', $pagina['javascript']);
          
          foreach($parts as $part) {
              
            $js = explode(':', $part);
 
              if (count($js) > 1) {
                $this->assets->setRecursiveJavascript( $js[1], $js[1], false, false );
            } else {
                $this->assets->setJavascript( 'main', array( $js[1] ), false, false );
            }
          }
      }
      
      $layout = $pagina['layout'] ? $pagina['layout'] : 'pagina';
      
      /*
       * Setando configurações
       */
      $this->configuracoes( $pagina['paginaId'] );
            
      /*
       * Meta include
       */
      $this->metainclude( $pagina['paginaId'] );
      
      /*
       * Extra fields
       */
      $this->campos( $pagina['paginaId'] );
            
      /*
       * Breadcrumb
       */
      $this->breadcrumb( $pagina['paginaId'] );
      
      /*
       * Keywords
       */
      $this->keywords( $pagina['paginaId'] );
      
      /*
       * Banners
       */
      $this->banners( $pagina['paginaId'] );
      
      /*
       * Menu
       */
      $this->menu( $pagina['paginaId'], $idioma );
      
      /*
       * Extensões fields
       */
      $this->extensoes( $pagina['paginaId'] );
      
      /*
       * Artigos em destaque
       */
      $this->artigosDestaque( $pagina['paginaId'] );
      
      /*
       * Cidades em destaque
       */
      $this->cidadesDestaque( $pagina['paginaId'] );
      
      /*
       * Carregamento de subpáginas
       */
      $this->subpaginas( $pagina['paginaId'], $idioma );
 
      /*
      * Mídias da página
      */
      $this->midias( $pagina['paginaId'] );
 
      /*
       * Regras de negócio
       */
      $this->business( $pagina['paginaId'], $idioma );
 
      /*
       * Tradução do conteúdo da página
       */
      $this->translation( $pagina['paginaId'] );
 
      /*
       * Grava dados na página na view
       */
      $this->view->page = $pagina;
      
      /*
       * Prepara o layout
       */
      $this->layout = $layout;
      
      /*
       * Definindo o título da página
       */
      if ( !in_array($pagina['url'], array('home', 'imoveis', 'fazendas', 'sitios', 'chacaras', 'haras') ) ) {
 
        if ($pagina['tituloseo']) {
          $this->setTitle($pagina['tituloseo']);
        } else {
          $this->setTitle($pagina['titulo']);
        }
      }
 
      /*
       * Prepara a página para ser cacheada
       */
      if ( $pagina['cache'] && $pagina['cachetipo'] == 't' )
          $this->params = array( 'cache' => true, 'lifetime' => $this->app->getConfig()->geral->cache, 'type' => 'layout' );
      
      return $pagina;
      
    } else {
      
      $this->layout = 'offline';
      $this->postActionEvent( array() );
      die;
      
    }
    
  }
  
    /**
     * Método para carregar artigos em destaque
     *
     * @param int $paginaId
     */
    protected function artigosDestaque( $paginaId, $idioma = 'pt-br' ) {
 
        if ( $this->predis->exists( 'artigos_destaque_' . $paginaId ) ) {
 
            $artigos = $this->predis->jsonget( 'artigos_destaque_' . $paginaId );
 
        } else {
 
            $artigos = $this->predis->jsonget( 'artigos_destaque' );
        }
 
        if ($artigos)
            $this->view->artigos_destaque = $artigos;
    }
    
    /**
     * 
     * @param int $paginaId
     */
    protected function cidadesDestaque( $paginaId ) {
        
        if( $this->predis->exists( 'cidades_destaque_home' ) ) {
            $this->view->cidadesDestaque = $this->predis->jsonget( 'cidades_destaque_home' );
 
        } else {
            $this->view->cidadesDestaque = $this->entityManager->getRepository('models\CidadesDestaques')
                    ->selectHome();
            $this->predis->jsonset( 'cidades_destaque_home', $this->view->cidadesDestaque);
        }
 
    }
 
    /**
     * Método para carregar campos
     *
     * @param int $paginaId
     */
    protected function campos( $paginaId ) {
 
        if ( $this->session->admin && $this->session->admin['gruponome'] == 'admin' ) {
 
            $camposPorPagina = $this->entityManager->getRepository('models\Campos')
                ->selectByPaginaId( $paginaId );
 
            $camposGeral = $this->entityManager->getRepository('models\Campos')
                ->selectByGeral();
 
            if (is_array($camposGeral) && is_array($camposPorPagina)) {
 
                $camposPorPagina = array_merge($camposGeral, $camposPorPagina);
 
            } else if (is_array($camposGeral) && !is_array($camposPorPagina)) {
 
                $camposPorPagina = $camposGeral;
            }
 
            $campos = array();
 
            foreach($camposPorPagina as $row) {
 
                $row['opcoes'] = @json_decode( $row['opcoes'], true );
 
                $json = @json_decode( $row['conteudo'], true );
 
                if (is_array($json))
                    $row['conteudo'] = $json;
 
                $campos[$row['nome']] = $row;
            }
 
            unset($camposPorPagina);
            unset($camposGeral);
 
        } else {
 
            $campos = $this->predis->jsonget( 'pagina_extra_' . $paginaId );
 
        }
 
        if ($campos) {
 
            foreach($campos as $row) {
 
                if ( $row['tipo'] == 'dynamic' ) {
 
                    foreach ( $row['opcoes'] as $elemento ) {
 
                        if ( isset($elemento['object']) ) {
 
                            $object = $this->predis->jsonget( $elemento['object'] );
 
                            if ( $object ) {
 
                                $viewObjects = array();
 
                                if ( $elemento['object'] == 'menus' ) {
 
                                    if ( isset($object['custom'][$elemento['menuId']]) )
                                      $viewObjects = $object['custom'][$elemento['menuId']];
 
                                }
 
                                if ( $elemento['object'] == 'artigos' ) {
                                    $viewObjects = &$object;
                                }
 
                                $this->view->$elemento['name'] = $viewObjects;
 
                            }
                        }
                    }
                }
 
                $campos[$row['nome']] = $row;
            }
        }
 
        $this->view->campos = $campos;
 
    }
 
    /**
     * Método para carregar extensões
     *
     * @param int $paginaId
     */
    protected function extensoes( $paginaId ) {
 
        if ($this->app->getConfig()->geral->extensions) {
 
            if ($this->session->admin && $this->session->admin['gruponome'] == 'admin') {
 
                $extensoes = $this->entityManager->getRepository('models\ExtensoesPagina')
                                    ->selectByPaginaId( $paginaId );
                
                if ( $extensoes ) {
                    
                    foreach ($extensoes as $key => $ext) {
                        
                        $extensaoCampos = $this->entityManager->getRepository('models\Campos')
                                                ->selectByExtensaoPaginaId( $ext['extensaoPaginaId'] );
                        
                        $extCampos = array();
                        
                        if ( $extensaoCampos ) {
                            foreach ($extensaoCampos as $extCampo) {
                                
                                $extCampo['opcoes'] = json_decode($extCampo['opcoes'], true);
                                $json = json_decode( $extCampo['conteudo'], true );
                                
                                if (is_array($json))
                                    $extCampo['conteudo'] = $json;
                                    
                                    $extCampos[$extCampo['nome']] = $extCampo;
                            }
                        }
                        
                        $extensoes[$key]['campos'] = $extCampos;
                    }
                }
 
            } else {
 
                $extensoes = $this->predis->jsonget( 'extensoes_' . $paginaId);
 
            }
 
            $ext = array();
 
            if ($extensoes) {
 
                usort($extensoes, function($a, $b) {
                    return $a['ordem'] - $b['ordem'];
                });
 
                foreach($extensoes as $row) {
                    
                    if ( !empty($row['objeto']) ) {
                        
                        $extensaoObjeto = new ExtensoesObjetos($row['objeto'], $this->entityManager, $this->predis);
                        
                        $this->view->{$row['objeto']} = $extensaoObjeto->getObjeto();
                    }
 
                    $ext[$row['elemento']][] = $row;
 
                    if (isset($row['plugins'])) {
 
                        $this->assets->loadPlugin( explode(',', $row['plugins']) );
                    }
 
                    if (!empty($row['javascript'])) {
 
                        $parts = explode(',', $row['javascript']);
 
                        foreach($parts as $part) {
 
                            $js = explode(':', $part);
 
                            if (count($js) > 1) {
 
                                $this->assets->setRecursiveJavascript( $js[1], $js[1], false, false );
 
                            } else {
 
                                $this->assets->setJavascript( 'main', array( $js[1] ), false, false );
 
                            }
                        }
                    }
                }
                
            }
 
            $this->view->extensoes = $ext;
 
            unset( $extensoes );
            unset( $ext );
        }
    }
  
  /**
   * Carrega breadcrumb por página do banco de dados
   * 
   * @param int $paginaId
   */
  protected function breadcrumb( $paginaId ) {
  
    $this->view->breadcrumb = $this->entityManager->getRepository('models\Paginas')
                       ->selectBreadcrumbByPaginaId( $paginaId );
  }
        
  /**
   * Carrega banners por página do cache
   * 
   * @param int $paginaId
   */
  protected function banners( $paginaId ) {
       
      $this->view->banners = $this->predis->jsonget( 'banners_' . $paginaId );
      
      if (!$this->view->banners)
          $this->view->banners = $this->predis->jsonget( 'banners_1' );
  }
 
    /**
     * Carrega menu do cache
     *
     * @param string $idioma
     */
  protected function menu( $paginaId, $idioma = 'pt-br' ) {
 
        /*
         * Menu em cache
         */
        $menus = $this->predis->jsonget( 'menus' );
        
        $menusPagina = array();
        $menusGeral = array();
 
        if ( is_array($menus) ) {
            
            if ( isset($menus['geral']) ) {
                
                $menusGeral = $menus['geral'];
            }
            
            if ( isset($menus[$paginaId]) ) {
                
              $menusPagina = $menus[$paginaId];
            }
            
            $menusPagina = array_merge($menusGeral, $menusPagina);
        }
        
        $this->view->menus = $menusPagina;
        
        $menuPagina = array();
        
        $menusPaginas = $this->predis->jsonget( 'menus_paginas' );
        
        if ( !empty($menusPaginas) ) {
            
            foreach ( $menusPaginas as $row ) {
                
                if ( in_array($paginaId, $row['paginasIds']) ) {
                    
                    $menuPagina = $row['submenus'];
                    break;
                }
            }
        }
        
        $this->view->menuPagina = $menuPagina;
    }
  
  /**
   * Retorna as palavras chaves para a view
   *
   * @param int $paginaId
   */
  protected function keywords( $paginaId ) {
  
      $keywords = $this->entityManager->getRepository('models\KeywordsPagina')
                     ->selectByPaginaId( $paginaId );
  
      $string = '';
  
      if ($keywords) {
          foreach($keywords as $row) {
              $string .= $row['keyword'] . ',';
          }
      }
  
      $this->view->keywords = $string;
  
      unset( $keywords );
  }
  
  /**
   * Retorna as meta informações da página
   *
   * @param int $paginaId
   */
  protected function metainclude( $paginaId ) {
  
      $meta = $this->entityManager->getRepository('models\Meta')
                 ->selectByPaginaId( $paginaId );
  
      if ($meta) {
        
          foreach($meta as $row) {
            
              if ($row['nome'] == 'title') {
                
                  $this->setTitle($row['conteudo']);
                  
              } else {
                
                  $this->setMeta($row['nome'], $row['conteudo']);
              }
          }
      }
  
      unset( $meta );
  }
 
  /**
   * Carregamento de subpáginas
   * 
   */
  protected function subpaginas( $paginaId = 1, $idioma = 'pt-br' ) {
 
    if ( $this->predis->jsonget( 'subpaginas_' . $paginaId ) ) {
 
      $this->view->subpages = $this->predis->jsonget( 'subpaginas_' . $paginaId );
 
    } else if ( $this->predis->jsonget( 'subpagina' ) ) {
 
      $paginas = $this->entityManager->getRepository('models\Paginas')
              ->selectAllWithoutParams();
 
      $parentPages = array();
 
      foreach($paginas as $pagina) {
 
        if ( $pagina['subpaginaId'] === $paginaId ) {
          
          $parentPages[] = $pagina;
 
        }
      }
 
      $this->view->subpages = $parentPages;
    }
 
    $this->view->subpages = [];
  }
 
  /**
   * Carregando mídias da página
   * 
   */
  protected function midias( $paginaId = null ) {
 
    if ( $this->predis->exists( 'midias_' .$paginaId ) ) {
 
      $this->view->medias = $this->view->jsonget( 'midias_' . $paginaId );
      
    } else {
      
      $midias = $this->entityManager->getRepository('models\PaginasMedia')
              ->selectByPaginaIdAndDestaque( $paginaId );
    }
 
    $this->view->medias = $midias;
 
  }
  
  /**
   * Carregando informações do cache importantes ao negócio
   * 
   */
  protected function business( $paginaId = 1, $idioma = 'pt-br' ) {
 
    $cidadesTipos = array();
    $cidadesPorPropriedades = array();
 
    if ( $this->predis->exists( 'imoveis_relacionados_home' ) ) {
 
      $cidadesPorPropriedades = $this->predis->jsonget( 'imoveis_relacionados_home' );
 
    } else {
 
      $cidadesPorPropriedades = $this->entityManager->getRepository('models\Imoveis')
                                 ->selectImoveisGroupByCidades();
                                 
      $this->predis->jsonset( 'imoveis_relacionados_home', $cidadesPorPropriedades);
 
    }
 
    if ( $this->predis->exists( 'imoveis_tipos_footer' ) ) {
 
      $cidadesTipos = $this->predis->jsonget( 'imoveis_tipos_footer' );
 
    } else {
 
      $cidadesTipos = $this->entityManager->getRepository('models\Imoveis')
                 ->selectImoveisByCidadesOrderByTipo();
                                 
      $this->predis->jsonset( 'imoveis_tipos_footer', $cidadesTipos);
 
    }
 
    $this->view->cidadesPorPropriedades = $cidadesPorPropriedades;
    
    $this->view->cidadesTipos = $cidadesTipos;
  }
 
  /**
   * 
   * Método para carregar tradução de mensagens 
   *  
   */ 
  protected function translation( $paginaId = 1 ) {
 
    if ( !isset($this->cookie->locale) ) {
      $this->cookie->locale = $this->defaultLocale;
    }
 
    $locale = $this->cookie->locale;
 
    $localePageKey = "locale_page_{$paginaId}_{$locale}";
 
    $pageField = [];
 
    if ( $this->predis->exists( $localePageKey ) ) {
 
      $pageField = $this->predis->jsonget( $localePageKey );
 
    } elseif ( $locale !== $this->defaultLocale ) {
  
      $translatedPageMessages = $this->entityManager->getRepository('models\TranslateAttributes')
                      ->selectByPaginaIdAndLocale( $paginaId, $locale );
  
      if ($translatedPageMessages) {
  
        $pageField = json_decode($translatedPageMessages['attributeData'], true);
  
        $this->predis->jsonset( $localePageKey, $pageField );
      }
    }
 
    if( empty($pageField) ) {
 
      $defaultPageMessages = $this->entityManager->getRepository('models\Paginas')
                    ->selectFieldsToTranslateByPaginaId( $paginaId );
  
      $pageField = $defaultPageMessages;
 
      $this->predis->jsonset( $localePageKey, $pageField );
    }
    
 
    $this->view->pageField = $pageField;
 
    $tipos = $this->getAllTipos();
 
    $translateModel = new TranslateModel( $this->entityManager, $this->predis );
 
    $this->view->allTipos = $translateModel->getLocaleTipos($tipos, $locale, $this->defaultLocale);
 
  }
 
  /**
   * Método para carregar as mensagens estáticas traduzidas
   */
  protected function loadStaticMessages() {
 
    $viewMessages = [];
    $staticField = [];
 
    if ( !isset($this->cookie->locale) ) {
      $this->cookie->locale = 'pt-br';
    }
 
    $locale = $this->cookie->locale;
 
    $staticMessages = $this->entityManager->getRepository('models\TranslateMessages')
                ->selectAllWithoutParams();
 
    if ( !empty($staticMessages) ) {
 
      foreach( $staticMessages as $message ) {
 
        $messageData = json_decode($message['messageData'], true);
 
        $viewMessages[$message['code']] = $messageData[$locale];
 
      };
 
    }          
 
    $staticField = $viewMessages;
 
    $this->view->staticField = $viewMessages;
    
  }
 
  /**
   * 
   * @return array
   */
  protected function getAllTipos() {
 
      $tipos = [];
      
      if ( $this->predis->exists( 'tipos_imoveis' ) ) {
      
          $tipos = $this->predis->jsonget( 'tipos_imoveis' );
          
      } else {
          
        $tipos = $this->entityManager->getRepository('models\Tipo')
                ->selectAllWithoutParams();
        
          $this->predis->jsonset( 'tipos_imoveis', $tipos );
      }
 
      return $tipos;
  }
    
  
  /**
   * Método para limpar cache
   * 
   */
  protected function limparCache() {
  
      if ($this->app->getConfig()->appmode == 'development') {
          $cachedb = new \Doctrine\Common\Cache\ArrayCache;
      } else {
          $cachedb = new \Doctrine\Common\Cache\ApcCache;
      }
  
      $cachedb->deleteAll();
  
      $this->predis->pipeline(function($pipe) {
          $pipe->flushdb();
      });
  }
  
  /**
   * Método para carregar layout da página
   *
   * @param string $layout
   */
  protected function setLayout( $layout, $params = null ) {
  
      if ($params)
          $this->params = $params;
       
      $this->layout = $layout;
  }
  
  /**
   * Carregando informações de configuração
   *
   * @param int $paginaId
   */
  private function configuracoes( $paginaId ) {
  
      $conf = $this->entityManager->getRepository('models\Configuracao')
                    ->selectByPaginaId( $paginaId );
  
      if (isset($conf)) {
          $grupos = array();
            
          foreach($conf as $row) {
              if (isset($row['grupo'])) {
                  $grupos[$row['grupo']][$row['nome']] = stripslashes($row['valor']);
              } else {
                  $this->app->getConfig()->$row['nome'] = stripslashes($row['valor']);
              }
          }
            
          $this->app->getConfig()->setArray($grupos);
      }
  
      unset($conf);
  
      return $this->app->getConfig();
  }
  
  /**
   * (non-PHPdoc)
   * @see \Cataya\Controller\AController::preActionEvent()
   */
  public function preActionEvent( array $params ) {
 
    if ($this->router->getUrlParsed()['original']) {
 
      $url = $this->router->getUrlParsed()['original'];
 
      if (\preg_match('/^(\/main)/', $url)) {
        
        $this->http->redirect(str_replace('/main/', '', $url), null, true);
      }
    }
      
      if ( $this->session->success ) {
          $this->view->success = true;
          $this->session->success = false;
      }
      
      if ( !empty($this->session->alert) ) {
          
          $this->view->alertMessage = $this->session->alert;
          $this->session->alert = '';
      }
  }
  
  /**
   * 
   * Sobrescrevendo o metodo postActionEvent para renderizar o layout certo.
   * (non-PHPdoc)
   * @see Cataya\Controller.AController::postActionEvent()
   */
  public function postActionEvent( array $params ) {
 
        /*
        * Formatando o título da página
        */
        $this->setTitleDirection( $this->app->getConfig()->geral->titulodirecao )
            ->formatTitle( $this->app->getConfig()->geral->titulohash );
 
        $module = preg_replace('/\\\/', '', $this->router->getModule());
 
        $module = $this->app->getConfig()->geral->mobile && $module == 'mobile' ? 'mobile' : $module;
 
        $this->assets->setRecursiveJavascript( 'main', 'main', $module );
 
        $this->assets->setJavascript( $module, array( 'app.js', 'custom.js' ), $module );
        $this->assets->setCss( $module, array( 'styles.css', 'custom.css' ), 'all', $module );
    
    if ($this->session->admin && $this->session->admin['gruponome'] == 'admin') {
 
        if (!is_array($this->assets->getPlugin('jquery')))
            $this->assets->loadPlugin( array( 'jquery' ), 'admin', false );
        
        if (!is_array($this->assets->getPlugin('jquery.ui')))
            $this->assets->loadPlugin( array( 'jquery.ui' ), 'admin', false );
      
      if (!is_array($this->assets->getPlugin('fontawesome')))
        $this->assets->loadPlugin( array( 'fontawesome' ), 'admin', false );
      
      if (!is_array($this->assets->getPlugin('wysihtml5')))
        $this->assets->loadPlugin( array( 'wysihtml5' => array( 'pt-BR' ) ), 'admin', false );
      
      if (!is_array($this->assets->getPlugin('fileuploader')))
        $this->assets->loadPlugin( array( 'fileuploader' ), 'admin', false );
      
      $this->assets->loadPlugin( array( 'cataya.frontend' ), 'admin', false );
      
    }
    
    if ( $this->layout )
      $this->view->layout( $this->layout, $this->params );
    
    parent::postActionEvent($params);
    
    /*
     * Verificar o tempo de execução da página
     */
    if ($this->view->debug)
            \Cataya\Utilities\Debugger\Tracking::end( $this->view->debug );
  }
  
  /**
   * (non-PHPdoc)
   * @see Cataya\Controller.AController::errorAction()
   */
  public function errorAction( array $params ) {
     
      if ( stripslashes($this->router->getModule()) === 'main' ) {
 
          if ( empty($params['pagina']) )
              $this->http->redirect('pagina', $params);
              
          if ( !empty($params['pagina']) && $params['pagina'] == 'home' )
              $this->http->redirect('../', null, true);
              
        if ( !empty($params['pagina']) )
              $this->pagina($params['pagina']);
      }
      
      $this->http->redirect('../404');
  }
#8Application\Controller\ControllerPagina->postActionEvent(Array(0 => imovel))
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Application/Frontcontroller/AFrontcontroller.php (281)
<?php
 
namespace Cataya\Application\Frontcontroller;
 
use Cataya\Application\Frontcontroller\Plugins\APlugin,
  ReflectionClass;
 
/**
 *
 * Abstract Class AFrontcontroller
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1
 * @copyright  GPL © 2010, hugomastromauro.com.
 * @access public
 * @package Cataya
 * @subpackage lib
 *
 */
abstract class AFrontcontroller
    implements \Cataya\Application\Frontcontroller\IFrontcontroller {
 
    /**
     * @var \Cataya\Application|Cataya\Application
     */
  protected $app;
 
    /**
     * @var string
     */
  protected $class;
 
  /**
   * @var \Cataya\Router\Router
   */
  protected $router;
 
  /**
   * @var \Cataya\View\View
   */
  protected $view;
 
  /**
   * @var \Cataya\Application\Request\Request
   */
  protected $request;
 
  /**
   * @var string
   */
  protected $controller;
 
  /**
   * @var \Cataya\Utilities\Session\Session
   */
  protected $session;
 
    /**
     * AFrontcontroller constructor.
     * @param \Cataya\Application $app
     */
  public function __construct( \Cataya\Application $app ) {
 
    $this ->app = $app;
 
    $this ->router = \Cataya\Loader\Loader::getInstance()
              ->loadClass( 'Cataya\Router\Router' );
 
    $this ->request = \Cataya\Loader\Loader::getInstance()
              ->loadClass( 'Cataya\Application\Request\Request',
                array( $this->router->getQuerystring() ) );
 
    $this ->view = \Cataya\Loader\Loader::getInstance()
              ->loadClass( 'Cataya\View\View',
                array( $this ) );
      
    $this->controller = "controllers" .
                $this ->app ->getConfig() ->namespaceseparator;
  }
  
  /**
     * Método que define e gera rotas
     *
     * @method callRouter
     * @access public
     * @return void
     */
  public function callRouter() {
 
        $conf = $this->config();
 
        $module = $this->app->getConfig()->controller->module->default;
 
        if ( isset( $this->app->getConfig()->geral->mobile ) && (bool) $this->app->getConfig()->geral->mobile ) {
          
          $detect = new \Cataya\Utilities\Device\MobileDetect();
          
          if ($detect->isMobile()) {
            
            if ( isset($this->app->getConfig()->geral->mobileredirect) && (bool) $this->app->getConfig()->geral->mobileredirect ) {
              
              $parts = explode('/', $_SERVER['REQUEST_URI']);
              
              if ($parts[1] != 'mobile') {
                header('Location: ' . $this->app->getConfig()->baseurl . 'mobile');
              }
            }
            
            $module = 'mobile';
          }
        }
 
        $this->router->setModule($module);
 
        /*
         * Definindo rotas
         */
        if ( isset( $conf->frontend->rotas ) ) {
 
            $routes = array();
 
            foreach(json_decode($conf->frontend->rotas, true) as $key => $value) {
                if (isset($value['module'])) {
                    $routes[$value['regex']] = "/{$value['module']}/{$value['route']}";
                } else {
                    $routes[$value['regex']] = "/{$module}/{$value['route']}";
                }
            }
 
            $this->router->setRoutes(array($routes));
        }
 
        /*
         * Definindo rotas para idiomas
         */
        if ( isset( $conf->frontend->idiomas ) ) {
 
            // CATAYA_TODO Implementar as rotas de idiomas
        }
 
        /*
         * Efetivando rotas
         */
        $this->router->route();
 
        return $this;
 
  }
    
  /**
     * Método que chama o controller
     *
     * @method callController
     * @access public
     * @return void
     */
  public function callController() {
 
      $controller = $this ->controller .
                      $this ->router ->getModule() .
                         $this ->router ->getController();
  
      $methodClass = $this ->router ->getMethod() . 'Action';
      $methodAjax = $this ->router ->getMethod() . 'AjaxAction';
      $methodHttp = $this ->router ->getMethod() . ucfirst(strtolower($_SERVER['REQUEST_METHOD'])) . 'Action';
      $newParam = $this ->router ->getMethod();
 
      $instObj = new ReflectionClass( $controller );
  
      $isService = false;
      
      if ($instObj->hasMethod($methodClass) === false) {
            
          $methodClass = $this ->app ->getConfig() ->controller ->method ->default;
            
          if ( $this->router->segments() >= 1 &&
              $this ->router ->getController() == $this ->app ->getConfig() ->controller ->default )
                  $methodClass = $this ->app ->getConfig() ->controller ->method ->error;
                
            if ( $this->router->segments() >= 1 &&
                preg_match("/{$this->router->segment(1)}$/", $this ->router ->getModule()) &&
                $this ->router ->getController() == $this ->app ->getConfig() ->controller ->default )
                    $methodClass = $this ->app ->getConfig() ->controller ->method ->error;
                  
            $params = $this ->router ->getParams();
            $params = array_merge(array_slice($params, 0, 0), array($newParam), array_slice($params, 0));
              
            if ( $instObj->implementsInterface( '\Cataya\Controller\IControllerServices' ) ) {
 
                $isService = true;
 
                if ( $instObj->hasMethod($methodHttp) === false ) {
 
                    $rMethod = strtolower($_SERVER['REQUEST_METHOD']);
 
                    if ($rMethod == 'post') {
                         
                        $methodClass = 'postAction';
                         
                    } else if ($rMethod == 'get') {
                          
                        $methodClass = 'getAction';
 
                    } else if ($rMethod == 'put') {
                         
                        $methodClass = 'putAction';
 
                    } else if ($rMethod == 'delete') {
                         
                        $methodClass = 'deleteAction';
                    }
 
                } else {
 
                    $methodClass = $methodHttp;
                }
 
                $this->router->setParams( $params );
 
            } else if ( $instObj->hasMethod($methodHttp) === true ) {
 
                $methodClass = $methodHttp;
 
            } else if ( $instObj->hasMethod($methodAjax) === true && (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') ) {
 
                $methodClass = $methodAjax;
                  
            } else {
 
                $this->router->setMethod( 'index' );
                $this->router->setParams( $params );
            }
                    
      } else if ( $instObj->hasMethod($methodAjax) === true && (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') ) {
 
          $methodClass = $methodAjax;
          
          $params = $this ->router ->getParams();
          
          $this->router->setParams( $params );
 
      } else {
          
        /*
         * 
         */
        if ( $instObj->hasMethod($methodHttp) === true ) {
            
          $methodClass = $methodHttp;
        }
        
        $params = $this ->router ->getParams();
        
        $this->router->setParams( $params );
      }
 
      $this->class = $instObj ->newInstanceArgs( array( $this ) );
  
      if ( $instObj->hasMethod('preActionEvent') ) {
          
          $this->class->preActionEvent( $this ->router ->getParams() );
      }
  
      if ($isService && $instObj->hasMethod('getAuthenticate') && $this->class->getAuthenticate()) {
          
          if ($this->class->authentication()) {
              
              $this->class->$methodClass( $this ->router ->getParams() );
              
          } else {
              
              $this->class->indexAction( $this ->router ->getParams() );
          }
          
      } else {
          
          $this->class->$methodClass( $this ->router ->getParams() );
      }
  
      if ( $instObj->hasMethod('postActionEvent') ) {
          $this->class->postActionEvent( $this ->router ->getParams() );
      }
  
      unset($instObj);
  }
 
  /**
   * Método que retorna a classe view
   *
   * @method getView
   * @access public
   * @return Cataya\View\View
   */
  public function getView() {
    return $this->view;
  }
 
  /**
   * Método que retorna a classe view
   *
   * @method getRequest
   * @access public
   * @return Cataya\Application\Request\Request
   */
  public function getRequest() {
    return $this->request;
  }
 
  /**
   * Método que retorna a classe Cataya\Application
   *
   * @method getApp
   * @access public
   * @return Cataya\Application
   */
  public function getApp() {
    return $this->app;
  }
 
  /**
   * Método que retorna a classe Cataya\Router
   *
   * @method getRouter
   * @access public
   * @return Cataya\Router
   */
  public function getRouter() {
    return $this->router;
  }
 
  /**
   * Método que retorna a classe Cataya\Utilities\Session\Session
   *
   * @method getSession
   * @access public
   * @return Cataya\Utilities\Session\Session
   */
  public function getSession() {
    return $this->session;
  }
 
  /**
   *
   * Enter description here ...
   *
   * @method setPlugin
   * @access public
   * @return Cataya\Applications\Frontcontroller\Plugins\Plugin
   */
    public function setPlugin( Array $plugin ) {
 
        if (is_array($plugin[0])) {
 
            foreach ($plugin as $key => $value) {
 
                if ( is_object( $value['object'] ) && $value['object'] instanceof APlugin ) {
                    if (!isset($this->view->$value['name'])) {
                        $this->view->$value['name'] = $value['object'];
                    }
                }
            }
 
        } else {
 
            if ( is_object( $plugin['object'] ) && $plugin['object'] instanceof APlugin ) {
                if (!isset($this->view->$plugin['name'])) {
                    $this->view->$plugin['name'] = $plugin['object'];
                }
            }
        }
    }
 
    /**
     * @return \Cataya\Cataya\Config
     */
    private function config() {
 
        $conf = $this->app->bootstrap()->stack('initDoctrine')->getRepository('models\Configuracao')
                    ->selectByPaginaId(0);
 
        $grupos = array();
 
        foreach($conf as $row) {
      if (isset($row['grupo'])) {
                if (!isset($this->app->getConfig()->{$row['grupo']}->{$row['nome']}))
                    $grupos[$row['grupo']][$row['nome']] = preg_replace('/(?<!:)\/{1,}/', '/', $row['valor']); //stripslashes($row['valor']);
            } else {
                if (!isset($this->app->getConfig()->{$row['grupo']}->{$row['nome']}))
                    $this->app->getConfig()->{$row['nome']} = preg_replace('/(?<!:)\/{1,}/', '/', $row['valor']); //stripslashes($row['valor']);
            }
        }
 
        $this->app->getConfig()->setArray($grupos);
        
        return $this->app->getConfig();
    }
 
    /**
     *
     * @method checkAdmin
     * @access private
     * @return void
     */
    private function checkAdmin() {
 
        if ($this ->router ->getModule() == 'admin\\') {
            $this->app->getConfig()->remove('template');
        }
    }
#9Cataya\Application\Frontcontroller\AFrontcontroller->callController()
/home/mercadodeterras/www/mercadodeterras.com.br/src/lib/Cataya/Application/Bootstrap/ABootstrap.php (72)
<?php
 
namespace Cataya\Application\Bootstrap;
 
/** 
 * 
 * Classe Abstrata ABootstrap
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 0.1 
 * @copyright  GPL © 2010, hugomastromauro.com. 
 * @access public  
 * @package Cataya 
 * @subpackage lib
 *  
 */ 
abstract class ABootstrap 
  extends \Cataya\AObject
    implements \Cataya\Application\Bootstrap\IBootstrap {
  
  /**
   * 
   * Enter description here ...
   * @var Cataya\Application
   */
  protected $app;  
  
  /**
   * Método contrutor da Classe Bootstrap
   * 
   * @method __construct
   * @access public
   * @param Cataya_Application $app
   * @return void
   */
  public function __construct( \Cataya\Application &$app ) {
    
    /*
     * Referencia do objeto da aplicacao para propagacao na aplicacao
     */
    $this->app = $app;  
    
    /*
     * Chamando o objeto padrão
     */
    parent::__construct();
  }
 
  /**
   * Método que inicializa a aplicação
   * 
   * @method run
   * @access public
   * @return void
   */
  public function run() {      
    
    /*
     * Instanciando a classe frontcontroller e encaminhando a ela a instancia da aplicação.
     * Aqui ela despacha os plugins e outros helpers da aplicaçao
     * 
     */
    $front = \Cataya\Loader\Loader::getInstance() 
          ->loadClass( 'Cataya\Application\Frontcontroller\Frontcontroller', 
            array( $this ->app ) );
    
    /*
     * Chamando o controller na classe frontcontroller.
     * Depois de todos os despachos feitos, e feita a chamada ao controller da aplicacao
     * 
     */
    $front ->callRouter() ->callController();
  }
  
  /**
   *
   * @param string $route
   * @param string $method
   */
  public function setVirtualRoute( $route, array $params = array(), $method = 'GET' ) {
       
      if (strtolower($method) == 'post') {
          $_POST = $params;
      }
       
      $url = parse_url($this->app->getConfig()->baseurl);
       
      $_SERVER['SERVER_NAME'] = $url['host'];
       
      $_SERVER['REQUEST_URI'] = $route;
      $_SERVER['REQUEST_METHOD'] = $method;
  
      return $this;
  }
  
  /**
   * Método que inicializa e confirma as configurações.
   * 
   * @method initConfirmSettings
   * @access public
   * return void
   */
  public function initConfirmSettings() {
        
    if (!isset($this ->app->getConfig() ->controller ->error))
      $this ->app->getConfig() ->controller ->error = 'controllererror';
      
    if (!isset($this ->app->getConfig() ->controller ->method))
      $this ->app->getConfig() ->controller ->method = 'indexaction';
 
    if (!isset($this ->app->getConfig() ->apppath))
      throw new \Cataya\Application\Bootstrap\Exception('Diretório da aplicação não informado!');
      
    if (!isset($this ->app->getConfig() ->controller ->path))
      throw new \Cataya\Application\Bootstrap\Exception('Diretório dos controllers não informado!');
    
  }
#10Cataya\Application\Bootstrap\ABootstrap->run()
/home/mercadodeterras/www/mercadodeterras.com.br/src/index.php (39)
<?php
 
 
/**
 * Cataya Framework
 *
 * index
 *
 * @author Hugo Mastromauro <hugomastromauro@gmail.com>
 * @version 3.0
 * @copyright  GPL © 2010, hugomastromauro.com.
 *
 */
 
defined('CATAYA_LIB')
|| define('CATAYA_LIB', realpath(dirname(__FILE__) . '/lib/'));
 
defined('APPLICATION_LIB')
|| define('APPLICATION_LIB', realpath(dirname(__FILE__) . '/application/lib/'));
 
set_include_path(implode(PATH_SEPARATOR, array(
 
            CATAYA_LIB,
            APPLICATION_LIB,
            get_include_path(),
 
        )
    )
);
 
if (file_exists ('vendor/autoload.php')){
    require 'vendor/autoload.php';
}
 
include 'lib/Cataya/Application.php';
 
$app = new \Cataya\Application();