File: D:/HostingSpaces/SBogers36/mecurity-ramkraakbeveiliging.nl/wwwroot/mvc/models/m_navigation.php
<?php
/**
* Easier and cleaner way to create menu list items
*/
class Navigation extends SiteTemplate
{
private $_lines;
public function __construct()
{
$this->_lines = array();
}
/**
* Adds data to the $_lines array. ( Adds a new line to the menu )
* If you want your home-button to go the the SITE_ROOT, enter "_root" as linkName
* You can set $siteRoot to FALSE if you want to link to a different website.
*
* @access public
* @param string $label
* @param string $linkName
* @param bool $siteRoot
* @return null
*/
public function addLine($label, $linkName=NULL, $siteRoot = TRUE)
{
if( ! empty($label))
{
if( empty($linkName))
{
$linkName = $this->encodeUrl($label);
}
if($siteRoot)
{
$url = SITE_ROOT.$linkName.'/';
}
else {
$url = $linkName;
}
if($linkName == '_root') $url = SITE_ROOT;
$this->_lines[] = array('url'=>$url,'label'=>$label,'linkName'=>$linkName);
}
}
/**
* Creates an array of listItems
*
* @access public
* @param
* @return null
*/
public function display($echo = TRUE)
{
$output = '';
foreach($this->_lines as $key => $line)
{
$active = FALSE;
$classes = array();
if(defined('URL_PAGE') && URL_PAGE == $line['linkName'])
{
$active = TRUE;
$classes[] = 'active';
}
else if(!defined('URL_PAGE') && $line['linkName'] == '_root')
{
$active = TRUE;
$classes[] = 'active';
}
else if(defined('URL_PAGE') && $line['label'] == 'Toepassingen')
{
$toepassingen = array('toepassingen','particulieren','detailhandel','garagehouders','bedrijfsgebouwen','high-security-objecten');
if(in_array( URL_PAGE,$toepassingen))
{
$active = TRUE;
$classes[] = 'active';
}
}
if($key%2!=0)
{
$classes[] = 'right';
}
$output .= '<li';
if(count($classes)>0)
{
$output .= ' class="';
foreach($classes as $n => $class)
{
if($n != 0) $output .= ' ';
$output .= $class;
}
$output .= '"';
}
$output .= '>';
if($active)
{
$output .= '<div class="arrow"></div>';
}
$output .= '<a href="'.$line['url'].'" title="'.$line['label'].'">'.$line['label'].'</a>';
$output .= '</li>';
}
if($echo)
{
echo $output;
}
else
{
return $output;
}
}
public function displaySubmenu()
{
$output = '';
foreach($this->_lines as $key => $line)
{
$classes = array();
if(defined('URL_SUB') && URL_PAGE.'/'.URL_SUB == $line['linkName'])
{
$classes[] = 'active';
}
if(!defined('URL_SUB') && $line['linkName'] == '_root')
{
$classes[] = 'active';
}
if($line['linkName'] == '_root')
{
$line['url'] = SITE_ROOT.URL_PAGE.'/';
}
if(count($this->_lines)-1 == $key)
{
$classes[] = 'first';
}
$output .= '<li';
if(count($classes)>0)
{
$output .= ' class="';
foreach($classes as $n => $class)
{
if($n != 0) $output .= ' ';
$output .= $class;
}
$output .= '"';
}
$output .= '>';
$output .= '<a href="'.$line['url'].'" class="simpleHover">
<span class="left">
<span class="text">'.$line['label'].'</span>
<span class="arrow"></span>
<span class="hover"></span>
<span class="up"></span>
</span>
<span class="right">
<span class="hover"></span>
<span class="up"></span>
</span>
</a>';
$output .= '</li>';
}
return $output;
}
}