From: Sébastien CHAZALLET Date: Tue, 6 Nov 2012 23:48:29 +0000 (+0100) Subject: Merge branch 'master' of ../application-blanche X-Git-Url: http://git.inspyration.org/?p=zf2.biz%2Fgalerie.git;a=commitdiff_plain;h=77531ba9ac094be7ed6a9c5b4e8ec07f49896ee8;hp=8ce32d13a3301c30a9e7bc7a17985ccfd6415b96 Merge branch 'master' of ../application-blanche --- diff --git a/composer.json b/composer.json index f534441..9e017e5 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "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", diff --git a/composer.phar b/composer.phar index 661fadd..28635d1 100755 Binary files a/composer.phar and b/composer.phar differ diff --git a/config/application.config.php b/config/application.config.php index 6504dea..1dab349 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -2,6 +2,7 @@ return array( 'modules' => array( 'Application', + 'Galerie', ), 'module_listener_options' => array( 'config_glob_paths' => array( diff --git a/config/autoload/global.php b/config/autoload/global.php index 104762e..39f8af7 100644 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -10,7 +10,19 @@ * 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', + ), + ), ); diff --git a/data/images/1/ama_dablam.jpg b/data/images/1/ama_dablam.jpg new file mode 100644 index 0000000..a2ee0f4 Binary files /dev/null and b/data/images/1/ama_dablam.jpg differ diff --git a/data/images/1/nupse.jpg b/data/images/1/nupse.jpg new file mode 100644 index 0000000..5b9a71c Binary files /dev/null and b/data/images/1/nupse.jpg differ diff --git a/data/images/1/panorama.jpg b/data/images/1/panorama.jpg new file mode 100644 index 0000000..bd3df02 Binary files /dev/null and b/data/images/1/panorama.jpg differ diff --git a/data/images/2/P9090395.jpg b/data/images/2/P9090395.jpg new file mode 100644 index 0000000..47e948b Binary files /dev/null and b/data/images/2/P9090395.jpg differ diff --git a/data/images/2/P9090577.jpg b/data/images/2/P9090577.jpg new file mode 100644 index 0000000..0dee226 Binary files /dev/null and b/data/images/2/P9090577.jpg differ diff --git a/data/images/2/P9110931.jpg b/data/images/2/P9110931.jpg new file mode 100644 index 0000000..3c29b7b Binary files /dev/null and b/data/images/2/P9110931.jpg differ diff --git a/data/images/2/P9110957.jpg b/data/images/2/P9110957.jpg new file mode 100644 index 0000000..eb7d9cf Binary files /dev/null and b/data/images/2/P9110957.jpg differ diff --git a/data/images/3/pelemele.jpg b/data/images/3/pelemele.jpg new file mode 100644 index 0000000..3f7f9f6 Binary files /dev/null and b/data/images/3/pelemele.jpg differ diff --git a/data/jeu_essai.db b/data/jeu_essai.db new file mode 100644 index 0000000..ca6418e Binary files /dev/null and b/data/jeu_essai.db differ diff --git a/data/scripts/data.sql b/data/scripts/data.sql new file mode 100644 index 0000000..d9a8da7 --- /dev/null +++ b/data/scripts/data.sql @@ -0,0 +1,56 @@ +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; + diff --git a/data/scripts/schema.sql b/data/scripts/schema.sql new file mode 100644 index 0000000..2a6a0b3 --- /dev/null +++ b/data/scripts/schema.sql @@ -0,0 +1,209 @@ +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; + diff --git a/module/Galerie/Module.php b/module/Galerie/Module.php new file mode 100644 index 0000000..74876bb --- /dev/null +++ b/module/Galerie/Module.php @@ -0,0 +1,76 @@ + 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') + ); + }, + ), + ); + } +} diff --git a/module/Galerie/autoload_classmap.php b/module/Galerie/autoload_classmap.php new file mode 100644 index 0000000..7f2deab --- /dev/null +++ b/module/Galerie/autoload_classmap.php @@ -0,0 +1,6 @@ + + __DIR__ . '/src/Galerie/Controller/IndexController.php', +); diff --git a/module/Galerie/config/module.config.php b/module/Galerie/config/module.config.php new file mode 100644 index 0000000..81f78ea --- /dev/null +++ b/module/Galerie/config/module.config.php @@ -0,0 +1,135 @@ + 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', + ), + ), + ), +); diff --git a/module/Galerie/language/fr_FR.mo b/module/Galerie/language/fr_FR.mo new file mode 100644 index 0000000..81f4d73 Binary files /dev/null and b/module/Galerie/language/fr_FR.mo differ diff --git a/module/Galerie/language/fr_FR.po b/module/Galerie/language/fr_FR.po new file mode 100644 index 0000000..cea2d97 --- /dev/null +++ b/module/Galerie/language/fr_FR.po @@ -0,0 +1,21 @@ +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 \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" + diff --git a/module/Galerie/src/Galerie/Controller/IndexController.php b/module/Galerie/src/Galerie/Controller/IndexController.php new file mode 100644 index 0000000..7fba8bc --- /dev/null +++ b/module/Galerie/src/Galerie/Controller/IndexController.php @@ -0,0 +1,81 @@ +_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(); + } +} diff --git a/module/Galerie/src/Galerie/Model/GalerieA.php b/module/Galerie/src/Galerie/Model/GalerieA.php new file mode 100644 index 0000000..01686bb --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieA.php @@ -0,0 +1,36 @@ +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, + ); + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieATable.php b/module/Galerie/src/Galerie/Model/GalerieATable.php new file mode 100644 index 0000000..c857112 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieATable.php @@ -0,0 +1,83 @@ +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 + ) + ); + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieArray.php b/module/Galerie/src/Galerie/Model/GalerieArray.php new file mode 100644 index 0000000..57a0263 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieArray.php @@ -0,0 +1,7 @@ +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 + ) + ); + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieB.php b/module/Galerie/src/Galerie/Model/GalerieB.php new file mode 100644 index 0000000..a10d540 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieB.php @@ -0,0 +1,104 @@ +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; + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieBTable.php b/module/Galerie/src/Galerie/Model/GalerieBTable.php new file mode 100644 index 0000000..6f8a3d8 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieBTable.php @@ -0,0 +1,82 @@ +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 + ) + ); + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieC.php b/module/Galerie/src/Galerie/Model/GalerieC.php new file mode 100644 index 0000000..dceb108 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieC.php @@ -0,0 +1,38 @@ +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 + ) + ); + } + +} diff --git a/module/Galerie/src/Galerie/Model/GalerieE3Table.php b/module/Galerie/src/Galerie/Model/GalerieE3Table.php new file mode 100644 index 0000000..194cded --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieE3Table.php @@ -0,0 +1,72 @@ +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 + ) + ); + } + +} diff --git a/module/Galerie/view/galerie/index/del.phtml b/module/Galerie/view/galerie/index/del.phtml new file mode 100644 index 0000000..049cf40 --- /dev/null +++ b/module/Galerie/view/galerie/index/del.phtml @@ -0,0 +1 @@ +

