From: vincent@cubedesigners.com Date: Fri, 24 Jun 2016 16:53:30 +0000 (+0000) Subject: Prepare forms, import datas from former website | wip #487 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b72151737e85fee48474b90d1ee3fb03a1f98be9;p=fluidbook-v3.git Prepare forms, import datas from former website | wip #487 @4 --- diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 36f13e9..4fc6368 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -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'; diff --git a/framework/application/configs/application.ini b/framework/application/configs/application.ini index d89c2c1..810434a 100644 --- a/framework/application/configs/application.ini +++ b/framework/application/configs/application.ini @@ -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 diff --git a/framework/application/controllers/MaintenanceController.php b/framework/application/controllers/MaintenanceController.php index 24e8354..fdbc3c7 100644 --- a/framework/application/controllers/MaintenanceController.php +++ b/framework/application/controllers/MaintenanceController.php @@ -1,6 +1,63 @@ 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 index 0000000..1358b9a --- /dev/null +++ b/framework/application/forms/CMS/Element/Exemple/Categories.php @@ -0,0 +1,11 @@ +setBaseForm(new Fluidbook_Form_CMS_Sub_Exemples_Category()); + $this->clearDecorators(); + + } + +} \ 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 index 0000000..275a220 --- /dev/null +++ b/framework/application/forms/CMS/Element/Exemples.php @@ -0,0 +1,17 @@ +setBaseForm(new Fluidbook_Form_CMS_Sub_Exemples_Fluidbook()); + $this->clearDecorators(); + } + +} \ No newline at end of file diff --git a/framework/application/forms/CMS/Exemples.php b/framework/application/forms/CMS/Exemples.php index 12ee9e1..83030f9 100644 --- a/framework/application/forms/CMS/Exemples.php +++ b/framework/application/forms/CMS/Exemples.php @@ -1,5 +1,11 @@ setLabel('Gestion des exemples'); + $this->addElement($exemples); + } } \ 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 index 0000000..af4ddd2 --- /dev/null +++ b/framework/application/forms/CMS/Exemplessub.php @@ -0,0 +1,5 @@ +addElement($id); + + $title = new Zend_Form_Element_Text('name'); + $title->setLabel('Nom'); + $this->addElementLocalized($title,false); + + $this->setListTitle('Exemples') + ->setNewTitle('Créer une catégorie') + ->setEditTitle('Edition de la catégory « $name »') + ->setModel('Fluidbook_Model_Reference_Category') + ->setTitleColumn("name"); + } +} \ 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 index 0000000..d0a0dc4 --- /dev/null +++ b/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php @@ -0,0 +1,53 @@ +addElement($id); + + $title = new Zend_Form_Element_Text('title'); + $title->setLabel('Titre'); + $this->addElementLocalized($title,false); + + $text = new Zend_Form_Element_Textarea('text'); + $text->setLabel('Texte'); + $this->addElementLocalized($text,false); + + $date = new CubeIT_Form_Element_Date('date'); + $date->setLabel('Date'); + $date->setPrecision(CubeIT_Date::DAY); + $this->addElement($date); + + $image = new CubeIT_Form_Element_File_Image('image'); + $image->setLabel('Image'); + $this->addElement($image); + + $url = new CubeIT_Form_Element_Url('url'); + $url->setLabel('URL'); + $this->addElementLocalized($url,false); + + $fluidbook = new CubeIT_Form_Element_Int('fluidbook_id'); + $fluidbook->setLabel('Identifiant du Fluidbook'); + $this->addElementLocalized($fluidbook,false); + + $categories = new Fluidbook_Form_CMS_Element_Exemple_Categories('categories'); + $categories->setLabel('Catégories'); + $this->addElement($categories); + + $featured = new Zend_Form_Element_Checkbox('featured'); + $featured->setLabel('Mis en avant'); + $this->addElement($featured); + + $this->setListTitle('Exemples') + ->setNewTitle('Créer un exemple') + ->setEditTitle('Edition de l\'exemple « $title »') + ->setModel('Fluidbook_Model_Reference') + ->setTitleColumn("title") + ->setAdditionnalColumns(array('fluidbook_id', 'featured')) + ->setSearchColumns(array('text', 'fluidbook_id')); + } + + +} \ No newline at end of file diff --git a/framework/application/models/Reference.php b/framework/application/models/Reference.php new file mode 100644 index 0000000..7fc37bd --- /dev/null +++ b/framework/application/models/Reference.php @@ -0,0 +1,28 @@ +addColumn('title', 'text'); + $table->addColumn('text', 'text'); + $table->addColumn('url', 'text'); + $table->addColumn('date', 'date'); + $table->addColumn('fluidbook_id', 'text'); + $table->addColumn('featured', 'boolean'); + $table->addColumn('image', 'string', array('length' => 64)); + $table->addColumn('categories', 'string', array('length' => 64)); + return $table; + } +} \ 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 index 0000000..fbed00d --- /dev/null +++ b/framework/application/models/Reference/Category.php @@ -0,0 +1,19 @@ +addColumn('name', 'text'); + return $table; + } +} \ No newline at end of file