]> _ Git - fluidbook-v3.git/commitdiff
Prepare forms, import datas from former website | wip #487 @4
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Jun 2016 16:53:30 +0000 (16:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 24 Jun 2016 16:53:30 +0000 (16:53 +0000)
framework/application/Bootstrap.php
framework/application/configs/application.ini
framework/application/controllers/MaintenanceController.php
framework/application/forms/CMS/Element/Exemple/Categories.php [new file with mode: 0644]
framework/application/forms/CMS/Element/Exemples.php [new file with mode: 0644]
framework/application/forms/CMS/Exemples.php
framework/application/forms/CMS/Exemplessub.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Exemples/Category.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Exemples/Fluidbook.php [new file with mode: 0644]
framework/application/models/Reference.php [new file with mode: 0644]
framework/application/models/Reference/Category.php [new file with mode: 0644]

index 36f13e9d10b980c1eb84c7d77772a60818eb6a91..4fc6368181dbdbc23030448dd183bcec21b89358 100644 (file)
@@ -20,6 +20,7 @@ class Bootstrap extends CubeIT_Bootstrap {
                $templates['texte'] = 'Texte';
                $templates['fonctionnalites'] = 'Fonctionnalites';
                $templates['exemples'] = 'Exemples';
+               $templates['exemplessub'] = 'Exemples (niveau 2)';
                $templates['contact'] = 'Contact';
                $templates['agences'] = 'Agences';
                $templates['faq'] = 'FAQ';
index d89c2c118baa55b50ea182c25d3e14c88d9be1d7..810434a7dd2f47e6d56ff4e565d3962a3b7ae125 100644 (file)
@@ -29,7 +29,7 @@ former.database.adapter = pdo_mysql
 former.database.params.host = localhost
 former.database.params.username = fluidbook
 former.database.params.password = *arica*2
-former.database.params.dbname = fluidbook_dev
+former.database.params.dbname = fluidbook
 
 former.home = /home/fluidbook/www
 
index 24e83544946abc7f45b53584b3bfb9fe5712b133..fdbc3c77448babf4378dc005eb79adb47a0bedf2 100644 (file)
@@ -1,6 +1,63 @@
 <?php
 
 class MaintenanceController extends CubeIT_Controller_MaintenanceController {
-}
+       public function importReferences() {
+               $former = Bootstrap::getInstance()->getFormerDb();
+               $references = $former->select()->from('liste_references')
+                       ->query()->fetchAll();
+
+               Fluidbook_Model_Reference::truncate();
+               Fluidbook_Model_Reference_Category::truncate();
+
+               $categories = array();
+
+               foreach ($references as $reference) {
+                       if (null == $reference->type || !$reference->type) {
+                               continue;
+                       }
+                       $categories = array_merge(explode('§', $reference->type), $categories);
+
+               }
+               $categories = array_unique($categories);
+               $categories = array_values($categories);
+               $categories = array_flip($categories);
+
+               $names = array('brochures' => 'Brochure', 'catalogues' => 'Catalogue', 'magazines' => 'Magazine', 'rapports' => 'Rapport annuel');
+               foreach ($categories as $name => $id) {
+                       $m = new Fluidbook_Model_Reference_Category();
+                       $m->setIdValue($id+1);
+                       $m->setName(array('fr' => $names[$name]));
+                       $m->save(true, false);
+               }
 
-?>
+
+               foreach ($references as $reference) {
+                       $data = array();
+                       $data['id'] = $reference->uid;
+                       $data['date'] = $reference->fluidbook_date;
+                       $data['title'] = array('fr' => $reference->titre, 'en' => $reference->titre);
+                       $data['image'] = array($this->_copyFileToCMS('http://www.fluidbook.com/files/' . $reference->image));
+
+                       if ($reference->type) {
+                               $c = array();
+                               $cc = explode('§', $reference->type);
+                               foreach ($cc as $item) {
+                                       $c[] = $categories[$item]+1;
+                               }
+                               $data['categories'] = $c;
+                       }
+                       $data['text'] = array('fr' => $reference->desc___fr, 'en' => $reference->desc___en);
+                       $data['url'] = array('fr' => $this->_filterURL($reference->link_url___fr), 'en' => $this->_filterURL($reference->link_url___en));
+
+                       $m = new Fluidbook_Model_Reference($data);
+                       $m->save(true, false);
+               }
+       }
+
+       protected function _filterURL($url) {
+               if (null === $url || !$url || $url == 'http://') {
+                       return '';
+               }
+               return $url;
+       }
+}
diff --git a/framework/application/forms/CMS/Element/Exemple/Categories.php b/framework/application/forms/CMS/Element/Exemple/Categories.php
new file mode 100644 (file)
index 0000000..1358b9a
--- /dev/null
@@ -0,0 +1,11 @@
+<?php\r
+\r
+class Fluidbook_Form_CMS_Element_Exemple_Categories extends CubeIT_Form_Element_TagList {\r
+       public function init() {\r
+               parent::init();\r
+               $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Exemples_Category());\r
+               $this->clearDecorators();\r
+\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Element/Exemples.php b/framework/application/forms/CMS/Element/Exemples.php
new file mode 100644 (file)
index 0000000..275a220
--- /dev/null
@@ -0,0 +1,17 @@
+<?php\r
+\r
+/**\r
+ * Created by IntelliJ IDEA.\r
+ * User: Vincent\r
+ * Date: 24/06/2016\r
+ * Time: 16:55\r
+ */\r
+class Fluidbook_Form_CMS_Element_Exemples extends CubeIT_Form_Element_List {\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Exemples_Fluidbook());\r
+               $this->clearDecorators();\r
+       }\r
+\r
+}
\ No newline at end of file
index 12ee9e1cb9422026514ad3012b8b92b2fda535e0..83030f92738419c532629cd38d0f4c4f1bb0738b 100644 (file)
@@ -1,5 +1,11 @@
 <?php\r
 \r