vue back-office d’une galerie : del

diff --git a/module/Galerie/view/galerie/index/edit.phtml b/module/Galerie/view/galerie/index/edit.phtml new file mode 100644 index 0000000..bcb2211 --- /dev/null +++ b/module/Galerie/view/galerie/index/edit.phtml @@ -0,0 +1 @@ +

vue back-office d’une galerie : edit

diff --git a/module/Galerie/view/galerie/index/index.phtml b/module/Galerie/view/galerie/index/index.phtml new file mode 100644 index 0000000..c6d2828 --- /dev/null +++ b/module/Galerie/view/galerie/index/index.phtml @@ -0,0 +1,49 @@ +

vue back-office d’une galerie : translate('index', 'galerie'); ?>

+ + +

GalerieArray

+

test de fetchAll()

+ +
count(); ?>
+
toArray()); ?>
+ +

test de getGalerie

+ +
+

Identifiant :

+ + +

GalerieA

+

test de fetchAll()

+ +
count(); ?>
+
toArray()); ?>
+ +

test de getGalerie

+ +
+

Identifiant : id; ?>

+ + +

GalerieB

+

test de fetchAll()

+ +
count(); ?>
+
toArray()); ?>
+ +

test de getGalerie

+ +
+

Identifiant : getId(); ?>

+ + +

GalerieC

+

test de fetchAll()

+ +
count(); ?>
+
toArray()); ?>
+ +

test de getGalerie

+ +
+

Identifiant : id; ?>

diff --git a/module/Galerie/view/galerie/index/view.phtml b/module/Galerie/view/galerie/index/view.phtml new file mode 100644 index 0000000..0c9253a --- /dev/null +++ b/module/Galerie/view/galerie/index/view.phtml @@ -0,0 +1 @@ +

vue back-office d’une galerie : view

diff --git a/server_config/site.alias b/server_config/site.alias index f3adcf0..473bc28 100644 --- a/server_config/site.alias +++ b/server_config/site.alias @@ -1,6 +1,6 @@ -Alias /appblanche /var/git/zf2biz/application-blanche/public +Alias /galerie /var/git/zf2biz/galerie/public - + Order deny,allow Allow from all diff --git a/server_config/site.vhost b/server_config/site.vhost index 9f3a510..9242fcb 100644 --- a/server_config/site.vhost +++ b/server_config/site.vhost @@ -1,10 +1,10 @@ - ServerName appblanche.local - DocumentRoot /var/git/zf2biz/application-blanche/public + ServerName galerie.local + DocumentRoot /var/git/zf2biz/gallerie/public SetEnv APPLICATION_ENV "development" - + Order deny,allow Allow from all diff --git a/vendor/.gitignore b/vendor/.gitignore index 4578c85..df89675 100644 --- a/vendor/.gitignore +++ b/vendor/.gitignore @@ -2,4 +2,6 @@ .composer composer zendframework +doctrine +symfony autoload.php