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/SBogers68/resortouddorpduin.nl/wwwroot/kms/lib/ui/navigation.class.php
<?php

/**
 * Easier and cleaner way to create menu list items
 */
class Navigation
{
	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))
			{
                $Functions = new Functions();
                $linkName = $Functions->encodeUrl($label);
			}
			if($siteRoot)
			{
				$url = LANG_ROOT.$linkName.'/';
			}
			else {
				$url = $linkName;
			}

            if($linkName == '_root') $url = LANG_ROOT;

			$this->_lines[] = array('url'=>$url,'label'=>$label,'$linkName'=>$linkName);
		}
	}

    /**
     * Creates an array of listItems
     * @access public
     * @param bool $echo
     * @internal param $boolean
     * @return mixed
     */
	public function display($echo = TRUE)
	{
		$output = '';
		foreach($this->_lines as $key => $line)
		{
            $output .= '<li';
            // Active ?
            $classes = array();
            if((defined('URL_PAGE') && URL_PAGE == $line['$linkName']) || (!defined('URL_PAGE') && $line['$linkName'] == '_root'))
            {
                $classes[] = 'active';
            }
            // First?
            if($key == 0)
            {
                $classes[] = 'first';
            }
            // Last ?
			if($key == count($this->_lines)-1)
            {
                $classes[] = 'last';
            }

            if(count($classes)>0)
            {
                $output .= ' class="';
                foreach($classes as $n => $class)
                {
                    if($n != 0) $output .= ' ';
                    $output .= $class;
                }
                $output .= '"';
            }
			$output .= '>';
				$output .= '<a href="'.$line['url'].'" title="'.$line['label'].'">'.$line['label'].'</a>';
            $output .= '</li>';
		}
		
		if($echo)
		{
			echo $output;
            return true;
		}
	    return $output;
	}
}