-class Fluidbook_Form_CMS_Exemples extends Fluidbook_Form_CMS{\r
+class Fluidbook_Form_CMS_Exemples extends Fluidbook_Form_CMS {\r
+       public function init() {\r
+               parent::init();\r
 \r
+               $exemples = new Fluidbook_Form_CMS_Element_Exemples('exemples');\r
+               $exemples->setLabel('Gestion des exemples');\r
+               $this->addElement($exemples);\r
+       }\r
 }
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Exemplessub.php b/framework/application/forms/CMS/Exemplessub.php
new file mode 100644 (file)
index 0000000..af4ddd2
--- /dev/null
@@ -0,0 +1,5 @@
+<?php\r
+\r
+class Fluidbook_Form_CMS_Exemplessub extends Fluidbook_Form_CMS{\r
+\r
+}
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Sub/Exemples/Category.php b/framework/application/forms/CMS/Sub/Exemples/Category.php
new file mode 100644 (file)
index 0000000..0be9386
--- /dev/null
@@ -0,0 +1,21 @@
+<?php\r
+\r
+\r
+class Fluidbook_Form_CMS_Sub_Exemples_Category extends CubeIT_Form_List_Model {\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $id = new CubeIT_Form_Element_Id();\r
+               $this->addElement($id);\r
+\r
+               $title = new Zend_Form_Element_Text('name');\r
+               $title->setLabel('Nom');\r
+               $this->addElementLocalized($title,false);\r
+\r
+               $this->setListTitle('Exemples')\r
+                       ->setNewTitle('Créer une catégorie')\r
+                       ->setEditTitle('Edition de la catégory « $name »')\r
+                       ->setModel('Fluidbook_Model_Reference_Category')\r
+                       ->setTitleColumn("name");\r
+       }\r
+}
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php b/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php
new file mode 100644 (file)
index 0000000..d0a0dc4
--- /dev/null
@@ -0,0 +1,53 @@
+<?php\r
+\r
+class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model {\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $id = new CubeIT_Form_Element_Id();\r
+               $this->addElement($id);\r
+\r
+               $title = new Zend_Form_Element_Text('title');\r
+               $title->setLabel('Titre');\r
+               $this->addElementLocalized($title,false);\r
+\r
+               $text = new Zend_Form_Element_Textarea('text');\r
+               $text->setLabel('Texte');\r
+               $this->addElementLocalized($text,false);\r
+\r
+               $date = new CubeIT_Form_Element_Date('date');\r
+               $date->setLabel('Date');\r
+               $date->setPrecision(CubeIT_Date::DAY);\r
+               $this->addElement($date);\r
+\r
+               $image = new CubeIT_Form_Element_File_Image('image');\r
+               $image->setLabel('Image');\r
+               $this->addElement($image);\r
+\r
+               $url = new CubeIT_Form_Element_Url('url');\r
+               $url->setLabel('URL');\r
+               $this->addElementLocalized($url,false);\r
+\r
+               $fluidbook = new CubeIT_Form_Element_Int('fluidbook_id');\r
+               $fluidbook->setLabel('Identifiant du Fluidbook');\r
+               $this->addElementLocalized($fluidbook,false);\r
+\r
+               $categories = new Fluidbook_Form_CMS_Element_Exemple_Categories('categories');\r
+               $categories->setLabel('Catégories');\r
+               $this->addElement($categories);\r
+\r
+               $featured = new Zend_Form_Element_Checkbox('featured');\r
+               $featured->setLabel('Mis en avant');\r
+               $this->addElement($featured);\r
+\r
+               $this->setListTitle('Exemples')\r
+                       ->setNewTitle('Créer un exemple')\r
+                       ->setEditTitle('Edition de l\'exemple « $title »')\r
+                       ->setModel('Fluidbook_Model_Reference')\r
+                       ->setTitleColumn("title")\r
+                       ->setAdditionnalColumns(array('fluidbook_id', 'featured'))\r
+                       ->setSearchColumns(array('text', 'fluidbook_id'));\r
+       }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/framework/application/models/Reference.php b/framework/application/models/Reference.php
new file mode 100644 (file)
index 0000000..7fc37bd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php\r
+\r
+\r
+class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {\r
+       protected static $_table = 'exemples';\r
+\r
+       protected $title;\r
+       protected $text;\r
+       protected $date;\r
+       protected $url;\r
+       protected $fluidbook_id;\r
+       protected $image;\r
+       protected $featured;\r
+       protected $categories;\r
+\r
+       public static function getSchema($schema) {\r
+               $table = parent::getSchema($schema);\r
+               $table->addColumn('title', 'text');\r
+               $table->addColumn('text', 'text');\r
+               $table->addColumn('url', 'text');\r
+               $table->addColumn('date', 'date');\r
+               $table->addColumn('fluidbook_id', 'text');\r
+               $table->addColumn('featured', 'boolean');\r
+               $table->addColumn('image', 'string', array('length' => 64));\r
+               $table->addColumn('categories', 'string', array('length' => 64));\r
+               return $table;\r
+       }\r
+}
\ No newline at end of file
diff --git a/framework/application/models/Reference/Category.php b/framework/application/models/Reference/Category.php
new file mode 100644 (file)
index 0000000..fbed00d
--- /dev/null
@@ -0,0 +1,19 @@
+<?php\r
+\r
+/**\r
+ * Created by IntelliJ IDEA.\r
+ * User: Vincent\r
+ * Date: 24/06/2016\r
+ * Time: 16:38\r
+ */\r
+class Fluidbook_Model_Reference_Category extends CubeIT_Model_Data_Table{\r
+       protected static $_table = 'exemples_categories';\r
+\r
+       protected $name;\r
+\r
+       public static function getSchema($schema) {\r
+               $table = parent::getSchema($schema);\r
+               $table->addColumn('name', 'text');\r
+               return $table;\r
+       }\r
+}
\ No newline at end of file