132 lines
2.2 KiB
PHP
132 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by CS medien- & kommunikationssysteme.
|
|
* @author Christian Steinle
|
|
* @date 03.08.2016
|
|
*
|
|
* @copyright CS medien- & kommunikationssysteme (http://www.steinle-computer.de)
|
|
*/
|
|
|
|
namespace Model;
|
|
|
|
|
|
use Helper\Database;
|
|
|
|
class NavigationModel extends Database
|
|
{
|
|
|
|
const TBL_NAME = TBL_FRONT_NAVIGATION;
|
|
|
|
const PRIMARY_KEY = 'navID';
|
|
|
|
const ORDER_BY = 'ORDER BY navSort ASC';
|
|
|
|
static $filter = 'navActive = "yes"';
|
|
|
|
protected static $navigationPath = array();
|
|
|
|
protected static $activeNavID = 0;
|
|
|
|
protected static $header = '';
|
|
|
|
protected static $headline = '';
|
|
|
|
protected static $contents = array();
|
|
|
|
|
|
/**
|
|
* Setzt später benötigte Variablen für den FrontendController, so dass die Datenmodelle und die Views instanziiert werden können
|
|
* @param array $routeParts
|
|
*/
|
|
public static function init(array $routeParts)
|
|
{
|
|
self::getIndex();
|
|
$nav = self::$data;
|
|
$navStart = 0;
|
|
foreach ($routeParts as $navLink)
|
|
{
|
|
foreach ($nav as $navID => $navItem)
|
|
{
|
|
if ($navItem['navStart'] == $navStart && $navItem['navLink'] == $navLink)
|
|
{
|
|
$navStart = $navItem['navID'];
|
|
self::$navigationPath[] = self::$activeNavID = $navItem['navID'];
|
|
self::$header = $navItem['navHeader'];
|
|
self::$headline = $navItem['navHeadline'];
|
|
self::initContent($navItem['navContent']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @param string $navContents
|
|
*/
|
|
protected static function initContent($navContents)
|
|
{
|
|
if (is_null($navContents))
|
|
{
|
|
return;
|
|
}
|
|
if (is_array(json_decode($navContents, true)))
|
|
{
|
|
self::$contents = json_decode($navContents, true);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getNavigationPath()
|
|
{
|
|
return self::$navigationPath;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public static function getActiveNavID()
|
|
{
|
|
return self::$activeNavID;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public static function getHeader()
|
|
{
|
|
return self::$header;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public static function getHeadline()
|
|
{
|
|
return self::$headline;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getContents()
|
|
{
|
|
return self::$contents;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getData()
|
|
{
|
|
return self::$data;
|
|
}
|
|
} |