File: D:/HostingSpaces/SBogers13/rie-jeanne.nl/wwwroot/lib/general/menu.class.php
<?php
/**
* menu.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 12/02/14
*/
class Menu
{
private $_pages = array();
// Language
private $_lang = array();
private $_urls = array();
public function __construct()
{
// Set language and url for conversion
$Translator = new Translator(URL_LANG);
$this->_lang = $Translator->get();
$this->_urls = $Translator->getUrls();
// Get all the pages
$this->_pages = array('cards','photography', 'business', 'contact');
}
/*
* Create Main Menu
*/
public function createMain()
{
// Start output with home
$output = '<li';
if( ! defined('URL_PAGE')) $output .= ' class="active"';
$output .= '><a href="/">Home</a></li>';
// Generate output for pages
foreach($this->_pages as $page)
{
// Get Label
$label = ucfirst($page);
if(isset($this->_lang[$page])) $label = $this->_lang[$page];
// Get Url
$url = $page;
// Search in URLS
if(isset($this->_urls[$page]))
{
$url = $this->_urls[$page];
}
// Search in LANG
else if(isset($this->_lang[$page]))
{
$label = $this->_lang[$page];
$url = Fn::encodeUrl($label);
}
$compareUrl = $url;
// Add to output
$output .= '<li';
if( defined('URL_PAGE') && URL_PAGE == $compareUrl) $output .= ' class="active"';
$output .= '><a href="' . LANG_ROOT . $url . '">';
if (defined('URL_PAGE'))
{
if (URL_PAGE == 'kaartjes' && $compareUrl == 'kaartjes')
{
if (defined('URL_SUB'))
{
if (URL_SUB == 'geboorte')
{
$output .= $label . '</a><ul class="sub"><li><a href="' . LANG_ROOT . $compareUrl . '">Intro</a></li><li class="active"><a href="' . LANG_ROOT . $compareUrl . '/geboorte">Geboorte</a></li><li><a href="' . LANG_ROOT . $compareUrl . '/feest">Feest</a></li></ul>';
}else if(URL_SUB == 'feest')
{
$output .= $label . '</a><ul class="sub"><li><a href="' . LANG_ROOT . $compareUrl . '">Intro</a></li><li><a href="' . LANG_ROOT . $compareUrl . '/geboorte">Geboorte</a></li><li class="active"><a href="' . LANG_ROOT . $compareUrl . '/feest">Feest</a></li></ul>';
}
}else
{
$output .= $label . '<ul class="sub"><li class="active"><a href="' . LANG_ROOT . $compareUrl . '">Intro</a></li><li><a href="' . LANG_ROOT . $compareUrl . '/geboorte">Geboorte</a></li><li><a href="' . LANG_ROOT . $compareUrl . '/feest">Feest</a></li></ul>';
}
}else{
$output .= $label . '</a></li>';
}
//if ($label != 'Kaartjes'){
// $output .= $label . '</a></li>';
}else{
$output .= $label . '</a></li>';
}
}
return $output;
}
}