Rajout d'un diagramme (galerie/pie pour index)
authorSébastien CHAZALLET <s.chazallet@gmail.com>
Thu, 29 Nov 2012 18:14:18 +0000 (19:14 +0100)
committerSébastien CHAZALLET <s.chazallet@gmail.com>
Thu, 29 Nov 2012 18:14:18 +0000 (19:14 +0100)
module/Galerie/autoload_classmap.php
module/Galerie/config/module.config.php
module/Galerie/src/Galerie/Controller/IndexController.php
module/Galerie/src/Galerie/Graph/Test.php [new file with mode: 0644]
module/Galerie/view/galerie/index/index.phtml

index f59b8ba..0cb5d20 100644 (file)
@@ -4,5 +4,7 @@ return array(
     'Galerie\Controller\IndexController' =>
         __DIR__ . '/src/Galerie/Controller/IndexController.php',
     'Galerie\Export\GalerieWorkbook' =>
-        __DIR__ . '/src/Galerie/Export/GalerieWorkbook.php'
+        __DIR__ . '/src/Galerie/Export/GalerieWorkbook.php',
+    'Galerie\Graph\Test' =>
+        __DIR__ . '/src/Galerie/Graph/Test.php'
 );
index c760d83..4704435 100644 (file)
@@ -150,6 +150,16 @@ return array(
                         ),
                         'verb' => 'get',
                     ),
+                    'pie' => array(
+                        'type'    => 'Literal',
+                        'options' => array(
+                            'route'    => '/pie',
+                            'defaults' => array(
+                                'action' => 'pie',
+                            ),
+                        ),
+                        'verb' => 'get',
+                    ),
 /*
                     'default' => array(
                         'type'    => 'Segment',
index 2bce519..d814b1a 100644 (file)
@@ -11,6 +11,7 @@ use Zend\View\Renderer\PhpRenderer;
 
 
 use Galerie\Model\Galerie;
+use Galerie\Graph\Test as TestPie;
 
 class IndexController extends AbstractActionController 
 {
@@ -162,6 +163,30 @@ class IndexController extends AbstractActionController
         return $response;
     }
 
+    public function pieAction()
+    {
+        // Accès aux modèles
+        $modelManager = $this->_getGalerieInfoTable();
+        $datas = $modelManager->all();
+
+        // Mise en forme des résultats
+        $nombres = array();
+        $noms = array();
+        foreach($datas as $d) {
+            $nombres[] = $d->nb;
+            $noms[] = $d->name;
+        }
+
+        // Construction (et envoi) du diagramme
+        $pie = new TestPie($nombres, $noms);
+
+        $response = $this->getResponse();
+        $response->setStatusCode(200);
+        $response->setContent('');
+
+        return $response;
+    }
+
     public function listAction() 
     { 
         // Récupération de l'objet requête
diff --git a/module/Galerie/src/Galerie/Graph/Test.php b/module/Galerie/src/Galerie/Graph/Test.php
new file mode 100644 (file)
index 0000000..3168b42
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Core Application.
+ *
+ * PHP version 5.3
+ *
+ * @category  Core
+ * @package   Core_View_Test
+ * @author    Stéphane Ciaravolo <stephane.ciaravolo@finances.gouv.fr>
+ * @author    Sébastien Chazallet <sebastien.chazallet@laposte.net>
+ * @copyright 2011 DGFiP
+ * @license   GNU GPL http://www.gnu.org/licenses/gpl.html
+ * @link      http://core.noisiel.dgfip
+ * @since     0.0.0.alpha1
+ *
+ */
+
+namespace Galerie\Graph;
+
+use Custom\Graph\Pie;
+
+/**
+ * Cette vue peut écrire dans une image pour générer un diagramme de Gantt.
+ *
+ * @category  Core
+ * @package   Core_View_Test
+ * @author    Stéphane Ciaravolo <stephane.ciaravolo@finances.gouv.fr>
+ * @author    Sébastien Chazallet <sebastien.chazallet@laposte.net>
+ * @copyright 2011 DGFiP
+ * @license   GNU GPL http://www.gnu.org/licenses/gpl.html
+ * @link      http://core.noisiel.dgfip
+ * @since     0.0.0.alpha1
+ *
+ */
+class Test extends Pie
+{
+
+    protected $title = "Nombre de photos par galerie";
+
+    /**
+     * On surcharge cette propriété afin d'avoir un graphique 3D
+     * @var int
+     */
+    protected $dim3D = true;
+
+
+    /**
+     * On définit le fait que certaines données doivent être mises en évidence.
+     *
+     * @see Coresocle_View_Statgraph_Default::getSlices
+     *
+     * @return array
+     */
+    public function getSlices()
+    {
+        return array(0);
+    }
+
+    /**
+     * On définit un nouveau format pour rajouter un mot après le chiffre
+     *
+     * @see Coresocle_View_Statgraph_Default::getFormat
+     *
+     * @return array
+     */
+    public function getFormat()
+    {
+        return '%d photos';
+    }
+
+}
index 10301d8..9e9abe2 100644 (file)
@@ -21,3 +21,4 @@
        <tbody>
        </tbody>
 </table>
+<img src="/galeries/pie" alt="Répartition des photographies par galerie" />