File: D:/HostingSpaces/SBogers10/tops.komma.pro/wwwroot/lib/general/submenu_tracker.class.php
<?php
/**
* page_tracker.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 13/02/14
*/
class Submenu_Tracker
{
/*
* What file should open in the submenu
*/
private $_file = '';
public function __construct()
{
// Make sure session exists
if( ! isset($_SESSION['submenu_last'])) $_SESSION['submenu_last'] = '';
}
/*
* Check if the submenu was open at the last page
*/
public function getClass()
{
$classOutput = '';
if( ! empty($_SESSION['submenu_last']))
{
// Start with open submenu
$classOutput = ' class="open_submenu"';
// Load old file in submenu
$this->_file = $_SESSION['submenu_last'];
}
return $classOutput;
}
/*
* Check if the submenu should be opened at the new page
*/
public function checkNew()
{
// Pages width submenu
$pages = array('filters','uses','certificates');
// Get key of current page
$Translator = new Translator(URL_LANG);
$key = $Translator->getPageKey(URL_PAGE);
// Check if submenu is needed
if(in_array($key,$pages))
{
// Load new file in the submenu
$this->_file = $_SESSION['submenu_last'] = $key;
return true;
}
else
{
$_SESSION['submenu_last'] = '';
}
return false;
}
/*
* What file should load in the submenu
*/
public function getFile()
{
return $this->_file;
}
}