HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/komma-mediadesign.nl/wwwroot/beheer/app/models/m_menu.php
<?php

/*
	
	Eassier and cleaner way to create menu list items

*/


class Menu
{
	private $_lines;
	private $_template;
	
	public function __construct()
	{
		global $template;
		$this->_template = $template;
		
		$this->_lines = array();
	}
	
	/**
	* Adds data to the $_lines array. ( Adds a new line to the menu )
	*
	* @access public
	* @param string string boolean
	* @return null
	*/
	public function addLine($label, $linkname, $siteroot = TRUE)
	{
		if( ! empty($linkname) && ! empty($label))
		{
			if($siteroot)
			{
				$url = SITE_ROOT.$linkname.'/';
			}
			else {
				$url = $linkname;
			}
			
			$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 $line)
		{
			$output .= '<li';
			if(isset($_GET['page']) && $_GET['page'] == $line['linkname']) $output .= ' class="active"';
			$output .= '>';
				$output .= '<a href="'.$line['url'].'" title="'.$line['label'].'">'.$line['label'].'</a>';
			$output .= '</li>';
		}
	
		if($echo)
		{
			echo $output;
		}
		else 
		{
			return $output;
		}
	}
}