Commit aca5ace14cf8f56a7db272ed8d3c63b9653743a1
1 parent
e5f8a8bd
Exists in
master
Refactorings em Core_Controller_Page_*Controller.
Showing
3 changed files
with
75 additions
and
15 deletions
Show diff stats
ieducar/lib/Core/Controller/Page/EditController.php
| ... | ... | @@ -366,8 +366,15 @@ abstract class Core_Controller_Page_EditController |
| 366 | 366 | { |
| 367 | 367 | if (isset($this->getRequest()->id)) { |
| 368 | 368 | if ($this->getDataMapper()->delete($this->getRequest()->id)) { |
| 369 | - $this->redirect($this->getDispatcher()->getControllerName() . '/' . | |
| 370 | - $this->getOption('delete_success')); | |
| 369 | + if (is_array($this->getOption('delete_success_params'))) { | |
| 370 | + $params = http_build_query($this->getOption('delete_success_params')); | |
| 371 | + } | |
| 372 | + | |
| 373 | + $this->redirect( | |
| 374 | + $this->getDispatcher()->getControllerName() . '/' . | |
| 375 | + $this->getOption('delete_success') . | |
| 376 | + (isset($params) ? '?' . $params : '') | |
| 377 | + ); | |
| 371 | 378 | } |
| 372 | 379 | } |
| 373 | 380 | return FALSE; | ... | ... |
ieducar/lib/Core/Controller/Page/ListController.php
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | * @license @@license@@ |
| 26 | 26 | * @package Core_Controller |
| 27 | 27 | * @since Arquivo disponível desde a versão 1.1.0 |
| 28 | - * @version $Id: /ieducar/branches/teste/ieducar/lib/Core/Controller/Page/Abstract.php 646 2009-11-12T21:54:25.107288Z eriksen $ | |
| 28 | + * @version $Id$ | |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | require_once 'Core/View/Tabulable.php'; |
| ... | ... | @@ -86,6 +86,29 @@ class Core_Controller_Page_ListController extends clsListagem implements Core_Vi |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | + * Retorna os registros a serem exibidos na listagem. | |
| 90 | + * | |
| 91 | + * Subclasses devem sobrescrever este método quando os parâmetros para | |
| 92 | + * CoreExt_DataMapper::findAll forem mais específicos. | |
| 93 | + * | |
| 94 | + * @return array (int => CoreExt_Entity) | |
| 95 | + */ | |
| 96 | + public function getEntries() | |
| 97 | + { | |
| 98 | + $mapper = $this->getDataMapper(); | |
| 99 | + return $mapper->findAll(); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Configura o botão de ação padrão para a criação de novo registro. | |
| 104 | + */ | |
| 105 | + public function setAcao() | |
| 106 | + { | |
| 107 | + $this->acao = 'go("edit")'; | |
| 108 | + $this->nome_acao = 'Novo'; | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 89 | 112 | * Implementação padrão para as subclasses que estenderem essa classe. Cria |
| 90 | 113 | * uma lista de apresentação de dados simples utilizando o mapeamento de |
| 91 | 114 | * $_tableMap. |
| ... | ... | @@ -97,10 +120,11 @@ class Core_Controller_Page_ListController extends clsListagem implements Core_Vi |
| 97 | 120 | { |
| 98 | 121 | $headers = $this->getTableMap(); |
| 99 | 122 | |
| 123 | + // Configura o cabeçalho da listagem. | |
| 100 | 124 | $this->addCabecalhos(array_keys($headers)); |
| 101 | 125 | |
| 102 | - $mapper = $this->getDataMapper(); | |
| 103 | - $entries = $mapper->findAll(); | |
| 126 | + // Recupera os registros para a listagem. | |
| 127 | + $entries = $this->getEntries(); | |
| 104 | 128 | |
| 105 | 129 | // Paginador |
| 106 | 130 | $this->limite = 20; |
| ... | ... | @@ -122,11 +146,12 @@ class Core_Controller_Page_ListController extends clsListagem implements Core_Vi |
| 122 | 146 | $this->addLinhas($item); |
| 123 | 147 | } |
| 124 | 148 | |
| 125 | - $this->addPaginador2("", count($entries), $_GET, $this->nome, $this->limite); | |
| 149 | + $this->addPaginador2('', count($entries), $_GET, $this->nome, $this->limite); | |
| 126 | 150 | |
| 127 | - $this->acao = "go(\"edit\")"; | |
| 128 | - $this->nome_acao = "Novo"; | |
| 151 | + // Configura o botão padrão de ação para a criação de novo registro. | |
| 152 | + $this->setAcao(); | |
| 129 | 153 | |
| 130 | - $this->largura = "100%"; | |
| 154 | + // Largura da tabela HTML onde se encontra a listagem. | |
| 155 | + $this->largura = '100%'; | |
| 131 | 156 | } |
| 132 | 157 | } |
| 133 | 158 | \ No newline at end of file | ... | ... |
ieducar/lib/Core/Controller/Page/ViewController.php
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | * @license @@license@@ |
| 26 | 26 | * @package Core_Controller |
| 27 | 27 | * @since Arquivo disponível desde a versão 1.1.0 |
| 28 | - * @version $Id: /ieducar/branches/teste/ieducar/lib/Core/Controller/Page/Abstract.php 646 2009-11-12T21:54:25.107288Z eriksen $ | |
| 28 | + * @version $Id$ | |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | require_once 'Core/View/Tabulable.php'; |
| ... | ... | @@ -96,6 +96,36 @@ class Core_Controller_Page_ViewController extends clsDetalhe implements Core_Vie |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | + * Configura a URL padrão para a ação de Edição de um registro. | |
| 100 | + * | |
| 101 | + * Por padrão, cria uma URL "edit/id", onde id é o valor do atributo "id" | |
| 102 | + * de uma instância CoreExt_Entity. | |
| 103 | + * | |
| 104 | + * @param CoreExt_Entity $entry A instância atual recuperada | |
| 105 | + * ViewController::Gerar(). | |
| 106 | + */ | |
| 107 | + public function setUrlEditar(CoreExt_Entity $entry) | |
| 108 | + { | |
| 109 | + $this->url_editar = CoreExt_View_Helper_UrlHelper::url( | |
| 110 | + 'edit', array('query' => array('id' => $entry->id)) | |
| 111 | + ); | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * Configura a URL padrão para a ação Cancelar da tela de Edição de um | |
| 116 | + * registro. | |
| 117 | + * | |
| 118 | + * Por padrão, cria uma URL "index". | |
| 119 | + * | |
| 120 | + * @param CoreExt_Entity $entry A instância atual recuperada | |
| 121 | + * ViewController::Gerar(). | |
| 122 | + */ | |
| 123 | + public function setUrlCancelar(CoreExt_Entity $entry) | |
| 124 | + { | |
| 125 | + $this->url_cancelar = CoreExt_View_Helper_UrlHelper::url('index'); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 99 | 129 | * Implementação padrão para as subclasses que estenderem essa classe. Cria |
| 100 | 130 | * uma tela de apresentação de dados simples utilizando o mapeamento de |
| 101 | 131 | * $_tableMap. |
| ... | ... | @@ -106,7 +136,7 @@ class Core_Controller_Page_ViewController extends clsDetalhe implements Core_Vie |
| 106 | 136 | public function Gerar() |
| 107 | 137 | { |
| 108 | 138 | $headers = $this->getTableMap(); |
| 109 | - $mapper = $this->getDataMapper(); | |
| 139 | + $mapper = $this->getDataMapper(); | |
| 110 | 140 | |
| 111 | 141 | $this->titulo = $this->getBaseTitulo(); |
| 112 | 142 | $this->largura = "100%"; |
| ... | ... | @@ -125,9 +155,7 @@ class Core_Controller_Page_ViewController extends clsDetalhe implements Core_Vie |
| 125 | 155 | } |
| 126 | 156 | } |
| 127 | 157 | |
| 128 | - $this->url_editar = CoreExt_View_Helper_UrlHelper::url( | |
| 129 | - 'edit', array('query' => array('id' => $entry->id)) | |
| 130 | - ); | |
| 131 | - $this->url_cancelar = CoreExt_View_Helper_UrlHelper::url('index'); | |
| 158 | + $this->setUrlEditar($entry); | |
| 159 | + $this->setUrlCancelar($entry); | |
| 132 | 160 | } |
| 133 | 161 | } |
| 134 | 162 | \ No newline at end of file | ... | ... |