Преглед изворни кода

add the pages.ot_page_type field

Olivier Massot пре 1 година
родитељ
комит
bc1664c66e

+ 38 - 8
ot_admin/Classes/Controller/SiteController.php

@@ -5,6 +5,7 @@ namespace Opentalent\OtAdmin\Controller;
 use Doctrine\DBAL\Driver\Exception;
 use Doctrine\DBAL\Driver\Exception;
 use Opentalent\OtAdmin\Domain\Entity\SiteInfos;
 use Opentalent\OtAdmin\Domain\Entity\SiteInfos;
 use Opentalent\OtAdmin\Domain\Entity\SiteStatus;
 use Opentalent\OtAdmin\Domain\Entity\SiteStatus;
+use Opentalent\OtAdmin\Enum\OtPageTypeEnum;
 use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
 use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
 use Opentalent\OtCore\Exception\NoSuchOrganizationException;
 use Opentalent\OtCore\Exception\NoSuchOrganizationException;
 use Opentalent\OtCore\Exception\NoSuchRecordException;
 use Opentalent\OtCore\Exception\NoSuchRecordException;
@@ -290,6 +291,7 @@ class SiteController extends ActionController
                 $rootUid,
                 $rootUid,
                 'Accueil',
                 'Accueil',
                 '/accueil',
                 '/accueil',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 [
                 [
                     'dokType' => self::DOK_SHORTCUT,
                     'dokType' => self::DOK_SHORTCUT,
@@ -302,7 +304,8 @@ class SiteController extends ActionController
                 $websiteUid,
                 $websiteUid,
                 $rootUid,
                 $rootUid,
                 'Présentation',
                 'Présentation',
-                '/presentation'
+                '/presentation',
+                OtPageTypeEnum::MANDATORY_EDITABLE
             );
             );
 
 
             // > 'Présentation > Qui sommes-nous ?' page (hidden by default)
             // > 'Présentation > Qui sommes-nous ?' page (hidden by default)
@@ -311,6 +314,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Qui sommes nous?',
                 'Qui sommes nous?',
                 '/qui-sommes-nous',
                 '/qui-sommes-nous',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 ['hidden' => 1]
                 ['hidden' => 1]
             );
             );
@@ -321,6 +325,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Les adhérents',
                 'Les adhérents',
                 '/les-adherents',
                 '/les-adherents',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 self::TEMPLATE_MEMBERS
                 self::TEMPLATE_MEMBERS
             );
             );
 
 
@@ -330,6 +335,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Les membres du CA',
                 'Les membres du CA',
                 '/les-membres-du-ca',
                 '/les-membres-du-ca',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 self::TEMPLATE_MEMBERSCA
                 self::TEMPLATE_MEMBERSCA
             );
             );
 
 
@@ -339,6 +345,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Informations Pratiques',
                 'Informations Pratiques',
                 '/informations-pratiques',
                 '/informations-pratiques',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 self::TEMPLATE_STRUCTUREDETAILS
                 self::TEMPLATE_STRUCTUREDETAILS
             );
             );
 
 
@@ -349,6 +356,7 @@ class SiteController extends ActionController
                     $this->createdPagesIndex['/presentation'],
                     $this->createdPagesIndex['/presentation'],
                     'Les sociétés adhérentes',
                     'Les sociétés adhérentes',
                     '/societes-adherentes',
                     '/societes-adherentes',
+                    OtPageTypeEnum::MANDATORY_EDITABLE,
                     self::TEMPLATE_STRUCTURES
                     self::TEMPLATE_STRUCTURES
                 );
                 );
             }
             }
@@ -359,6 +367,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Historique',
                 'Historique',
                 '/historique',
                 '/historique',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 ['hidden' => 1]
                 ['hidden' => 1]
             );
             );
@@ -371,6 +380,7 @@ class SiteController extends ActionController
                 $rootUid,
                 $rootUid,
                 'Actualités',
                 'Actualités',
                 '/actualites',
                 '/actualites',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 self::TEMPLATE_NEWS,
                 self::TEMPLATE_NEWS,
                 ['hidden' => 1]
                 ['hidden' => 1]
             );
             );
@@ -389,6 +399,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/saison-en-cours'],
                 $this->createdPagesIndex['/saison-en-cours'],
                 'Les évènements',
                 'Les évènements',
                 '/les-evenements',
                 '/les-evenements',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 self::TEMPLATE_EVENTS
                 self::TEMPLATE_EVENTS
             );
             );
 
 
@@ -399,6 +410,7 @@ class SiteController extends ActionController
                     $this->createdPagesIndex['/presentation'],
                     $this->createdPagesIndex['/presentation'],
                     'Évènements des structures',
                     'Évènements des structures',
                     '/evenements-des-structures',
                     '/evenements-des-structures',
+                    OtPageTypeEnum::MANDATORY_EDITABLE,
                     self::TEMPLATE_STRUCTURESEVENTS
                     self::TEMPLATE_STRUCTURESEVENTS
                 );
                 );
             }
             }
