Rajout des aides de vue et d'action
authorSébastien CHAZALLET <s.chazallet@gmail.com>
Sun, 18 Nov 2012 18:37:05 +0000 (19:37 +0100)
committerSébastien CHAZALLET <s.chazallet@gmail.com>
Sun, 18 Nov 2012 18:37:05 +0000 (19:37 +0100)
data/jeu_essai.db
module/Application/view/layout/layout.phtml
module/Galerie/Module.php
module/Galerie/config/module.config.php
module/Galerie/src/Galerie/Controller/IndexController.php
module/Galerie/view/galerie/index/index.phtml

index 0e2a0dc..6954bf8 100644 (file)
Binary files a/data/jeu_essai.db and b/data/jeu_essai.db differ
index 6922bbe..9ef159f 100644 (file)
             </div>
         </div>
         <div class="container">
+<?php
+    $views = $this->viewModel()->getCurrent()->getChildren();
+    $main_view = $views[0];
+    $variables = $main_view->getVariables();
+?>
+<?php if (isset($variables['infos'])) : ?>
+<?php foreach($main_view->infos as $info): ?>
+    <?php echo $this->format($info, 'info'); ?>
+<?php endforeach; ?>
+<?php endif; ?>
+<?php if (isset($main_view->warnings)) : ?>
+<?php foreach($warnings as $warning): ?>
+    <?php echo $this->format($warning, 'warning'); ?>
+<?php endforeach; ?>
+<?php endif; ?>
+<?php if (isset($main_view->errors)) : ?>
+<?php foreach($errors as $error): ?>
+    <?php echo $this->format($error, 'error'); ?>
+<?php endforeach; ?>
+<?php endif; ?>
+            <hr />
             <?php echo $this->content; ?>
-            <hr>
+            <hr />
             <footer>
                 <p>&copy; 2005 - 2012 by Zend Technologies Ltd. <?php echo $this->translate('All rights reserved.') ?></p>
             </footer>
index 32cd7ae..ab7faad 100644 (file)
@@ -6,7 +6,7 @@ use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
 use Zend\ModuleManager\Feature\ConfigProviderInterface;
 use Zend\ModuleManager\Feature\BootstrapListenerInterface;
 use Zend\ModuleManager\Feature\ServiceProviderInterface;
-
+use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
 
 use Zend\EventManager\EventInterface;
 use Zend\Mvc\ModuleRouteListener;
@@ -16,12 +16,15 @@ use Galerie\Model\GalerieTable;
 use Galerie\Model\GalerieInfoTable;
 use Galerie\Form\GalerieForm;
 
+use Custom\View\Helper\Format;
+
 
 class Module implements
     AutoloaderProviderInterface,
     ConfigProviderInterface,
     BootstrapListenerInterface,
-    ServiceProviderInterface
+    ServiceProviderInterface,
+    ViewHelperProviderInterface
 {
 
     public function getAutoloaderConfig() 
@@ -72,4 +75,19 @@ class Module implements
             ),
         );
     }
+
+    public function getViewHelperConfig() 
+    { 
+        return array( 
+            'factories' => array( 
+                'format' => function($sm) { 
+                    return new Format;
+                }, 
+            ), 
+        ); 
+    } 
+    
+    
+    
+    
 }
index 569165c..5c06d9c 100644 (file)
@@ -4,7 +4,13 @@ return array(
     'controllers' => array(
         'invokables' => array(
             'Galerie\Controller\Index' =>
-                'Galerie\Controller\IndexController'
+                'Galerie\Controller\IndexController',
+        ),
+    ),
+    'controller_plugins' => array(
+        'invokables' => array(
+            'MessageGetter' =>
+                'Custom\Mvc\Controller\Plugin\MessageGetter',
         ),
     ),
     'view_manager' => array(
index bacff03..fefa823 100644 (file)
@@ -57,10 +57,8 @@ class IndexController extends AbstractActionController
 
 
     public function indexAction() 
-    { 
-        return new ViewModel(array(
-            'messages' => $this->flashMessenger()->getMessages(),
-        )); 
+    {
+        return new ViewModel($this->MessageGetter());
     } 
 
     public function listAction() 
@@ -164,10 +162,12 @@ class IndexController extends AbstractActionController
                 $this->_getGalerieTable()->save($galerie);
 
                 $translator = $this->_getTranslator();
+                $messenger = $this->flashMessenger();
+                $messenger->setNamespace('infos');
                 if ($is_new) {
-                    $this->flashMessenger()->addMessage($translator->translate('Galerie_added', 'galerie'));
+                    $messenger->addMessage($translator->translate('Galerie_added', 'galerie'));
                 } else {
-                    $this->flashMessenger()->addMessage($translator->translate('Galerie_updated', 'galerie'));
+                    $messenger->addMessage($translator->translate('Galerie_updated', 'galerie'));
                 }
                 // Redirection à l'ancienne mode
                 //return $this->redirect()->toRoute('galerie');
index 546eb7e..10301d8 100644 (file)
@@ -1,9 +1,5 @@
 <h1><?php echo $this->translate('Galerie_index_title', 'galerie'); ?></h1>
 
-<?php foreach($messages as $message): ?>
-    <div class='alert-info'><?php echo $message; ?></div>
-<?php endforeach; ?>
-
 <table id="galeries" class="sorted">
        <thead>
                <tr>