{
- "name": "zf2biz/application-blanche",
- "description": "Application blanche pour ZF2",
+ "name": "zf2biz/galerie",
+ "description": "Galerie construite à partir de l'Application blanche pour ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
return array(
'modules' => array(
'Application',
+ 'Galerie',
),
'module_listener_options' => array(
'config_glob_paths' => array(
* control, so do not include passwords or other sensitive information in this
* file.
*/
-
return array(
- // ...
+ 'db' => array(
+ 'driver' => 'Pdo',
+ 'dsn' => 'sqlite:' . getcwd() . '/data/jeu_essai.db',
+ ),
+ /* Alternative
+ 'db' => array(
+ 'driver' => 'Pdo_Sqlite',
+ 'database' => getcwd() . '/data/jeu_essai.db',
+ ),*/
+ 'service_manager' => array(
+ 'factories' => array(
+ 'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
+ ),
+ ),
);
--- /dev/null
+PRAGMA foreign_keys = ON;
+
+INSERT INTO user (lastname, firstname, birth, email)
+ SELECT 'Finy', 'Alain', '1962-09-17', 'alain@example.com'
+UNION SELECT 'Mulder', 'Fox', '1980-12-20', 'fox@ailleurs.com'
+UNION SELECT 'Cah', 'Paul', '1972-10-19', 'paul.c@example.com'
+UNION SELECT 'Satch', 'Joe', '1956-07-15', 'john.d@example.com';
+
+
+INSERT INTO contact
+ SELECT 1, 2
+UNION SELECT 1, 3
+UNION SELECT 1, 4
+UNION SELECT 2, 1
+UNION SELECT 2, 3
+UNION SELECT 3, 1;
+
+
+INSERT INTO gallery (id_user, name, description)
+ SELECT 2, 'Pérou', 'Photos des vacances au Pérou, 2011'
+UNION SELECT 1, 'Himalaya', 'Entrainement requis'
+UNION SELECT 2, 'Parapente', 'Photos de vol en parapente';
+
+
+INSERT INTO photo (id_gallery, name, description, filename, extension)
+ SELECT 1, 'Machu Picchu 1', 'Vue d''ensemble du Machu Picchu', 'P9110931', 'jpg'
+UNION SELECT 1, 'Machu Picchu 2', 'Vue depuis la ville', 'P9110957', 'jpg'
+UNION SELECT 1, 'Paysages 1', 'Un peu désertique', 'P9090395', 'jpg'
+UNION SELECT 1, 'Paysages 2', 'Un peu de verdure', 'P9090577', 'jpg'
+UNION SELECT 2, 'Ama Dablam', 'Sommet à 6856m. Situé au pied de l''Everest et du Lhotse. Signifie "reliquaire de la mère" en référence au pendentif que portent les Sherpanis', 'ama_dablam', 'jpg'
+UNION SELECT 2, 'Nupse', 'Sommet à 7864m', 'nupse', 'jpg'
+UNION SELECT 2, 'Panorama', 'Vue vers l''est depuis le camp d''altitude', 'panorama', 'jpg'
+UNION SELECT 1, 'Lac Titicaca', 'Lac Titicaca', 'lt', 'jpg'
+UNION SELECT 3, 'Pêle-mêle', 'Pêle-mêle de photographies', 'pelemele', 'jpg';
+
+
+INSERT INTO order_form (id_gallery)
+ SELECT 1
+UNION SELECT 2
+UNION SELECT 2;
+
+
+INSERT INTO order_element (id_order_form, id_user, id_photo, quantity)
+ SELECT 1, 1, 1, 1
+UNION SELECT 1, 1, 2, 1
+UNION SELECT 1, 1, 3, 1
+UNION SELECT 1, 1, 4, 1
+UNION SELECT 1, 2, 1, 2
+UNION SELECT 1, 2, 2, 4
+UNION SELECT 1, 1, 2, 1
+UNION SELECT 2, 1, 1, 1
+UNION SELECT 2, 1, 2, 1;
+
+UPDATE order_form SET status='wait' WHERE id IN (1, 2);
+UPDATE order_form SET status='end' WHERE id=1;
+
--- /dev/null
+PRAGMA foreign_keys = ON;
+
+/*
+ * Utilisateur ayant un compte sur l'application
+ */
+CREATE TABLE user (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ lastname VARCHAR(32) NOT NULL COLLATE NOCASE,
+ firstname VARCHAR(32) NOT NULL COLLATE NOCASE,
+ birth DATE NOT NULL,
+ email VARCHAR(32) NOT NULL UNIQUE COLLATE NOCASE,
+ UNIQUE (lastname, firstname, birth)
+);
+
+CREATE INDEX idx_user_id ON user(id);
+CREATE INDEX idx_user_unique_triptyque ON user(lastname, firstname, birth);
+CREATE INDEX idx_user_email ON user(email);
+CREATE INDEX idx_user_all ON user(id, lastname, firstname, birth, email);
+
+/*
+ * Gestion du carnet de contacts entre utilisateurs
+ * Non réciproque
+ */
+CREATE TABLE contact (
+ id_user_owner INTEGER ASC REFERENCES user(id),
+ id_user_contact INTEGER ASC REFERENCES user(id),
+ PRIMARY KEY (id_user_owner, id_user_contact)
+);
+
+CREATE INDEX idx_contact ON contact(id_user_owner, id_user_contact);
+
+/*
+ * Gallerie de photos (pas de workflow associé)
+ */
+CREATE TABLE gallery (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ id_user INTEGER REFERENCES user(id),
+ name VARCHAR(32) NOT NULL UNIQUE COLLATE NOCASE,
+ description TEXT NOT NULL,
+ created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX idx_gallery_id ON gallery(id);
+CREATE INDEX idx_gallery_name ON gallery(name);
+CREATE INDEX idx_gallery_user_fk ON gallery(id_user);
+CREATE INDEX idx_gallery_all ON gallery(id, id_user, name, description, created, updated);
+
+/*
+ * Element de gallerie : photographie
+ * Plusieurs photographies sont stockées sur le disque dur, aux formats:
+ * - original (format de l'appareil photo)
+ * - écran (format d'affichage de la photo à l'écran)
+ * - miniature (format d'affichage pour les miniatures de la gallerie)
+ */
+CREATE TABLE photo (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ id_gallery INTEGER REFERENCES gallery(id),
+ name VARCHAR(16) NOT NULL UNIQUE COLLATE RTRIM,
+ description TEXT NOT NULL,
+ filename VARCHAR(12) NOT NULL COLLATE NOCASE,
+ extension VARCHAR(4) NOT NULL COLLATE NOCASE CHECK (extension IN ('jpg', 'png')),
+ created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX idx_photo_id ON photo(id);
+CREATE INDEX idx_photo_name ON photo(name);
+CREATE INDEX idx_photo_gallery_fk ON photo(id_gallery);
+CREATE INDEX idx_photo_all ON photo(id, id_gallery, name, description, filename, extension, created, updated);
+
+/*
+ * Commande qui dispose d'un workflow:
+ * - le propriétaire de la gallerie ouvre une commande
+ * - tant que la commande est ouverte, les contacts du propriétaire peuvent demander des exemplaire de chaque photo
+ * - après une certaine période, la commande passé au statut en attente; les photos sont en cours de développement
+ * - lorsque la commande est reçue, elle est alors fermée
+ * - tous les contacts du propriétaires passent donc commande en même temps
+ * - le propriétaire peut réouvrir au besoin une nouvelle commande
+ */
+CREATE TABLE order_form (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ id_gallery UNSIGNED SMALLINT REFERENCES gallery (id),
+ status VARCHAR(4) NOT NULL COLLATE NOCASE CHECK (status IN ('open', 'wait', 'end')) DEFAULT 'open',
+ created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ closed TIMESTAMP NOT NULL DEFAULT (datetime('now', '+1 month')),
+ ended TIMESTAMP NULL DEFAULT NULL
+);
+
+CREATE INDEX idx_order_form_id ON order_form(id);
+CREATE INDEX idx_order_form_gallery_fk ON order_form(id_gallery);
+CREATE INDEX idx_order_form_all ON order_form(id, id_gallery, status, created, closed, ended);
+
+/*
+ * élément de commande :
+ * - il n'est pas possible de créer un tel élément lorsque la commande n'est pas ouverte
+ * - il n'est pas possible de passer commande si l'on ne fait pas parti des contacts du propriétaire
+ */
+CREATE TABLE order_element (
+ id_order_form INTEGER REFERENCES order_form(id),
+ id_user INTEGER REFERENCES user(id),
+ id_photo INTEGER REFERENCES photo(id),
+ quantity UNSIGNED SMALLINT DEFAULT 1,
+ PRIMARY KEY (id_user, id_order_form, id_photo)
+);
+
+CREATE INDEX idx_order_element_primary ON order_element(id_order_form, id_user, id_photo);
+CREATE INDEX idx_order_element_all ON order_element(id_order_form, id_user, id_photo, quantity);
+
+/*
+ * à chaque fois que les propriétés d'une gallerie sont modifiées, le champs contenant la date de mise à jour l'est également
+ */
+CREATE TRIGGER gallery_update_management AFTER UPDATE ON gallery
+BEGIN
+ UPDATE gallery SET updated = datetime('now') WHERE id = old.id;
+END;
+
+/*
+ * à chaque fois que les propriétés d'une photographie sont modifiées, le champs contenant la date de mise à jour l'est également ainsi que celui de la gallerie liée
+ */
+CREATE TRIGGER photo_update_management AFTER UPDATE ON photo
+BEGIN
+ UPDATE gallery SET updated = datetime('now') WHERE id = old.id_gallery;
+ UPDATE photo SET updated = datetime('now') WHERE id = old.id;
+END;
+
+/*
+ * Gestion du workflow sur une commande: mise à jour de la date de fermeture au changement de statut open vers wait
+ */
+CREATE TRIGGER order_form_update_management_closed AFTER UPDATE OF status ON order_form WHEN old.status='open' AND new.status='wait'
+BEGIN
+ UPDATE order_form SET closed = datetime('now') WHERE id = old.id;
+END;
+
+/*
+ * Gestion du workflow sur une commande: mise à jour de la date de fermeture au changement de statut wait vers end
+ */
+CREATE TRIGGER order_form_update_management_ended AFTER UPDATE OF status ON order_form WHEN old.status='wait' AND new.status='end'
+BEGIN
+ UPDATE order_form SET ended = datetime('now') WHERE id = old.id;
+END;
+
+/*
+ * Gestion du workflow sur une commande: il doit être impossible d'aller en arrière
+ */
+CREATE TRIGGER order_form_update_management_workflow BEFORE UPDATE OF status ON order_form
+BEGIN
+ SELECT CASE
+ WHEN (old.status='wait' AND new.status='open')
+ OR (old.status='end' AND new.status<>'end')
+ THEN RAISE(ABORT, 'new status do not respect workflow')
+ END;
+END;
+
+/*
+ * Gestion d'un élément de commande: il doit être impossible de modifier uns des clés primaires
+ */
+CREATE TRIGGER order_element_update_management_workflow BEFORE UPDATE OF status ON order_element
+BEGIN
+ SELECT CASE
+ WHEN old.id_order_form <> new.id_order_form
+ OR old.id_user <> new.id_user
+ OR old.id_photo <> new.id_photo
+ THEN RAISE(ABORT, 'bad usage of order element')
+ END;
+END;
+
+/*
+ * Gestion du workflow sur un élément de commande: il doit être impossible de modifier un élément de commande si la commande n'est pas ouverte
+ */
+CREATE TRIGGER order_element_update_management_when_closed BEFORE UPDATE ON order_element
+BEGIN
+ SELECT CASE
+ WHEN ((SELECT order_form.id FROM order_form WHERE order_form.id=old.id_order_form AND order_form.status='open') IS NULL)
+ THEN RAISE(ABORT, 'try to update element in not opened order form')
+ END;
+END;
+
+/*
+ * Gestion du workflow sur un élément de commande: il doit être impossible de rajouter un élément de commande si la commande n'est pas ouverte
+ */
+CREATE TRIGGER order_element_insert_management_when_closed BEFORE INSERT ON order_element
+BEGIN
+ SELECT CASE
+ WHEN ((SELECT order_form.id FROM order_form WHERE order_form.id=new.id_order_form AND order_form.status='open') IS NULL)
+ THEN RAISE(ABORT, 'try to insert element in not opened order form')
+ END;
+END;
+
+/*
+ * Gestion du contraintes sur un élément de commande: un utilisateur ne faisant pas partie des contacts du propriétaire de la gallerie concernée par la commande ne doit pas pouvoir créer un élément de commande.
+ */
+CREATE TRIGGER order_element_insert_management_check_user_is_authored BEFORE INSERT ON order_element
+BEGIN
+ SELECT CASE
+ WHEN (
+ (
+ SELECT contact.id_user_contact
+ FROM contact
+ JOIN gallery ON gallery.id_user=contact.id_user_owner
+ JOIN order_form ON order_form.id_gallery=gallery.id
+ WHERE (contact.id_user_contact=new.id_user OR contact.id_user_owner=new.id_user)
+ AND order_form.id=new.id_order_form
+ ) IS NULL
+ )
+ THEN RAISE(ABORT, 'unauthorized user is ordering')
+ END;
+END;
+
--- /dev/null
+<?php
+
+namespace Galerie;
+
+use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
+use Zend\ModuleManager\Feature\ConfigProviderInterface;
+use Zend\ModuleManager\Feature\BootstrapListenerInterface;
+use Zend\ModuleManager\Feature\ServiceProviderInterface;
+
+use Zend\EventManager\EventInterface;
+use Zend\Mvc\ModuleRouteListener;
+
+use Galerie\Model\GalerieArrayTable;
+use Galerie\Model\GalerieATable;
+use Galerie\Model\GalerieBTable;
+use Galerie\Model\GalerieCTable;
+
+class Module implements
+ AutoloaderProviderInterface,
+ ConfigProviderInterface,
+ BootstrapListenerInterface,
+ ServiceProviderInterface
+{
+
+ public function getAutoloaderConfig()
+ {
+ return array(
+ 'Zend\Loader\ClassMapAutoloader' => array(
+ __DIR__ . '/autoload_classmap.php',
+ ),
+ 'Zend\Loader\StandardAutoloader' => array(
+ 'namespaces' => array(
+ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
+ ),
+ ),
+ );
+ }
+
+ public function getConfig()
+ {
+ return include __DIR__ . '/config/module.config.php';
+ }
+
+ public function onBootstrap(EventInterface $e)
+ {
+ $e->getApplication()->getServiceManager()->get('translator');
+ }
+
+ public function getServiceConfig()
+ {
+ return array(
+ 'factories' => array(
+ 'Galerie\Model\GalerieArrayTable' => function($sm) {
+ return new GalerieArrayTable(
+ $sm->get('Zend\Db\Adapter\Adapter')
+ );
+ },
+ 'Galerie\Model\GalerieATable' => function($sm) {
+ return new GalerieATable(
+ $sm->get('Zend\Db\Adapter\Adapter')
+ );
+ },
+ 'Galerie\Model\GalerieBTable' => function($sm) {
+ return new GalerieBTable(
+ $sm->get('Zend\Db\Adapter\Adapter')
+ );
+ },
+ 'Galerie\Model\GalerieCTable' => function($sm) {
+ return new GalerieCTable(
+ $sm->get('Zend\Db\Adapter\Adapter')
+ );
+ },
+ ),
+ );
+ }
+}
--- /dev/null
+<?php
+
+return array(
+ 'Galerie\Controller\IndexController' =>
+ __DIR__ . '/src/Galerie/Controller/IndexController.php',
+);
--- /dev/null
+<?php
+
+return array(
+ 'controllers' => array(
+ 'invokables' => array(
+ 'Galerie\Controller\Index' =>
+ 'Galerie\Controller\IndexController'
+ ),
+ ),
+ 'view_manager' => array(
+ 'template_map' => array(
+ 'galerie/index/index' =>
+ __DIR__ . '/../view/galerie/index/index.phtml',
+ 'galerie/index/edit' =>
+ __DIR__ . '/../view/galerie/index/edit.phtml',
+ 'galerie/index/del' =>
+ __DIR__ . '/../view/galerie/index/del.phtml',
+ 'galerie/index/view' =>
+ __DIR__ . '/../view/galerie/index/view.phtml',
+ ),
+ 'template_path_stack' => array(
+ 'galerie' => __DIR__ . '/../view',
+ ),
+ ),
+ 'router' => array(
+ 'routes' => array(
+ 'galerie' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/galeries',
+ 'defaults' => array(
+ '__NAMESPACE__' => 'Galerie\Controller',
+ 'controller' => 'Index',
+ 'action' => 'index',
+ ),
+ ),
+ 'verb' => 'get',
+ 'may_terminate' => true,
+ 'child_routes' => array(
+
+ 'add' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/ajout',
+ 'defaults' => array(
+ 'action' => 'edit',
+ ),
+ ),
+ 'verb' => 'get,post',
+ ),
+ 'edit' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/editer/:id',
+ 'constraints' => array(
+ 'id' => '[1-9][0-9]*',
+ ),
+ 'defaults' => array(
+ 'action' => 'edit',
+ ),
+ ),
+ 'verb' => 'get,post',
+ ),
+ 'del' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/supprimer/:id',
+ 'constraints' => array(
+ 'id' => '[1-9][0-9]*',
+ ),
+ 'defaults' => array(
+ 'action' => 'del',
+ ),
+ ),
+ 'verb' => 'get,post',
+ ),
+ 'view' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/voir/:id',
+ 'constraints' => array(
+ 'id' => '[1-9][0-9]*',
+ ),
+ 'defaults' => array(
+ 'action' => 'view',
+ ),
+ ),
+ ),
+ 'add_or_edit' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/ajouter_editer/[:id]',
+ 'constraints' => array(
+ 'id' => '[1-9][0-9]*',
+ ),
+ 'defaults' => array(
+ 'action' => 'edit',
+ 'id' => null,
+ ),
+ ),
+ 'verb' => 'get,post',
+ ),
+ 'default' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/[:controller[/:action]]',
+ 'constraints' => array(
+ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
+ 'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
+ ),
+ 'defaults' => array(
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ 'service_manager' => array(
+ 'factories' => array(
+ 'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
+ ),
+ ),
+ 'translator' => array(
+ 'locale' => 'fr_FR',
+ 'translation_file_patterns' => array(
+ array(
+ 'type' => 'gettext',
+ 'base_dir' => __DIR__ . '/../language',
+ 'pattern' => '%s.mo',
+ 'text_domain' => 'galerie',
+ ),
+ ),
+ ),
+);
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: Projet galerie, Module galerie\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-11-02 15:39+0100\n"
+"PO-Revision-Date: 2012-11-02 15:46+0100\n"
+"Last-Translator: Sébastien CHAZALLET <s.chazallet@gmail.com>\n"
+"Language-Team: \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-KeywordsList: _;gettext;gettext_noop;translate\n"
+"X-Poedit-Basepath: .\n"
+"X-Poedit-SearchPath-0: /var/git/zf2biz/galerie/module/Galerie\n"
+"X-Poedit-SearchPath-1: .\n"
+
+#: /var/git/zf2biz/galerie/module/Galerie/view/galerie/index/index.phtml:1
+msgid "index"
+msgstr "Page d'accueil galerie/back-office"
+
--- /dev/null
+<?php
+
+namespace Galerie\Controller;
+
+use Zend\Mvc\Controller\AbstractActionController;
+use Zend\View\Model\ViewModel;
+
+class IndexController extends AbstractActionController
+{
+
+ private $_galerieArrayTable;
+ private $_galerieATable;
+ private $_galerieBTable;
+ private $_galerieCTable;
+
+
+ private function _getGalerieArrayTable()
+ {
+ if (!$this->_galerieArrayTable) {
+ $sm = $this->getServiceLocator();
+ $this->_galerieArrayTable = $sm->get('Galerie\Model\GalerieArrayTable');
+ }
+ return $this->_galerieArrayTable;
+ }
+
+ private function _getGalerieATable()
+ {
+ if (!$this->_galerieATable) {
+ $sm = $this->getServiceLocator();
+ $this->_galerieATable = $sm->get('Galerie\Model\GalerieATable');
+ }
+ return $this->_galerieATable;
+ }
+
+ private function _getGalerieBTable()
+ {
+ if (!$this->_galerieBTable) {
+ $sm = $this->getServiceLocator();
+ $this->_galerieBTable = $sm->get('Galerie\Model\GalerieBTable');
+ }
+ return $this->_galerieBTable;
+ }
+
+ private function _getGalerieCTable()
+ {
+ if (!$this->_galerieCTable) {
+ $sm = $this->getServiceLocator();
+ $this->_galerieCTable = $sm->get('Galerie\Model\GalerieCTable');
+ }
+ return $this->_galerieCTable;
+ }
+
+ public function indexAction()
+ {
+ return new ViewModel(array(
+ 'GalerieArray_all' => $this->_getGalerieArrayTable()->fetchAll(),
+ 'GalerieArray_one' => $this->_getGalerieArrayTable()->getGalerie(1),
+ 'GalerieA_all' => $this->_getGalerieATable()->fetchAll(),
+ 'GalerieA_one' => $this->_getGalerieATable()->getGalerie(1),
+ 'GalerieB_all' => $this->_getGalerieBTable()->fetchAll(),
+ 'GalerieB_one' => $this->_getGalerieBTable()->getGalerie(1),
+ 'GalerieC_all' => $this->_getGalerieCTable()->fetchAll(),
+ 'GalerieC_one' => $this->_getGalerieCTable()->getGalerie(1),
+ ));
+ }
+
+ public function editAction()
+ {
+ return array();
+ }
+
+ public function delAction()
+ {
+ return array();
+ }
+
+ public function viewAction()
+ {
+ return array();
+ }
+}
--- /dev/null
+<?php
+
+namespace Galerie\Model;
+
+class GalerieA
+{
+ public $id;
+ public $id_user;
+ public $name;
+ public $description;
+ public $created;
+ public $updated;
+
+ public function exchangeArray($data)
+ {
+ $this->id = isset($data['id']) ? $data['id'] : null;
+ $this->id_user = isset($data['is_user']) ? $data['id_user'] : null;
+ $this->name = isset($data['name']) ? $data['name'] : null;
+ $this->description = isset($data['description']) ? $data['description'] : null;
+ $this->created = isset($data['created']) ? $data['created'] : null;
+ $this->updated = isset($data['updated']) ? $data['updated'] : null;
+ }
+
+ public function toArray()
+ {
+ return array(
+ 'id' => $this->id,
+ 'is_user' => $this->id_user,
+ 'name' => $this->name,
+ 'description' => $this->description,
+ 'created' => $this->created,
+ 'updated' => $this->updated,
+ );
+ }
+
+}
--- /dev/null
+<?php
+namespace Galerie\Model;
+
+use Zend\Db\Adapter\Adapter;
+use Zend\Db\ResultSet\ResultSet;
+use Zend\Db\TableGateway\AbstractTableGateway;
+
+
+class GalerieATable extends AbstractTableGateway
+{
+ public $table = 'gallery';
+
+ public function __construct(Adapter $adapter)
+ {
+ // Composition avec l'adaptateur
+ $this->adapter = $adapter;
+
+ // Utilisation du patron de conception Prototype
+ // pour la création des objets ResultSet
+ $this->resultSetPrototype = new ResultSet();
+ $this->resultSetPrototype->setArrayObjectPrototype(
+ new GalerieA()
+ );
+
+ // Initialisation du gestionnaire
+ $this->initialize();
+ }
+
+ public function fetchAll()
+ {
+ return $this->select();
+ }
+
+ public function getGalerie($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array(
+ 'id' => (int) $id,
+ ))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row $id in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public function saveGalerie(GalerieA $galerie)
+ {
+ if ($galerie->id === null) {
+ $this->insert(
+ array(
+ 'id_user' => $galerie->id_user,
+ 'name' => $galerie->name,
+ 'description' => $galerie->description,
+ )
+ );
+ } elseif ($this->getGalerie($galerie->id)) {
+ $this->update(
+ array(
+ 'id_user' => $galerie->id_user,
+ 'name' => $galerie->name,
+ 'description' => $galerie->description,
+ ),
+ array(
+ 'id' => $galerie->id,
+ )
+ );
+ } else {
+ throw new \Exception("cannot update row {$galerie->id} in table 'galerie'");
+ }
+ }
+
+ public function deleteGalerie($id)
+ {
+ $this->delete(array(
+ 'id' => (int) $id
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+
+namespace Galerie\Model;
+
+class GalerieArray extends \ArrayObject
+{
+}
--- /dev/null
+<?php
+namespace Galerie\Model;
+
+use Zend\Db\Adapter\Adapter;
+use Zend\Db\ResultSet\ResultSet;
+use Zend\Db\TableGateway\AbstractTableGateway;
+
+
+class GalerieArrayTable extends AbstractTableGateway
+{
+ public $table = 'gallery';
+
+ public function __construct(Adapter $adapter)
+ {
+ // Composition avec l'adaptateur
+ $this->adapter = $adapter;
+
+ // Utilisation du patron de conception Prototype
+ // pour la création des objets ResultSet
+ $this->resultSetPrototype = new ResultSet();
+ $this->resultSetPrototype->setArrayObjectPrototype(
+ new GalerieArray()
+ );
+
+ // Initialisation du gestionnaire
+ $this->initialize();
+ }
+
+ public function fetchAll()
+ {
+ return $this->select();
+ }
+
+ public function getGalerie($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array(
+ 'id' => (int) $id,
+ ))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row $id in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public function saveGalerie(GalerieArray $galerie)
+ {
+ if ($galerie->id === null) {
+ $this->insert(
+ array(
+ 'name' => $galerie->name,
+ 'description' => $galerie->description,
+ )
+ );
+ } elseif ($this->getGalerie($galerie->id)) {
+ $this->update(
+ array(
+ 'name' => $galerie->name,
+ 'description' => $galerie->description,
+ ),
+ array(
+ 'id' => $galerie->id,
+ )
+ );
+ } else {
+ throw new \Exception("cannot update row $galerie->id in table 'galerie'");
+ }
+ }
+
+ public function deleteGalerie($id)
+ {
+ $this->delete(array(
+ 'id' => (int) $id
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+
+namespace Galerie\Model;
+
+class GalerieB
+{
+ protected $id;
+ protected $id_user;
+ protected $name;
+ protected $description;
+ protected $created;
+ protected $updated;
+
+
+ public function exchangeArray($data)
+ {
+ $this->id = isset($data['id']) ? $data['id'] : null;
+ $this->id_user = isset($data['is_user']) ? $data['id_user'] : null;
+ $this->name = isset($data['name']) ? $data['name'] : null;
+ $this->description = isset($data['description']) ? $data['description'] : null;
+ $this->created = isset($data['created']) ? $data['created'] : null;
+ $this->updated = isset($data['updated']) ? $data['updated'] : null;
+ }
+
+ public function toArray()
+ {
+ return array(
+ 'id' => $this->id,
+ 'is_user' => $this->id_user,
+ 'name' => $this->name,
+ 'description' => $this->description,
+ 'created' => $this->created,
+ 'updated' => $this->updated,
+ );
+ }
+
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ public function getIdUser()
+ {
+ return $this->id_user;
+ }
+
+ public function setIdUser($id_user)
+ {
+ $this->id_user = $id_user;
+ return $this;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ public function setDescription ($description)
+ {
+ $this-> description = $description;
+ return $this;
+ }
+
+ public function getCreated()
+ {
+ return $this->created;
+ }
+
+ public function setCreated($created)
+ {
+ $this->created = $created;
+ return $this;
+ }
+
+ public function getUpdated()
+ {
+ return $this->updated;
+ }
+
+ public function setUpdated($updated)
+ {
+ $this->updated = $updated;
+ return $this;
+ }
+
+}
--- /dev/null
+<?php
+namespace Galerie\Model;
+
+use Zend\Db\Adapter\Adapter;
+use Zend\Db\ResultSet\ResultSet;
+use Zend\Db\TableGateway\AbstractTableGateway;
+
+
+class GalerieBTable extends AbstractTableGateway
+{
+ public $table = 'gallery';
+
+ public function __construct(Adapter $adapter)
+ {
+ // Composition avec l'adaptateur
+ $this->adapter = $adapter;
+
+ // Utilisation du patron de conception Prototype
+ // pour la création des objets ResultSet
+ $this->resultSetPrototype = new ResultSet();
+ $this->resultSetPrototype->setArrayObjectPrototype(
+ new GalerieB()
+ );
+
+ // Initialisation du gestionnaire
+ $this->initialize();
+ }
+
+ public function fetchAll()
+ {
+ return $this->select();
+ }
+
+ public function getGalerie($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array(
+ 'id' => (int) $id,
+ ))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row $id in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public function saveGalerie(GalerieA $galerie)
+ {
+ if ($galerie->getId() === null) {
+ $this->insert(
+ array(
+ 'id_user' => $galerie->getName(),
+ 'name' => $galerie->getName(),
+ 'description' => $galerie->getDescription(),
+ )
+ );
+ } elseif ($this->getGalerie($galerie->getId())) {
+ $this->update(
+ array(
+ 'name' => $galerie->getName(),
+ 'description' => $galerie->getDescription(),
+ ),
+ array(
+ 'id' => $galerie->getId(),
+ )
+ );
+ } else {
+ throw new \Exception("cannot update row {$galerie->getId()} in table 'galerie'");
+ }
+ }
+
+ public function deleteGalerie($id)
+ {
+ $this->delete(array(
+ 'id' => (int) $id
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+
+namespace Galerie\Model;
+
+use Custom\Model\Entity;
+
+class GalerieC extends Entity
+{
+ public $id;
+ public $id_user;
+ public $name;
+ public $description;
+ public $created;
+ public $updated;
+
+
+ protected $columns = array(
+ 'id',
+ 'id_user',
+ 'name',
+ 'description',
+ 'created',
+ 'updated',
+ );
+
+ protected $updatable_columns = array(
+ 'id_user',
+ 'name',
+ 'description',
+ 'created',
+ 'updated',
+ );
+
+ protected $primary_columns = array(
+ 'id',
+ );
+
+}
--- /dev/null
+<?php
+namespace Galerie\Model;
+
+use Zend\Db\Adapter\Adapter;
+use Zend\Db\ResultSet\ResultSet;
+use Zend\Db\TableGateway\AbstractTableGateway;
+
+
+class GalerieCTable extends AbstractTableGateway
+{
+ public $table = 'gallery';
+
+ public function __construct(Adapter $adapter)
+ {
+ // Composition avec l'adaptateur
+ $this->adapter = $adapter;
+
+ // Utilisation du patron de conception Prototype
+ // pour la création des objets ResultSet
+ $this->resultSetPrototype = new ResultSet();
+ $this->resultSetPrototype->setArrayObjectPrototype(
+ new GalerieC()
+ );
+
+ // Initialisation du gestionnaire
+ $this->initialize();
+ }
+
+ public function fetchAll()
+ {
+ return $this->select();
+ }
+
+ public function getGalerie($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array(
+ 'id' => (int) $id,
+ ))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row $id in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public function saveGalerie(GalerieC $galerie)
+ {
+ if ($galerie->id === null) {
+ $this->insert(
+ $galerie->toUpdatableArray()
+ );
+ } elseif ($this->getGalerie($galerie->id)) {
+ $this->update(
+ $galerie->toUpdatableArray(),
+ $galerie->toPrimaryArray()
+ );
+ } else {
+ throw new \Exception("cannot update row {$galerie->id} in table 'galerie'");
+ }
+ }
+
+ public function deleteGalerie($id)
+ {
+ $this->delete(array(
+ 'id' => (int) $id
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+namespace Galerie\Model
+
+use Zend\Db\Adapter\Adapter;
+use Zend\Db\ResultSet\ResultSet;
+use Zend\Db\TableGateway\AbstractTableGateway;
+
+class GalerieTableE extends AbstractTableGateway
+{
+ public $table = 'galerie';
+
+ public function __construct(Adapter $adapter)
+ {
+ // Composition avec l'adaptateur
+ $this->adapter = $adapter;
+
+ // Utilisation du patron de conception Prototype
+ // pour la création des objets ResultSet
+ $this->resultSetPrototype = new ResultSet();
+ $this->resultSetPrototype->setArrayObjectPrototype(
+ new Galerie()
+ );
+
+ // Initialisation du gestionnaire
+ $this->initialize();
+ }
+
+ public function fetchAll()
+ {
+ return $this->select();
+ }
+
+ public function getGalerie($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array(
+ 'id' => (int) $id
+ ))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row $id in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public saveGalerie(Galerie $galerie)
+ {
+ if ($galerie->id === null) {
+ $this->insert(
+ $galerie->toUpdatableArray()
+ );
+ } elseif ($this->getGalerie($galerie->id)) {
+ $this->update(
+ $galerie->toUpdatableArray(),
+ $galerie->toPrimaryArray()
+ );
+ } else {
+ throw new \Exception("cannot update row $galerie->id in table 'galerie'");
+ }
+ }
+
+ public function deleteGalerie($id)
+ {
+ $this->delete(array(
+ 'id' => (int) $id
+ )
+ );
+ }
+
+}
--- /dev/null
+<p>vue <em>back-office</em> d’une <strong>galerie</strong> : del</p>
--- /dev/null
+<p>vue <em>back-office</em> d’une <strong>galerie</strong> : edit</p>
--- /dev/null
+<p>vue <em>back-office</em> d’une <strong>galerie</strong> : <?php echo $this->translate('index', 'galerie'); ?></p>
+
+
+<h1>GalerieArray</h1>
+<h2>test de fetchAll()</h2>
+
+<pre><?php echo $GalerieArray_all->count(); ?></pre>
+<pre><?php print_r($GalerieArray_all->toArray()); ?></pre>
+
+<h2>test de getGalerie</h2>
+
+<pre><?php print_r($GalerieArray_one); ?></pre>
+<p>Identifiant : <?php echo $GalerieArray_one['id']; ?></p>
+
+
+<h1>GalerieA</h1>
+<h2>test de fetchAll()</h2>
+
+<pre><?php echo $GalerieA_all->count(); ?></pre>
+<pre><?php print_r($GalerieA_all->toArray()); ?></pre>
+
+<h2>test de getGalerie</h2>
+
+<pre><?php print_r($GalerieA_one); ?></pre>
+<p>Identifiant : <?php echo $GalerieA_one->id; ?></p>
+
+
+<h1>GalerieB</h1>
+<h2>test de fetchAll()</h2>
+
+<pre><?php echo $GalerieB_all->count(); ?></pre>
+<pre><?php print_r($GalerieB_all->toArray()); ?></pre>
+
+<h2>test de getGalerie</h2>
+
+<pre><?php print_r($GalerieB_one); ?></pre>
+<p>Identifiant : <?php echo $GalerieB_one->getId(); ?></p>
+
+
+<h1>GalerieC</h1>
+<h2>test de fetchAll()</h2>
+
+<pre><?php echo $GalerieC_all->count(); ?></pre>
+<pre><?php print_r($GalerieC_all->toArray()); ?></pre>
+
+<h2>test de getGalerie</h2>
+
+<pre><?php print_r($GalerieC_one); ?></pre>
+<p>Identifiant : <?php echo $GalerieC_one->id; ?></p>
--- /dev/null
+<p>vue <em>back-office</em> d’une <strong>galerie</strong> : view</p>
-Alias /appblanche /var/git/zf2biz/application-blanche/public
+Alias /galerie /var/git/zf2biz/galerie/public
-<Directory /var/git/zf2biz/application-blanche/public>
+<Directory /var/git/zf2biz/galerie/public>
Order deny,allow
Allow from all
<VirtualHost *:80>
- ServerName appblanche.local
- DocumentRoot /var/git/zf2biz/application-blanche/public
+ ServerName galerie.local
+ DocumentRoot /var/git/zf2biz/gallerie/public
SetEnv APPLICATION_ENV "development"
- <Directory /var/git/zf2biz/application-blanche/public>
+ <Directory /var/git/zf2biz/galerie/public>
Order deny,allow
Allow from all
.composer
composer
zendframework
+doctrine
+symfony
autoload.php