Created
June 18, 2015 00:48
-
-
Save NiltonMorais/36b8d1e2d3b7b6036dc4 to your computer and use it in GitHub Desktop.
No localhost a aplicação funciona normal, mas quando subo pro servidor dar esse erro: Fatal error: Using $this when not in object context in /home/site/public_html/module/Site/view/partial/colunas_sort_arquivos.phtml on line 4 O que pode ser? versão do php? a versão do php do servidor é 5.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Site\Controller; | |
| use Site\Form\Upload; | |
| use Zend\Mvc\Controller\AbstractActionController; | |
| use Zend\View\Model\ViewModel; | |
| class ArquivoController extends AbstractActionController | |
| { | |
| public function indexAction() | |
| { | |
| $paramsUrl = array( | |
| 'pagina_atual' => $this->params()->fromQuery('pagina', 1), | |
| 'itens_pagina' => $this->params()->fromQuery('itens_pagina', 10), | |
| 'coluna_nome' => $this->params()->fromQuery('coluna_nome', 'data_criacao'), | |
| 'coluna_sort' => $this->params()->fromQuery('coluna_sort', 'DESC'), | |
| 'search' => $this->params()->fromQuery('search', null), | |
| ); | |
| $paginacao = $this->getServiceLocator()->get('ModelVwArquivos')->fetchPaginator( | |
| $paramsUrl['pagina_atual'], | |
| $paramsUrl['itens_pagina'], | |
| "{$paramsUrl['coluna_nome']} {$paramsUrl['coluna_sort']}", | |
| $paramsUrl['search'], | |
| 5 // itens por paginação | |
| ); | |
| return new ViewModel(array('data' => $paginacao) + $paramsUrl); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Site\Model; | |
| use Zend\Db\TableGateway\TableGateway; | |
| use \Exception; | |
| // import for fetchPaginator | |
| use Zend\Db\Sql\Select, | |
| Zend\Db\ResultSet\HydratingResultSet, | |
| Zend\Stdlib\Hydrator\Reflection, | |
| Zend\Paginator\Adapter\DbSelect, | |
| Zend\Paginator\Paginator; | |
| class ArquivosTable { | |
| protected $tableGateway; | |
| public function __construct(TableGateway $tableGateway) { | |
| $this->tableGateway = $tableGateway; | |
| } | |
| public function fetchPaginator($pagina = 1, $itensPagina = 10, $ordem = 'NOME_ARQUIVO ASC', $like = null, $itensPaginacao = 5) | |
| { | |
| $select = (new Select('vw_arquivos')); | |
| $select->order($ordem); | |
| if (isset($like)) { | |
| $select | |
| ->where | |
| ->like('ID_ARQUIVO', "%{$like}%") | |
| ->or | |
| ->like('NOME_ARQUIVO', "%{$like}%") | |
| ->or | |
| ->like('NOME_CATEGORIA', "%{$like}%") | |
| ; | |
| } | |
| $resultSet = new HydratingResultSet(new Reflection(), new VwArquivos()); | |
| $paginatorAdapter = new DbSelect( | |
| $select, | |
| $this->tableGateway->getAdapter(), | |
| $resultSet | |
| ); | |
| $paginator = (new Paginator($paginatorAdapter)); | |
| $paginator->setCurrentPageNumber((int) $pagina); | |
| $paginator->setItemCountPerPage((int) $itensPagina); | |
| $paginator->setPageRange((int) $itensPaginacao); | |
| return $paginator; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $estruturaColuna = function($label, $coluna_nome) { | |
| $html = ''; | |
| $html .= "<a title='Ordenar por $coluna_nome' href='{$this->url('arquivo', array('action' => 'index'), array('query' => array('pagina' => $this->pagina_atual, 'coluna_nome' => $coluna_nome, 'coluna_sort' => ($this->coluna_nome != $coluna_nome ? 'ASC' : ($this->coluna_sort == 'DESC' ? 'ASC' : 'DESC')), 'itens_pagina' => $this->itens_pagina, 'search' => $this->search)))}'>"; | |
| if ($this->coluna_nome == $coluna_nome) { | |
| $icon = $this->coluna_sort == 'ASC' ? '' : '-alt'; | |
| $html .= "<span class='glyphicon glyphicon-sort-by-attributes{$icon}'></span> "; | |
| } | |
| $html .= $label; | |
| return $html; | |
| }; | |
| ?> | |
| <tr> | |
| <th> | |
| <?php echo $estruturaColuna('ID', 'id_arquivo'); ?> | |
| </th> | |
| <th> | |
| <?php echo $estruturaColuna('Nome', 'nome_arquivo'); ?> | |
| </th> | |
| <th> | |
| Endereço | |
| </th> | |
| <th> | |
| <?php echo $estruturaColuna('Categoria', 'nome_categoria'); ?> | |
| </th> | |
| <th> | |
| <?php echo $estruturaColuna('Dt. Cadastro', 'data_criacao'); ?> | |
| </th> | |
| <th>Ação</th> | |
| </tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <div class="topo-table"> | |
| <a href="arquivo/novo" class="btn btn-default" title="Novo"><span class="glyphicon glyphicon-plus"></span> Novo</a> | |
| <div class="btn-group" title="Itens por Página"> | |
| <button type="button" class="btn btn-default"><?php echo $this->itens_pagina?></button> | |
| <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> | |
| <span class="caret"></span> | |
| </button> | |
| <ul class="dropdown-menu pull-right" style="min-width: 75px" role="menu"> | |
| <?php foreach (array('1','5', '10', '25', '50', '100') as $value): ?> | |
| <li class="<?php echo ($this->itens_pagina == $value ? 'active' : ''); ?>"><a href="<?php echo $this->url('arquivo', array('action' => 'index'), array('query' => array('pagina' => $this->pagina_atual, 'coluna_nome' => $coluna_nome, 'coluna_sort' => $this->coluna_sort, 'itens_pagina' => $value, 'search' => $this->search)))?>"><?php echo $value; ?></a></li> | |
| <?php endforeach;?> | |
| </ul> | |
| </div> | |
| <form class="form-inline pull-right" role="form"> | |
| <div class="form-group"> | |
| <label class="sr-only" for="localizar">Buscar...</label> | |
| <input type="search" name="search" value="<?php echo $this->search; ?>" class="form-control" id="localizar" placeholder="Buscar arquivo..."> | |
| </div> | |
| <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button> | |
| </form> | |
| </div> | |
| <br /> | |
| <div class="corpo-table"> | |
| <table class="table table-striped table-bordered table-hover"> | |
| <thead> | |
| <?php echo $this->partial('partial/colunas_sort_arquivos'); ?> | |
| </thead> | |
| <tbody> | |
| <?php foreach ($this->data as $arquivo) : ?> | |
| <tr> | |
| <td class="text-center"><?php echo $arquivo->ID_ARQUIVO; ?></td> | |
| <td><?php echo $arquivo->NOME_ARQUIVO; ?></td> | |
| <td><?php echo $arquivo->CAMINHO_ARQUIVO; ?></td> | |
| <td><?php echo $arquivo->NOME_CATEGORIA; ?></td> | |
| <td><?php echo $arquivo->DATA_CRIACAO; ?></td> | |
| <td class="text-center"> | |
| <a class="btn btn-xs btn-info" title="Visualizar" href="<?php echo 'arquivo/detalhes/'.$arquivo->ID_ARQUIVO; ?>"><span class="glyphicon glyphicon-new-window"></span></a> | |
| <a class="btn btn-xs btn-warning" title="Editar" href="<?php echo 'arquivo/editar/'.$arquivo->ID_ARQUIVO; ?>"><span class="glyphicon glyphicon-pencil"></span></a> | |
| <a class="btn btn-xs btn-danger" title="Deletar" href="<?php echo 'arquivo/deletar/'.$arquivo->ID_ARQUIVO; ?>"><span class="glyphicon glyphicon-trash"></span></a> | |
| </td> | |
| </tr> | |
| <?php endforeach; ?> | |
| </tbody> | |
| </table> | |
| <?php | |
| // controle de paginação | |
| echo $this->paginationControl( | |
| // objeto contentdo os contatos | |
| $this->data, | |
| // tipo de style da paginação | |
| 'Sliding', | |
| // partial que vai conter o html da paginação | |
| array(/*path*/ 'partial/paginator.phtml', /*modulo*/ 'Arquivo'), | |
| // link rotas da paginação | |
| array('route' => 'arquivo') | |
| ); | |
| ?> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $urlPaginator = function($pagina) { | |
| $uri = Zend\Uri\UriFactory::factory($this->serverUrl(true)); | |
| $query = $uri->getQueryAsArray(); | |
| $query['pagina'] = $pagina; | |
| return $this->url($this->route, [], ['query' => $query]); | |
| }; | |
| ?> | |
| <?php if ($this->pageCount): ?> | |
| <div> | |
| <ul class="pagination pagination-sm"> | |
| <li class="disabled"> | |
| <a href="#"> | |
| Total Páginas: <?php echo $this->pageCount ?> | |
| </a> | |
| </li> | |
| <li class="disabled"> | |
| <a href="#"> | |
| Total Itens: <?php echo $this->totalItemCount ?> | |
| </a> | |
| </li> | |
| </ul> | |
| <ul class="pagination pull-right pagination-sm"> | |
| <!-- Previous page link --> | |
| <?php if (isset($this->previous)): ?> | |
| <li> | |
| <a href="<?php echo $urlPaginator($this->previous); ?>"> | |
| << | |
| </a> | |
| </li> | |
| <?php else: ?> | |
| <li class="disabled"> | |
| <a href="#"> | |
| << | |
| </a> | |
| </li> | |
| <?php endif; ?> | |
| <!-- First page link --> | |
| <?php if (isset($this->previous) && ($this->previous > $this->first + 2)): ?> | |
| <li> | |
| <a href="<?php echo $urlPaginator($this->first); ?>"> | |
| <?php echo $this->first ?> | |
| </a> | |
| </li> | |
| <li class="disabled"> | |
| <a href="#">...</a> | |
| </li> | |
| <?php endif; ?> | |
| <!-- Numbered page links --> | |
| <?php foreach ($this->pagesInRange as $page): ?> | |
| <?php if ($page != $this->current): ?> | |
| <li> | |
| <a href="<?php echo $urlPaginator($page); ?>"> | |
| <?php echo $page; ?> | |
| </a> | |
| </li> | |
| <?php else: ?> | |
| <li class="active"> | |
| <a href="#"><?php echo $page; ?></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php endforeach; ?> | |
| <!-- Last page link --> | |
| <?php if (isset($this->next) && ($this->next + 2 < $this->last)): ?> | |
| <li class="disabled"> | |
| <a href="#">...</a> | |
| </li> | |
| <li> | |
| <a href="<?php echo $urlPaginator($this->last); ?>"> | |
| <?php echo $this->last ?> | |
| </a> | |
| </li> | |
| <?php endif; ?> | |
| <!-- Next page link --> | |
| <?php if (isset($this->next)): ?> | |
| <li> | |
| <a href="<?php echo $urlPaginator($this->next); ?>"> | |
| >> | |
| </a> | |
| </li> | |
| <?php else: ?> | |
| <li class="disabled"> | |
| <a href="#"> | |
| >> | |
| </a> | |
| </li> | |
| <?php endif; ?> | |
| </ul> | |
| </div> | |
| <?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment