From c0d135f2f6c5b2fad517d8aba13770a4ce62e728 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 23 Jun 2020 10:07:58 +0000 Subject: [PATCH] wip #3726 @0.5 --- framework/application/Bootstrap.php | 248 +++++++++++++++------------- 1 file changed, 129 insertions(+), 119 deletions(-) diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 7215eae..77f797b 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -1,34 +1,38 @@ bootstrap('doctype'); - $this->bootstrap('scripts'); - } - - /** - * - * @return array - */ - public function getCMSTemplates() { - $templates['texte'] = 'Texte'; - $templates['fonctionnalites'] = 'Fonctionnalités générales'; - $templates['fonctionnalitessub'] = 'Détail fonctionnalité'; - $templates['exemples'] = 'Exemples'; - $templates['exemplessub'] = 'Exemples (niveau 2)'; - $templates['contact'] = 'Contact'; - $templates['landingcampaign'] = 'Landing Campagne (Intro + formulaire)'; - $templates['agences'] = 'Agences'; - $templates['faq'] = 'FAQ'; - $templates['blog'] = 'Blog'; - $templates = array_merge($templates, parent::getCMSTemplates()); - return $templates; - } - - protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) { +class Bootstrap extends CubeIT_Bootstrap +{ + + protected function _initMinimum() + { + parent::_initMinimum(); + // If a project with html display (don't activate by default for web services apps) + $this->bootstrap('doctype'); + $this->bootstrap('scripts'); + } + + /** + * + * @return array + */ + public function getCMSTemplates() + { + $templates['texte'] = 'Texte'; + $templates['fonctionnalites'] = 'Fonctionnalités générales'; + $templates['fonctionnalitessub'] = 'Détail fonctionnalité'; + $templates['exemples'] = 'Exemples'; + $templates['exemplessub'] = 'Exemples (niveau 2)'; + $templates['contact'] = 'Contact'; + $templates['landingcampaign'] = 'Landing Campagne (Intro + formulaire)'; + $templates['agences'] = 'Agences'; + $templates['faq'] = 'FAQ'; + $templates['blog'] = 'Blog'; + $templates = array_merge($templates, parent::getCMSTemplates()); + return $templates; + } + + protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) + { $page = parent::_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale); if (!$page) return; @@ -39,12 +43,14 @@ class Bootstrap extends CubeIT_Bootstrap { } // URL template used for blog pages - public static function getBlogPostURLTemplate() { + public static function getBlogPostURLTemplate() + { return 'blog/%title%'; } /* @param CubeIT_Navigation_Page_Locale $page */ - protected function addBlogPages($page, $locale, $isAdmin) { + protected function addBlogPages($page, $locale, $isAdmin) + { //$datas = $this->getCMSDatasOfNavigationPage($page); // How the URLs should be formed for the news articles @@ -67,7 +73,7 @@ class Bootstrap extends CubeIT_Bootstrap { $p = new CubeIT_Navigation_Page_Locale(); $p->setController('Blogpost'); - $p->setId($locale .'/blog/'. $r->id); + $p->setId($page->getId() . '/' . $r->id); $p->setAutoUri($r, $URL_template, $locale); $p->setSitemap($online); $p->setTitle($pageTitle); @@ -76,97 +82,101 @@ class Bootstrap extends CubeIT_Bootstrap { $p->setOnline($online); $p->setDomain($page->getDomain()); $p->setLabel($pageTitle); + $p->setVisible(false); $page->addPage($p); } } - public function _initRouter($initCms = true, $standard = true) { - profile(__FILE__, __LINE__, 'Init Router'); - $router = parent::_initRouter($initCms, $standard); - $router->addStaticRoute('15000', 'landing', 'quinzemille'); - - return $router; - } - - public function handleRedirections($req) { - profile(__FILE__, __LINE__, 'Handle redirection'); - - $path = explode('/', trim($req->getParam('page', '/'), '/')); - - if ($path[0] == 'fr' || $path[0] == 'en') { - $locale = $path[0]; - $domain = $this->getOpt('locales.' . $path[0]); - } else { - return false; - } - array_shift($path); - - $path = implode('/', $path); - - // Si un des cas ci-dessus - if (isset($name)) { - $nav = $this->getNavigation()->getLocaleContainer($locale); - $page = $nav->findOneBy('name', $name); - if ($page !== null) { - return $page->getHref(); - } - } - // Autres redirections - - $map = array(); - $map['fr'] = array( - 'Questions-reponses' => 'fonctionnalites', - 'Presentation-fonctionnalites-services' => 'fonctionnalites', - 'Demande-de-devis' => 'contact', - 'Revendeurs' => 'agences', - 'References' => 'exemples', - 'References/catalogues' => 'catalogue-interactif', - 'References/rapports' => 'rapport-annuel', - 'References/magazines' => 'magazine', - 'References/brochures' => 'brochure', - ); - - $map['en'] = array( - 'Faq' => 'fonctionnalites', - 'Overview' => 'fonctionnalites', - 'Quote-request' => 'contact', - 'Resellers' => 'agences', - 'Clients' => 'exemples', - 'Clients/catalogues' => 'catalogue-interactif', - 'Clients/rapports' => 'rapport-annuel', - 'Clients/magazines' => 'magazine', - 'Clients/brochures' => 'brochure', - ); - - if (!isset($map[$locale][$path]) && (strpos($path, 'References') === 0 || strpos($path, 'Clients') === 0)) { - $nav = $this->getNavigation()->getLocaleContainer($locale); - $page = $nav->findOneBy('name', 'exemples'); - if ($page != null) { - return $page->getHref(); - } - } - - if (isset($map[$locale][$path])) { - $nav = $this->getNavigation()->getLocaleContainer($locale); - $page = $nav->findOneBy('name', $map[$locale][$path]); - if ($page != null) { - return $page->getHref(); - } - } else { - $url = SITE_PROTOCOL . $domain . '/'; - } - - if (isset($url)) { - return $url; - } - - return false; - } - - - function __destroy() { - endProfile(); - } + public function _initRouter($initCms = true, $standard = true) + { + profile(__FILE__, __LINE__, 'Init Router'); + $router = parent::_initRouter($initCms, $standard); + $router->addStaticRoute('15000', 'landing', 'quinzemille'); + + return $router; + } + + public function handleRedirections($req) + { + profile(__FILE__, __LINE__, 'Handle redirection'); + + $path = explode('/', trim($req->getParam('page', '/'), '/')); + + if ($path[0] == 'fr' || $path[0] == 'en') { + $locale = $path[0]; + $domain = $this->getOpt('locales.' . $path[0]); + } else { + return false; + } + array_shift($path); + + $path = implode('/', $path); + + // Si un des cas ci-dessus + if (isset($name)) { + $nav = $this->getNavigation()->getLocaleContainer($locale); + $page = $nav->findOneBy('name', $name); + if ($page !== null) { + return $page->getHref(); + } + } + // Autres redirections + + $map = array(); + $map['fr'] = array( + 'Questions-reponses' => 'fonctionnalites', + 'Presentation-fonctionnalites-services' => 'fonctionnalites', + 'Demande-de-devis' => 'contact', + 'Revendeurs' => 'agences', + 'References' => 'exemples', + 'References/catalogues' => 'catalogue-interactif', + 'References/rapports' => 'rapport-annuel', + 'References/magazines' => 'magazine', + 'References/brochures' => 'brochure', + ); + + $map['en'] = array( + 'Faq' => 'fonctionnalites', + 'Overview' => 'fonctionnalites', + 'Quote-request' => 'contact', + 'Resellers' => 'agences', + 'Clients' => 'exemples', + 'Clients/catalogues' => 'catalogue-interactif', + 'Clients/rapports' => 'rapport-annuel', + 'Clients/magazines' => 'magazine', + 'Clients/brochures' => 'brochure', + ); + + if (!isset($map[$locale][$path]) && (strpos($path, 'References') === 0 || strpos($path, 'Clients') === 0)) { + $nav = $this->getNavigation()->getLocaleContainer($locale); + $page = $nav->findOneBy('name', 'exemples'); + if ($page != null) { + return $page->getHref(); + } + } + + if (isset($map[$locale][$path])) { + $nav = $this->getNavigation()->getLocaleContainer($locale); + $page = $nav->findOneBy('name', $map[$locale][$path]); + if ($page != null) { + return $page->getHref(); + } + } else { + $url = SITE_PROTOCOL . $domain . '/'; + } + + if (isset($url)) { + return $url; + } + + return false; + } + + + function __destroy() + { + endProfile(); + } } -- 2.39.5