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_display.php
<?php

/**

	This class returns output such as listitems which are used to display data to the user.

*/

class Display
{
	
	/**
	*
	* @var string  String containing the linkname used in the display.
	*/
	private $_linkname = '';
	
	/**
	*	
	* Constructor
	*/
	public function __construct()
	{
	}
	
	/* 
	
	 	GET / SET
	
	*/
	
	/**
	* Sets the linkname variable
	*
	* @access public 
	* @param int
	* @return null
	*/
	public function setLinkname($str)
	{
		if( ! empty($str))
		{	
			$this->_linkname = $str;
		}	
	}	
		
	/**
	* Creates an output string containing listitems to display
	* Also creates an array of ids from items which are displayed in the list
	* These two are returned in an array($output, $ids);
	*
	* @access public
	* @param array(two-dimensional), boolean
	* @return array
	*/
	public function createList($data, $editable = TRUE)
	{
		$output = 'Er zijn nog geen items gevonden.';
		$ids = array();
				
		if($data != NULL)
		{			
			$i = 1;	
			$output = '';
			foreach($data as $info)
			{
				$ids[] = $info['id'];
				if(isset($info['timest']))
				{
					$added = date('d / m / Y',$info['timest']);
				}
				else if(isset($info['lastUpdate']))
				{
					$added = date('d / m / Y',$info['lastUpdate']);
				}
				else
				{
					$added = '';
				}
			
				$output .= '<li';
				if($i % 2 != 0) $output .= ' class="alt"';
				$output .= '>';
					$output .= '<div class="col cb">';
					if($editable)
					{
						$output .= '<input type="checkbox" name="selected[]" value="'.$info['id'].'" />';
					}
					else
					{
						$output .= '&nbsp;';
					}
					$output .= '</div>';
					$output .= '<div class="col title">'.ucfirst($info['title']).'</div>';
					$output .= '<div class="col added">'.$added.'</div>';
					$output .= '<div class="col edit">';
					if($editable)
					{
						/*
						$output .= '<div class="subcol">';
							$output .= '<a href="'.SITE_ROOT.$this->_linkname.'/publish/'.$info['id'].'/">';
							
							$published = $this->checkPublished($info['id']);
							
							if($published)
							{
								$output .= 'Depubliceer';
							}
							else
							{
								$output .= '<span class="publish">Publiceer</a>';
							}
							$output .= '</a>';
						$output .= '</div>';
						*/
						$output .= '<div class="subcol">';
							$output .= '<a href="'.SITE_ROOT.$this->_linkname.'/verwijder-item/'.$info['id'].'/">Verwijderen</a>';
						$output .= '</div>';
						
						$output .= '<div class="subcol">';
							$output .= '<a href="'.SITE_ROOT.$this->_linkname.'/wijzig-item/'.$info['id'].'/">Wijzigen</a>';
						$output .= '</div>';
						$output .= '<div class="clear"></div>';
					}
					else
					{
						$output .= '&nbsp;';
					}
					$output .= '</div>';
				$output .= '</li>';
				$i++;
			}
		}
		return array($output, $ids);
	}
}