File: D:/HostingSpaces/SBogers10/deensekroon.komma-mediadesign.nl/wwwroot/php/dispatcher.php
<?php
// Create RouteResolver
$routeResolver = new App\Routes\RouteResolver();
// Resolve route
if( ! $currentRoute = $routeResolver->resolve())
{
// todo 404;
$contentOutput = '';
}
// Create Repositories and Tree
$categoryRepo = new \App\Categories\CategoryRepository();
$brandRepo = new \App\Brands\BrandRepository();
$tree = new \App\Categories\CategoryTree();
// Get root categories and brands which have products
$categories = $categoryRepo->activeCategories();
$brands = $brandRepo->brands();
// Create a tree
$tree->make($categories);
$activeId = $tree->setActiveIdByRoute($currentRoute);
// Create content output
$contentOutput = $routeResolver->dispatchType($currentRoute);
#reset colorArray
if(isset($_SESSION['colorCatArr'])) unset($_SESSION['colorCatArr']);
$pageTitle = '';
$siteTitle = 'Deense Kroon - Scandinavian concept store';
////////////////// CONTENT OUTPUT \\\\\\\\\\\\\\\\\\\\
if( ! $contentOutput)
{
$contentOutput = '';
if(isset($_POST['submit-newsletter'])){
# Newsletter
submitNewsletter($_POST['email']); //in sitefunctions
}
else if(defined('URL_SUB') && URL_SUB == 'voeg-artikel-toe'){
validateAddProductsFromGet('instance');
}
else if(defined('URL_SUB') && URL_SUB == 'voeg-product-toe'){
validateAddProductsFromGet('product');
}
else if(defined('URL_PAGE')){
$page = URL_PAGE;
switch($page){
case 'toont-haar-collectie':
/* load collection */
require_once './php/page_collection.php';
$contentOutput .= initCollection();
if(defined('URL_SUB') && URL_SUB == 'van-het-merk'){
$brand = str_replace('-',' ',URL_SUB2);
$brand = ucwords($brand);
$pageTitle .= $brand . ' | Merken | ' . $siteTitle;
}
else if(defined('URL_SUB') && URL_SUB == 'uit-de-categorie'){
$cat = str_replace('-',' ',URL_SUB2);
$pageTitle .= $cat.' | ' . $siteTitle;
}
else{
$pageTitle .= 'Collectie | ' . $siteTitle;
}
break;
case 'sale':
/* load collection */
require_once './php/page_extraleuk.php';
$contentOutput .= initExtraleuk();
$pageTitle .= 'Actie | ' . $siteTitle;
break;
case 'toont-het-artikel':
/* load product */
require_once './php/page_product.php';
$contentOutput .= initProduct();
$pageTitle .= getProductTitle();
$pageTitle .= ' | ' . $siteTitle;
break;
case 'toont-haar-merken':
include_once($_SERVER['DOCUMENT_ROOT'] . '/App/Brands/BrandController.php');
$brandController = new \App\Brands\BrandController();
$contentOutput = $brandController->index();
/* load brands */
// require_once './php/page_brands.php';
// $contentOutput .= initBrands();
$pageTitle .= 'Merken | ' . $siteTitle;
break;
case 'blogt':
/* load blog */
require_once './php/page_blog.php';
$contentOutput .= initBlog();
$pageTitle .= 'Deense Kroon blogt';
break;
case 'voorwaarden':
/* load voorwaarden */
require_once './php/page_terms.php';
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('voorwaarden');
$pageTitle .= 'Voorwaarden | ' . $siteTitle;
break;
case 'privacy':
/* load voorwaarden */
require_once './php/page_privacy.php';
$contentOutput .= showPrivacyPage();
$pageTitle .= 'Privacyverklaring | ' . $siteTitle;
break;
case 'faq':
/* load faq */
require_once './php/page_faq.php';
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('faq');
$pageTitle .= 'FAQ | ' . $siteTitle;
break;
case 'betalen':
/* load faq */
require_once './php/init_pay.php';
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('betalen');
$pageTitle .= 'Betalen | ' . $siteTitle;
break;
case 'levering':
/* load faq */
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('levering');
$pageTitle .= 'Levering | ' . $siteTitle;
break;
case 'ruilen-en-retour':
/* load faq */
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('ruilenRetour');
$pageTitle .= 'Ruilen en retour | ' . $siteTitle;
break;
case 'pers':
/* load pers */
require_once './php/page_multipage.php';
$contentOutput .= showMultipage('pers');
$pageTitle .= 'Pers | ' . $siteTitle;
break;
case 'contact':
/* load contact */
require_once './php/page_contact.php';
$contentOutput .= initContact();
$pageTitle .= 'Contact | ' . $siteTitle;
break;
case 'toont-uw-winkelwagen':
require_once './php/page_cart.php';
$contentOutput .= initCart();
$pageTitle .= 'Winkelwagen | ' . $siteTitle;
break;
case 'mijn-account' :
case 'registreren' :
case 'inloggen-of-registreren':
case 'activeer-uw-account' :
/* load my account */
require_once './php/page_myaccount.php';
$contentOutput .= initMyAccount();
$pageTitle .= 'Mijn account | ' . $siteTitle;
break;
case 'wachtwoord-vergeten':
require_once './php/page_forgot_pass.php';
$contentOutput .= getForgotPass();
$pageTitle .= 'Wachtwoord vergeten | ' . $siteTitle;
break;
case 'uitloggen' :
unset($_SESSION['customerstr']);
header('location: ../');
break;
case 'zoekresultaten':
require_once './php/page_searchresults.php';
$contentOutput .= initSearchresults();
$pageTitle .= 'Zoekresultaten | ' . $siteTitle;
break;
case 'miinto':
require_once './php/miinto/MiintoService.php';
$Miinto = new MiintoService();
$Miinto->index();
exit;
break;
case 'sweebr':
require_once './php/sweebr/SweebrService.php';
$Sweebr = new SweebrService();
$Sweebr->index();
exit;
break;
case 'vend':
require_once './php/Vend/VendController.php';
$controller = new \Vend\VendController();
$controller->index();
exit;
break;
case 'knijter':
require_once './php/knijter/KnijterController.php';
$controller = new \Knijter\KnijterController();
$controller->index();
exit;
break;
case 'google-feed':
require_once $_SERVER['DOCUMENT_ROOT'] . '/App/Feeds/FeedController.php';
$controller = new \App\Feeds\FeedController();
$controller->google();
exit;
break;
case 'daisycon':
require_once $_SERVER['DOCUMENT_ROOT'] . '/App/Feeds/FeedController.php';
$controller = new \App\Feeds\FeedController();
$controller->daisycon();
exit;
break;
case 'naar':
if(defined('URL_SUB'))
{
shortLinkToProduct(URL_SUB);
}
else{
require_once './php/page_home.php';
$contentOutput .= initHome();
$pageTitle .= $siteTitle;
}
break;
case 'heeft-een-aanbieding':
case 'vertelt-over-zichzelf':
case 'over-ons':
require_once './php/page_over.php';
$contentOutput = about();
$pageTitle .= 'Over ons | ' . $siteTitle;
break;
case 'kopenhagen-tips':
require_once './php/page_over.php';
$contentOutput = kopenhagen();
$pageTitle .= 'Kopenhagen Tips | ' . $siteTitle;
break;
case 'shoppen-op-afspraak':
require_once './php/page_over.php';
$contentOutput = shoppenOpAfspraak();
$pageTitle .= 'Shoppen op afspraak | ' . $siteTitle;
break;
default:
/* load home */
require_once './php/page_home.php';
$contentOutput .= initHome();
$pageTitle .= $siteTitle;
};
}
else{
/* load home */
require_once './php/page_home.php';
$contentOutput .= initHome();
$pageTitle .= $siteTitle;
}
}
////////////////// ASIDE OUTPUT \\\\\\\\\\\\\\\\\\\\
$asideOutput = '';
// NEW IN
$asideOutput .= '<ul class="tree-navigation">';
$asideOutput .= '<li';
if(defined('URL_SUB') && URL_SUB == 'nieuw') $asideOutput .= ' class="active"';
$asideOutput .= '><a href="/toont-haar-collectie/nieuw/">NEW IN</a></li></li>';
// Categories
foreach($tree->nodes() as $key => $category)
{
// Get title
$title = fromDatabase($category->title_nl);
$route = fromDatabase($category->route_nl);
// todo: get route
$asideOutput .= '<li';
if($tree->isActive($category)) $asideOutput .= ' class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/' . $route . '">' . $title . '</a>';
// Level 2
if($category->hasChildren())
{
$asideOutput .= '<ul>';
foreach ($category->children() as $child)
{
$childTitle = fromDatabase($child->title_nl);
$childRoute = fromDatabase($child->route_nl);
$asideOutput .= '<li';
if($tree->isActive($child)) $asideOutput .= ' class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/' . $childRoute . '">' . $childTitle . '</a>';
// Level 3
if($child->hasChildren())
{
$asideOutput .= '<ul>';
foreach ($child->children() as $grandchild)
{
$grandchildTitle = fromDatabase($grandchild->title_nl);
$grandchildRoute = fromDatabase($grandchild->route_nl);
$asideOutput .= '<li';
if($tree->isActive($grandchild)) $asideOutput .= ' class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/' . $grandchildRoute . '">' . $grandchildTitle . '</a>';
$asideOutput .= '</li>';
}
$asideOutput .= '</ul>';
}
$asideOutput .= '</li>';
}
$asideOutput .= '</ul>';
}
$asideOutput .= '</li>';
}
// End categories
// Brands
$asideOutput .= '<li';
if($routeResolver->path() == 'toont-haar-merken' || (isset($currentRoute->routeable_type)) && $currentRoute->routeable_type == 'brand') $asideOutput .= ' class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/toont-haar-merken">Merken</a>';
$asideOutput .= '<ul>';
foreach($brands as $brand)
{
$title = fromDatabase($brand->name);
$linktitle = linkname($title);
$link = $brand->route_nl;
$asideOutput .= '<li';
if($routeResolver->path() == $link) $asideOutput .= ' class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/'.$link.'">'.($title).'</a>';
$asideOutput .= '</li>';
}
$asideOutput .= '</ul>';
$asideOutput .= '</li>';
// End brands
// Sale
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'sale') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/sale/">Sale</a></li>';
$asideOutput .= '</ul>';
$asideOutput .= '<ul class="tree-navigation">';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'vertelt-over-zichzelf') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/vertelt-over-zichzelf/">Over ons</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'kopenhagen-tips') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/kopenhagen-tips/">Kopenhagen Tips</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'shoppen-op-afspraak') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/shoppen-op-afspraak/">Shoppen op afspraak</a></li>';
// Customer service
$customerService = ['faq','ruilen-en-retour','betalen','levering','voorwaarden','privacy'];
$asideOutput .= '<li ';
if(defined('URL_PAGE') && in_array(URL_PAGE,$customerService)) $asideOutput .= 'class="active"';
$asideOutput .= '>';
$asideOutput .= '<a href="/faq">Klantenservice</a>';
$asideOutput .= '<ul>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'faq') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/faq/">Veelgestelde vragen</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'ruilen-en-retour') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/ruilen-en-retour/">Ruilen en retour</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'betalen') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/betalen/">Veilig betalen</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'levering') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/levering/">Leveren</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'voorwaarden') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/voorwaarden/">Voorwaarden</a></li>';
$asideOutput .= '<li'; if(defined('URL_PAGE') && URL_PAGE == 'privacy') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/privacy/">Privacy</a></li>';
$asideOutput .= '</ul>';
$asideOutput .= '</li>';
// End customer service
// Contact
$asideOutput .= '<li'; if(defined('URL_SUB') && URL_PAGE == 'contact') $asideOutput .= ' class="active"'; $asideOutput .= '><a href="/contact/">Contact</a></li>';
$asideOutput .= '</ul>';
?>