1'use strict'; // 2 3// **************************************************** 4// Gestion des Reecritures dUrl et des balises SEO 5// **************************************************** 6angular.module('AboShopApp').provider('seo',function ($stateProvider, commonConfig, $urlRouterProvider) { 7 let rewriteUrlStore = []; 8 let routesExclues = ['/','/index','/common/login','/common/autologin','/common/logout','/common/logininfo', 9 '/common/logingetpassword','/common/logingetpasswordcp','/common/logingetemail','/common/logingetemailpwd', 10 '/common/passwordnonconforme','/common/passwordexpired','/common/updatepassword']; 11 12 var productdetails = { 13 name: "root.productarticle", 14 url: "/common/product-article/:ID_PRODUCT", 15 views: { 16 'container@': { 17 templateUrl: "COMMONROOT/content/product-subscriptions.html?v=COMMONVERSION", 18 controller: "productsubscriptionCtrl" 19 } 20 }, 21 data : { pageTitle: 'DICO_ROUTING_PRODUITS_TITRE' } 22 }; 23 24 var productsubscription = { 25 name: "root.productsubscription", 26 url: "/common/product-subscription/:ID_PRODUCT", 27 views: { 28 'container@': { 29 templateUrl: "COMMONROOT/content/product-subscriptions.html?v=COMMONVERSION", 30 controller: "productsubscriptionCtrl" 31 } 32 }, 33 data : { pageTitle: 'DICO_ROUTING_ABONNEMENT_TITRE' } 34 }; 35 36 var productsubscriptionreab = { 37 name: "root.productsubscriptionreab", 38 url: "/common/product-subscription/:ID_PRODUCT/:REF_ABO_ECHU", 39 views: { 40 'container@': { 41 templateUrl: "COMMONROOT/content/product-subscriptions.html?v=COMMONVERSION", 42 controller: "productsubscriptionCtrl" 43 } 44 }, 45 data : { pageTitle: 'DICO_ROUTING_ABONNEMENT_TITRE' } 46 }; 47 48 var listproductsbycategories = { 49 name: "root.listproductsbycategories", 50 url: "/common/categories/:ID_CATEGORIE", 51 views: { 52 'container@': { 53 templateUrl: "COMMONROOT/content/products.html?v=COMMONVERSION", 54 controller: "productsCtrl" 55 } 56 }, 57 data : { pageTitle: 'DICO_ROUTING_LISTE_DES_PRODUITS_TITRE' } 58 }; 59 60 var listchildcategoriesbycategories = { 61 name: "root.listchildcategoriesbycategories", 62 url: "/common/categories-list/:ID_CATEGORIE", 63 views: { 64 'container@': { 65 templateUrl: "COMMONROOT/content/categories-child.html?v=COMMONVERSION", 66 controller: "productsCtrl" 67 } 68 }, 69 data : { pageTitle: 'DICO_ROUTING_LISTE_DES_CATEGORIES_TITRE' } 70 }; 71 72 var cms = { 73 name: "root.cms", 74 url: "/common/cms/:ID_PAGE", 75 views: { 76 'container@': { 77 templateUrl: "COMMONROOT/content/cms.html?v=COMMONVERSION", 78 controller: "cmsCtrl" 79 } 80 }, 81 data : { pageTitle: 'DICO_ROUTING_CMS_TITRE' } 82 }; 83 84 85 function _registerCommonRoutes(){ 86 // For any unmatched url, redirect to /404 87 $urlRouterProvider.otherwise("/message/404"); 88 89 let sitemapTemplate = { 90 url: '', 91 abstract: true, 92 name: "sitemap", 93 views: { 94 'sitemap': { 95 template: '' 96 } 97 } 98 }; 99 100 let sitemap = { 101 name: "sitemap.display", 102 url: "/sitemap", 103 views: { 104 'sitemap@': { 105 templateUrl: commonConfig.commonroot+"/content/sitemap.html?v="+commonConfig.forceversion, 106 controller: "sitemapCtrl" 107 } 108 }, 109 data : { pageTitle: 'Sitemap' } 110 }; 111 112 //$stateProvider 113 // .state(sitemapTemplate) 114 // .state(sitemap); 115 let home = {}; 116 if (commonConfig.forceRedirectToCategorie === undefined) { 117 home = { 118 name: "root.home", 119 url: "/", 120 views: { 121 'container@': { 122 templateUrl: commonConfig.commonroot+"/content/home/home.html?v="+commonConfig.forceversion, 123 controller: "homeCtrl" 124 } 125 }, 126 data : { pageTitle: 'DICO_ROUTING_ACCUEIL_TITRE' } 127 }; 128 } else { 129 home = { 130 name: "root.home", 131 url: "/", 132 params : { ID_CATEGORIE : commonConfig.forceRedirectToCategorie}, 133 views: { 134 'container@': { 135 templateUrl: commonConfig.commonroot+"/content/products.html?v="+commonConfig.forceversion, 136 controller: "productsCtrl" 137 }, 138 }, 139 data : { pageTitle: 'DICO_ROUTING_ACCUEIL_TITRE' } 140 }; 141 } 142 143 let homeperso = { 144 name: "root.homeperso", 145 url: "/index", 146 views: { 147 'container@': { 148 templateUrl: commonConfig.commonroot+"/content/home/home.html?v="+commonConfig.forceversion, 149 controller: "homeCtrl" 150 } 151 }, 152 data : { pageTitle: 'DICO_ROUTING_ACCUEIL_TITRE' } 153 }; 154 155 let shopclose = { 156 name: "root.shopclose", 157 url: "/shopclose", 158 views: { 159 'container@': { 160 templateUrl: commonConfig.commonroot+"/content/shopclose.html?v="+commonConfig.forceversion, 161 controller: "errorCtrl" 162 } 163 }, 164 data : { pageTitle: 'DICO_ROUTING_ACCUEIL_TITRE' } 165 }; 166 167 let login = { 168 name: "root.login", 169 url: "/common/login", 170 views: { 171 'container@': { 172 templateUrl: commonConfig.commonroot+"/content/identification.html?v="+commonConfig.forceversion, 173 controller: "loginCtrl" 174 } 175 }, 176 data : { pageTitle: 'DICO_ROUTING_IDENTIFICATION_TITRE' } 177 }; 178 179 if (commonConfig.oAuthExterne !== undefined && commonConfig.oAuthExterne.urlFront != null) { 180 if(commonConfig.oAuthExterne.ssoQiota){ 181 login = { 182 name: "root.login", 183 url: "/common/login", 184 views: { 185 'container@': { 186 templateUrl: commonConfig.commonroot+"/content/identificationqiota.html?v="+commonConfig.forceversion, 187 controller: "loginQiotaCtrl" 188 } 189 }, 190 data : { pageTitle: 'DICO_ROUTING_IDENTIFICATION_TITRE' } 191 }; 192 } else { 193 login = { 194 name: "root.login", 195 url: "/common/login", 196 views: { 197 'container@': { 198 templateUrl: commonConfig.commonroot+"/content/identificationiframe.html?v="+commonConfig.forceversion, 199 controller: "loginIframeCtrl" 200 } 201 }, 202 data : { pageTitle: 'DICO_ROUTING_IDENTIFICATION_TITRE' } 203 }; 204 } 205 } 206 207 let loginforget = { 208 name: "root.loginforget", 209 url: "/common/login/forget", 210 params : { OPEN_FORGET : true}, 211 views: { 212 'container@': { 213 templateUrl: commonConfig.commonroot+"/content/identification.html?v="+commonConfig.forceversion, 214 controller: "loginCtrl" 215 } 216 }, 217 data : { pageTitle: 'DICO_ROUTING_IDENTIFICATION_TITRE' } 218 }; 219 220 let autologin = { 221 name: "root.autologin", 222 url: "/common/autologin", 223 views: { 224 'container@': { 225 templateUrl: commonConfig.commonroot+"/content/autologin.html?v="+commonConfig.forceversion, 226 controller: "autologinCtrl" 227 } 228 }, 229 data : { pageTitle: 'DICO_ROUTING_IDENTIFICATION_TITRE' } 230 }; 231 232 let delivery = { 233 name: "root.delivery", 234 url: "/common/delivery", 235 views: { 236 'container@': { 237 templateUrl: commonConfig.commonroot+"/content/delivery.html?v="+commonConfig.forceversion, 238 controller: "deliveryCtrl" 239 } 240 }, 241 data : { pageTitle: 'DICO_ROUTING_LIVRAISON_TITRE' } 242 }; 243 244 let payment = { 245 name: "root.payment", 246 url: "/common/payment", 247 views: { 248 'container@': { 249 templateUrl: commonConfig.commonroot+"/content/payment.html?v="+commonConfig.forceversion, 250 controller: "paymentCtrl" 251 } 252 }, 253 data : { pageTitle: 'DICO_ROUTING_PAIEMENT_TITRE' } 254 }; 255 256 let paymentdetails = { 257 name: "root.paymentdetails", 258 url: "/common/paymentdetails", 259 views: { 260 'container@': { 261 templateUrl: commonConfig.commonroot+"/content/payment-details.html?v="+commonConfig.forceversion, 262 controller: "paymentdetailsCtrl" 263 } 264 }, 265 data : { pageTitle: 'DICO_ROUTING_PAIEMENT_DETAILS_TITRE' } 266 }; 267 268 let paymentstatus = { 269 name: "root.paymentstatus", 270 url: "/common/paymentstatus", 271 views: { 272 'container@': { 273 templateUrl: commonConfig.commonroot+"/content/paymentstatus.html?v="+commonConfig.forceversion, 274 controller: "paymentstatusCtrl" 275 } 276 }, 277 data : { pageTitle: 'DICO_ROUTING_VALIDATION_COMMANDE_TITRE' } 278 }; 279 280 let paymentstatuspaybox = { 281 name: "root.paymentstatuspaybox", 282 url: "/common/paymentstatuspaybox", 283 views: { 284 'container@': { 285 templateUrl: commonConfig.commonroot+"/content/paymentstatus.html?v="+commonConfig.forceversion, 286 controller: "paymentstatuspayboxCtrl" 287 } 288 }, 289 data : { pageTitle: 'DICO_ROUTING_VALIDATION_COMMANDE_TITRE' } 290 }; 291 292 let paymentstatuspayboxerror = { 293 name: "root.paymentstatuspayboxerror", 294 url: "/common/paymentstatuspayboxerror", 295 views: { 296 'container@': { 297 templateUrl: commonConfig.commonroot+"/content/paymentstatus.html?v="+commonConfig.forceversion, 298 controller: "paymentstatuspayboxerrorCtrl" 299 } 300 }, 301 data : { pageTitle: 'DICO_ROUTING_VALIDATION_COMMANDE_TITRE' } 302 }; 303 304 let paymentcancel = { 305 name: "root.paymentcancel", 306 url: "/common/paymentcancel", 307 views: { 308 'container@': { 309 templateUrl: commonConfig.commonroot+"/content/paymentcancel.html?v="+commonConfig.forceversion, 310 controller: "paymentcancelCtrl" 311 } 312 }, 313 data : { pageTitle: 'DICO_ROUTING_ANNULATION_COMMANDE_TITRE' } 314 }; 315 316 let logout = { 317 name: "root.logout", 318 url: "/common/logout", 319 views: { 320 'container@': { 321 templateUrl: commonConfig.commonroot+"/content/logout.html?v="+commonConfig.forceversion, 322 controller: "logoutCtrl" 323 } 324 }, 325 data : { pageTitle: 'DICO_ROUTING_DECONNEXION_TITRE' } 326 }; 327 328 let productlistsubscription = { 329 name: "root.productlistsubscription", 330 url: "/common/product-list-subscription/:REF_ABO_ECHU", 331 views: { 332 'container@': { 333 templateUrl: commonConfig.commonroot+"/content/products-list-subscriptions.html?v="+commonConfig.forceversion, 334 controller: "productlistsubscriptionCtrl" 335 } 336 }, 337 data : { pageTitle: 'DICO_ROUTING_LISTE_DES_PRODUITS_TITRE' } 338 }; 339 340 let listproductsbycategoriesbydate = { 341 name: "root.listproductsbycategoriesbydate", 342 url: "/common/categories/:ID_CATEGORIE/:YEAR/:MONTH", 343 views: { 344 'container@': { 345 templateUrl: commonConfig.commonroot+"/content/products.html?v="+commonConfig.forceversion, 346 controller: "productsCtrl" 347 } 348 }, 349 data : { pageTitle: 'DICO_ROUTING_LISTE_DES_PRODUITS_TITRE' } 350 }; 351 352 let productdonation = { 353 name: "root.productdonation", 354 url: "/common/product-donation/:ID_PRODUCT", 355 views: { 356 'container@': { 357 templateUrl: commonConfig.commonroot+"/content/product-donation.html?v="+commonConfig.forceversion, 358 controller: "productdonationCtrl" 359 } 360 }, 361 data : { pageTitle: 'DICO_ROUTING_DONATION_TITRE' } 362 }; 363 364 let listproducts = { 365 name: "root.listofproducts", 366 url: "/common/products", 367 views: { 368 'container@': { 369 templateUrl: commonConfig.commonroot+"/content/products.html?v="+commonConfig.forceversion, 370 controller: "productsCtrl" 371 } 372 }, 373 data : { pageTitle: 'DICO_ROUTING_LISTE_DES_PRODUITS_TITRE' } 374 }; 375 376 let searchproducts = { 377 name: "root.searchproducts", 378 url: "/common/search/:SEARCH/:FILTER", 379 views: { 380 'container@': { 381 templateUrl: commonConfig.commonroot+"/content/search.html?v="+commonConfig.forceversion, 382 controller: "searchCtrl" 383 } 384 }, 385 data : { pageTitle: 'DICO_ROUTING_RESULTAT_DE_LA_RECHERCHE_TITRE' } 386 }; 387 388 let trylog = { 389 name: "root.trylog", 390 url: "/common/trylog/:EMAIL/:PASSWORD", 391 views: { 392 'container@': { 393 templateUrl: commonConfig.commonroot+"/content/trylog.html?v="+commonConfig.forceversion, 394 controller: "trylogCtrl" 395 } 396 }, 397 data : { pageTitle: 'DICO_ROUTING_PROBLEME_CONNEXION' } 398 }; 399 400 let activate = { 401 name: "root.activatecustomer", 402 url: "/common/activate/:ID_ACTIVATION", 403 views: { 404 'container@': { 405 templateUrl: commonConfig.commonroot+"/content/activate.html?v="+commonConfig.forceversion, 406 controller: "activateCustomerCtrl" 407 } 408 }, 409 data : { pageTitle: 'DICO_ROUTING_ACTIVATION_DU_COMPTE_TITRE' } 410 }; 411 412 let validate = { 413 name: "root.validate", 414 url: "/common/validate/:CODE_CLIENT", 415 views: { 416 'container@': { 417 templateUrl: commonConfig.commonroot+"/content/vali
417date.html?v="+commonConfig.forceversion, 418 controller: "validateAccountCtrl" 419 } 420 }, 421 data : { pageTitle: 'DICO_ROUTING_VALIDATION_DU_COMPTE_TITRE' } 422 }; 423 424 425 let activatenewsletter = { 426 name: "root.activatenewsletter", 427 url: "/common/activatenewsletter/:ID_ACTIVATION", 428 views: { 429 'container@': { 430 templateUrl: commonConfig.commonroot+"/content/activatenewsletter.html?v="+commonConfig.forceversion, 431 controller: "activatenewsletterCtrl" 432 } 433 }, 434 data : { pageTitle: 'DICO_ROUTING_ACTIVATION_DU_COMPTE_TITRE' } 435 }; 436 437 let contact = { 438 name: "root.contact", 439 url: "/common/contact", 440 views: { 441 'container@': { 442 templateUrl: commonConfig.commonroot+"/content/contact.html?v="+commonConfig.forceversion, 443 controller: "contactCtrl" 444 } 445 }, 446 data : { pageTitle: 'DICO_ROUTING_CONTACT_TITRE' } 447 }; 448 449 let profil = { 450 name: "root.profil", 451 url: "/common/profil/:ID_ANCHOR", 452 views: { 453 'container@': { 454 templateUrl: commonConfig.commonroot+"/content/profil.html?v="+commonConfig.forceversion, 455 controller: "profilCtrl" 456 } 457 }, 458 data : { pageTitle: 'DICO_ROUTING_PROFILE_TITRE' } 459 }; 460 461 let basket = { 462 name: "root.basket", 463 url: "/common/cart", 464 views: { 465 'container@': { 466 templateUrl: commonConfig.commonroot+"/content/basket.html?v="+commonConfig.forceversion, 467 controller: "cartCtrl" 468 } 469 }, 470 data : { pageTitle: 'DICO_ROUTING_PANIER_TITRE' } 471 }; 472 473 let logininfo = { 474 name: "root.logininfo", 475 url: "/common/logininfo", 476 views: { 477 'container@': { 478 templateUrl: commonConfig.commonroot+"/content/login/logininfo.html?v="+commonConfig.forceversion, 479 controller: "logininfoCtrl" 480 } 481 }, 482 data : { pageTitle: 'DICO_ROUTING_LOGIN_INFO' } 483 }; 484 485 let logingetpassword = { 486 name: "root.logingetpassword", 487 url: "/common/logingetpassword", 488 views: { 489 'container@': { 490 templateUrl: commonConfig.commonroot+"/content/login/logingetpassword.html?v="+commonConfig.forceversion, 491 controller: "logingetpasswordCtrl" 492 } 493 }, 494 data : { pageTitle: 'DICO_ROUTING_LOGIN_INFO_MOTDEPASSE' } 495 }; 496 497 let logingetpasswordcp = { 498 name: "root.logingetpasswordcp", 499 url: "/common/logingetpasswordcp", 500 views: { 501 'container@': { 502 templateUrl: commonConfig.commonroot+"/content/login/logingetpasswordcp.html?v="+commonConfig.forceversion, 503 controller: "logingetpasswordcpCtrl" 504 } 505 }, 506 data : { pageTitle: 'DICO_ROUTING_LOGIN_INFO_MOTDEPASSE' } 507 }; 508 509 let logingetemail = { 510 name: "root.logingetemail", 511 url: "/common/logingetemail", 512 views: { 513 'container@': { 514 templateUrl: commonConfig.commonroot+"/content/login/logingetemail.html?v="+commonConfig.forceversion, 515 controller: "logingetemailCtrl" 516 } 517 }, 518 data : { pageTitle: 'DICO_ROUTING_GET_EMAIL' } 519 }; 520 521 let logingetemailpwd = { 522 name: "root.logingetemailpwd", 523 url: "/common/logingetemailpwd", 524 views: { 525 'container@': { 526 templateUrl: commonConfig.commonroot+"/content/login/logingetemailpwd.html?v="+commonConfig.forceversion, 527 controller: "logingetemailpwdCtrl" 528 } 529 }, 530 data : { pageTitle: 'DICO_ROUTING_GET_EMAIL' } 531 }; 532 533 let passwordnonconforme = { 534 name: "root.passwordnonconforme", 535 url: "/common/passwordnonconforme", 536 views: { 537 'container@': { 538 templateUrl: commonConfig.commonroot+"/content/login/passwordnonconforme.html?v="+commonConfig.forceversion, 539 controller: "passwordnonconformeCtrl" 540 } 541 }, 542 data : { pageTitle: 'DICO_ROUTING_GET_EMAIL' } 543 }; 544 545 let passwordexpired = { 546 name: "root.passwordexpired", 547 url: "/common/passwordexpired", 548 views: { 549 'container@': { 550 templateUrl: commonConfig.commonroot+"/content/login/passwordexpired.html?v="+commonConfig.forceversion, 551 controller: "passwordexpiredCtrl" 552 } 553 }, 554 data : { pageTitle: 'DICO_ROUTING_GET_EMAIL' } 555 }; 556 557 let updatepassword = { 558 name: "root.updatepassword", 559 url: "/common/updatepassword/:JETON", 560 views: { 561 'container@': { 562 templateUrl: commonConfig.commonroot+"/content/login/updatepassword.html?v="+commonConfig.forceversion, 563 controller: "updatepasswordCtrl" 564 } 565 }, 566 data : { pageTitle: 'DICO_ROUTING_GET_EMAIL' } 567 }; 568 569 replaceRootConf(cms, commonConfig); 570 replaceRootConf(productdetails, commonConfig); 571 replaceRootConf(productsubscription, commonConfig); 572 replaceRootConf(productsubscriptionreab, commonConfig); 573 replaceRootConf(listproductsbycategories, commonConfig); 574 replaceRootConf(listchildcategoriesbycategories, commonConfig); 575 576 let allRoutes = []; 577 578 // routes disponibles pour l'espace mon compte 579 if(commonConfig.module == undefined || !commonConfig.module.profil) { 580 _checkRoutesAndPush(allRoutes,profil); 581 582 // en cas d'externalisation de l'espace mon compte on force la page d'accueil 583 if (commonConfig.module != undefined && commonConfig.module.others
583) { 584 home.views = login.views; 585 home.data = login.data; 586 homeperso.views = login.views; 587 homeperso.data = login.data; 588 } 589 } 590 591 // routes disponibles pour la partie boutique 592 if(commonConfig.module == undefined || !commonConfig.module.others) { 593 _checkRoutesAndPush(allRoutes,basket); 594 _checkRoutesAndPush(allRoutes,contact); 595 _checkRoutesAndPush(allRoutes,activate); 596 _checkRoutesAndPush(allRoutes,validate); 597 _checkRoutesAndPush(allRoutes,activatenewsletter); 598 _checkRoutesAndPush(allRoutes,delivery); 599 _checkRoutesAndPush(allRoutes,payment); 600 _checkRoutesAndPush(allRoutes,paymentstatus); 601 _checkRoutesAndPush(allRoutes,paymentstatuspaybox); 602 _checkRoutesAndPush(allRoutes,paymentstatuspayboxerror); 603 _checkRoutesAndPush(allRoutes,paymentdetails); 604 _checkRoutesAndPush(allRoutes,shopclose); 605 _checkRoutesAndPush(allRoutes,productlistsubscription); 606 _checkRoutesAndPush(allRoutes,listproductsbycategoriesbydate); 607 _checkRoutesAndPush(allRoutes,productdonation); 608 _checkRoutesAndPush(allRoutes,listproducts); 609 _checkRoutesAndPush(allRoutes,searchproducts); 610 611 _checkRoutesAndPush(allRoutes,cms) 612 _checkRoutesAndPush(allRoutes,productdetails) 613 _checkRoutesAndPush(allRoutes,productsubscription) 614 _checkRoutesAndPush(allRoutes,productsubscriptionreab) 615 _checkRoutesAndPush(allRoutes,listproductsbycategories) 616 _checkRoutesAndPush(allRoutes,listchildcategoriesbycategories) 617 ; 618 } 619 620 // routes toujours disponibles 621 _checkRoutesAndPush(allRoutes,home); 622 _checkRoutesAndPush(allRoutes,homeperso); 623 _checkRoutesAndPush(allRoutes,trylog); 624 _checkRoutesAndPush(allRoutes,login); 625 _checkRoutesAndPush(allRoutes,loginforget); 626 _checkRoutesAndPush(allRoutes,autologin); 627 _checkRoutesAndPush(allRoutes,logout); 628 _checkRoutesAndPush(allRoutes,logininfo); 629 _checkRoutesAndPush(allRoutes,logingetpassword); 630 _checkRoutesAndPush(allRoutes,logingetpasswordcp); 631 _checkRoutesAndPush(allRoutes,logingetemail); 632 _checkRoutesAndPush(allRoutes,logingetemailpwd); 633 _checkRoutesAndPush(allRoutes,passwordnonconforme); 634 _checkRoutesAndPush(allRoutes,passwordexpired); 635 _checkRoutesAndPush(allRoutes,updatepassword); 636 637 if (typeof addCustomerRooting === "function") { 638 try{addCustomerRooting($stateProvider, commonConfig);} catch (e) { 639 console.error(e); 640 }; 641 } 642 643 return allRoutes; 644 }; 645 646 let replaceRootConf = function replaceRootConf(route, commonConfig){ 647 route.views['container@'].templateUrl = route.views['container@'].templateUrl.replace('COMMONROOT',commonConfig.commonroot).replace('COMMONVERSION',commonConfig.forceversion); 648 } 649 650 function _getRealPath(currentPath) { 651 let ob = _.findWhere(rewriteUrlStore, {from: currentPath}); 652 if(ob !== undefined){ 653 return ob.to; 654 } 655 return currentPath; 656 } 657 658 function _getOldPath(currentPath) { 659 let ob = _.findWhere(rewriteUrlStore, {to: currentPath}); 660 if(ob !== undefined){ 661 return ob.from; 662 } 663 return currentPath; 664 } 665 666 function _isUrlRewrite(currentPath) { 667 let ob = _.findWhere(rewriteUrlStore, {to: currentPath}); 668 if(ob !== undefined){ 669 return true; 670 } 671 return false; 672 } 673 674 function _checkRoutesAndPush(allRoutes,newRoute){ 675 if(newRoute !== undefined && newRoute.name !== undefined && newRoute.url !== undefined && newRoute.name !== "" && newRoute.url !== "") { 676 let foundRoute = _findRoute(allRoutes,newRoute); 677 if(foundRoute === undefined) { 678 allRoutes.push(newRoute); 679 } else { 680 console.log("ERROR : Route not registered : [urlOld=" + foundRoute.url+ ",urlNew=" + newRoute.url + " nameOld=" + foundRoute.name+ ",nameNew=" + newRoute.name); 681 } 682 } 683 } 684 685 function _findRoute(allRoutes,newRoute){ 686 let foundRoute = undefined; 687 if(newRoute !== undefined && newRoute.name !== undefined && newRoute.url !== undefined && newRoute.name !== "" && newRoute.url !== "") { 688 for(let i = 0; i < allRoutes.length; i++) { 689 if(allRoutes[i].name === newRoute.name || allRoutes[i].url === newRoute.url){ 690 foundRoute = allRoutes[i]; 691 break; 692 } 693 } 694 } 695 return foundRoute; 696 } 697 698 function _findRouteStartsWith(allRoutes,newRoute){ 699 let foundRoute = undefined; 700 if(newRoute !== undefined && newRoute.url !== undefined && newRoute.url !== "") { 701 for(let i = 0; i < allRoutes.length; i++) { 702 if(allRoutes[i].url.startsWith(newRoute.url)){ 703 foundRoute = allRoutes[i]; 704 break; 705 } 706 } 707 } 708 return foundRoute; 709 } 710 711 function _storeRoutes(allRoutes){
712 console.log("register all routes"); 713 714 for(let i = 0; i < allRoutes.length; i++) { 715 //console.log(allRoutes[i].url); 716 $stateProvider.state(allRoutes[i]); 717 } 718 719 let len = routesExclues.length; 720 for(let i = 0; i < len; i++) { 721 routesExclues.push(_getRealPath(routesExclues[i])); 722 } 723 routesExclues = _.uniq(routesExclues); 724 } 725 726 this.registerCommonRoutes = function registerCommonRoutes(){ 727 let allRoutes = _registerCommonRoutes(); 728 _storeRoutes(allRoutes); 729 } 730 731 var registerRoutes = function registerRoutes($window, rewriteurls, $state){ 732 733 let allRoutes = _registerCommonRoutes(); 734 735 const entitiesUrl = { 736 ARTICLE_LIBRE: 'article', 737 ABONNEMENT: 'abonnement', 738 FORMULE: 'formule', 739 CATEGORIE: 'CATEGORIE', 740 PAGE: 'PAGE', 741 URL: 'URL' 742 } 743 744 let newState = {}, ob = {}, urlRewrite = {}; 745 746 if(rewriteurls !== undefined && rewriteurls.length > 0){ 747 let i = 0; 748 for(i = 0; i < rewriteurls.length; i++) { 749 urlRewrite = rewriteurls[i]; 750 751 if(urlRewrite !== null && urlRewrite.typeEntity !== undefined) { 752 newState = {}; 753 ob = {}; 754 if(urlRewrite.urlRewrite.startsWith('/') === false){ 755 urlRewrite.urlRewrite = '/'+urlRewrite.urlRewrite; 756 } 757 switch(urlRewrite.typeEntity){ 758 case entitiesUrl.ARTICLE_LIBRE: 759 newState = Object.assign({}, productdetails); 760 newState.name = 'root.produitarticle-'+urlRewrite.refEntity; 761 newState.url = urlRewrite.urlRewrite; 762 newState.params = { ID_PRODUCT : urlRewrite.refEntity}; 763 ob.from = "/common/product-article/"+urlRewrite.refEntity; 764 ob.to = urlRewrite.urlRewrite; 765 rewriteUrlStore.push(ob); 766 _checkRoutesAndPush(allRoutes,newState); 767 break; 768 case entitiesUrl.ABONNEMENT: 769 case entitiesUrl.FORMULE: 770 /*let lastSlash = totn_string.lastIndexOf('/'); 771 if(lastSlash > 0){ 772 let firstpart = lastSlash 773 } 774 let foundRoute = _findRouteStartsWith(allRoutes,urlRewrite.urlRewrite) 775 if(foundRoute === undefined){ 776 newState = Object.assign({}, productsubscription); 777 newState.name = 'root.produitsubscription-'+urlRewrite.refEntity; 778 newState.url = urlRewrite.urlRewrite; 779 newState.params = { ID_PRODUCT : urlRewrite.refEntity}; 780 ob.from = "/common/product-subscription/"+urlRewrite.refEntity; 781 ob.to = urlRewrite.urlRewrite; 782 rewriteUrlStore.push(ob); 783 _checkRoutesAndPush(allRoutes,newState); 784 785 //if("/common/product-subscription/*") 786 787 urlRewrite.urlRewrite 788 789 newState = Object.assign({}, productsubscriptionreab); 790 newState.name = 'root.productsubscriptionreab-'+urlRewrite.refEntity; 791 newState.url = urlRewrite.urlRewrite+'/:REF_ABO_ECHU'; 792 newState.params = { ID_PRODUCT : urlRewrite.refEntity}; 793 ob = {}; 794 ob.from = "/common/product-subscription/"+urlRewrite.refEntity+"/:REF_ABO_ECHU"; 795 ob.to = urlRewrite.urlRewrite+'/:REF_ABO_ECHU'; 796 rewriteUrlStore.push(ob); 797 //_checkRoutesAndPush(allRoutes,ob); 798 }*/ 799 800 newState = Object.assign({}, productsubscription); 801 newState.name = 'root.produitsubscription-'+urlRewrite.refEntity; 802 newState.url = urlRewrite.urlRewrite; 803 newState.params = { ID_PRODUCT : urlRewrite.refEntity}; 804 ob.from = "/common/product-subscription/"+urlRewrite.refEntity; 805 ob.to = urlRewrite.urlRewrite; 806 rewriteUrlStore.push(ob); 807 _checkRoutesAndPush(allRoutes,newState); 808 809 break; 810 case entitiesUrl.CATEGORIE: 811 if(urlRewrite.page) { 812 newState = Object.assign({}, listchildcategoriesbycategories); 813 newState.name = 'root.listchildcategoriesbycategories-'+urlRewrite.refEntity; 814 newState.url = urlRewrite.urlRewrite; 815 newState.params = { ID_CATEGORIE : urlRewrite.refEntity}; 816 ob.from = "/common/categories-list/"+urlRewrite.refEntity; 817 ob.to = urlRewrite.urlRewrite; 818 rewriteUrlStore.push(ob); 819 _checkRoutesAndPush(allRoutes,newState); 820 } else { 821 newState = Object.assign({}, listproductsbycategories); 822 newState.name = 'root.category-'+urlRewrite.refEntity; 823 newState.url = urlRewrite.urlRewrite; 824 newState.params = { ID_CATEGORIE : urlRewrite.refEntity}; 825 ob.from = "/common/categories/"+urlRewrite.refEntity; 826 ob.to = urlRewrite.urlRewrite; 827 rewriteUrlStore.push(ob); 828 _checkRoutesAndPush(allRoutes,newState); 829 } 830 831 break; 832 case entitiesUrl.PAGE: 833 newState = Object.assign({}, cms); 834 newState.name = 'root.page-'+urlRewrite.urlAboshop; 835 newState.url = urlRewrite.urlRewrite; 836 newState.params = { ID_PAGE : urlRewrite.urlAboshop}; 837 ob.from = "/common/cms/"+urlRewrite.urlAboshop; 838 ob.to = urlRewrite.urlRewrite; 839 rewriteUrlStore.push(ob); 840 _checkRoutesAndPush(allRoutes,newState); 841 842 break; 843 case entitiesUrl.URL: 844 let newRoute = {}; 845 newRoute.url = urlRewrite.urlAboshop; 846 newRoute.name = "####"; 847 newRoute = _findRoute(allRoutes,newRoute); 848 if(newRoute !== undefined) { 849 ob.from = newRoute.url; 850 ob.to = urlRewrite.urlRewrite; 851 rewriteUrlStore.push(ob); 852 newRoute.url = urlRewrite.urlRewrite; 853 } else { 854 console.log("ERROR : Route not exists : [urlAboshop=" + urlRewrite.urlAboshop+ ",urlRewrite=" + urlRewrite.urlRewrite); 855 } 856 break; 857 } 858 } 859 } 860 } 861 862 _storeRoutes(allRoutes); 863 864 if(commonConfig.removediese){ 865 // FIX for trailing slashes. Gracefully "borrowed" from https://github.com/angular-ui/ui-router/issues/50 866 $urlRouterProvider.rule(function ruleRemoveDiese($injector, $location) { 867 if($location.protocol() === 'file') 868 return; 869 870 var path = $location.path() 871 // Note: misnomer. This returns a query object, not a search string 872 , search = $location.search() 873 , params 874 ; 875 876 // check to see if the path already ends in '/' 877 if (path[path.length - 1] === '/') { 878 return; 879 } 880 881 // If there was no search string / query params, return with a `/` 882 if (Object.keys(search).length === 0) { 883 return path + '/'; 884 } 885 886 // Otherwise build the search string and return a `/?` prefix 887 params = []; 888 angular.forEach(search, function(v, k){ 889 params.push(k + '=' + v); 890 }); 891 return path + '/?' + params.join('&'); 892 }); 893 } 894 }; 895 896 this.$get = function($q, TbsWS, $window, $timeout, $state, $urlRouter, $rootScope){ 897 return { 898 loadUrlRewrite: function loadUrlRewrite(){ 899 var deferred = $q.defer(); 900 if(commonConfig.useRewriteUrl) { 901 TbsWS.call('geturlsrewrite','public').then( 902 function(rewriteurls){ 903 console.log(rewriteurls); 904 registerRoutes($window,rewriteurls,$state); 905 //$urlRouter.sync(); 906 //$urlRouter.listen(); 907 $rootScope.pageunauthorized = _getRealPath($rootScope.pageunauthorized); 908 deferred.resolve(); 909 } 910 ,function(error) { 911 deferred.reject(); 912 } 913 ); 914 } else { 915 registerRoutes($window,[],$state); 916 deferred.resolve(); 917 } 918 return deferred.promise; 919 }, 920 getRoutesExclues: function getRoutesExclues(){ 921 return routesExclues; 922 }, 923 getRealPath: function getRealPath(currentPath){ 924 return _getRealPath(currentPath); 925 }, 926 getOldPath: function getOldPath(currentPath){ 927 return _getOldPath(currentPath); 928 }, 929 isUrlRewrite: function isUrlRewrite(currentPath){ 930 return _isUrlRewrite(currentPath); 931 }, 932 loadMetaInDom: function loadMetaInDom(seo){ 933 if(seo !== undefined && seo !== null) { 934 $('meta[class=tbsmeta]').remove(); 935 if(seo.titleRewrite !== undefined && seo.titleRewrite !== null && seo.titleRewrite !== "") { 936 $('title').html(seo.titleRewrite); 937 } 938 if(seo.metas !== undefined && seo.metas !== null) { 939 for(let i=0; i < seo.metas.length; i++){ 940 let meta = seo.metas[i]; 941 $(meta.balise+"["+meta.nomPropriete+"='"+meta.valeurPropriete+"']").remove(); 942 $('head').append( '<'+meta.balise+' '+meta.nomPropriete+'="'+meta.valeurPropriete+'" content="'+meta.content+'" class="tbsmeta">' ); 943 } 944 } 945 } 946 $timeout(function() { 947 window.prerenderReady = true; 948 },1000); 949 }, 950 loadUrlCanonique: function loadUrlCanonique(){ 951 $('link[rel=canonical]').remove(); 952 let link = '<link rel="canonical" href="'+window.location.protocol + "//" + window.location.host + window.location.pathname+'">'; 953 $('head').append(link); 954 } 955 }; 956 }; 957 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.