@@ -409,6 +421,7 @@ class SiteController extends ActionController
                 $rootUid,
                 $rootUid,
                 'Vie interne',
                 'Vie interne',
                 '/vie-interne',
                 '/vie-interne',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 [
                 [
                     'hidden' => 1,
                     'hidden' => 1,
@@ -422,6 +435,7 @@ class SiteController extends ActionController
                 $rootUid,
                 $rootUid,
                 'Footer',
                 'Footer',
                 '/footer',
                 '/footer',
+                OtPageTypeEnum::MANDATORY_NON_EDITABLE,
                 '',
                 '',
                 [
                 [
                     'dokType' => self::DOK_FOLDER,
                     'dokType' => self::DOK_FOLDER,
@@ -435,6 +449,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/footer'],
                 $this->createdPagesIndex['/footer'],
                 'Contact',
                 'Contact',
                 '/contact',
                 '/contact',
+                OtPageTypeEnum::MANDATORY_NON_EDITABLE,
                 self::TEMPLATE_CONTACT
                 self::TEMPLATE_CONTACT
             );
             );
 
 
@@ -443,7 +458,8 @@ class SiteController extends ActionController
                 $websiteUid,
                 $websiteUid,
                 $this->createdPagesIndex['/footer'],
                 $this->createdPagesIndex['/footer'],
                 'Plan du site',
                 'Plan du site',
-                '/plan-du-site'
+                '/plan-du-site',
+                OtPageTypeEnum::MANDATORY_NON_EDITABLE
             );
             );
 
 
             // > 'Footer > Mentions légales' page
             // > 'Footer > Mentions légales' page
@@ -452,6 +468,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/footer'],
                 $this->createdPagesIndex['/footer'],
                 'Mentions légales',
                 'Mentions légales',
                 '/mentions-legales',
                 '/mentions-legales',
+                OtPageTypeEnum::MANDATORY_NON_EDITABLE,
                 self::TEMPLATE_LEGAL
                 self::TEMPLATE_LEGAL
             );
             );
 
 
@@ -461,6 +478,7 @@ class SiteController extends ActionController
                 $this->createdPagesIndex['/presentation'],
                 $this->createdPagesIndex['/presentation'],
                 'Contact',
                 'Contact',
                 '/ecrivez-nous',
                 '/ecrivez-nous',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 [
                 [
                     'dokType' => self::DOK_SHORTCUT,
                     'dokType' => self::DOK_SHORTCUT,
@@ -474,6 +492,7 @@ class SiteController extends ActionController
                 $rootUid,
                 $rootUid,
                 'Page introuvable',
                 'Page introuvable',
                 '/page-introuvable',
                 '/page-introuvable',
+                OtPageTypeEnum::MANDATORY_EDITABLE,
                 '',
                 '',
                 [
                 [
                     'nav_hide' => 1,
                     'nav_hide' => 1,
@@ -1817,6 +1836,13 @@ class SiteController extends ActionController
         }
         }
     }
     }
 
 
+    public function deleteNonMandatoryPages(int $organizationId): void
+    {
+        $pages = $this->otPageRepository->getPageWithSubpages($organizationId);
+
+
+    }
+
     /**
     /**
      * Delete then regenerate all the typo3 sites yaml config files
      * Delete then regenerate all the typo3 sites yaml config files
      *
      *
@@ -1995,16 +2021,18 @@ class SiteController extends ActionController
      * @param int $pid
      * @param int $pid
      * @param string $title
      * @param string $title
      * @param string $slug
      * @param string $slug
+     * @param OtPageTypeEnum $otPageType
      * @param string $template
      * @param string $template
      * @param array $moreValues
      * @param array $moreValues
      * @return int
      * @return int
      */
      */
-    private function insertPage(int $website_uid,
-                                int $pid,
-                                string $title,
-                                string $slug,
-                                string $template = '',
-                                array $moreValues = []
+    private function insertPage(int            $website_uid,
+                                int            $pid,
+                                string         $title,
+                                string         $slug,
+                                OtPageTypeEnum $otPageType = OtPageTypeEnum::MANDATORY_EDITABLE,
+                                string         $template = '',
+                                array          $moreValues = []
                                 ): int
                                 ): int
     {
     {
         $defaultValues = [
         $defaultValues = [
@@ -2017,6 +2045,7 @@ class SiteController extends ActionController
             'backend_layout' => 'flux__grid',
             'backend_layout' => 'flux__grid',
             'backend_layout_next_level' => 'flux__grid',
             'backend_layout_next_level' => 'flux__grid',
             'ot_website_uid' => $website_uid,
             'ot_website_uid' => $website_uid,
+            'ot_page_type' => $otPageType->value
         ];
         ];
 
 
         if ($template) {
         if ($template) {
@@ -2052,6 +2081,7 @@ class SiteController extends ActionController
             $this->getParentFolderUid(),
             $this->getParentFolderUid(),
             $title,
             $title,
             '/',
             '/',
+            OtPageTypeEnum::ROOT,
             self::TEMPLATE_HOME,
             self::TEMPLATE_HOME,
             [
             [
                 'is_siteroot' => 1,
                 'is_siteroot' => 1,

+ 12 - 0
ot_admin/Classes/Enum/OtPageTypeEnum.php

@@ -0,0 +1,12 @@
+<?php
+declare(strict_types=1);
+
+namespace Opentalent\OtAdmin\Enum;
+
+enum OtPageTypeEnum: string
+{
+    case ROOT = 'ROOT';
+    case MANDATORY_EDITABLE = 'MANDATORY_EDITABLE';
+    case MANDATORY_NON_EDITABLE = 'MANDATORY_NON_EDITABLE';
+    case USER_CREATED = 'USER_CREATED';
+}

+ 3 - 1
ot_admin/ext_tables.sql

@@ -2,9 +2,11 @@
 
 
 #
 #
 # Table structure for table 'pages'
 # Table structure for table 'pages'
+# Possible values for ot_page_type are : ROOT, MANDATORY_EDITABLE, MANDATORY_NON_EDITABLE, USER_CREATED
 #
 #
 CREATE TABLE pages (
 CREATE TABLE pages (
-   manually_deleted smallint(5) unsigned NOT NULL DEFAULT 0
+    manually_deleted smallint(5) unsigned NOT NULL DEFAULT 0,
+    ot_page_type text DEFAULT 'USER_CREATED'
 );
 );
 
 
 #
 #